From patchwork Wed Aug 9 08:14:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1819172 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=srPJALKV; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=S3NUfjB4; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RLNBH4TdMz1yfl for ; Wed, 9 Aug 2023 18:14:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bbK5WjNGweMS8pt6l6hXo0IUazwd02EPIj+AYjWLwaw=; b=srPJALKVfHgupJ 0xe+lWocvcBgxFR7f4AHYw+jn7coyQFyhall+5cX1OqkqDrPm6k7BoOT+nXGvyzpxgLyDjrTof3Lb LC3p7KoWB8t69ApdEFjzw0QxShRjOPCtyuOWNk6Dc1fVDhIvpMnkktsIAORUI373EP8IhEhdrhzaA yo2MxNU0HKkA+WmDjj9AWPKlucn8d7iHOW3IWOnhfV5yVNIiK31DcsLGzwscdmsKfUFGSldnL1zIm QisFZB/34ZhfNEn8VfJxx937Elq5l6sZszhtM2i+pwkB3jxTXVT22DfpIUOw7u5w7Za9c38UtrejP Ouj0Dk8I62uaBE2rrBFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qTeKZ-004LCG-17; Wed, 09 Aug 2023 08:14:11 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qTeKX-004LAB-0N for linux-snps-arc@lists.infradead.org; Wed, 09 Aug 2023 08:14:10 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-4fe21e7f3d1so10767380e87.3 for ; Wed, 09 Aug 2023 01:14:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691568844; x=1692173644; 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=S3NUfjB4bsVe9j6vOvkgbzCiTwC+/LUZKHOJA+DVd1hF79XKEdcJLk5HeANwSJMNbE wFpiDbSv79eoDUKbFvABoRC4bzoj14hmJCAJZ+IEaSBva/ry7TZMziatdW3YEqIdCjgB YulVLM079c0A02u23M9dDfoB9cMLWz0IkCBNCjYoMH6qyb1qOSwKadguXMuWw3CgQUVQ 0+9kRZjClq3de5Y0DtfavbxvkIy/dspo/iG+vratIzTwZtvaM+YMiU76D9uExhAgJoxH 7UE9kG79yVX/aXKS7E+0xBKcFA0aQMmaJjFSi5930Xbdy/54AMjv26QFYnm5g9zPIY59 7OpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691568844; x=1692173644; 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=PfVVS9mPh3c0r8i0ZNHbKO9WMBP1f12odHYxyzu+mjz9KfX+8xSXmvkLhoNllBNTgG zfns6vLV/wtBj1q+qQiQgGY5DcIxCJvFM/jMUs50yeFXdUFr3XlRKWk+KQvL/aXtPmXl rVMSIR9Xer6A9tNWEcpnPArvVt/OXKlWoJH+1A9YQpBGjGXXgeuQ1T47X5KzQ9y7cu+P 7Tu9LHQRfcnHS9NHbop/DPahSliEZdMqDwBd33+PfluiJ6l/bvP4Ny/LzGwxnpg3krwu Jih1kqjI7dbZhuwtDymSQuWYNf4Ona0FPINV8N57E40RyPhRLuBbPp6IKzZ7kQ7Bkdod +AWA== X-Gm-Message-State: AOJu0YwSdp31PxezgcI/ErIL3yYS9WyyXSGorEEN+5ns1dlepCTNmtY6 2hiRr9NKkBZhbeaA56H33sD+Ow== X-Google-Smtp-Source: AGHT+IGFV6oMEHkHKUKwQzLqMtPfeM/T6iurCa7KQ+Aco/96KR8LzXnX/g855E8IYulDBfcHTtWs6Q== X-Received: by 2002:a05:6512:3d24:b0:4f9:571d:c50e with SMTP id d36-20020a0565123d2400b004f9571dc50emr1501208lfv.36.1691568843947; Wed, 09 Aug 2023 01:14:03 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id w12-20020ac25d4c000000b004f84a92ba75sm2196916lfd.65.2023.08.09.01.14.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 01:14:03 -0700 (PDT) From: Linus Walleij Date: Wed, 09 Aug 2023 10:14:01 +0200 Subject: [PATCH v2 1/2] csky: Cast argument to virt_to_pfn() to (void *) MIME-Version: 1.0 Message-Id: <20230809-csky-virt-to-phys-v2-1-2697c93f60cf@linaro.org> References: <20230809-csky-virt-to-phys-v2-0-2697c93f60cf@linaro.org> In-Reply-To: <20230809-csky-virt-to-phys-v2-0-2697c93f60cf@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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230809_011409_180304_E738765B X-CRM114-Status: GOOD ( 10.97 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:135 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 Wed Aug 9 08:14:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1819171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=zU+Sjmk/; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=AaZNvaOL; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RLNBH4QpLz1yfB for ; Wed, 9 Aug 2023 18:14:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=79ky5j617C7gwBrBeoTqNhemeCaz7pLOgenH+QiUeIA=; b=zU+Sjmk/5KLSLQ 9xnzejfLIFYxMZF59QnH5wTNpyat/+s13sTZSAO2w/ZqpPKNwL96m8r64DB8l4PvuOpc3yqSktQzA TXANI40ANRUn3k6RkLVE+4qUasFUjNauRAKoNN1XVeHQZVKZ/DYfCmICx3ozkEtewVcBrpE3vBHfS IuSip5CbeiH925WJtgq17AYo2IikQ0CrpHWupX5tmUXx6Y4vqWFAHSFhhT61kNF2bfPvWmIGeK2wV TwatRBk2NZKOq45pah5ufgFauFEMHGeNhQ4RNnbhX1nIbRPnrHoyeHCsw+bw87ZUYST2UaIB+Y12p k73MqvleYsmjqotKtTlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qTeKZ-004LCV-29; Wed, 09 Aug 2023 08:14:11 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qTeKX-004LAF-0O for linux-snps-arc@lists.infradead.org; Wed, 09 Aug 2023 08:14:11 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4f4b2bc1565so10569861e87.2 for ; Wed, 09 Aug 2023 01:14:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691568845; x=1692173645; 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=zTXAtK4LyKDOWesDbd7G0no9IFm0HYr1YL9cGl87EzQ=; b=AaZNvaOLHpTrWuNHOIAzKFkJD8Yhj84hT19T1S7uT/t4tAzdb7OJkojkl/IfOZM0ZT 9OINRO5D+ZqlDOHj1/yMIimjGzifYxI4yS9+jjO4Xn+E6Vya6HLMzKt3k76Dg/VjFSMI PvMctNeBYwj67QOe5HCfNpg6SS6/OFsOV5WrJIYEy4YlQhsGyTgb2yhcsak2KrWHzLtr KVOcpMyQfhALHBin9A/U1b/I5aJw2ovXVaIN6hjIeRn7l1HHNMV3eZ9i7JiLNF6zYT9v O1a1qb9IK2i/+JXmfbv24ygVsmeoyP4XXvc1d+Q636+IwmVApXCHvdX5yKKaco2Q556t ONfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691568845; x=1692173645; 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=zTXAtK4LyKDOWesDbd7G0no9IFm0HYr1YL9cGl87EzQ=; b=izMJicisidDPT8XMQLjx0G2FJc6vZTKO3/xVyLfDppx8hquG2mtkZz/chxlevkqYhY L2HMhq/jujXfAvmNWtexMwBgmclBYbn9FjXn/S//cssWRWtnM2loofCCwvKw/7IUjLKk TOVMYU2huFuwuiMqzKiDb1GUv722fMORKgzrcYm+HpUh+vfJ851sY0bJCapg439N4M3d QHr48CQa6CFSwJdj6YWoZOks3ti2feMURtmXMQMoePOg/uLGApd2xkcUUKckpApLlsXK SGFN7F/0tKdOYMLCjfNz4LOUmDQU/jS+ZALXNGkK5ur/UJf/se47QioM8qPC64iqHJ2T 3tWQ== X-Gm-Message-State: AOJu0YwBYdBjxbNgaN+WH9CWJdM+4xxddLtemOavds4vSYwtdX/Q1gtC H5cJE9F1GunVXioVaF2ns++7IIrDFPoDW4NWxWo= X-Google-Smtp-Source: AGHT+IEo8krRs8F/gpp8zmi1UGtwXUgDYy/Wh4w3IdCIabujY5wZOYPZK6TC/S1L29E7S+3sft7jKA== X-Received: by 2002:a05:6512:2507:b0:4f8:770f:1b08 with SMTP id be7-20020a056512250700b004f8770f1b08mr1528563lfb.13.1691568844988; Wed, 09 Aug 2023 01:14:04 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id w12-20020ac25d4c000000b004f84a92ba75sm2196916lfd.65.2023.08.09.01.14.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 01:14:04 -0700 (PDT) From: Linus Walleij Date: Wed, 09 Aug 2023 10:14:02 +0200 Subject: [PATCH v2 2/2] csky: Make pfn accessors static inlines MIME-Version: 1.0 Message-Id: <20230809-csky-virt-to-phys-v2-2-2697c93f60cf@linaro.org> References: <20230809-csky-virt-to-phys-v2-0-2697c93f60cf@linaro.org> In-Reply-To: <20230809-csky-virt-to-phys-v2-0-2697c93f60cf@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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230809_011409_180458_EEEA2B5E X-CRM114-Status: GOOD ( 10.01 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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_ [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:133 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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..57b3f106ae77 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 const void * pfn_to_virt(unsigned long pfn) +{ + return (const 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))