diff mbox series

[v4,6/6] xen/arm: mpu: Implement a dummy enable_secondary_cpu_mm

Message ID 20241028124547.1371867-7-ayan.kumar.halder@amd.com (mailing list archive)
State Superseded
Headers show
Series Enable early bootup of AArch64 MPU systems | expand

Commit Message

Ayan Kumar Halder Oct. 28, 2024, 12:45 p.m. UTC
Secondary cpus initialization is not yet supported. Thus, we print an
appropriate message and put the secondary cpus in WFE state.
And we introduce to BUILD_BUG_ON to prevent users using from building Xen
on multiprocessor based MPU systems.

In Arm, there is no clean way to disable SMP. As of now, we wish to support
MPU on UNP only. So, we have defined the default range of NR_CPUs to be 1 for
MPU.

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

v1 - 1. NR_CPUS is defined as 1 for MPU

2. Added a message in enable_secondary_cpu_mm()

v2 - 1. Added the range

2. Clarified in the commit message why/how we have disabled SMP.

v3 - 1. BUILD_BUG_ON() is moved to smp.c.

 xen/arch/Kconfig              |  2 ++
 xen/arch/arm/arm64/mpu/head.S | 10 ++++++++++
 xen/arch/arm/smp.c            | 11 +++++++++++
 3 files changed, 23 insertions(+)

Comments

Jan Beulich Oct. 28, 2024, 12:55 p.m. UTC | #1
On 28.10.2024 13:45, Ayan Kumar Halder wrote:
> --- a/xen/arch/Kconfig
> +++ b/xen/arch/Kconfig
> @@ -6,11 +6,13 @@ config PHYS_ADDR_T_32
>  
>  config NR_CPUS
>  	int "Maximum number of CPUs"
> +	range 1 1 if ARM && MPU
>  	range 1 16383
>  	default "256" if X86
>  	default "8" if ARM && RCAR3
>  	default "4" if ARM && QEMU
>  	default "4" if ARM && MPSOC
> +	default "1" if ARM && MPU
>  	default "128" if ARM
>  	help
>  	  Controls the build-time size of various arrays and bitmaps

I'm afraid I can't easily tell whether MPU can be used together with any of
RCAR3, QEMU, or MPSOC. If it can, the new default line would need to move
up, as it's the first one that has a match on its condition which is being
used.

Jan
Ayan Kumar Halder Oct. 28, 2024, 2:39 p.m. UTC | #2
Hi Jan,

On 28/10/2024 12:55, Jan Beulich wrote:
> On 28.10.2024 13:45, Ayan Kumar Halder wrote:
>> --- a/xen/arch/Kconfig
>> +++ b/xen/arch/Kconfig
>> @@ -6,11 +6,13 @@ config PHYS_ADDR_T_32
>>   
>>   config NR_CPUS
>>   	int "Maximum number of CPUs"
>> +	range 1 1 if ARM && MPU
>>   	range 1 16383
>>   	default "256" if X86
>>   	default "8" if ARM && RCAR3
>>   	default "4" if ARM && QEMU
>>   	default "4" if ARM && MPSOC
>> +	default "1" if ARM && MPU
>>   	default "128" if ARM
>>   	help
>>   	  Controls the build-time size of various arrays and bitmaps
> I'm afraid I can't easily tell whether MPU can be used together with any of
> RCAR3, QEMU, or MPSOC. If it can, the new default line would need to move
> up, as it's the first one that has a match on its condition which is being
> used.

MPU cannot be used with any of the existing platforms.

There will be patch in the future series where we will introduce a 
platform specific for MPU. That can be FVP for R82 and R52.

- Ayan

>
> Jan
Jan Beulich Oct. 28, 2024, 3:01 p.m. UTC | #3
On 28.10.2024 15:39, Ayan Kumar Halder wrote:
> On 28/10/2024 12:55, Jan Beulich wrote:
>> On 28.10.2024 13:45, Ayan Kumar Halder wrote:
>>> --- a/xen/arch/Kconfig
>>> +++ b/xen/arch/Kconfig
>>> @@ -6,11 +6,13 @@ config PHYS_ADDR_T_32
>>>   
>>>   config NR_CPUS
>>>   	int "Maximum number of CPUs"
>>> +	range 1 1 if ARM && MPU
>>>   	range 1 16383
>>>   	default "256" if X86
>>>   	default "8" if ARM && RCAR3
>>>   	default "4" if ARM && QEMU
>>>   	default "4" if ARM && MPSOC
>>> +	default "1" if ARM && MPU
>>>   	default "128" if ARM
>>>   	help
>>>   	  Controls the build-time size of various arrays and bitmaps
>> I'm afraid I can't easily tell whether MPU can be used together with any of
>> RCAR3, QEMU, or MPSOC. If it can, the new default line would need to move
>> up, as it's the first one that has a match on its condition which is being
>> used.
> 
> MPU cannot be used with any of the existing platforms.

