[PATCH v2 1/4] xen/arm: mpu: Introduce choice between MMU and MPU

Ayan Kumar Halder posted 4 patches 1 year, 1 month ago
There is a newer version of this series
[PATCH v2 1/4] xen/arm: mpu: Introduce choice between MMU and MPU
Posted by Ayan Kumar Halder 1 year, 1 month ago
There are features in the forthcoming patches which are dependent on
MPU. For eg fixed start address.
Also, some of the Xen features (eg STATIC_MEMORY) will be selected
by the MPU configuration.

Thus, this patch introduces a choice between MMU and MPU for the type
of memory management system. By default, MMU is selected.
MPU is now gated by UNSUPPORTED.

Updated SUPPORT.md to state that the support for MPU is experimental.

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
---
Changes from :-

v1 - 1. Reworded the help messages.
2. Updated Support.md.

 SUPPORT.md                     |  1 +
 xen/arch/arm/Kconfig           | 16 +++++++++++++++-
 xen/arch/arm/platforms/Kconfig |  2 +-
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/SUPPORT.md b/SUPPORT.md
index 23dd7e6424..3f6d788a43 100644
--- a/SUPPORT.md
+++ b/SUPPORT.md
@@ -40,6 +40,7 @@ supported in this document.
 
     Status, Xen in AArch64 mode: Supported
     Status, Xen in AArch32 mode: Tech Preview
+    Status, Xen with MPU: Experimental
     Status, Cortex A57 r0p0-r1p1: Supported, not security supported
     Status, Cortex A77 r0p0-r1p0: Supported, not security supported
 
diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index 323c967361..e881f5ba57 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -58,10 +58,24 @@ config PADDR_BITS
 	default 40 if ARM_PA_BITS_40
 	default 48 if ARM_64
 
+choice
+	prompt "Memory management system"
+	default MMU if ARM
+	help
+	  User can choose between the different forms of memory management system.
+
 config MMU
-	def_bool y
+	bool "MMU"
 	select HAS_PMAP
 	select HAS_VMAP
+	help
+	  Select it if you plan to run Xen on A-profile Armv7+
+
+config MPU
+	bool "MPU" if UNSUPPORTED
+	help
+	  Memory protection unit is supported on some Armv8-R systems (UNSUPPORTED).
+endchoice
 
 source "arch/Kconfig"
 
diff --git a/xen/arch/arm/platforms/Kconfig b/xen/arch/arm/platforms/Kconfig
index 76f7e76b1b..02322c259c 100644
--- a/xen/arch/arm/platforms/Kconfig
+++ b/xen/arch/arm/platforms/Kconfig
@@ -1,5 +1,5 @@
 choice
-	prompt "Platform Support"
+	prompt "Platform Support" if MMU
 	default ALL_PLAT
 	help
 	Choose which hardware platform to enable in Xen.
-- 
2.25.1
Re: [PATCH v2 1/4] xen/arm: mpu: Introduce choice between MMU and MPU
Posted by Jan Beulich 1 year, 1 month ago
On 18.09.2024 19:50, Ayan Kumar Halder wrote:
> --- a/xen/arch/arm/Kconfig
> +++ b/xen/arch/arm/Kconfig
> @@ -58,10 +58,24 @@ config PADDR_BITS
>  	default 40 if ARM_PA_BITS_40
>  	default 48 if ARM_64
>  
> +choice
> +	prompt "Memory management system"
> +	default MMU if ARM

Why the "if ARM", when ARM=y in all cases?

Jan
Re: [PATCH v2 1/4] xen/arm: mpu: Introduce choice between MMU and MPU
Posted by Julien Grall 1 year, 1 month ago
Hi Ayan,

