[PATCH v3 09/20] xen/dom0less: abstract Arm-specific p2m type name for device MMIO mappings

Oleksii Kurochko posted 20 patches 3 months ago
There is a newer version of this series
[PATCH v3 09/20] xen/dom0less: abstract Arm-specific p2m type name for device MMIO mappings
Posted by Oleksii Kurochko 3 months ago
Rename `p2m_mmio_direct_dev` to a more architecture-neutral alias
`p2m_mmio_direct` to avoid leaking Arm-specific naming into common Xen code,
such as dom0less passthrough property handling.

This helps reduce platform-specific terminology in shared logic and
improves clarity for future non-Arm ports (e.g. RISC-V or PowerPC).

No functional changes — the definition is preserved via a macro alias
for Arm.

Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
---
Changes in v3:
 - New patch
---
 xen/arch/arm/include/asm/p2m.h          | 2 ++
 xen/common/device-tree/dom0less-build.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/include/asm/p2m.h b/xen/arch/arm/include/asm/p2m.h
index 2d53bf9b61..bade1eb71b 100644
--- a/xen/arch/arm/include/asm/p2m.h
+++ b/xen/arch/arm/include/asm/p2m.h
@@ -137,6 +137,8 @@ typedef enum {
     p2m_max_real_type,  /* Types after this won't be store in the p2m */
 } p2m_type_t;
 
+#define p2m_mmio_direct p2m_mmio_direct_dev
+
 /* We use bitmaps and mask to handle groups of types */
 #define p2m_to_mask(_t) (1UL << (_t))
 
diff --git a/xen/common/device-tree/dom0less-build.c b/xen/common/device-tree/dom0less-build.c
index 6bb038111d..5b97bf0343 100644
--- a/xen/common/device-tree/dom0less-build.c
+++ b/xen/common/device-tree/dom0less-build.c
@@ -185,7 +185,7 @@ static int __init handle_passthrough_prop(struct kernel_info *kinfo,
                                gaddr_to_gfn(gstart),
                                PFN_DOWN(size),
                                maddr_to_mfn(mstart),
-                               p2m_mmio_direct_dev);
+                               p2m_mmio_direct);
         if ( res < 0 )
         {
             printk(XENLOG_ERR
-- 
2.50.1


Re: [PATCH v3 09/20] xen/dom0less: abstract Arm-specific p2m type name for device MMIO mappings
Posted by Jan Beulich 2 months, 3 weeks ago
On 31.07.2025 17:58, Oleksii Kurochko wrote:
> Rename `p2m_mmio_direct_dev` to a more architecture-neutral alias
> `p2m_mmio_direct` to avoid leaking Arm-specific naming into common Xen code,
> such as dom0less passthrough property handling.
> 
> This helps reduce platform-specific terminology in shared logic and
> improves clarity for future non-Arm ports (e.g. RISC-V or PowerPC).
> 
> No functional changes — the definition is preserved via a macro alias
> for Arm.
> 
> Suggested-by: Jan Beulich <jbeulich@suse.com>

I'm sorry, but no, ...

> --- a/xen/arch/arm/include/asm/p2m.h
> +++ b/xen/arch/arm/include/asm/p2m.h
> @@ -137,6 +137,8 @@ typedef enum {
>      p2m_max_real_type,  /* Types after this won't be store in the p2m */
>  } p2m_type_t;
>  
> +#define p2m_mmio_direct p2m_mmio_direct_dev

... this isn't what I suggested. When Arm has three p2m_mmio_direct_*,
randomly aliasing one to p2m_mmio_direct is imo more likely to create
confusion than to help things. Imo you want to introduce ...

> --- a/xen/common/device-tree/dom0less-build.c
> +++ b/xen/common/device-tree/dom0less-build.c
> @@ -185,7 +185,7 @@ static int __init handle_passthrough_prop(struct kernel_info *kinfo,
>                                 gaddr_to_gfn(gstart),
>                                 PFN_DOWN(size),
>                                 maddr_to_mfn(mstart),
> -                               p2m_mmio_direct_dev);
> +                               p2m_mmio_direct);

... a per-arch inline function which returns the type to use here.
The name of the function would want to properly reflect the purpose;
my limited DT knowledge may make arch_dt_passthrough_p2m_type() an
entirely wrong suggestion.

Jan

Re: [PATCH v3 09/20] xen/dom0less: abstract Arm-specific p2m type name for device MMIO mappings
Posted by Oleksii Kurochko 2 months, 3 weeks ago
On 8/4/25 4:11 PM, Jan Beulich wrote:
> On 31.07.2025 17:58, Oleksii Kurochko wrote:
>> Rename `p2m_mmio_direct_dev` to a more architecture-neutral alias
>> `p2m_mmio_direct` to avoid leaking Arm-specific naming into common Xen code,
>> such as dom0less passthrough property handling.
>>
>> This helps reduce platform-specific terminology in shared logic and
>> improves clarity for future non-Arm ports (e.g. RISC-V or PowerPC).
>>
>> No functional changes — the definition is preserved via a macro alias
>> for Arm.
>>
>> Suggested-by: Jan Beulich<jbeulich@suse.com>
> I'm sorry, but no, ...
>
>> --- a/xen/arch/arm/include/asm/p2m.h
>> +++ b/xen/arch/arm/include/asm/p2m.h
>> @@ -137,6 +137,8 @@ typedef enum {
>>       p2m_max_real_type,  /* Types after this won't be store in the p2m */
>>   } p2m_type_t;
>>   
>> +#define p2m_mmio_direct p2m_mmio_direct_dev
> ... this isn't what I suggested. When Arm has three p2m_mmio_direct_*,
> randomly aliasing one to p2m_mmio_direct is imo more likely to create
> confusion than to help things. Imo you want to introduce ...

This is not randomly, this what Arm uses for device's node(s), which is going
to be passthroughed...

>
>> --- a/xen/common/device-tree/dom0less-build.c
>> +++ b/xen/common/device-tree/dom0less-build.c
>> @@ -185,7 +185,7 @@ static int __init handle_passthrough_prop(struct kernel_info *kinfo,
>>                                  gaddr_to_gfn(gstart),
>>                                  PFN_DOWN(size),
>>                                  maddr_to_mfn(mstart),
>> -                               p2m_mmio_direct_dev);
>> +                               p2m_mmio_direct);
> ... a per-arch inline function which returns the type to use here.
> The name of the function would want to properly reflect the purpose;
> my limited DT knowledge may make arch_dt_passthrough_p2m_type() an
> entirely wrong suggestion.

... But make it even more generic by providing an inline function which
just return p2m_type_t would be really better.

~ Oleksii