Skip to contentSkip to conversation

xen/arm: mm: fix nr_second calculation in setup_frametable_mappings

PATCH In review Peng Fan 3 participants 3 messages May 12, 2016 – May 16, 2016

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH v2 1/1 xen/arm: mm: fix nr_second calculation in setup_frametable_mappings

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.

Cc Stefano Stabellini <[email protected]>
Cc Julien Grall <[email protected]>

---

V2:
Take Julien's suggestion in http://lists.xen.org/archives/html/xen-devel/2016-05/msg01145.html.
Refine commit log.

 xen/arch/arm/mm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/arm/mm.c +2 -1
index 0a4f845..5f60aa4 100644
@@ -767,7 +767,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++ )
Signature · 7 lines
2.6.2


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Reviewed-by on v2 1/1
#1 lore raw

(CC Wei for Xen 4.7)

Hi,

Quoted 10 lines · Peng Fan

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.

Cc Stefano Stabellini <[email protected]>
Cc Julien Grall <[email protected]>

This is a bug fix for Xen 4.7 and should be backported up to Xen 4.4.

Wei, could we get a release-ack for this patch?

The computation of the number of page to allocation was wrong. This could result to overrun xen_first on platform with big amount of memory.

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#2 lore raw
Quoted 12 lines · Julien Grall

(CC Wei for Xen 4.7)

Hi,

Quoted 7 lines · Peng Fan

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.

Quoted 5 lines
Quoted 3 lines
Cc Stefano Stabellini <[email protected]>
Cc Julien Grall <[email protected]>

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel