xen/dom0less: arm: fix hwdom 1:1 low memory allocation
PATCH v3 1/1 xen/dom0less: arm: fix hwdom 1:1 low memory allocation
From: Grygorii Strashko <[email protected]>
Call stack for dom0less hwdom case (1:1) memory:create_domUs
|-construct_domU
|-construct_hwdom()
|-allocate_memory_11()
And allocate_memory_11() uses "dom0_mem" as:min_low_order =
get_order_from_bytes(min_t(paddr_t, dom0_mem, MB(128)));
In case of dom0less boot the "dom0_mem" is not used and defaulted to 0, which causes min_low_order to get high value > order and so no allocations happens from low memory.
Fix it, by using kinfo->unassigned_mem instead of "dom0_mem" which has correct memory size in both cases: regular dom0 boot and dom0less boot.
---
Changes in v3:
- updated "dom0_mem" doc in xen-command-line.pandoc
- add tag from Julien Grall
Changes in v2:
- changed 'fixes' tag
- fixed comment for allocate_memory_11()
- added reviewer's tags
docs/misc/xen-command-line.pandoc | 3 ++- xen/arch/arm/domain_build.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)
docs/misc/xen-command-line.pandoc +2 -1
@@ -1035,7 +1035,8 @@ For example, with `dom0_max_vcpus=4-8`: > `= <size>` Set the amount of memory for the initial domain (dom0). It must be -greater than zero. This parameter is required. +greater than zero. This parameter is required (and only used) when the initial +domain is not described in the Device-Tree. ### dom0_mem (x86) > `= List of ( min:<sz> | max:<sz> | <sz> )`
xen/arch/arm/domain_build.c +2 -2
@@ -249,7 +249,7 @@ fail:* * We first allocate the largest allocation we can as low as we * can. This then becomes the first bank. This bank must be at least -* 128MB (or dom0_mem if that is smaller). +* 128MB (or memory size requested for domain if that is smaller). * * Then we start allocating more memory, trying to allocate the * largest possible size and trying smaller sizes until we
@@ -278,7 +278,7 @@ static void __init allocate_memory_11(struct domain *d, struct kernel_info *kinfo) {const unsigned int min_low_order = -get_order_from_bytes (min_t (paddr_t, dom0_mem,MB (128 ))); +get_order_from_bytes (min_t (paddr_t, kinfo->unassigned_mem,MB (128 )));const unsigned int min_order =get_order_from_bytes (MB (4 ));struct membanks *mem =kernel_info_get_mem (kinfo);struct page_info *pg;
Signature · 1 line
2.34.1
Hi Grygorii,
Quoted 16 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
Call stack for dom0less hwdom case (1:1) memory:
create_domUs
|-construct_domU
|-construct_hwdom()|-allocate_memory_11()And
allocate_memory_11()uses "dom0_mem" as:min_low_order=
get_order_from_bytes(min_t(paddr_t, dom0_mem, MB(128)));In case of dom0less boot the "
dom0_mem" is not used and defaulted to 0, which causesmin_low_orderto get high value > order and so no allocations happens from low memory.
Quoted 8 lines
Fix it, by using
kinfo->unassigned_meminstead of "dom0_mem" which has correct memory size in both cases: regular dom0 boot and dom0less boot.Fixes 52cb53f1816a ("xen/arm: dom0less hwdom construction")Signed-off-by Grygorii Strashko <[email protected]>Reviewed-by Denis Mukhin <[email protected]>Reviewed-by Jason Andryuk <[email protected]>Acked-by Julien Grall <[email protected]>
I have now committed the patch.
Cheers,
Signature · 1 line
Julien Grall