x86: fix pte allocation in "x86: introduce init_memory_mapping for 32bit"
PATCH 1/1 x86: fix pte allocation in "x86: introduce init_memory_mapping for 32bit"
The patch "x86: introduce init_memory_mapping for 32bit" does not allocate enough space for PTEs if the CPU does not implement PSE.
---arch/x86/mm/init_32.c | 5 +++++
1 file changed, 5 insertions(+)
===================================================================
arch/x86/mm/init_32.c +0 -0
@@ -733,6 +733,11 @@
pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT; tables += PAGE_ALIGN(pmds * sizeof(pmd_t));
+ if (!cpu_has_pse) {
+ int ptes = (end + PAGE_SIZE - 1) >> PAGE_SHIFT;
+ tables += PAGE_ALIGN(ptes * sizeof(pte_t));
+ }
+
/*
* RED-PEN putting page tables only on node 0 could
* cause a hotspot and fill up ZONE_DMA. The page tables
Quoted 15 lines · Jeremy Fitzhardinge
The patch "x86: introduce
init_memory_mappingfor 32bit" does not allocate enough space for PTEs if the CPU does not implement PSE.Signed-off-by Jeremy Fitzhardinge <[email protected]>Cc Yinghai Lu <[email protected]>---
arch/x86/mm/init_32.c| 5 +++++1 file changed, 5 insertions(+)===================================================================
arch/x86/mm/init_32.c +0
-0@@ -733,6 +733,11 @@ pmds = (end +PMD_SIZE -1 ) >>PMD_SHIFT ;
arch/x86/mm/init_32.c line 743
Quoted 10 lines
arch/x86/mm/init_32.c +5
-0tables +=PAGE_ALIGN (pmds *sizeof (pmd_t)); +if (!cpu_has_pse) { +int ptes = (end +PAGE_SIZE -1 ) >>PAGE_SHIFT ; + tables +=PAGE_ALIGN (ptes *sizeof (pte_t)); + } +/* * RED-PEN putting page tables only on node 0 could * cause a hotspot and fill up ZONE_DMA. The page tables
thanks.
my test system never use the area from table_start to table_end. and I wonder why init_pgtable is that big..
YH
Quoted 4 lines · Yinghai Lu
thanks.
my test system never use the area from
table_starttotable_end. and I wonder whyinit_pgtableis that big..
This code looks just like the 64-bit code (I guess it's becoming prime for unification), and I'd just spent some time debugging a bug in Xen64 caused by an overrun of the allocated area when creating non-PSE mappings of physical memory. I didn't observe a specific problem with this code, but consistency and pattern matching made it seem like a necessary addition. It only ends up reserving the amount of space actually used, so there's no wasted memory.
If you use PSE to create the mapping and have enough mapped pages anyway (small kernel), then you may not end up using any of this space.
J
Ingo Molnar
AppliedQuoted 2 lines · Jeremy Fitzhardinge
The patch "x86: introduce
init_memory_mappingfor 32bit" does not allocate enough space for PTEs if the CPU does not implement PSE.
applied to tip/x86/unify-setup - thanks Jeremy!
Ingo