xen/arm: Don't call init_domheap_page with an empty range
PATCH 1/1 xen/arm: Don't call init_domheap_page with an empty range
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_page 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.
--- xen/arch/arm/setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/arm/setup.c +2 -1
@@ -173,7 +173,8 @@ static void dt_unreserved_regions(paddr_t s, paddr_t e, } } -cb (s, e); +if ( s != e ) +cb (s, e); }void __init discard_initial_modules (void )
Signature · 1 line
1.8.3.1
Quoted 6 lines · Julien Grall
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_pagewith 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.
init_xenheap_pages starts with "if (pe<=ps) return". I think init_domheap_pages usefully do the same.
If we are to fix this in dt_unreserved_regions it should be with < or whatever not !=.
Quoted 20 lines
Signed-off-by Julien Grall <[email protected]>--- xen/arch/arm/setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)xen/arch/arm/setup.c +2
-1@@ -173,7 +173,8 @@ static void dt_unreserved_regions(paddr_t s, paddr_t e, } } -cb (s, e); +if ( s != e ) +cb (s, e); }void __init discard_initial_modules (void )
Quoted 10 lines · Ian Campbell
Quoted 6 lines · Julien Grall
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_pagewith 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.
init_xenheap_pagesstarts with "if (pe<=ps) return". I thinkinit_domheap_pagesusefully do the same.
Actually, init_domheap_pages doesn't contain this fix. I will rework this patch to move the check in this function.
Signature · 1 line
Julien Grall
Quoted 10 lines · Julien Grall
Quoted 8 lines · Ian Campbell
Quoted 6 lines · Julien Grall
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_pagewith 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 2 lines
Quoted 2 lines
init_xenheap_pagesstarts with "if (pe<=ps) return". I thinkinit_domheap_pagesusefully do the same.
oops: ^could
Quoted 1 line
Actually,
init_domheap_pagesdoesn't contain this fix.
Yeah, I missed a word out, sorry!
Quoted 1 line
I will rework this patch to move the check in this function.
Thanks!
Ian.