[PATCH 3/5] xen/arm: mpu: Move some of the definitions to common file

Ayan Kumar Halder posted 5 patches 1 month, 1 week ago
[PATCH 3/5] xen/arm: mpu: Move some of the definitions to common file
Posted by Ayan Kumar Halder 1 month, 1 week ago
For AArch32, refer to ARM DDI 0568A.c ID110520.
MPU_REGION_SHIFT is same between AArch32 and AArch64 (HPRBAR).
Also, NUM_MPU_REGIONS_SHIFT is same between AArch32 and AArch64
(HMPUIR).

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
---
 xen/arch/arm/arm64/mpu/head.S              | 2 +-
 xen/arch/arm/include/asm/early_printk.h    | 2 +-
 xen/arch/arm/include/asm/{arm64 => }/mpu.h | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)
 rename xen/arch/arm/include/asm/{arm64 => }/mpu.h (87%)

diff --git a/xen/arch/arm/arm64/mpu/head.S b/xen/arch/arm/arm64/mpu/head.S
index e4f2021f45..7b659aa42b 100644
--- a/xen/arch/arm/arm64/mpu/head.S
+++ b/xen/arch/arm/arm64/mpu/head.S
@@ -3,7 +3,7 @@
  * Start-of-day code for an Armv8-R MPU system.
  */
 
-#include <asm/arm64/mpu.h>
+#include <asm/mpu.h>
 #include <asm/early_printk.h>
 
 /* Backgroud region enable/disable */
diff --git a/xen/arch/arm/include/asm/early_printk.h b/xen/arch/arm/include/asm/early_printk.h
index 219705a8b6..644fd0fcfb 100644
--- a/xen/arch/arm/include/asm/early_printk.h
+++ b/xen/arch/arm/include/asm/early_printk.h
@@ -11,7 +11,7 @@
 #define __ARM_EARLY_PRINTK_H__
 
 #include <xen/page-size.h>
-#include <asm/arm64/mpu.h>
+#include <asm/mpu.h>
 #include <asm/fixmap.h>
 
 #ifdef CONFIG_EARLY_PRINTK
diff --git a/xen/arch/arm/include/asm/arm64/mpu.h b/xen/arch/arm/include/asm/mpu.h
similarity index 87%
rename from xen/arch/arm/include/asm/arm64/mpu.h
rename to xen/arch/arm/include/asm/mpu.h
index f8a029f1a1..40fa6eaaca 100644
--- a/xen/arch/arm/include/asm/arm64/mpu.h
+++ b/xen/arch/arm/include/asm/mpu.h
@@ -3,8 +3,8 @@
  * mpu.h: Arm Memory Protection Unit definitions.
  */
 
-#ifndef __ARM64_MPU_H__
-#define __ARM64_MPU_H__
+#ifndef __ARM_MPU_H__
+#define __ARM_MPU_H__
 
 #define MPU_REGION_SHIFT  6
 #define MPU_REGION_ALIGN  (_AC(1, UL) << MPU_REGION_SHIFT)
@@ -13,7 +13,7 @@
 #define NUM_MPU_REGIONS_SHIFT   8
 #define NUM_MPU_REGIONS         (_AC(1, UL) << NUM_MPU_REGIONS_SHIFT)
 #define NUM_MPU_REGIONS_MASK    (NUM_MPU_REGIONS - 1)
