Skip to contentSkip to conversation

xen/arm: static-shmem: request host address to be specified for 1:1 domains

PATCH In review Michal Orzel 3 participants 5 messages Jun 21, 2024 – Jun 24, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: static-shmem: request host address to be specified for 1:1 domains

As a follow up to commit cb1ddafdc573 ("xen/arm/static-shmem: Static-shmem should be direct-mapped for direct-mapped domains") add a check to request that both host and guest physical address must be supplied for direct mapped domains. Otherwise return an error to prevent unwanted behavior.

---
Reasoning for 4.19:
this is hardening the code to prevent a feature misuse and unwanted behavior.

---
 xen/arch/arm/static-shmem.c | 7 +++++++
 1 file changed, 7 insertions(+)
xen/arch/arm/static-shmem.c +7 -0
index cd48d2896b7e..aa80756c3ca5 100644
@@ -378,6 +378,13 @@ int __init process_shm(struct domain *d, struct kernel_info *kinfo,
             const struct membank *alloc_bank =
                 find_shm_bank_by_id(get_shmem_heap_banks(), shm_id);
 
+            if ( is_domain_direct_mapped(d) )
+            {
+                printk("%pd: host and guest physical address must be supplied for direct-mapped domains\n",
+                       d);
+                return -EINVAL;
+            }
+
             /* guest phys address is right at the beginning */
             gbase = dt_read_paddr(cells, addr_cells);
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 8 lines · Michal Orzel

As a follow up to commit cb1ddafdc573 ("xen/arm/static-shmem: Static- shmem
should be direct-mapped for direct-mapped domains") add a check to request that both host and guest physical address must be supplied for
direct mapped domains. Otherwise return an error to prevent unwanted behavior.

Quoted 6 lines

---
Reasoning for 4.19:
this is hardening the code to prevent a feature misuse and unwanted behavior.
---

~ Oleksii

Quoted 24 lines

 xen/arch/arm/static-shmem.c | 7 +++++++

 1 file changed, 7 insertions(+)
xen/arch/arm/static- renamed from xen/arch/arm/static-shmem.c +0 -0

shmem.c
index cd48d2896b7e..aa80756c3ca5 100644

xen/arch/arm/static-shmem.c +0 -0
@@ -378,6 +378,13 @@ int __init process_shm(struct domain *d, struct
 kernel_info *kinfo,

             const struct membank *alloc_bank = find_shm_bank_by_id(get_shmem_heap_banks(), shm_id);
+            if ( is_domain_direct_mapped(d) )
+            {
+                printk("%pd: host and guest physical address must be supplied for direct-mapped domains\n",
+                       d);
+                return -EINVAL;
+            }
+
             /* guest phys address is right at the beginning */ gbase = dt_read_paddr(cells, addr_cells);

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

Hi Michal,

Quoted 7 lines · Michal Orzel

As a follow up to commit cb1ddafdc573 ("xen/arm/static-shmem: Static-shmem should be direct-mapped for direct-mapped domains") add a check to request that both host and guest physical address must be supplied for direct mapped domains. Otherwise return an error to prevent unwanted behavior.

I would argue that it should be have a fixes tag:

Fixes 988f1c7e1f40 ("xen/arm: static-shmem: fix "gbase/pbase used uninitialized" build failure")

Mainly because while you fixed the build, it was missing the check in the "else" part.

I am happy to update it on commit if you are ok with the change.

Cheers,

Signature · 1 line
Julien Grall
#3 lore raw

Hi Julien,

Quoted 24 lines · Julien Grall

Hi Michal,

Quoted 7 lines · Michal Orzel

As a follow up to commit cb1ddafdc573 ("xen/arm/static-shmem: Static-shmem should be direct-mapped for direct-mapped domains") add a check to request that both host and guest physical address must be supplied for direct mapped domains. Otherwise return an error to prevent unwanted behavior.

I would argue that it should be have a fixes tag:

Fixes 988f1c7e1f40 ("xen/arm: static-shmem: fix "gbase/pbase used

uninitialized" build failure")

Mainly because while you fixed the build, it was missing the check in the "else" part.

I am happy to update it on commit if you are ok with the change.Yes, I'm fine with it.

Quoted 6 lines

Cheers,

--
Julien Grall

~Michal

#4 lore raw
Quoted 18 lines · Michal Orzel

Hi Julien,

Quoted 15 lines · Julien Grall

Hi Michal,

Quoted 7 lines · Michal Orzel

As a follow up to commit cb1ddafdc573 ("xen/arm/static-shmem: Static-shmem should be direct-mapped for direct-mapped domains") add a check to request that both host and guest physical address must be supplied for direct mapped domains. Otherwise return an error to prevent unwanted behavior.

I would argue that it should be have a fixes tag:

Quoted 8 lines
Quoted 7 lines
Fixes 988f1c7e1f40 ("xen/arm: static-shmem: fix "gbase/pbase used

uninitialized" build failure")

Mainly because while you fixed the build, it was missing the check in the "else" part.

I am happy to update it on commit if you are ok with the change.

Yes, I'm fine with it.

Committed.

Cheers,

Signature · 1 line
Julien Grall