That is - qemu can't emulate such an environment, i.e. even QEMU and MPU
don't go together?

Jan
Ayan Kumar Halder Oct. 28, 2024, 5:38 p.m. UTC | #4
Hi Jan,

On 28/10/2024 15:01, Jan Beulich wrote:
> On 28.10.2024 15:39, Ayan Kumar Halder wrote:
>> On 28/10/2024 12:55, Jan Beulich wrote:
>>> On 28.10.2024 13:45, Ayan Kumar Halder wrote:
>>>> --- a/xen/arch/Kconfig
>>>> +++ b/xen/arch/Kconfig
>>>> @@ -6,11 +6,13 @@ config PHYS_ADDR_T_32
>>>>    
>>>>    config NR_CPUS
>>>>    	int "Maximum number of CPUs"
>>>> +	range 1 1 if ARM && MPU
>>>>    	range 1 16383
>>>>    	default "256" if X86
>>>>    	default "8" if ARM && RCAR3
>>>>    	default "4" if ARM && QEMU
>>>>    	default "4" if ARM && MPSOC
>>>> +	default "1" if ARM && MPU
>>>>    	default "128" if ARM
>>>>    	help
>>>>    	  Controls the build-time size of various arrays and bitmaps
>>> I'm afraid I can't easily tell whether MPU can be used together with any of
>>> RCAR3, QEMU, or MPSOC. If it can, the new default line would need to move
>>> up, as it's the first one that has a match on its condition which is being
>>> used.
>> MPU cannot be used with any of the existing platforms.
> That is - qemu can't emulate such an environment, i.e. even QEMU and MPU
> don't go together?

Qemu has support for Aarch32 MPU at EL2 and EL1 (ie R52). As far as I am 
aware, there is no support for Aarch64 MPU in Qemu (ie R82).

Even for R52, I could not get the upstream Qemu working (emulating some 
Arm reference platform).

