Subject: [PATCH] ARM: Kconfig: Disable ARM_VIRT extension if XIP_KERNEL

From: "Rob Herring (Arm)" <[email-masked]>
Date: Tue, 28 Apr 2026 16:58:15 -0500

From: Vishnu Banavath <[email-masked]>

XIP is intended to execute kernel inplace and typically from
flash and is used mostly on low memory devices.

.macro  store_primary_cpu_mode  reg1, reg2, reg3
        mrs     \reg1, cpsr
        and     \reg1, \reg1, #MODE_MASK
        adr     \reg2, .L__boot_cpu_mode_offset
        ldr     \reg3, [\reg2]
        str     \reg1, [\reg2, \reg3]

As text section is in flash memory and data section is in RAM.
L__boot_cpu_mode_offset would evaluate to address based
on virtual addresses provided by linker script. At this stage
the MMU is OFF.

The logic used based stored @L__boot_cpu_mode_offset on the offset
between the  boot_cpu_mode in data section and the location of
L__boot_cpu_mode_offset can't be used along with PC to fetch the value
of boot_cpu_mode doesn't work.

Signed-off-by: Vishnu Banavath <[email-masked]>
Signed-off-by: Rob Herring (Arm) <[email-masked]>
---
This patch is from Alif E8 SoC tree which I'm working on. It's 
originally from corstone700 trees.

 arch/arm/mm/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index 7b27ee9482b3..e2f5d3d7d3fb 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -705,6 +705,7 @@ config ARM_THUMBEE
 
 config ARM_VIRT_EXT
 	bool
+	depends on MMU && !XIP_KERNEL
 	default y if CPU_V7
 	help
 	  Enable the kernel to make use of the ARM Virtualization
-- 
2.53.0