[PATCH v3 3/3] arm/mpu: Implement ioremap_attr for MPU

Harry Ramsey posted 3 patches 3 weeks, 3 days ago
[PATCH v3 3/3] arm/mpu: Implement ioremap_attr for MPU
Posted by Harry Ramsey 3 weeks, 3 days ago
Implement the function `ioremap_attr` for MPU systems.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
Acked-by: Michal Orzel <michal.orzel@amd.com>
---
 xen/arch/arm/mpu/mm.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/mpu/mm.c b/xen/arch/arm/mpu/mm.c
index 29dd8c4622..f25560d746 100644
--- a/xen/arch/arm/mpu/mm.c
+++ b/xen/arch/arm/mpu/mm.c
@@ -473,8 +473,13 @@ void free_init_memory(void)
 
 void __iomem *ioremap_attr(paddr_t start, size_t len, unsigned int flags)
 {
-    BUG_ON("unimplemented");
-    return NULL;
+    paddr_t start_pg = round_pgdown(start);
+    paddr_t end_pg = round_pgup(start_pg + len);
+    if ( xen_mpumap_update(start_pg, end_pg, flags) )
+        return NULL;
+
+    /* Mapped or already mapped */
+    return maddr_to_virt(start_pg);
 }
 
 /*
-- 
2.43.0
Re: [PATCH v3 3/3] arm/mpu: Implement ioremap_attr for MPU
Posted by Orzel, Michal 3 weeks, 3 days ago

On 19/11/2025 08:53, Harry Ramsey wrote:
> Implement the function `ioremap_attr` for MPU systems.
> 
> Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
> Acked-by: Michal Orzel <michal.orzel@amd.com>
> ---
>  xen/arch/arm/mpu/mm.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/arch/arm/mpu/mm.c b/xen/arch/arm/mpu/mm.c
> index 29dd8c4622..f25560d746 100644
> --- a/xen/arch/arm/mpu/mm.c
> +++ b/xen/arch/arm/mpu/mm.c
> @@ -473,8 +473,13 @@ void free_init_memory(void)
>  
>  void __iomem *ioremap_attr(paddr_t start, size_t len, unsigned int flags)
>  {
> -    BUG_ON("unimplemented");
> -    return NULL;
> +    paddr_t start_pg = round_pgdown(start);
> +    paddr_t end_pg = round_pgup(start_pg + len);
NIT (can be done on commit): There should be a space between initializers and
rest of code. I missed that previously.

~Michal

> +    if ( xen_mpumap_update(start_pg, end_pg, flags) )
> +        return NULL;
> +
> +    /* Mapped or already mapped */
> +    return maddr_to_virt(start_pg);
>  }
>  
>  /*
Re: [PATCH v3 3/3] arm/mpu: Implement ioremap_attr for MPU
Posted by Luca Fancellu 3 weeks, 3 days ago
Hi Harry,

> On 19 Nov 2025, at 07:53, Harry Ramsey <Harry.Ramsey@arm.com> wrote:
> 
> Implement the function `ioremap_attr` for MPU systems.
> 
> Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
> Acked-by: Michal Orzel <michal.orzel@amd.com>
> ---

Looks good to me, I’ve also tested that with the FVP.

Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
Tested-by: Luca Fancellu <luca.fancellu@arm.com>

Cheers,
Luca