I could get the Xilinx fork of Qemu (https://github.com/Xilinx/qemu) 
working which emulates AMD's SoC using R52.

However, this should not impact the current patch. There is no Qemu in 
xen/arch/arm/platforms/*.

- Ayan
Jan Beulich Oct. 29, 2024, 8:08 a.m. UTC | #5
On 28.10.2024 18:38, Ayan Kumar Halder wrote:
> On 28/10/2024 15:01, Jan Beulich wrote:
>> On 28.10.2024 15:39, Ayan Kumar Halder wrote:
>>> On 28/10/2024 12:55, Jan Beulich wrote:
>>>> On 28.10.2024 13:45, Ayan Kumar Halder wrote:
>>>>> --- a/xen/arch/Kconfig
>>>>> +++ b/xen/arch/Kconfig
>>>>> @@ -6,11 +6,13 @@ config PHYS_ADDR_T_32
>>>>>    
>>>>>    config NR_CPUS
>>>>>    	int "Maximum number of CPUs"
>>>>> +	range 1 1 if ARM && MPU
>>>>>    	range 1 16383
>>>>>    	default "256" if X86
>>>>>    	default "8" if ARM && RCAR3
>>>>>    	default "4" if ARM && QEMU
>>>>>    	default "4" if ARM && MPSOC
>>>>> +	default "1" if ARM && MPU
>>>>>    	default "128" if ARM
>>>>>    	help
>>>>>    	  Controls the build-time size of various arrays and bitmaps
>>>> I'm afraid I can't easily tell whether MPU can be used together with any of
>>>> RCAR3, QEMU, or MPSOC. If it can, the new default line would need to move
>>>> up, as it's the first one that has a match on its condition which is being
>>>> used.
>>> MPU cannot be used with any of the existing platforms.
>> That is - qemu can't emulate such an environment, i.e. even QEMU and MPU
>> don't go together?
> 
> Qemu has support for Aarch32 MPU at EL2 and EL1 (ie R52). As far as I am 
> aware, there is no support for Aarch64 MPU in Qemu (ie R82).
> 
> Even for R52, I could not get the upstream Qemu working (emulating some 
> Arm reference platform).
> 
> I could get the Xilinx fork of Qemu (https://github.com/Xilinx/qemu) 
> working which emulates AMD's SoC using R52.
> 
> However, this should not impact the current patch. There is no Qemu in 
> xen/arch/arm/platforms/*.

Aiui that's not relevant. There is a QEMU item in xen/arch/arm/platforms/Kconfig.
I continue to fail to see why that couldn't be selected together with MPU. Yet if
it can be, you'd end up with a default of 4, not 1, if it actually _is_ selected.
Alternatively QEMU (and maybe also RCAR3 and MPSOC) need to be mutually exclusive
with MPU. Hmm, looks like that's already the case, by patch 2 suppressing the
"Platform Support" prompt. While that looks fragile to me, I'm sorry for the
noise then.

Jan
Luca Fancellu Oct. 29, 2024, 9:30 a.m. UTC | #6
Hi Jan,

> On 29 Oct 2024, at 08:08, Jan Beulich <jbeulich@suse.com> wrote:
> 
> On 28.10.2024 18:38, Ayan Kumar Halder wrote:
>> On 28/10/2024 15:01, Jan Beulich wrote:
>>> On 28.10.2024 15:39, Ayan Kumar Halder wrote:
>>>> On 28/10/2024 12:55, Jan Beulich wrote:
>>>>> On 28.10.2024 13:45, Ayan Kumar Halder wrote:
>>>>>> --- a/xen/arch/Kconfig
>>>>>> +++ b/xen/arch/Kconfig
>>>>>> @@ -6,11 +6,13 @@ config PHYS_ADDR_T_32
>>>>>> 
>>>>>>   config NR_CPUS
>>>>>>   	int "Maximum number of CPUs"
>>>>>> +	range 1 1 if ARM && MPU
>>>>>>   	range 1 16383
>>>>>>   	default "256" if X86
>>>>>>   	default "8" if ARM && RCAR3
>>>>>>   	default "4" if ARM && QEMU
>>>>>>   	default "4" if ARM && MPSOC
>>>>>> +	default "1" if ARM && MPU
>>>>>>   	default "128" if ARM
>>>>>>   	help
>>>>>>   	  Controls the build-time size of various arrays and bitmaps
>>>>> I'm afraid I can't easily tell whether MPU can be used together with any of
>>>>> RCAR3, QEMU, or MPSOC. If it can, the new default line would need to move
>>>>> up, as it's the first one that has a match on its condition which is being
>>>>> used.
>>>> MPU cannot be used with any of the existing platforms.
>>> That is - qemu can't emulate such an environment, i.e. even QEMU and MPU
>>> don't go together?
>> 
>> Qemu has support for Aarch32 MPU at EL2 and EL1 (ie R52). As far as I am 
>> aware, there is no support for Aarch64 MPU in Qemu (ie R82).
>> 
>> Even for R52, I could not get the upstream Qemu working (emulating some 
>> Arm reference platform).
>> 
>> I could get the Xilinx fork of Qemu (https://github.com/Xilinx/qemu) 
>> working which emulates AMD's SoC using R52.
>> 
>> However, this should not impact the current patch. There is no Qemu in 
>> xen/arch/arm/platforms/*.
> 
> Aiui that's not relevant. There is a QEMU item in xen/arch/arm/platforms/Kconfig.
> I continue to fail to see why that couldn't be selected together with MPU. Yet if
> it can be, you'd end up with a default of 4, not 1, if it actually _is_ selected.
> Alternatively QEMU (and maybe also RCAR3 and MPSOC) need to be mutually exclusive
> with MPU. Hmm, looks like that's already the case, by patch 2 suppressing the
> "Platform Support" prompt. While that looks fragile to me, I'm sorry for the
> noise then.

Are you suggesting to move "default "1" if ARM && MPU” right after “default "256" if X86”?

Cheers,
Luca
Jan Beulich Oct. 29, 2024, 9:41 a.m. UTC | #7
On 29.10.2024 10:30, Luca Fancellu wrote:
> Hi Jan,
> 
>> On 29 Oct 2024, at 08:08, Jan Beulich <jbeulich@suse.com> wrote:
>>
>> On 28.10.2024 18:38, Ayan Kumar Halder wrote:
>>> On 28/10/2024 15:01, Jan Beulich wrote:
>>>> On 28.10.2024 15:39, Ayan Kumar Halder wrote:
>>>>> On 28/10/2024 12:55, Jan Beulich wrote:
>>>>>> On 28.10.2024 13:45, Ayan Kumar Halder wrote:
>>>>>>> --- a/xen/arch/Kconfig
>>>>>>> +++ b/xen/arch/Kconfig
>>>>>>> @@ -6,11 +6,13 @@ config PHYS_ADDR_T_32
>>>>>>>
>>>>>>>   config NR_CPUS
>>>>>>>   	int "Maximum number of CPUs"
>>>>>>> +	range 1 1 if ARM && MPU
>>>>>>>   	range 1 16383
>>>>>>>   	default "256" if X86
>>>>>>>   	default "8" if ARM && RCAR3
>>>>>>>   	default "4" if ARM && QEMU
>>>>>>>   	default "4" if ARM && MPSOC
>>>>>>> +	default "1" if ARM && MPU
>>>>>>>   	default "128" if ARM
>>>>>>>   	help
>>>>>>>   	  Controls the build-time size of various arrays and bitmaps
>>>>>> I'm afraid I can't easily tell whether MPU can be used together with any of
>>>>>> RCAR3, QEMU, or MPSOC. If it can, the new default line would need to move
>>>>>> up, as it's the first one that has a match on its condition which is being
>>>>>> used.
>>>>> MPU cannot be used with any of the existing platforms.
>>>> That is - qemu can't emulate such an environment, i.e. even QEMU and MPU
>>>> don't go together?
>>>
>>> Qemu has support for Aarch32 MPU at EL2 and EL1 (ie R52). As far as I am 
>>> aware, there is no support for Aarch64 MPU in Qemu (ie R82).
>>>
>>> Even for R52, I could not get the upstream Qemu working (emulating some 
>>> Arm reference platform).
>>>
>>> I could get the Xilinx fork of Qemu (https://github.com/Xilinx/qemu) 
>>> working which emulates AMD's SoC using R52.
>>>
>>> However, this should not impact the current patch. There is no Qemu in 
>>> xen/arch/arm/platforms/*.
>>
>> Aiui that's not relevant. There is a QEMU item in xen/arch/arm/platforms/Kconfig.
>> I continue to fail to see why that couldn't be selected together with MPU. Yet if
>> it can be, you'd end up with a default of 4, not 1, if it actually _is_ selected.
>> Alternatively QEMU (and maybe also RCAR3 and MPSOC) need to be mutually exclusive
>> with MPU. Hmm, looks like that's already the case, by patch 2 suppressing the
>> "Platform Support" prompt. While that looks fragile to me, I'm sorry for the
>> noise then.
> 
> Are you suggesting to move "default "1" if ARM && MPU” right after “default "256" if X86”?

Yes.

Jan
Luca Fancellu Oct. 29, 2024, 9:58 a.m. UTC | #8
> On 29 Oct 2024, at 09:41, Jan Beulich <jbeulich@suse.com> wrote:
> 
> On 29.10.2024 10:30, Luca Fancellu wrote:
>> Hi Jan,
>> 
>>> On 29 Oct 2024, at 08:08, Jan Beulich <jbeulich@suse.com> wrote:
>>> 
>>> On 28.10.2024 18:38, Ayan Kumar Halder wrote:
>>>> On 28/10/2024 15:01, Jan Beulich wrote:
>>>>> On 28.10.2024 15:39, Ayan Kumar Halder wrote:
>>>>>> On 28/10/2024 12:55, Jan Beulich wrote:
>>>>>>> On 28.10.2024 13:45, Ayan Kumar Halder wrote:
>>>>>>>> --- a/xen/arch/Kconfig
>>>>>>>> +++ b/xen/arch/Kconfig
>>>>>>>> @@ -6,11 +6,13 @@ config PHYS_ADDR_T_32
>>>>>>>> 
>>>>>>>>  config NR_CPUS
>>>>>>>>  	int "Maximum number of CPUs"
>>>>>>>> +	range 1 1 if ARM && MPU
>>>>>>>>  	range 1 16383
>>>>>>>>  	default "256" if X86
>>>>>>>>  	default "8" if ARM && RCAR3
>>>>>>>>  	default "4" if ARM && QEMU
>>>>>>>>  	default "4" if ARM && MPSOC
>>>>>>>> +	default "1" if ARM && MPU
>>>>>>>>  	default "128" if ARM
>>>>>>>>  	help
>>>>>>>>  	  Controls the build-time size of various arrays and bitmaps
>>>>>>> I'm afraid I can't easily tell whether MPU can be used together with any of
>>>>>>> RCAR3, QEMU, or MPSOC. If it can, the new default line would need to move
>>>>>>> up, as it's the first one that has a match on its condition which is being
>>>>>>> used.
>>>>>> MPU cannot be used with any of the existing platforms.
>>>>> That is - qemu can't emulate such an environment, i.e. even QEMU and MPU
>>>>> don't go together?
>>>> 
>>>> Qemu has support for Aarch32 MPU at EL2 and EL1 (ie R52). As far as I am 
>>>> aware, there is no support for Aarch64 MPU in Qemu (ie R82).
>>>> 
>>>> Even for R52, I could not get the upstream Qemu working (emulating some 
>>>> Arm reference platform).
>>>> 
>>>> I could get the Xilinx fork of Qemu (https://github.com/Xilinx/qemu) 
>>>> working which emulates AMD's SoC using R52.
>>>> 
>>>> However, this should not impact the current patch. There is no Qemu in 
>>>> xen/arch/arm/platforms/*.
>>> 
>>> Aiui that's not relevant. There is a QEMU item in xen/arch/arm/platforms/Kconfig.
>>> I continue to fail to see why that couldn't be selected together with MPU. Yet if
>>> it can be, you'd end up with a default of 4, not 1, if it actually _is_ selected.
>>> Alternatively QEMU (and maybe also RCAR3 and MPSOC) need to be mutually exclusive
>>> with MPU. Hmm, looks like that's already the case, by patch 2 suppressing the
>>> "Platform Support" prompt. While that looks fragile to me, I'm sorry for the
>>> noise then.
>> 
>> Are you suggesting to move "default "1" if ARM && MPU” right after “default "256" if X86”?
> 
> Yes.

Makes sense! 

With that:

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

> 
> Jan
diff mbox series

Patch

diff --git a/xen/arch/Kconfig b/xen/arch/Kconfig
index 308ce129a8..aa383577a4 100644
--- a/xen/arch/Kconfig
+++ b/xen/arch/Kconfig
@@ -6,11 +6,13 @@  config PHYS_ADDR_T_32
 
 config NR_CPUS
 	int "Maximum number of CPUs"
+	range 1 1 if ARM && MPU
 	range 1 16383
 	default "256" if X86
 	default "8" if ARM && RCAR3
 	default "4" if ARM && QEMU
 	default "4" if ARM && MPSOC
+	default "1" if ARM && MPU
 	default "128" if ARM
 	help
 	  Controls the build-time size of various arrays and bitmaps
diff --git a/xen/arch/arm/arm64/mpu/head.S b/xen/arch/arm/arm64/mpu/head.S
index 0edadb009c..5a6aaf47cd 100644
--- a/xen/arch/arm/arm64/mpu/head.S
+++ b/xen/arch/arm/arm64/mpu/head.S
@@ -140,6 +140,16 @@  FUNC(enable_boot_cpu_mm)
     ret
 END(enable_boot_cpu_mm)
 
+/*
+ * We don't yet support secondary CPUs bring-up. Implement a dummy helper to
+ * please the common code.
+ */
+ENTRY(enable_secondary_cpu_mm)
+    PRINT("- SMP not enabled yet -\r\n")
+1:  wfe
+    b 1b
+ENDPROC(enable_secondary_cpu_mm)
+
 /*
  * Local variables:
  * mode: ASM
diff --git a/xen/arch/arm/smp.c b/xen/arch/arm/smp.c
index c11bba93ad..b372472188 100644
--- a/xen/arch/arm/smp.c
+++ b/xen/arch/arm/smp.c
@@ -1,4 +1,5 @@ 
 /* SPDX-License-Identifier: GPL-2.0-only */
+#include <xen/init.h>
 #include <xen/mm.h>
 #include <asm/system.h>
 #include <asm/smp.h>
@@ -6,6 +7,16 @@ 
 #include <asm/gic.h>
 #include <asm/flushtlb.h>
 
+static void __init __maybe_unused build_assertions(void)
+{
+#ifdef CONFIG_MPU
+    /*
+     * Currently, SMP is not enabled on MPU based systems.
+     */
+    BUILD_BUG_ON(NR_CPUS > 1);
+#endif
+}
+
 void arch_flush_tlb_mask(const cpumask_t *mask)
 {
     /* No need to IPI other processors on ARM, the processor takes care of it. */