xen: Check if the range is valid in init_domheap_pages
PATCH v3 1/1 xen: Check if the range is valid in init_domheap_pages
On ARM, when an initrd is given to xen by U-boot, it will reserve the memory in the device tree.
In this case, when xen decides to free unused memory, dt_unreserved_regions will call init_domheap_pages with the start and the end of range equals. But the latter assumes that (start > end), if not Xen will hang because the number of pages is equals to (unsigned)-1.
---
Changes in v3:
- Invert the check
Changes in v2:
- Change commit title
- Move the check in init_domheap_pages
--- xen/common/page_alloc.c | 3 +++ 1 file changed, 3 insertions(+)
xen/common/page_alloc.c +3 -0
@@ -1429,6 +1429,9 @@ void init_domheap_pages(paddr_t ps, paddr_t pe) smfn =round_pgup (ps) >>PAGE_SHIFT ; emfn =round_pgdown (pe) >>PAGE_SHIFT ; +if ( emfn <= smfn ) +return ; +init_heap_pages (mfn_to_page (smfn), emfn - smfn); }
Signature · 1 line
1.8.3.1
Quoted 11 lines · Julien Grall
On ARM, when an initrd is given to xen by U-boot, it will reserve the memory in
the device tree.
In this case, when xen decides to free unused memory,dt_unreserved_regionswill callinit_domheap_pageswith the start and the end of range equals. But the latter assumes that (start > end), if not Xen will hang because the number of pages is equals to (unsigned)-1.Signed-off-by Julien Grall <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>
I understand Jan's reservations, but I think just being more liberal here is fine really.
Quoted 10 lines · Julien Grall
On ARM, when an initrd is given to xen by U-boot, it will reserve the memory in the device tree.
In this case, when xen decides to free unused memory,dt_unreserved_regionswill callinit_domheap_pageswith the start and the end of range equals. But the latter assumes that (start > end), if not Xen will hang because the number of pages is equals to (unsigned)-1.Signed-off-by Julien Grall <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>
Ping ? Without this commit, the user is unable to pass initrd to dom0 on ARM.
Signature · 1 line
Julien Grall
Keir Fraser
Acked-byQuoted 9 lines · Julien Grall
Quoted 8 lines · Julien Grall
On ARM, when an initrd is given to xen by U-boot, it will reserve the memory in
the device tree.
In this case, when xen decides to free unused memory,dt_unreserved_regionswill callinit_domheap_pageswith the start and the end of range equals. But the latter assumes that (start > end), if not Xen will hang because the number of pages is equals to (unsigned)-1.
Quoted 6 lines
Quoted 3 lines
Signed-off-by Julien Grall <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>Ping ? Without this commit, the user is unable to pass initrd to dom0 on ARM.
It was fine with me.