xen/arm: Fix booting hwdom/1:1 domU with CONFIG_GRANT_TABLE=n
PATCH 1/1 xen/arm: Fix booting hwdom/1:1 domU with CONFIG_GRANT_TABLE=n
At the moment, we unconditionally allocate space for grant table region membank and add it in the membanks array to find_unallocated_memory() to find unused memory. In case of CONFIG_GRANT_TABLE=n, the size of the region is empty and assertion in rangeset_remove_range() fails when booting hwdom or 1:1 domU without IOMMU. Example:
(XEN) Assertion 's <= e' failed at common/rangeset.c:189
...
(XEN) Xen call trace:
(XEN) [<00000a0000218b5c>] rangeset_remove_range+0xbc/0x2d4 (PC) (XEN) [<00000a00002b8370>] find_unallocated_memory+0x140/0x208 (LR) (XEN) [<00000a00002cc28c>] make_hypervisor_node+0x310/0x7e0
...
Same issue would occur when booting hwdom with LLC coloring enabled. Fix it by performing conditional allocation and configuration.
--- xen/arch/arm/domain_build.c | 19 ++++++++++++------- xen/common/device-tree/domain-build.c | 7 ++++++- 2 files changed, 18 insertions(+), 8 deletions(-)
xen/arch/arm/domain_build.c +12 -7
@@ -1011,7 +1011,10 @@ static int __init find_host_extended_regions(const struct kernel_info *kinfo, struct membanks *ext_regions) {int res; -struct membanks *gnttab =membanks_xzalloc (1 ,MEMORY ); +struct membanks *gnttab = +IS_ENABLED (CONFIG_GRANT_TABLE ) + ?membanks_xzalloc (1 ,MEMORY ) + :NULL ;struct membanks *xen_reg = kinfo->xen_reg_assigned ? membanks_xzalloc(count_ranges(kinfo->xen_reg_assigned), MEMORY)
@@ -1037,12 +1040,6 @@ static int __init find_host_extended_regions(const struct kernel_info *kinfo,dt_dprintk ("Find unallocated memory for extended regions\n" ); -if ( !gnttab ) - { - res = -ENOMEM ; - goto out; - } -if ( kinfo->xen_reg_assigned ) {if ( !xen_reg )
@@ -1056,9 +1053,17 @@ static int __init find_host_extended_regions(const struct kernel_info *kinfo, rangeset_to_membank, xen_reg); } +#ifdef CONFIG_GRANT_TABLE +if ( !gnttab ) + { + res = -ENOMEM ; + goto out; + } + gnttab->nr_banks =1 ; gnttab->bank[0 ].start = kinfo->gnttab_start; gnttab->bank[0 ].size = kinfo->gnttab_size; +#endif res =find_unallocated_memory (kinfo, mem_banks,ARRAY_SIZE (mem_banks), ext_regions, add_ext_regions);
xen/common/device-tree/domain-build.c +6 -1
@@ -250,7 +250,10 @@ void __init allocate_memory(struct domain *d, struct kernel_info *kinfo)*/ if (is_hardware_domain (d) ) { -struct membanks *gnttab =membanks_xzalloc (1 ,MEMORY ); +struct membanks *gnttab = +IS_ENABLED (CONFIG_GRANT_TABLE ) + ?membanks_xzalloc (1 ,MEMORY ) + :NULL ;/* * Exclude the following regions: * 1) Remove reserved memory
@@ -261,12 +264,14 @@ void __init allocate_memory(struct domain *d, struct kernel_info *kinfo) gnttab, }; +#ifdef CONFIG_GRANT_TABLE if ( !gnttab ) goto fail; gnttab->nr_banks =1 ; gnttab->bank[0 ].start = kinfo->gnttab_start; gnttab->bank[0 ].size = kinfo->gnttab_size; +#endif hwdom_free_mem =membanks_xzalloc (NR_MEM_BANKS ,MEMORY );if ( !hwdom_free_mem )
Signature · 1 line
2.25.1
Hi Michal,
Quoted 14 lines · Michal Orzel
At the moment, we unconditionally allocate space for grant table region membank and add it in the membanks array to
find_unallocated_memory()to find unused memory. In case ofCONFIG_GRANT_TABLE=n, the size of the region is empty and assertion inrangeset_remove_range()fails when booting hwdom or 1:1 domU without IOMMU. Example:(XEN) Assertion 's <= e' failed at
common/rangeset.c:189
...
(XEN) Xen call trace:(XEN) [<00000a0000218b5c>] rangeset_remove_range+0xbc/0x2d4 (PC) (XEN) [<00000a00002b8370>] find_unallocated_memory+0x140/0x208 (LR) (XEN) [<00000a00002cc28c>] make_hypervisor_node+0x310/0x7e0
Quoted 6 lines
...
Same issue would occur when booting hwdom with LLC coloring enabled. Fix it by performing conditional allocation and configuration.
Signed-off-by Michal Orzel <[email protected]>
The patch looks good to me, I’ve reproduced locally the issue and tested that this patch solves it, using FVP.
Stefano Stabellini
Reviewed-byQuoted 21 lines · Luca Fancellu
Hi Michal,
Quoted 19 lines · Michal Orzel
At the moment, we unconditionally allocate space for grant table region membank and add it in the membanks array to
find_unallocated_memory()to find unused memory. In case ofCONFIG_GRANT_TABLE=n, the size of the region is empty and assertion inrangeset_remove_range()fails when booting hwdom or 1:1 domU without IOMMU. Example:(XEN) Assertion 's <= e' failed at
common/rangeset.c:189
...
(XEN) Xen call trace:(XEN) [<00000a0000218b5c>] rangeset_remove_range+0xbc/0x2d4 (PC) (XEN) [<00000a00002b8370>] find_unallocated_memory+0x140/0x208 (LR) (XEN) [<00000a00002cc28c>] make_hypervisor_node+0x310/0x7e0...
Same issue would occur when booting hwdom with LLC coloring enabled. Fix it by performing conditional allocation and configuration.
Quoted 7 lines
Quoted 1 line
Signed-off-by Michal Orzel <[email protected]>The patch looks good to me, I’ve reproduced locally the issue and tested that this patch solves it, using FVP.
Reviewed-by Luca Fancellu <[email protected]>Tested-by Luca Fancellu <[email protected]>