xen/arm: setup_xenheap_mappings: BUG when alloc_boot_pages
PATCH 1/1 xen/arm: setup_xenheap_mappings: BUG when alloc_boot_pages
On ARM64, bootmem is initialized after setup_xenheap_mappings, so we should not call alloc_boot_pages in setup_xenheap_mappings.
We could not simply move setup_xenheap_mappings after init_boot_pages, because in bootmem_region_add, when bootmem_region_list is NULL, it will assign the first virtual address of the first bootmem region to bootmem_region_list. If the bootmem is not mapped, it will trigger data abort when writting to the bootmem_region_list[] area.
Currently we did not met issue, because FIRST_SIZE is 1GB on ARM64, and xenheap_first_first table could hold up to 512GB virtual memory region. we do not have SoC support such large DRAM now, but we might have in future.
Add BUG() to let people be aware of this issue.
--- xen/arch/arm/mm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
xen/arch/arm/mm.c +8 -2
@@ -850,8 +850,14 @@ void __init setup_xenheap_mappings(unsigned long base_mfn, }else { -mfn_t first_mfn =alloc_boot_pages (1 ,1 ); - +mfn_t first_mfn; + +/* +* TODO: bootmem not ready, need init_boot_pages before alloc +* boot pages. +*/ +BUG (); + first_mfn =alloc_boot_pages (1 ,1 );clear_page (mfn_to_virt (first_mfn)); pte =mfn_to_xen_entry (first_mfn,MT_NORMAL ); pte.pt.table =1 ;
Signature · 7 lines
2.16.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hello,
Quoted 10 lines · Peng Fan
On ARM64, bootmem is initialized after
setup_xenheap_mappings, so we should not callalloc_boot_pagesinsetup_xenheap_mappings.We could not simply move
setup_xenheap_mappingsafterinit_boot_pages, because inbootmem_region_add, whenbootmem_region_listis NULL, it will assign the first virtual address of the first bootmem region tobootmem_region_list. If the bootmem is not mapped, it will trigger data abort when writting to the bootmem_region_list[] area.
Quoted 4 lines
Currently we did not met issue, because
FIRST_SIZEis 1GB on ARM64, andxenheap_first_firsttable could hold up to 512GB virtual memory region. we do not have SoC support such large DRAM now, but we might have in future.
"We" is a bit vague. Do you mean NXP or Arm ecosystem? If the latter, there are definitely platform that can support more than 512GB. Xen supports some of them, but I don't think someone ever tried to boot Xen with that much memory.
Quoted 2 lines
Add
BUG()to let people be aware of this issue.
While I understand the problem, I don't think the BUG() is the correct approach.
Firstly, alloc_boot_pages can only return if a page was allocated. Otherwise, Xen will crash (see various BUG()). So adding a BUG() is a bit pointless.
Secondly, we are meant to support up to 5TB of RAM (see [1]) and there are platform out there supporting more than 512GB.
This means this is a bug in the code that should be fixed. One solution I can see is to rework setup_xenheap_mappings to call init_boot_pages.
Cheers,
[1] https://lists.xenproject.org/archives/html/xen-devel/2018-12/msg00881.html
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel