[PATCH 4/5] ARM: fix CPU_V6 dependencies

Arnd Bergmann posted 5 patches 3 years, 7 months ago
[PATCH 4/5] ARM: fix CPU_V6 dependencies
Posted by Arnd Bergmann 3 years, 7 months ago
From: Arnd Bergmann <arnd@arndb.de>

CONFIG_XIP_KERNEL must not be combined with CONFIG_SMP_ON_UP
because the patching of read-only data does not work.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/arm/mach-imx/Kconfig       | 1 +
 arch/arm/mach-omap2/Kconfig     | 1 +
 arch/arm/mach-versatile/Kconfig | 2 ++
 3 files changed, 4 insertions(+)

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index ab767f059929..9308e9894be5 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -41,6 +41,7 @@ comment "ARM1136 platforms"
 
 config SOC_IMX31
 	bool "i.MX31 support"
+	depends on !SMP || !XIP_KERNEL # for SMP_ON_UP
 	select CPU_V6
 	select MXC_AVIC
 	help
diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 3b53dda9ec79..f2ce262958c4 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -8,6 +8,7 @@ config OMAP_HWMOD
 config ARCH_OMAP2
 	bool "TI OMAP2"
 	depends on ARCH_MULTI_V6
+	depends on !SMP || !XIP_KERNEL # for SMP_ON_UP
 	select ARCH_OMAP2PLUS
 	select CPU_V6
 	select OMAP_HWMOD
diff --git a/arch/arm/mach-versatile/Kconfig b/arch/arm/mach-versatile/Kconfig
index 2ef226194c3a..25723b0c63dd 100644
--- a/arch/arm/mach-versatile/Kconfig
+++ b/arch/arm/mach-versatile/Kconfig
@@ -21,6 +21,7 @@ menuconfig ARCH_INTEGRATOR
 	bool "ARM Ltd. Integrator family"
 	depends on ARCH_MULTI_V4T || ARCH_MULTI_V5 || ARCH_MULTI_V6
 	depends on CPU_LITTLE_ENDIAN || ARCH_MULTI_V6
+	depends on !SMP || !XIP_KERNEL # for SMP_ON_UP
 	select ARM_AMBA
 	select CMA
 	select DMA_CMA
@@ -146,6 +147,7 @@ endif
 menuconfig ARCH_REALVIEW
 	bool "ARM Ltd. RealView family"
 	depends on (CPU_LITTLE_ENDIAN && ARCH_MULTI_V5) || ARCH_MULTI_V6 || ARCH_MULTI_V7
+	depends on !SMP || !XIP_KERNEL # for SMP_ON_UP
 	select ARM_AMBA
 	select ARM_GIC
 	select ARM_TIMER_SP804
-- 
2.29.2
Re: [PATCH 4/5] ARM: fix CPU_V6 dependencies
Posted by Linus Walleij 3 years, 7 months ago
On Thu, Aug 18, 2022 at 4:56 PM Arnd Bergmann <arnd@kernel.org> wrote:

> From: Arnd Bergmann <arnd@arndb.de>
>
> CONFIG_XIP_KERNEL must not be combined with CONFIG_SMP_ON_UP
> because the patching of read-only data does not work.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

The $SUBJECT of this patch is mildly confusing, as the affected
targets are maybe CPU_V6 but the change is related to XIP and
SMP_ON_UP.

Other than that it looks good.

Yours,
Linus Walleij
Re: [PATCH 4/5] ARM: fix CPU_V6 dependencies
Posted by Arnd Bergmann 3 years, 7 months ago
On Thu, Aug 25, 2022 at 3:43 PM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> On Thu, Aug 18, 2022 at 4:56 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > CONFIG_XIP_KERNEL must not be combined with CONFIG_SMP_ON_UP
> > because the patching of read-only data does not work.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> The $SUBJECT of this patch is mildly confusing, as the affected
> targets are maybe CPU_V6 but the change is related to XIP and
> SMP_ON_UP.
>
> Other than that it looks good.

The patch caused a regression, so I ended up completely replacing it,
new patch follows.

         Arnd
[PATCH] ARM: fix XIP_KERNEL dependencies
Posted by Arnd Bergmann 3 years, 7 months ago
CONFIG_XIP_KERNEL does not work with any option that involves patching
the read-only kernel .text.

Since at least CONFIG_SMP_ON_UP is required in certain configurations,
flip the dependency to always allow the .text patching options but make
XIP_KERNEL have the dependency instead.

