xen/arm: mm: fix nr_second calculation in setup_frametable_mappings
authorPeng Fan <van.freenix@gmail.com>
Thu, 12 May 2016 13:03:08 +0000 (21:03 +0800)
committerStefano Stabellini <sstabellini@kernel.org>
Mon, 16 May 2016 15:27:04 +0000 (16:27 +0100)
On ARM64, "frametable_size >> SECOND_SHIFT" computes the number
of second level entries, not the number of second level pages.

"ROUNDUP(frametable_size, FIRST_SIZE) >> FIRST_SHIFT" which computes
the number of the first level entries (the number of second level pages),
is the correct one that should be used.

Signed-off-by: Peng Fan <van.freenix@gmail.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/mm.c

index 94ea0541cdaeb8f4a434475ea89a37253242af1b..b46e23ed8c8b3e08cea39ba17414c5cf0973b703 100644 (file)
@@ -770,7 +770,8 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe)
     base_mfn = alloc_boot_pages(frametable_size >> PAGE_SHIFT, 32<<(20-12));
 
 #ifdef CONFIG_ARM_64
-    nr_second = frametable_size >> SECOND_SHIFT;
+    /* Compute the number of second level pages. */
+    nr_second = ROUNDUP(frametable_size, FIRST_SIZE) >> FIRST_SHIFT;
     second_base = alloc_boot_pages(nr_second, 1);
     second = mfn_to_virt(second_base);
     for ( i = 0; i < nr_second; i++ )