Skip to contentSkip to conversation

xen/dom0less: arm: fix hwdom 1:1 low memory allocation

PATCH Superseded Grygorii Strashko 3 participants 5 messages Aug 1, 2025 – Aug 5, 2025

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

Fixes 43afe6f030244 ("xen/common: dom0less: introduce common dom0less-build.c")
---
 xen/arch/arm/domain_build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/domain_build.c +1 -1
index 801a09071a50..0a555d1ae0e5 100644
@@ -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
Reviewed-by Denis Mukhin on v1 1/1
#1 lore raw
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 causes min_low_order to get high value > order and so no allocations happens from low memory.

Quoted 5 lines

Fix it, by using kinfo->unassigned_mem instead of "dom0_mem" has correct memory size in both cases: regular dom0 boot and dom0less boot.

Fixes 43afe6f030244 ("xen/common: dom0less: introduce common dom0less-build.c")
Quoted 20 lines
---
 xen/arch/arm/domain_build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/domain_build.c +1 -2
index 801a09071a50..0a555d1ae0e5 100644
@@ -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;
--

2.34.1

Reviewed-by on v1 1/1
#2 lore raw
In reply to Grygorii Strashko
Quoted 12 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)));

Quoted 8 lines

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.

Fixes 43afe6f030244 ("xen/common: dom0less: introduce common dom0less-build.c")

I think I introduced this bug with the dom0less hwdom support, and the correct fixes is:

Fixes 52cb53f1816a ("xen/arm: dom0less hwdom construction")
Quoted 1 line

dom0_mem is also mentioned in the comment on line 252. With that changed as well:

Thanks,
Jason

#3 lore raw

Hi Jason,

Quoted 24 lines · Jason Andryuk
Quoted 12 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)));

Quoted 8 lines

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.

Fixes 43afe6f030244 ("xen/common: dom0less: introduce common dom0less-build.c")

I think I introduced this bug with the dom0less hwdom support, and the correct fixes is:

Quoted 7 lines
Fixes 52cb53f1816a ("xen/arm: dom0less hwdom construction")
Quoted 1 line

dom0_mem is also mentioned in the comment on line 252.  With that changed as well:

Will smth like below be ok?

* 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).

Signature · 2 lines
Best regards,
-grygorii
#4 lore raw
Quoted 36 lines · Grygorii Strashko

Hi Jason,

Quoted 24 lines · Jason Andryuk
Quoted 12 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)));

Quoted 8 lines

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.

Fixes 43afe6f030244 ("xen/common: dom0less: introduce common dom0less-build.c")

I think I introduced this bug with the dom0less hwdom support, and the correct fixes is:

Quoted 7 lines
Fixes 52cb53f1816a ("xen/arm: dom0less hwdom construction")
Quoted 1 line

dom0_mem is also mentioned in the comment on line 252.  With that changed as well:

Quoted 6 lines

Will smth like below be ok?

  * 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).

LGTM - Thank you.

-Jason