[PATCH 1/4] arm64: Introduce aarch32_enabled()

Andrea della Porta andrea.porta at suse.com
Wed Oct 18 04:13:19 PDT 2023


Aarch32 bit support on 64bit kernels depends on whether CONFIG_COMPAT
is selected or not. As it is a compile time option it doesn't
provide the flexibility to have distributions set their own policy for
Aarch32 support and give the user the flexibility to override it.

As a first step introduce aarch32_enabled() which abstracts whether 32
bit compat is turned on or off. Upcoming patches will implement
the ability to set Aarch32 compat state at boot time.

Signed-off-by: Andrea della Porta <andrea.porta at suse.com>
---
 arch/arm64/include/asm/compat.h  | 12 ++++++++++++
 arch/arm64/kernel/entry-common.c |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index ae904a1ad529..f5ef71bd0024 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -98,6 +98,13 @@ static inline int is_compat_thread(struct thread_info *thread)
 
 long compat_arm_syscall(struct pt_regs *regs, int scno);
 
+extern bool __aarch32_enabled;
+
+static inline bool aarch32_enabled(void)
+{
+	return __aarch32_enabled;
+}
+
 #else /* !CONFIG_COMPAT */
 
 static inline int is_compat_thread(struct thread_info *thread)
@@ -105,5 +112,10 @@ static inline int is_compat_thread(struct thread_info *thread)
 	return 0;
 }
 
+static inline bool aarch32_enabled(void)
+{
+	return false;
+}
+
 #endif /* CONFIG_COMPAT */
 #endif /* __ASM_COMPAT_H */
diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
index 0fc94207e69a..69ff9b8c0bde 100644
--- a/arch/arm64/kernel/entry-common.c
+++ b/arch/arm64/kernel/entry-common.c
@@ -877,6 +877,8 @@ asmlinkage void noinstr el0t_32_error_handler(struct pt_regs *regs)
 {
 	__el0_error_handler_common(regs);
 }
+
+bool __aarch32_enabled __ro_after_init = true;
 #else /* CONFIG_COMPAT */
 UNHANDLED(el0t, 32, sync)
 UNHANDLED(el0t, 32, irq)
-- 
2.35.3




More information about the linux-arm-kernel mailing list