-#endif /* __ARM64_MPU_H__ */
+#endif /* __ARM_MPU_H__ */
 
 /*
  * Local variables:
-- 
2.25.1
Re: [PATCH 3/5] xen/arm: mpu: Move some of the definitions to common file
Posted by Luca Fancellu 1 month ago
Hi Ayan,

> On 4 Feb 2025, at 19:23, Ayan Kumar Halder <ayan.kumar.halder@amd.com> wrote:
> 
> For AArch32, refer to ARM DDI 0568A.c ID110520.
> MPU_REGION_SHIFT is same between AArch32 and AArch64 (HPRBAR).
> Also, NUM_MPU_REGIONS_SHIFT is same between AArch32 and AArch64
> (HMPUIR).
> 
> Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
> ---
> xen/arch/arm/arm64/mpu/head.S              | 2 +-
> xen/arch/arm/include/asm/early_printk.h    | 2 +-
> xen/arch/arm/include/asm/{arm64 => }/mpu.h | 6 +++---
> 3 files changed, 5 insertions(+), 5 deletions(-)
> rename xen/arch/arm/include/asm/{arm64 => }/mpu.h (87%)
> 
> diff --git a/xen/arch/arm/arm64/mpu/head.S b/xen/arch/arm/arm64/mpu/head.S
> index e4f2021f45..7b659aa42b 100644
> --- a/xen/arch/arm/arm64/mpu/head.S
> +++ b/xen/arch/arm/arm64/mpu/head.S
> @@ -3,7 +3,7 @@
>  * Start-of-day code for an Armv8-R MPU system.
>  */
> 
> -#include <asm/arm64/mpu.h>
> +#include <asm/mpu.h>
> #include <asm/early_printk.h>
> 
> /* Backgroud region enable/disable */
> diff --git a/xen/arch/arm/include/asm/early_printk.h b/xen/arch/arm/include/asm/early_printk.h
> index 219705a8b6..644fd0fcfb 100644
> --- a/xen/arch/arm/include/asm/early_printk.h
> +++ b/xen/arch/arm/include/asm/early_printk.h
> @@ -11,7 +11,7 @@
> #define __ARM_EARLY_PRINTK_H__
> 
> #include <xen/page-size.h>
> -#include <asm/arm64/mpu.h>
> +#include <asm/mpu.h>
> #include <asm/fixmap.h>
> 
> #ifdef CONFIG_EARLY_PRINTK
> diff --git a/xen/arch/arm/include/asm/arm64/mpu.h b/xen/arch/arm/include/asm/mpu.h

Why not in include/mpu/ ?

Cheers,
Luca
Re: [PATCH 3/5] xen/arm: mpu: Move some of the definitions to common file
Posted by Julien Grall 2 weeks, 2 days ago
Hi Luca,

On 06/02/2025 15:01, Luca Fancellu wrote:
> Hi Ayan,
> 
>> On 4 Feb 2025, at 19:23, Ayan Kumar Halder <ayan.kumar.halder@amd.com> wrote:
>>
>> For AArch32, refer to ARM DDI 0568A.c ID110520.
>> MPU_REGION_SHIFT is same between AArch32 and AArch64 (HPRBAR).
>> Also, NUM_MPU_REGIONS_SHIFT is same between AArch32 and AArch64
>> (HMPUIR).
>>
>> Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
>> ---
>> xen/arch/arm/arm64/mpu/head.S              | 2 +-
>> xen/arch/arm/include/asm/early_printk.h    | 2 +-
>> xen/arch/arm/include/asm/{arm64 => }/mpu.h | 6 +++---
>> 3 files changed, 5 insertions(+), 5 deletions(-)
>> rename xen/arch/arm/include/asm/{arm64 => }/mpu.h (87%)
>>
>> diff --git a/xen/arch/arm/arm64/mpu/head.S b/xen/arch/arm/arm64/mpu/head.S
>> index e4f2021f45..7b659aa42b 100644
>> --- a/xen/arch/arm/arm64/mpu/head.S
>> +++ b/xen/arch/arm/arm64/mpu/head.S
>> @@ -3,7 +3,7 @@
>>   * Start-of-day code for an Armv8-R MPU system.
>>   */
>>
>> -#include <asm/arm64/mpu.h>
>> +#include <asm/mpu.h>
>> #include <asm/early_printk.h>
>>
>> /* Backgroud region enable/disable */
>> diff --git a/xen/arch/arm/include/asm/early_printk.h b/xen/arch/arm/include/asm/early_printk.h
>> index 219705a8b6..644fd0fcfb 100644
>> --- a/xen/arch/arm/include/asm/early_printk.h
>> +++ b/xen/arch/arm/include/asm/early_printk.h
>> @@ -11,7 +11,7 @@
>> #define __ARM_EARLY_PRINTK_H__
>>
>> #include <xen/page-size.h>
>> -#include <asm/arm64/mpu.h>
>> +#include <asm/mpu.h>
>> #include <asm/fixmap.h>
>>
>> #ifdef CONFIG_EARLY_PRINTK
>> diff --git a/xen/arch/arm/include/asm/arm64/mpu.h b/xen/arch/arm/include/asm/mpu.h
> 
> Why not in include/mpu/ ?