On 18/09/2024 19:50, Ayan Kumar Halder wrote:
> There are features in the forthcoming patches which are dependent on
> MPU. For eg fixed start address.
> Also, some of the Xen features (eg STATIC_MEMORY) will be selected
> by the MPU configuration.
> 
> Thus, this patch introduces a choice between MMU and MPU for the type
> of memory management system. By default, MMU is selected.
> MPU is now gated by UNSUPPORTED.
> 
> Updated SUPPORT.md to state that the support for MPU is experimental.
> 
> Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
> ---
> Changes from :-
> 
> v1 - 1. Reworded the help messages.
> 2. Updated Support.md.
> 
>   SUPPORT.md                     |  1 +
>   xen/arch/arm/Kconfig           | 16 +++++++++++++++-
>   xen/arch/arm/platforms/Kconfig |  2 +-
>   3 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/SUPPORT.md b/SUPPORT.md
> index 23dd7e6424..3f6d788a43 100644
> --- a/SUPPORT.md
> +++ b/SUPPORT.md
> @@ -40,6 +40,7 @@ supported in this document.
>   
>       Status, Xen in AArch64 mode: Supported
>       Status, Xen in AArch32 mode: Tech Preview
> +    Status, Xen with MPU: Experimental
>       Status, Cortex A57 r0p0-r1p1: Supported, not security supported
>       Status, Cortex A77 r0p0-r1p0: Supported, not security supported
>   
> diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
> index 323c967361..e881f5ba57 100644
> --- a/xen/arch/arm/Kconfig
> +++ b/xen/arch/arm/Kconfig
> @@ -58,10 +58,24 @@ config PADDR_BITS
>   	default 40 if ARM_PA_BITS_40
>   	default 48 if ARM_64
>   
> +choice
> +	prompt "Memory management system"
> +	default MMU if ARM
> +	help
> +	  User can choose between the different forms of memory management system.
> +
>   config MMU
> -	def_bool y
> +	bool "MMU"
>   	select HAS_PMAP
>   	select HAS_VMAP
> +	help
> +	  Select it if you plan to run Xen on A-profile Armv7+
> +
> +config MPU
> +	bool "MPU" if UNSUPPORTED
> +	help
> +	  Memory protection unit is supported on some Armv8-R systems (UNSUPPORTED).

I am a bit confused with this statement. Does this mean that not all 
Armv8-R supports MPU? Or are you trying to say that not all of them 
support EL2?

If the former, we probably want to check pretty early during boot that 
the an MPU is present *and* we have enough regions.

> +endchoice
>   
>   source "arch/Kconfig"
>   
> diff --git a/xen/arch/arm/platforms/Kconfig b/xen/arch/arm/platforms/Kconfig
> index 76f7e76b1b..02322c259c 100644
> --- a/xen/arch/arm/platforms/Kconfig
> +++ b/xen/arch/arm/platforms/Kconfig
> @@ -1,5 +1,5 @@
>   choice
> -	prompt "Platform Support"
> +	prompt "Platform Support" if MMU
>   	default ALL_PLAT
>   	help
>   	Choose which hardware platform to enable in Xen.

Cheers,

-- 
Julien Grall
Re: [PATCH v2 1/4] xen/arm: mpu: Introduce choice between MMU and MPU
Posted by Ayan Kumar Halder 1 year, 1 month ago
On 19/09/2024 13:33, Julien Grall wrote:
> Hi Ayan,
Hi Julien,
>
> On 18/09/2024 19:50, Ayan Kumar Halder wrote:
>> There are features in the forthcoming patches which are dependent on
>> MPU. For eg fixed start address.
>> Also, some of the Xen features (eg STATIC_MEMORY) will be selected
>> by the MPU configuration.
>>
>> Thus, this patch introduces a choice between MMU and MPU for the type
>> of memory management system. By default, MMU is selected.
>> MPU is now gated by UNSUPPORTED.
>>
>> Updated SUPPORT.md to state that the support for MPU is experimental.
>>
>> Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
>> ---
>> Changes from :-
>>
>> v1 - 1. Reworded the help messages.
>> 2. Updated Support.md.
>>
>>   SUPPORT.md                     |  1 +
>>   xen/arch/arm/Kconfig           | 16 +++++++++++++++-
>>   xen/arch/arm/platforms/Kconfig |  2 +-
>>   3 files changed, 17 insertions(+), 2 deletions(-)
>>
>> diff --git a/SUPPORT.md b/SUPPORT.md
>> index 23dd7e6424..3f6d788a43 100644
>> --- a/SUPPORT.md
>> +++ b/SUPPORT.md
>> @@ -40,6 +40,7 @@ supported in this document.
>>         Status, Xen in AArch64 mode: Supported
>>       Status, Xen in AArch32 mode: Tech Preview
>> +    Status, Xen with MPU: Experimental
>>       Status, Cortex A57 r0p0-r1p1: Supported, not security supported
>>       Status, Cortex A77 r0p0-r1p0: Supported, not security supported
>>   diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
>> index 323c967361..e881f5ba57 100644
>> --- a/xen/arch/arm/Kconfig
>> +++ b/xen/arch/arm/Kconfig
>> @@ -58,10 +58,24 @@ config PADDR_BITS
>>       default 40 if ARM_PA_BITS_40
>>       default 48 if ARM_64
>>   +choice
>> +    prompt "Memory management system"
>> +    default MMU if ARM
>> +    help
>> +      User can choose between the different forms of memory 
>> management system.
>> +
>>   config MMU
>> -    def_bool y
>> +    bool "MMU"
>>       select HAS_PMAP
>>       select HAS_VMAP
>> +    help
>> +      Select it if you plan to run Xen on A-profile Armv7+
>> +
>> +config MPU
>> +    bool "MPU" if UNSUPPORTED
>> +    help
>> +      Memory protection unit is supported on some Armv8-R systems 
>> (UNSUPPORTED).
>
> I am a bit confused with this statement. Does this mean that not all 
> Armv8-R supports MPU? Or are you trying to say that not all of them 
> support EL2?

