From patchwork Thu Aug 10 07:40:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133749 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp261626vqi; Thu, 10 Aug 2023 01:10:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7b95zPP+Ny/DC/hvV01PEKW1HMV2w1Yy/zOlFcM7+X6be+C3N25dmNDo0h+pmgmJU8dde X-Received: by 2002:a05:6402:332:b0:522:3a0d:38c2 with SMTP id q18-20020a056402033200b005223a0d38c2mr1408459edw.9.1691655025556; Thu, 10 Aug 2023 01:10:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691655025; cv=none; d=google.com; s=arc-20160816; b=tKggVYM645351CbzWNg9ycO/f/MYGakmmTIm0jtE3FTyz50JsBFIbBN2EC5iI8QBNA 1GQgXy6dWmvQk8NolO/Cec+BdyyMnonTLf9dihfgJDctiPL6d4H7BL82JvUUNJ3VYoNi 01UmKiM9omQHg7GKTZpzuVhDv/NLdm3ehy/lPLRRLKbVRs8GbxtqGTHyOpkYjzZtKy5D 2633iLmtTOGpzoRiBBAvXc2zFbFg6hWt/Nv0j0p28jsN0I27feVo2L5RZpT5jwjCZuND lEg9Gg6z90R9TeU4xh1exsoopdrtuhu0qDqfoMbb3vbBwutR2Bmgh2LCxu5g1O1Ni0hu Nq9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=WPNuwr8BV2crYdR1HSxa9CVFwtJ2x4ORzKRyFk7VJAs=; fh=U9aMXhC4C3vp50RpX5/W/je1e0oxyhy5HPsCZC8XORg=; b=0VsOZKfIueAduv79TS8aqYaY8xKhr/G8ZhxyUrR1VSzSRL2qx8weYSnSXjsEr9Zbjx kZglFGoIYl5CnOyDbfbGZcFlw1k6mGT6T6p8ICA47K9GSABWzIn61YT5rnyzeT63+GHo 55ilPTuersPjKi06+eRG8R+z8PFBzNH4JTR/d3+/G01HZluE4moOwwjY9fkqz8EugK6Z qLaWUMIUradiJnvkYqSBMuZQCWjd9DEEEu0BtIMY7HqCp340QV6Ac2JI4xHoG88rk3oW IQEuHfbwjSkgHjQ1Nx5os4d2aPFHisFmr01yNwI6g2UCQZnReQ+BYOvqWi58BJEqRhqf Be/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jZlUe8Gq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b23-20020aa7cd17000000b005236978cabesi869676edw.684.2023.08.10.01.09.53; Thu, 10 Aug 2023 01:10:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jZlUe8Gq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232740AbjHJHky (ORCPT + 99 others); Thu, 10 Aug 2023 03:40:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233952AbjHJHkp (ORCPT ); Thu, 10 Aug 2023 03:40:45 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6BA8268D for ; Thu, 10 Aug 2023 00:40:33 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2b9b9f0387dso9116771fa.0 for ; Thu, 10 Aug 2023 00:40:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691653232; x=1692258032; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=WPNuwr8BV2crYdR1HSxa9CVFwtJ2x4ORzKRyFk7VJAs=; b=jZlUe8GqXYZExHEJdIjbkYCeW5NeDHITr/Fgx1X6BQQzH+TcMTfY7zWzrjCM5fXdGG wVTk7Z5VEteWvnFlpVciGAaQ3AQPV68SaDecR70MGUuyh/CB0I1+a2Mh3OtXhPNg0PG8 k5PuUUHO1Fg4SrMYMiHFsQGRvDsoGXZm3Tj3q/1+SN8ScI9aXbBqbBLCcNi+PkazlbNR P2A1myCEQ5zkOwT+1JU6wOcWKJyO7jH0tkOIrRv12LrcEycE1LfXKlqizKt38zylaseU FYKYufBLCbLw9IqxbCM54RVW4cddZ6HRGUECzkzvFmiw4Rt5CZNMG6pmOx0ZiDyih0Q9 YVGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691653232; x=1692258032; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WPNuwr8BV2crYdR1HSxa9CVFwtJ2x4ORzKRyFk7VJAs=; b=gNAQdV03Pd/SrPwctg9nWYe7NqDnaRF2C7Gzr8ziRMOwfjEdztfau4SDDOJFBRYJhh otaJtdFYMM+lNb/AY++NA1jITDk/0Jwa3gb4ba37OniDy7a0ko7qtSZOe759ehs7Ey8B SaeySyGlgtlEx3FGeOz5gwPT+MJy1jf+u01bB6bU2PaKaTF+K8XO1a0pqlvo3KGkZfFI rH1PNRetuVhQsOAoSikebZgMv1JBGZbVpNY08/T2BtNSuBabU6BJp3IxTqIue8Q/yrKX aTznls7G18zCK8X0IbTQ/AvSrWHcAZDSZn/erQaWY8iD9EcnS6q+eUyHtr0HGCDx38n+ a1Mw== X-Gm-Message-State: AOJu0Yxk34Hc6+MNXY5dlWU5MVax4Munqzdk3sj5GLPqHsjF8eo5wItP 4nTX2r1+vUq3imaOIuFj5DnEAg== X-Received: by 2002:a2e:9b43:0:b0:2b9:b904:74d7 with SMTP id o3-20020a2e9b43000000b002b9b90474d7mr1221973ljj.18.1691653231817; Thu, 10 Aug 2023 00:40:31 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id e4-20020a2e9844000000b002b9ff8450aesm234500ljj.91.2023.08.10.00.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 00:40:31 -0700 (PDT) From: Linus Walleij Date: Thu, 10 Aug 2023 09:40:30 +0200 Subject: [PATCH v3 1/2] csky: Cast argument to virt_to_pfn() to (void *) MIME-Version: 1.0 Message-Id: <20230810-csky-virt-to-phys-v3-1-f443cd2fc050@linaro.org> References: <20230810-csky-virt-to-phys-v3-0-f443cd2fc050@linaro.org> In-Reply-To: <20230810-csky-virt-to-phys-v3-0-f443cd2fc050@linaro.org> To: Vineet Gupta , Guo Ren Cc: linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773828859707970921 X-GMAIL-MSGID: 1773828859707970921 The virt_to_pfn() function takes a (void *) as argument, fix this up to avoid exploiting the unintended polymorphism of virt_to_pfn. Acked-by: Guo Ren Signed-off-by: Linus Walleij --- arch/arc/include/asm/page.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h index e43fe27ec54d..02b53ad811fb 100644 --- a/arch/arc/include/asm/page.h +++ b/arch/arc/include/asm/page.h @@ -108,7 +108,7 @@ extern int pfn_valid(unsigned long pfn); #else /* CONFIG_HIGHMEM */ -#define ARCH_PFN_OFFSET virt_to_pfn(CONFIG_LINUX_RAM_BASE) +#define ARCH_PFN_OFFSET virt_to_pfn((void *)CONFIG_LINUX_RAM_BASE) #endif /* CONFIG_HIGHMEM */ From patchwork Thu Aug 10 07:40:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133787 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp290906vqi; Thu, 10 Aug 2023 02:21:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQ5NZTiG2oeyo3bBaEkGC6NdkGEKQLAyNSqGt+150otFbxfmqkiidr6hZ2k0KF6qD8EgK4 X-Received: by 2002:a05:6a00:1992:b0:668:69fa:f78f with SMTP id d18-20020a056a00199200b0066869faf78fmr1789177pfl.1.1691659316009; Thu, 10 Aug 2023 02:21:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691659315; cv=none; d=google.com; s=arc-20160816; b=ZItRCm2s8w54Jn9Zv0DjzNl1pWyNd7PSnJHoCmFa0biIRy9gzmnymbsOvg5GCuz94k WmDHEEnKgcCUeV6K8Ykv2bWNgsSDpyN/RULTUVGoZX7mENxdhm6R+frlKehj44X/8Zgl BLfu9W3mH/D5j+snM6kehUxhicEd8Lr5XrLwRCRKFIP1uXhbJjfI0r5ScwSGDTz8Sqx+ wi+aBspsqziWHXR6agRGxSnakTw1zv4d372BKaAXJPV6TUHLvmzVcvR9lWi3KL4224f1 gwm/wcX7jkWndJNiZJcg0ZByfTs4fzaH4cDFuUENm62xGZ1cdCdM8TN0Nwg5Xz2QA+w6 yj9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=JE+tuaEjTOobPVuUoR018Dq94fxPMbAMe7BcedomcTI=; fh=U9aMXhC4C3vp50RpX5/W/je1e0oxyhy5HPsCZC8XORg=; b=VM/oV4DvLNVEGfw1tU9gv5Yp3xHV8Nv8gkMt+SNjgfSBgzGtyH5vOANYCBIugSY5+u jPXaNibHZGt6CIbOYRh8UV1tmGLZxBe57L1AK4zMcSeX8UBQgeSNlnjJbQ5YrOnrkRrc A/GSjF0XhXt+o7XAoUFeqP6mqjWxXjZX89noUFNDrfM7jrsW/xzm1gulHXqCZuQt4t71 hnWFmyCodc4FDut/BtOGmBn6w2K1R1Th0ZSQaa4IXLWn03rsheooyhghaiO0VHz6Grn3 cKHZhx7ZE1kSsWMJeTIE1xutxtubVEoM2VJL9XNyjTTa8exC3ndoqCXW+Zqmxy0wfmTP oQaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WnmBDlQN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c8-20020a63d148000000b00563dd9b6da6si1228591pgj.718.2023.08.10.02.21.42; Thu, 10 Aug 2023 02:21:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WnmBDlQN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233940AbjHJHk5 (ORCPT + 99 others); Thu, 10 Aug 2023 03:40:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233907AbjHJHkr (ORCPT ); Thu, 10 Aug 2023 03:40:47 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7835C2697 for ; Thu, 10 Aug 2023 00:40:34 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2b9c907bc68so9274031fa.2 for ; Thu, 10 Aug 2023 00:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691653232; x=1692258032; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=JE+tuaEjTOobPVuUoR018Dq94fxPMbAMe7BcedomcTI=; b=WnmBDlQNs2BhfbzgpjkxvyonZEj2KENAKRPJCd6GxuoNAbLIb/BsmV45oj5T2IzBwu efwKJ+BHHwpYOXdX9wtBsU0r6j00Y4rFnM1DNNd8g+8J7KfnJhVetrbExXYhBvpDftIc P+jlxgZDoevp5MpQCxV99jQU7N3UGViCeW8VeuCpwI5W8Lxg8JQSIRgouBbOMu2cVWlZ qVzbGHLyD4hcTKwGmY5CxC8JVdhSV00OZyt7JqD9WNu4BES5SrPRKmZInUsKVgvcmyzq j/bjj3XjtQqB/qtaaPkLSVbIGaSZarxdbquiowkUuRzIAZpPddxnpZla5MuIdu3VFkrt EdVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691653232; x=1692258032; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JE+tuaEjTOobPVuUoR018Dq94fxPMbAMe7BcedomcTI=; b=iRNITyEM724pYCWDc1nIAkl3tqXceMmVUAD0YGimuE22Lb1tIlwV3YDbB4E14lF6px frVGIv8tNEqe4b4kXz9tcnSHuNP51ILPfYF1NIz6O2wSzoyPa6FhQIoG+PgWCW0l97kx 5BFFNoDhrceTB0SyRQdsPDs4/q38RAd8knm48d6qEwfurjQmv2chQzWrWbFbY3u2IBzu uYKyXhb1bzKtAHvMuraDm683u1Ym/WcJOOzyX9Sdb0P+VrgHK1YrMhL63WebioRo/qpe LjA3BCNHOfqTvu5VLGjdOxLAXK9Az23myEU0j93lss0INmYOKN+FNc7arg7UcBGm+WLV uD1w== X-Gm-Message-State: AOJu0Yy9urqIWeqgUx5jV4G/5MC5qPmfbwYzowGeI4uINwF/bzzEZeej nDkVqxG2V4fEXcLo0FdH5xlT4g== X-Received: by 2002:a2e:9f4b:0:b0:2b7:3656:c594 with SMTP id v11-20020a2e9f4b000000b002b73656c594mr1272196ljk.3.1691653232743; Thu, 10 Aug 2023 00:40:32 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id e4-20020a2e9844000000b002b9ff8450aesm234500ljj.91.2023.08.10.00.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 00:40:32 -0700 (PDT) From: Linus Walleij Date: Thu, 10 Aug 2023 09:40:31 +0200 Subject: [PATCH v3 2/2] csky: Make pfn accessors static inlines MIME-Version: 1.0 Message-Id: <20230810-csky-virt-to-phys-v3-2-f443cd2fc050@linaro.org> References: <20230810-csky-virt-to-phys-v3-0-f443cd2fc050@linaro.org> In-Reply-To: <20230810-csky-virt-to-phys-v3-0-f443cd2fc050@linaro.org> To: Vineet Gupta , Guo Ren Cc: linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773833358689518601 X-GMAIL-MSGID: 1773833358689518601 Making virt_to_pfn() a static inline taking a strongly typed (const void *) makes the contract of a passing a pointer of that type to the function explicit and exposes any misuse of the macro virt_to_pfn() acting polymorphic and accepting many types such as (void *), (unitptr_t) or (unsigned long) as arguments without warnings. For symmetry to the same thing with pfn_to_virt(). In order to do this we move the virt_to_phys() and phys_to_virt() below the definitions of the __pa() and __va() macros so it compiles. The macro version was also able to do recursive symbol resolution. Acked-by: Guo Ren Signed-off-by: Linus Walleij --- arch/csky/include/asm/page.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/csky/include/asm/page.h b/arch/csky/include/asm/page.h index b23e3006a9e0..4a0502e324a6 100644 --- a/arch/csky/include/asm/page.h +++ b/arch/csky/include/asm/page.h @@ -34,9 +34,6 @@ #include -#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) -#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) - #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && \ (void *)(kaddr) < high_memory) @@ -80,6 +77,16 @@ extern unsigned long va_pa_offset; #define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x), 0)) +static inline unsigned long virt_to_pfn(const void *kaddr) +{ + return __pa(kaddr) >> PAGE_SHIFT; +} + +static inline void * pfn_to_virt(unsigned long pfn) +{ + return (void *)((unsigned long)__va(pfn) << PAGE_SHIFT); +} + #define MAP_NR(x) PFN_DOWN((unsigned long)(x) - PAGE_OFFSET - \ PHYS_OFFSET_OFFSET) #define virt_to_page(x) (mem_map + MAP_NR(x))