[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1566179120-5910-1-git-send-email-huangzhaoyang@gmail.com>
Date: Mon, 19 Aug 2019 09:45:20 +0800
From: Zhaoyang Huang <huangzhaoyang@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Zhaoyang Huang <zhaoyang.huang@...soc.com>,
Russell King <linux@...linux.org.uk>,
Mike Rapoport <rppt@...ux.ibm.com>,
Rob Herring <robh@...nel.org>,
Florian Fainelli <f.fainelli@...il.com>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Doug Berger <opendmb@...il.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2] arch : arm : add a criteria for pfn_valid
From: Zhaoyang Huang <zhaoyang.huang@...soc.com>
pfn_valid can be wrong when parsing a invalid pfn whose phys address
exceeds BITS_PER_LONG as the MSB will be trimed when shifted.
Signed-off-by: Zhaoyang Huang <zhaoyang.huang@...soc.com>
---
v2: use __pfn_to_phys/__phys_to_pfn instead of max_pfn as the criteria
---
arch/arm/mm/init.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index c2daabb..cc769fa 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -177,6 +177,11 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max_low,
#ifdef CONFIG_HAVE_ARCH_PFN_VALID
int pfn_valid(unsigned long pfn)
{
+ phys_addr_t addr = __pfn_to_phys(pfn);
+
+ if (__phys_to_pfn(addr) != pfn)
+ return 0;
+
return memblock_is_map_memory(__pfn_to_phys(pfn));
}
EXPORT_SYMBOL(pfn_valid);
--
1.9.1
Powered by blists - more mailing lists