aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mmzone.h
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2011-05-19 08:21:14 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-05-26 05:23:24 -0400
commit7b7bf499f79de3f6c85a340c8453a78789523f85 (patch)
tree1d0bf7ae8d5befe135fb7e7cfc455656a0ec7b34 /include/linux/mmzone.h
parent4db70f73e56961b9bcdfd0c36c62847a18b7dbb5 (diff)
ARM: 6913/1: sparsemem: allow pfn_valid to be overridden when using SPARSEMEM
In commit eb33575c ("[ARM] Double check memmap is actually valid with a memmap has unexpected holes V2"), a new function, memmap_valid_within, was introduced to mmzone.h so that holes in the memmap which pass pfn_valid in SPARSEMEM configurations can be detected and avoided. The fix to this problem checks that the pfn <-> page linkages are correct by calculating the page for the pfn and then checking that page_to_pfn on that page returns the original pfn. Unfortunately, in SPARSEMEM configurations, this results in reading from the page flags to determine the correct section. Since the memmap here has been freed, junk is read from memory and the check is no longer robust. In the best case, reading from /proc/pagetypeinfo will give you the wrong answer. In the worst case, you get SEGVs, Kernel OOPses and hung CPUs. Furthermore, ioremap implementations that use pfn_valid to disallow the remapping of normal memory will break. This patch allows architectures to provide their own pfn_valid function instead of using the default implementation used by sparsemem. The architecture-specific version is aware of the memmap state and will return false when passed a pfn for a freed page within a valid section. Acked-by: Mel Gorman <mgorman@suse.de> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Tested-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'include/linux/mmzone.h')
-rw-r--r--include/linux/mmzone.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 217bcf6bca7..261f299c944 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1056,12 +1056,14 @@ static inline struct mem_section *__pfn_to_section(unsigned long pfn)
1056 return __nr_to_section(pfn_to_section_nr(pfn)); 1056 return __nr_to_section(pfn_to_section_nr(pfn));
1057} 1057}
1058 1058
1059#ifndef CONFIG_HAVE_ARCH_PFN_VALID
1059static inline int pfn_valid(unsigned long pfn) 1060static inline int pfn_valid(unsigned long pfn)
1060{ 1061{
1061 if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS) 1062 if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
1062 return 0; 1063 return 0;
1063 return valid_section(__nr_to_section(pfn_to_section_nr(pfn))); 1064 return valid_section(__nr_to_section(pfn_to_section_nr(pfn)));
1064} 1065}
1066#endif
1065 1067
1066static inline int pfn_present(unsigned long pfn) 1068static inline int pfn_present(unsigned long pfn)
1067{ 1069{