This is a prerequisite for allowing CONFIG_ARCH_MULTIPLATFORM to
be disabled.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
forgot to send this yesterday, replaces the CPU_v6 dependency patch

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 3066ce82cffc..2d94e53037ec 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -246,7 +246,7 @@ config ARCH_MTD_XIP
 config ARM_PATCH_PHYS_VIRT
 	bool "Patch physical to virtual translations at runtime" if EMBEDDED
 	default y
-	depends on !XIP_KERNEL && MMU
+	depends on MMU
 	help
 	  Patch phys-to-virt and virt-to-phys translation functions at
 	  boot and module load time according to the position of the
@@ -975,7 +975,7 @@ config SMP
 
 config SMP_ON_UP
 	bool "Allow booting SMP kernel on uniprocessor systems"
-	depends on SMP && !XIP_KERNEL && MMU
+	depends on SMP && MMU
 	default y
 	help
 	  SMP kernels contain instructions which fail on non-SMP processors.
@@ -1224,7 +1224,7 @@ config THUMB2_KERNEL
 
 config ARM_PATCH_IDIV
 	bool "Runtime patch udiv/sdiv instructions into __aeabi_{u}idiv()"
-	depends on CPU_32v7 && !XIP_KERNEL
+	depends on CPU_32v7
 	default y
 	help
 	  The ARM compiler inserts calls to __aeabi_idiv() and
@@ -1619,6 +1619,7 @@ endchoice
 config XIP_KERNEL
 	bool "Kernel Execute-In-Place from ROM"
 	depends on !ARM_LPAE && !ARCH_MULTIPLATFORM
+	depends on !SMP_ON_UP && !ARM_PATCH_IDIV && !ARM_PATCH_PHYS_VIRT
 	help
 	  Execute-In-Place allows the kernel to run from non-volatile storage
 	  directly addressable by the CPU, such as NOR flash. This saves RAM
Re: [PATCH] ARM: fix XIP_KERNEL dependencies
Posted by Linus Walleij 3 years, 7 months ago
On Tue, Aug 30, 2022 at 9:21 AM Arnd Bergmann <arnd@arndb.de> wrote:

> CONFIG_XIP_KERNEL does not work with any option that involves patching
> the read-only kernel .text.
>
> Since at least CONFIG_SMP_ON_UP is required in certain configurations,
> flip the dependency to always allow the .text patching options but make
> XIP_KERNEL have the dependency instead.
>
> This is a prerequisite for allowing CONFIG_ARCH_MULTIPLATFORM to
> be disabled.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

OK this should work!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Re: [PATCH] ARM: fix XIP_KERNEL dependencies
Posted by Geert Uytterhoeven 3 years, 7 months ago
Hi Arnd,

On Tue, Aug 30, 2022 at 9:21 AM Arnd Bergmann <arnd@arndb.de> wrote:
> CONFIG_XIP_KERNEL does not work with any option that involves patching
> the read-only kernel .text.
>
> Since at least CONFIG_SMP_ON_UP is required in certain configurations,
> flip the dependency to always allow the .text patching options but make
> XIP_KERNEL have the dependency instead.
>
> This is a prerequisite for allowing CONFIG_ARCH_MULTIPLATFORM to
> be disabled.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks for your patch!

> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1619,6 +1619,7 @@ endchoice
>  config XIP_KERNEL
>         bool "Kernel Execute-In-Place from ROM"
>         depends on !ARM_LPAE && !ARCH_MULTIPLATFORM
> +       depends on !SMP_ON_UP && !ARM_PATCH_IDIV && !ARM_PATCH_PHYS_VIRT

You may want to keep the list sorted.

>         help
>           Execute-In-Place allows the kernel to run from non-volatile storage
>           directly addressable by the CPU, such as NOR flash. This saves RAM

Regardless, LGTM, so
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Re: [PATCH] ARM: fix XIP_KERNEL dependencies
Posted by Arnd Bergmann 3 years, 7 months ago
On Tue, Aug 30, 2022, at 9:41 AM, Geert Uytterhoeven wrote:
>> --- a/arch/arm/Kconfig
>> +++ b/arch/arm/Kconfig
>> @@ -1619,6 +1619,7 @@ endchoice
>>  config XIP_KERNEL
>>         bool "Kernel Execute-In-Place from ROM"
>>         depends on !ARM_LPAE && !ARCH_MULTIPLATFORM
>> +       depends on !SMP_ON_UP && !ARM_PATCH_IDIV && !ARM_PATCH_PHYS_VIRT
>
> You may want to keep the list sorted.

Done

> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thanks,

       Arnd