My bad. All Armv8-R system supports MPU at EL2 (as Bertrand correctly 
pointed out). Some of them (eg R82) supports both MMU and MPU at EL1. 
While others (eg R52) supports only MPU at EL1.

I should rewrite it as

"Memory protection unit is supported on Armv8-R systems (UNSUPPORTED)."

- Ayan

>
> If the former, we probably want to check pretty early during boot that 
> the an MPU is present *and* we have enough regions.
>
>> +endchoice
>>     source "arch/Kconfig"
>>   diff --git a/xen/arch/arm/platforms/Kconfig 
>> b/xen/arch/arm/platforms/Kconfig
>> index 76f7e76b1b..02322c259c 100644
>> --- a/xen/arch/arm/platforms/Kconfig
>> +++ b/xen/arch/arm/platforms/Kconfig
>> @@ -1,5 +1,5 @@
>>   choice
>> -    prompt "Platform Support"
>> +    prompt "Platform Support" if MMU
>>       default ALL_PLAT
>>       help
>>       Choose which hardware platform to enable in Xen.
>
> Cheers,
>

Re: [PATCH v2 1/4] xen/arm: mpu: Introduce choice between MMU and MPU
Posted by Julien Grall 1 year, 1 month ago

On 23/09/2024 10:18, Ayan Kumar Halder wrote:
> 
> On 19/09/2024 13:33, Julien Grall wrote:
>> Hi Ayan,
> Hi Julien,
>>
>> On 18/09/2024 19:50, Ayan Kumar Halder wrote:
>>> There are features in the forthcoming patches which are dependent on
>>> MPU. For eg fixed start address.
>>> Also, some of the Xen features (eg STATIC_MEMORY) will be selected
>>> by the MPU configuration.
>>>
>>> Thus, this patch introduces a choice between MMU and MPU for the type
>>> of memory management system. By default, MMU is selected.
>>> MPU is now gated by UNSUPPORTED.
>>>
>>> Updated SUPPORT.md to state that the support for MPU is experimental.
>>>
>>> Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
>>> ---
>>> Changes from :-
>>>
>>> v1 - 1. Reworded the help messages.
>>> 2. Updated Support.md.
>>>
>>>   SUPPORT.md                     |  1 +
>>>   xen/arch/arm/Kconfig           | 16 +++++++++++++++-
>>>   xen/arch/arm/platforms/Kconfig |  2 +-
>>>   3 files changed, 17 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/SUPPORT.md b/SUPPORT.md
>>> index 23dd7e6424..3f6d788a43 100644
>>> --- a/SUPPORT.md
>>> +++ b/SUPPORT.md
>>> @@ -40,6 +40,7 @@ supported in this document.
>>>         Status, Xen in AArch64 mode: Supported
>>>       Status, Xen in AArch32 mode: Tech Preview
>>> +    Status, Xen with MPU: Experimental
>>>       Status, Cortex A57 r0p0-r1p1: Supported, not security supported
>>>       Status, Cortex A77 r0p0-r1p0: Supported, not security supported
>>>   diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
>>> index 323c967361..e881f5ba57 100644
>>> --- a/xen/arch/arm/Kconfig
>>> +++ b/xen/arch/arm/Kconfig
>>> @@ -58,10 +58,24 @@ config PADDR_BITS
>>>       default 40 if ARM_PA_BITS_40
>>>       default 48 if ARM_64
>>>   +choice
>>> +    prompt "Memory management system"
>>> +    default MMU if ARM
>>> +    help
>>> +      User can choose between the different forms of memory 
>>> management system.
>>> +
>>>   config MMU
>>> -    def_bool y
>>> +    bool "MMU"
>>>       select HAS_PMAP
>>>       select HAS_VMAP
>>> +    help
>>> +      Select it if you plan to run Xen on A-profile Armv7+
>>> +
>>> +config MPU
>>> +    bool "MPU" if UNSUPPORTED
>>> +    help
>>> +      Memory protection unit is supported on some Armv8-R systems 
>>> (UNSUPPORTED).
>>
>> I am a bit confused with this statement. Does this mean that not all 
>> Armv8-R supports MPU? Or are you trying to say that not all of them 
>> support EL2?
> 
> My bad. All Armv8-R system supports MPU at EL2 (as Bertrand correctly 
> pointed out). Some of them (eg R82) supports both MMU and MPU at EL1. 
> While others (eg R52) supports only MPU at EL1.
> 
> I should rewrite it as
> 
> "Memory protection unit is supported on Armv8-R systems (UNSUPPORTED)."

