[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 3/3] xen/arm: fix mask calculation in init_pdx



The mask calculation in init_pdx is wrong when the first bank starts at
address 0x0. The reason is that pdx_init_mask will do '0 - 1' causing an
underflow. As a result, the mask becomes 0xffffffffffffffff which is the
biggest possible mask and ends up causing a significant memory waste in
the frametable size computation.

For instance, on platforms that have a low memory bank and a high memory
bank, the frametable will end up covering all the holes in between.

The purpose of the mask is to be passed as a parameter to
pfn_pdx_hole_setup, which based on the mask parameter caculates
pfn_pdx_hole_shift, pfn_pdx_bottom_mask, etc. which are actually the
important masks for frametable initialization later on.

pfn_pdx_hole_setup never compresses addresses below MAX_ORDER bits (1GB
on ARM). Thus, it is safe to initialize mask passing 1ULL << (MAX_ORDER
+ PAGE_SHIFT) as start address to pdx_init_mask.

Signed-off-by: Stefano Stabellini <stefanos@xxxxxxxxxx>
CC: JBeulich@xxxxxxxx
---
 xen/arch/arm/setup.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index ccb0f18..22f20bb 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -481,10 +481,15 @@ static paddr_t __init next_module(paddr_t s, paddr_t *end)
 static void __init init_pdx(void)
 {
     paddr_t bank_start, bank_size, bank_end;
-
-    u64 mask = pdx_init_mask(bootinfo.mem.bank[0].start);
+    u64 mask;
     int bank;
 
+    /*
+     * We always map the first 1<<MAX_ORDER of RAM, hence, they are left
+     * uncompressed.
+     */
+    mask = pdx_init_mask(1ULL << (MAX_ORDER + PAGE_SHIFT));
+
     for ( bank = 0 ; bank < bootinfo.mem.nr_banks; bank++ )
     {
         bank_start = bootinfo.mem.bank[bank].start;
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.