xen/dom0less: arm: fix hwdom 1:1 low memory allocation
PATCH v2 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" has correct memory size in both cases: regular dom0 boot and dom0less boot.
---
Changes in v2:
- changed 'fixes' tag
- fixed comment for allocate_memory_11()
- added reviewer's tags
xen/arch/arm/domain_build.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
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 6 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
Call stack for dom0less hwdom case (1:1) memory:
create_domUs
|-construct_domU
|-construct_hwdom()
Quoted 7 lines
|-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,
From docs/mics/xen-command-linux.pandoc:
---
### dom0_mem (ARM)
Quoted 1 line
= <size>
Set the amount of memory for the initial domain (dom0). It must be greater than zero. This parameter is required.
---
If dom0_mem is effectively optional, then shouldn't the doc be updated?
Quoted 9 lines
which causes
min_low_orderto get high value > order and so no allocations happens from low memory.Quoted 1 line
Fix it, by using
kinfo->unassigned_meminstead of "dom0_mem" has correctmemory 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]>
Cheers,
Signature · 1 line
Julien Grall
Hi Julien,
Quoted 22 lines · Julien Grall
Hi Grygorii,
Quoted 8 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()Quoted 5 lines
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,From docs/mics/xen-command-linux.pandoc:
---
###
dom0_mem(ARM)
Quoted 8 lines
Quoted 1 line
= <size>Set the amount of memory for the initial domain (dom0). It must be greater than zero. This parameter is required.
---
If
dom0_memis effectively optional, then shouldn't the doc be updated?
No. I think doc is correct because when regular Dom0(hwdom)(initial domain) is created code goes through regular Dom0 path and "dom0_mem" is accounted for.
create_dom0()->construct_dom0()
kinfo.unassigned_mem = dom0_mem;
construct_hwdom()->allocate_memory_11()The issue happens in dom0less mode when hwdom is created and domain's configuration parameters are obtained from DT.
Quoted 4 lines
Quoted 4 lines
which causes
min_low_orderto get high value > order and so no allocations happens from low memory.Quoted 1 line
Fix it, by using
kinfo->unassigned_meminstead of "dom0_mem" has correct
Right, it should be "which has"
Quoted 11 lines
Quoted 6 lines
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]>Cheers,
Signature · 2 lines
Best regards, -grygorii
Hi Grygorii,
Quoted 30 lines · Grygorii Strashko
Hi Julien,
Quoted 27 lines · Julien Grall
Hi Grygorii,
Quoted 8 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()Quoted 5 lines
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,From docs/mics/xen-command-linux.pandoc:
---
###
dom0_mem(ARM)
>= <size>Set the amount of memory for the initial domain (dom0). It must be greater than zero. This parameter is required.
Quoted 6 lines
Quoted 3 lines
---
If
dom0_memis effectively optional, then shouldn't the doc be updated?No. I think doc is correct because when regular Dom0(hwdom)(initial domain) is created code goes through regular Dom0 path and "
dom0_mem" is accounted for.
I understand this is used when dom0 is not described in the device tree.
The crucial part in your sentence is "when", to me this indicates a condition. Whereas the current wording in xen-command-linux is using "required" with no condition. So a reader can rightfully think the parameter is also used in dom0less and have to be specified.
So I think the wording needs to be tweaked to something like "This parameter is required (and only used) when the initial domain is not described in the Device-Tree."
Although, "required" might still be too strict because it looks like we would provide a configuration for dom0_mem if it is not set.
Cheers,
Signature · 1 line
Julien Grall
Quoted 37 lines · Julien Grall
Hi Grygorii,
Quoted 34 lines · Grygorii Strashko
Hi Julien,
Quoted 30 lines · Julien Grall
Hi Grygorii,
Quoted 8 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()Quoted 5 lines
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,From docs/mics/xen-command-linux.pandoc:
---
###
dom0_mem(ARM)
>= <size>Set the amount of memory for the initial domain (dom0). It must be greater than zero. This parameter is required.
---
If
dom0_memis effectively optional, then shouldn't the doc be updated?
Quoted 7 lines
Quoted 2 lines
No. I think doc is correct because when regular Dom0(hwdom)(initial domain) is created code goes through regular Dom0 path and "
dom0_mem" is accounted for.I understand this is used when dom0 is not described in the device tree.
The crucial part in your sentence is "when", to me this indicates a condition. Whereas the current wording in xen-command-linux is using "required" with no condition. So a reader can rightfully think the parameter is also used in dom0less and have to be specified.So I think the wording needs to be tweaked to something like "This parameter is required (and only used) when the initial domain is not described in the Device-Tree."
Got it.
Quoted 2 lines
Although, "required" might still be too strict because it looks like we would provide a configuration for
dom0_memif it is not set.
Correct - it will be defaulted to MB(512) if not configured + log notification "PLEASE SPECIFY dom0_mem PARAMETER - USING 512M FOR NOW\n"
Thank you.
Signature · 2 lines
Best regards, -grygorii