Do you mean include/asm/mpu? or something different?

Cheers,

-- 
Julien Grall
Re: [PATCH 3/5] xen/arm: mpu: Move some of the definitions to common file
Posted by Luca Fancellu 2 weeks, 1 day ago
Hi Julien,

>>> 
>>> #ifdef CONFIG_EARLY_PRINTK
>>> diff --git a/xen/arch/arm/include/asm/arm64/mpu.h b/xen/arch/arm/include/asm/mpu.h
>> Why not in include/mpu/ ?
> 
> Do you mean include/asm/mpu? or something different?

Yes, sorry typo, I mean include/asm/mpu/mpu.h

Cheers,
Luca
Re: [PATCH 3/5] xen/arm: mpu: Move some of the definitions to common file
Posted by Julien Grall 1 week, 6 days ago
On 26/02/2025 08:28, Luca Fancellu wrote:
> Hi Julien,

Hi Luca,

> 
>>>>
>>>> #ifdef CONFIG_EARLY_PRINTK
>>>> diff --git a/xen/arch/arm/include/asm/arm64/mpu.h b/xen/arch/arm/include/asm/mpu.h
>>> Why not in include/mpu/ ?
>>
>> Do you mean include/asm/mpu? or something different?
> 
> Yes, sorry typo, I mean include/asm/mpu/mpu.h

Thanks for the clarification. I don't have a strong opinion either way. 
I will let Ayan decide.

Cheers,

-- 
Julien Grall
Re: [PATCH 3/5] xen/arm: mpu: Move some of the definitions to common file
Posted by Ayan Kumar Halder 1 week, 6 days ago
Hi Julien/Luca,

On 28/02/2025 09:22, Julien Grall wrote:
>
>
> On 26/02/2025 08:28, Luca Fancellu wrote:
>> Hi Julien,
>
> Hi Luca,
>
>>
>>>>>
>>>>> #ifdef CONFIG_EARLY_PRINTK
>>>>> diff --git a/xen/arch/arm/include/asm/arm64/mpu.h 
>>>>> b/xen/arch/arm/include/asm/mpu.h
>>>> Why not in include/mpu/ ?
>>>
>>> Do you mean include/asm/mpu? or something different?
>>
>> Yes, sorry typo, I mean include/asm/mpu/mpu.h
>
> Thanks for the clarification. I don't have a strong opinion either 
> way. I will let Ayan decide.
Can I leave as it is for the time being ?

I mean I will create "xen/arch/arm/include/asm/mpu/" directory when I 
know there will be more files.

Let me know what you suggest.

- Ayan

>
> Cheers,
>
Re: [PATCH 3/5] xen/arm: mpu: Move some of the definitions to common file
Posted by Luca Fancellu 1 week, 2 days ago
> On 28 Feb 2025, at 10:34, Ayan Kumar Halder <ayankuma@amd.com> wrote:
> 
> Hi Julien/Luca,
> 
> On 28/02/2025 09:22, Julien Grall wrote:
>> 
>> 
>> On 26/02/2025 08:28, Luca Fancellu wrote:
>>> Hi Julien,
>> 
>> Hi Luca,
>> 
>>> 
>>>>>> 
>>>>>> #ifdef CONFIG_EARLY_PRINTK
>>>>>> diff --git a/xen/arch/arm/include/asm/arm64/mpu.h b/xen/arch/arm/include/asm/mpu.h
>>>>> Why not in include/mpu/ ?
>>>> 
>>>> Do you mean include/asm/mpu? or something different?
>>> 
>>> Yes, sorry typo, I mean include/asm/mpu/mpu.h
>> 
>> Thanks for the clarification. I don't have a strong opinion either way. I will let Ayan decide.
> Can I leave as it is for the time being ?
> 
> I mean I will create "xen/arch/arm/include/asm/mpu/" directory when I know there will be more files.
> 
> Let me know what you suggest.
> 
> - Ayan

Ok, as agreed on Matrix that Ayan would like to go with include/asm/mpu.h:

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


> 
>> 
>> Cheers,
>>