Skip to contentSkip to conversation

xen/dt: Don't advertise Xen static-heap region to hwdom

PATCH In review Michal Orzel 3 participants 4 messages Oct 29 – Oct 30

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/dt: Don't advertise Xen static-heap region to hwdom

bootinfo.reserved_mem is used to store different types of memory that Xen considers as reserved: domU static mem, normal /reserved-memory, FDT memreserve and Xen static heap. make_memory_node(), invoked during FDT generation for a hwdom for reserved memory, only skips the domU static memory and FDT memreserve. This results in advertising Xen static heap (if used) to a hwdom as /memory. This memory is not mapped in P2M and guest attempt to access it fails. Interestingly, if the /reserved-memory node is placed after /chosen, there is no problem because of the check at the beginning of make_memory_node() that finds the first memory range using the correct type.

Fixes 4596329291f5 ("docs, xen/arm: Introduce static heap memory")
---
 xen/common/device-tree/domain-build.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
xen/common/device-tree/domain-build.c +1 -2
index 30a59abfa722..634a26946c24 100644
@@ -541,8 +541,7 @@ int __init make_memory_node(const struct kernel_info *kinfo, int addrcells,
         u64 start = mem->bank[i].start;
         u64 size = mem->bank[i].size;
 
-        if ( (mem->bank[i].type == MEMBANK_STATIC_DOMAIN) ||
-             (mem->bank[i].type == MEMBANK_FDT_RESVMEM) )
+        if ( mem->bank[i].type != MEMBANK_DEFAULT )
             continue;
 
         nr_cells += reg_size;
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Michal Orzel

bootinfo.reserved_mem is used to store different types of memory that Xen considers as reserved: domU static mem, normal /reserved-memory, FDT memreserve and Xen static heap. make_memory_node(), invoked during FDT generation for a hwdom for reserved memory, only skips the domU static memory and FDT memreserve. This results in advertising Xen static heap (if used) to a hwdom as /memory. This memory is not mapped in P2M and guest attempt to access it fails. Interestingly, if the /reserved-memory node is placed after /chosen, there is no problem because of the check at the beginning of make_memory_node() that finds the first memory range using the correct type.>

Quoted 2 lines
Fixes 4596329291f5 ("docs, xen/arm: Introduce static heap memory")

LGTM:

~ Oleksii

Reviewed-by on v1 1/1
#2 lore raw
In reply to Michal Orzel
Quoted 11 lines · Michal Orzel

bootinfo.reserved_mem is used to store different types of memory that Xen considers as reserved: domU static mem, normal /reserved-memory, FDT memreserve and Xen static heap. make_memory_node(), invoked during FDT generation for a hwdom for reserved memory, only skips the domU static memory and FDT memreserve. This results in advertising Xen static heap (if used) to a hwdom as /memory. This memory is not mapped in P2M and guest attempt to access it fails. Interestingly, if the /reserved-memory node is placed after /chosen, there is no problem because of the check at the beginning of make_memory_node() that finds the first memory range using the correct type.

Quoted 2 lines
Fixes 4596329291f5 ("docs, xen/arm: Introduce static heap memory")

I guess git will treat this as conflicting with my dt patch when applying. Let me know if this gets merged first and you would like me to rebase and resend.

Regards,
Kuan-Wei

Quoted 23 lines
---
 xen/common/device-tree/domain-build.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
xen/common/device-tree/domain-build.c +1 -2
index 30a59abfa722..634a26946c24 100644
@@ -541,8 +541,7 @@ int __init make_memory_node(const struct kernel_info *kinfo, int addrcells,
         u64 start = mem->bank[i].start;
         u64 size = mem->bank[i].size;
 
-        if ( (mem->bank[i].type == MEMBANK_STATIC_DOMAIN) ||
-             (mem->bank[i].type == MEMBANK_FDT_RESVMEM) )
+        if ( mem->bank[i].type != MEMBANK_DEFAULT )
             continue;
 
         nr_cells += reg_size;
Signature · 1 line
2.43.0
#3 lore raw
Quoted 12 lines · Kuan-Wei Chiu
Quoted 11 lines · Michal Orzel

bootinfo.reserved_mem is used to store different types of memory that Xen considers as reserved: domU static mem, normal /reserved-memory, FDT memreserve and Xen static heap. make_memory_node(), invoked during FDT generation for a hwdom for reserved memory, only skips the domU static memory and FDT memreserve. This results in advertising Xen static heap (if used) to a hwdom as /memory. This memory is not mapped in P2M and guest attempt to access it fails. Interestingly, if the /reserved-memory node is placed after /chosen, there is no problem because of the check at the beginning of make_memory_node() that finds the first memory range using the correct type.

Quoted 8 lines
Quoted 2 lines
Fixes 4596329291f5 ("docs, xen/arm: Introduce static heap memory")

I guess git will treat this as conflicting with my dt patch when applying. Let me know if this gets merged first and you would like me to rebase and resend.

It will likely get merged first but don't worry. I can solve the conflict when I start reviewing your patch.

~Michal