Message ID | 20241023053644.311692-3-hch@lst.de |
---|---|
State | New |
Headers | show
Return-Path: <SRS0=mzEY=RT=vger.kernel.org=sparclinux+bounces-2444-patchwork-incoming=ozlabs.org@ozlabs.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=h3p8AkRX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=mzey=rt=vger.kernel.org=sparclinux+bounces-2444-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XYHr272kzz1xwf for <incoming@patchwork.ozlabs.org>; Wed, 23 Oct 2024 16:37:38 +1100 (AEDT) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4XYHr13l3xz4wbr for <incoming@patchwork.ozlabs.org>; Wed, 23 Oct 2024 16:37:37 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4XYHr13jYFz4wyk; Wed, 23 Oct 2024 16:37:37 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2604:1380:45d1:ec00::1" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1729661857; cv=pass; b=JdIixPO5OToGHeila+5sKixJ8e3AoKe/gszDiRgbc0PxfFjNP13U3hJEYgKaErWHSL12r0EIw5VT2smPC85tO+FPLuZrNSTH7kRq5jSDPY2GmKtNjHns4jfhEUUOaRA4HWiBCLOOpS2IZ22alArOP/k4JzFc2Q8ZpXD+oH5OwXpwr9aYoEawtUbuPaUS+6NbM2f+5Yk/FamXNzRloH00VFkTEIy1EYB996sO1MXmlG8yQ+ELgVCnT0nklL9MoMZ9vEPLz7Fx1AuIGlxvuWlbafYL4b69PepOxPjyWTT1vbx4Olcziawqa0CnCkMpNHjtBFaflY6JNjSa5E8s68i88A== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1729661857; c=relaxed/relaxed; bh=pMVglSrzfw659uFTl63Kmjtp2oxz/obCT3ExoMvUsd0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jGo3iaArUnodahMe71oFRP2oDqEWbn0732XeG73xvUmV5BfDRcbHC7zoZnTOvRoZnyBs9E8m+EUd3NVL5amu7EpaVPIUXMgxL23bL3EMlot1MsutL6gdZ/KLG9DSwEjEo5McvqGCraPiXDx4ArSNRZEVeq6ug29zCBqTwDF2N/kZ01YfjKGEFLeeBthFw6FDIqiLR9Vwk+R08wVSiDdj7P2vQPuiSO6wG4l56TUjwisI2nnsylyLT1ALcKKFhm1Pqme3uSfHevVTkpIuf0D4FT/6bX4OQNMPC5cgJLLl3Mo8AgVFfRLIa7yIBjSaUHY2LJTp+W09P1yqHtsSjRfkbA== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=none (p=none dis=none) header.from=lst.de; dkim=pass (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=h3p8AkRX; dkim-atps=neutral; spf=pass (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=sparclinux+bounces-2444-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=h3p8AkRX; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=sparclinux+bounces-2444-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4XYHr10YSPz4wbr for <patchwork-incoming@ozlabs.org>; Wed, 23 Oct 2024 16:37:37 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 78D071C22C86 for <patchwork-incoming@ozlabs.org>; Wed, 23 Oct 2024 05:37:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ECC0114A0BC; Wed, 23 Oct 2024 05:36:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="h3p8AkRX" X-Original-To: sparclinux@vger.kernel.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FB90149E09; Wed, 23 Oct 2024 05:36:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729661815; cv=none; b=s2jJsoSCCXOIdBRyZi0SzBxFY7o1GpYnJPrkTU4IjgVEFXlklssW+3egxYsSlCX1VMHO62Y5qr+muyemV5ID1H+XuHDgOBfzuKG6MuEG6EATM65bepdR1ndQjGto1P/2MiXeMA8DAeMlNX9cq4lHdS061k0YCjSn3MwRONRnjDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729661815; c=relaxed/simple; bh=ClvX9P0YomXUmyBHowrG7BxBjln1Yzy53NGFXrXeMOE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VL0XVyjSTLguf4px08v6b6Q9AwEMdTAUzEKqBtojs1y9z6E1nBqkpZfP7VIri7ckmRi3zE08yqN5/gY5DQ8g9J01fivOZHQNPa4FaFndTdDTPkhbry6euOoPgc0K5dd0NlQC58wwmoPBqshG0jiibRofRPpVq0LOcGWw2dCz1MY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=h3p8AkRX; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=pMVglSrzfw659uFTl63Kmjtp2oxz/obCT3ExoMvUsd0=; b=h3p8AkRXGihxrDLi0oq5AhmjrT sTISKsZ7wx8jV9O21Ahj8jdqo90qdhmRBhAZz6XhMrq1rXwehioiPD6gl5siWuIOERts7rl0d6BoC 3RXx6Ufopbo8/Ijiz2CMgtPiWHqU9iDJBhboPe53eyEGZezeZeQr+LrYePax3DOdL5SmXQOPwk7tK 4JCXJSs0b2T4XEPEy9UvFFL59NVLAw9aBC9j8arBo/tX4fX+Qev54AaYCEE2jWENLGxtGguKSu9Cd uqSZBqpqJY7atLAmszcql9T2iUE9VUXqWmY35nWH5Ppdmsc8z7fVK9ofvS2xayhi0AEqU/zp51pos /x8WzO4A==; Received: from 2a02-8389-2341-5b80-8c6c-e123-fc47-94a5.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:8c6c:e123:fc47:94a5] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1t3U3A-0000000D4L4-25Zx; Wed, 23 Oct 2024 05:36:53 +0000 From: Christoph Hellwig <hch@lst.de> To: Arnd Bergmann <arnd@arndb.de> Cc: linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, linux-arch@vger.kernel.org Subject: [PATCH 2/2] asm-generic: add an optional pfn_valid check to page_to_phys Date: Wed, 23 Oct 2024 07:36:37 +0200 Message-ID: <20241023053644.311692-3-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241023053644.311692-1-hch@lst.de> References: <20241023053644.311692-1-hch@lst.de> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: <sparclinux.vger.kernel.org> List-Subscribe: <mailto:sparclinux+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:sparclinux+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from <hch@infradead.org> by bombadil.infradead.org. See http://www.infradead.org/rpr.html |
Series |
[1/2] asm-generic: provide generic page_to_phys and phys_to_page implementations
|
expand
|
diff --git a/include/asm-generic/memory_model.h b/include/asm-generic/memory_model.h index a73a140cbecd..6d1fb6162ac1 100644 --- a/include/asm-generic/memory_model.h +++ b/include/asm-generic/memory_model.h @@ -64,7 +64,17 @@ static inline int pfn_valid(unsigned long pfn) #define page_to_pfn __page_to_pfn #define pfn_to_page __pfn_to_page +#ifdef CONFIG_DEBUG_VIRTUAL +#define page_to_phys(page) \ +({ \ + unsigned long __pfn = page_to_pfn(page); \ + \ + WARN_ON_ONCE(!pfn_valid(__pfn)); \ + PFN_PHYS(__pfn); \ +}) +#else #define page_to_phys(page) PFN_PHYS(page_to_pfn(page)) +#endif /* CONFIG_DEBUG_VIRTUAL */ #define phys_to_page(phys) pfn_to_page(PHYS_PFN(phys)) #endif /* __ASSEMBLY__ */
page_to_pfn is usually implemented by pointer arithmetics on the memory map, which means that bogus input can lead to even more bogus output. Powerpc had a pfn_valid check on the intermediate pfn in the page_to_phys implementation when CONFIG_DEBUG_VIRTUAL is defined, which seems generally useful, so add that to the generic version. Signed-off-by: Christoph Hellwig <hch@lst.de> --- include/asm-generic/memory_model.h | 10 ++++++++++ 1 file changed, 10 insertions(+)