I think it would be more consistent with CONFIG_MMU if you write the 
following:

"Memory Protection Unit (MPU). Select if you plan to run Xen on ARMv8-R 
systems supporting EL2. (UNSUPPORTED)"

Cheers,

-- 
Julien Grall


Re: [PATCH v2 1/4] xen/arm: mpu: Introduce choice between MMU and MPU
Posted by Bertrand Marquis 1 year, 1 month ago
Hi,

> On 19 Sep 2024, at 14:33, Julien Grall <julien@xen.org> wrote:
> 
> Hi Ayan,
> 
> On 18/09/2024 19:50, Ayan Kumar Halder wrote:
>> There are features in the forthcoming patches which are dependent on
>> MPU. For eg fixed start address.
>> Also, some of the Xen features (eg STATIC_MEMORY) will be selected
>> by the MPU configuration.
>> Thus, this patch introduces a choice between MMU and MPU for the type
>> of memory management system. By default, MMU is selected.
>> MPU is now gated by UNSUPPORTED.
>> Updated SUPPORT.md to state that the support for MPU is experimental.
>> Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
>> ---
>> Changes from :-
>> v1 - 1. Reworded the help messages.
>> 2. Updated Support.md.
>>  SUPPORT.md                     |  1 +
>>  xen/arch/arm/Kconfig           | 16 +++++++++++++++-
>>  xen/arch/arm/platforms/Kconfig |  2 +-
>>  3 files changed, 17 insertions(+), 2 deletions(-)
>> diff --git a/SUPPORT.md b/SUPPORT.md
>> index 23dd7e6424..3f6d788a43 100644
>> --- a/SUPPORT.md
>> +++ b/SUPPORT.md
>> @@ -40,6 +40,7 @@ supported in this document.
>>        Status, Xen in AArch64 mode: Supported
>>      Status, Xen in AArch32 mode: Tech Preview
>> +    Status, Xen with MPU: Experimental
>>      Status, Cortex A57 r0p0-r1p1: Supported, not security supported
>>      Status, Cortex A77 r0p0-r1p0: Supported, not security supported
>>  diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
>> index 323c967361..e881f5ba57 100644
>> --- a/xen/arch/arm/Kconfig
>> +++ b/xen/arch/arm/Kconfig
>> @@ -58,10 +58,24 @@ config PADDR_BITS
>>   default 40 if ARM_PA_BITS_40
>>   default 48 if ARM_64
>>  +choice
>> + prompt "Memory management system"
>> + default MMU if ARM
>> + help
>> +   User can choose between the different forms of memory management system.
>> +
>>  config MMU
>> - def_bool y
>> + bool "MMU"
>>   select HAS_PMAP
>>   select HAS_VMAP
>> + help
>> +   Select it if you plan to run Xen on A-profile Armv7+
>> +
>> +config MPU
>> + bool "MPU" if UNSUPPORTED
>> + help
>> +   Memory protection unit is supported on some Armv8-R systems (UNSUPPORTED).
> 
> I am a bit confused with this statement. Does this mean that not all Armv8-R supports MPU? Or are you trying to say that not all of them support EL2?
> 
> If the former, we probably want to check pretty early during boot that the an MPU is present *and* we have enough regions.

On Armv8-R if there is EL2 then there is an MPU at EL2.
Only EL1 might have an MMU with the MPU (but i do not think it can have only an MMU).

Cheers
Bertrand

> 
>> +endchoice
>>    source "arch/Kconfig"
>>  diff --git a/xen/arch/arm/platforms/Kconfig b/xen/arch/arm/platforms/Kconfig
>> index 76f7e76b1b..02322c259c 100644
>> --- a/xen/arch/arm/platforms/Kconfig
>> +++ b/xen/arch/arm/platforms/Kconfig
>> @@ -1,5 +1,5 @@
>>  choice
>> - prompt "Platform Support"
>> + prompt "Platform Support" if MMU
>>   default ALL_PLAT
>>   help
>>   Choose which hardware platform to enable in Xen.
> 
> Cheers,
> 
> -- 
> Julien Grall