x86: Introduce ia32_enabled()
authorNikolay Borisov <nik.borisov@suse.com>
Fri, 23 Jun 2023 11:14:04 +0000 (14:14 +0300)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 14 Sep 2023 11:19:53 +0000 (13:19 +0200)
IA32 support on 64bit kernels depends on whether CONFIG_IA32_EMULATION
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
IA32 support and give the user the flexibility to override it.

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

Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230623111409.3047467-2-nik.borisov@suse.com
arch/x86/entry/common.c
arch/x86/include/asm/ia32.h

index 6c2826417b3376cb70d53df8006f5998a0e33d9c..cfbd3aec3ddc7f0a996b1c7aaeffe12df9196cf2 100644 (file)
@@ -96,6 +96,10 @@ static __always_inline int syscall_32_enter(struct pt_regs *regs)
        return (int)regs->orig_ax;
 }
 
+#ifdef CONFIG_IA32_EMULATION
+bool __ia32_enabled __ro_after_init = true;
+#endif
+
 /*
  * Invoke a 32-bit syscall.  Called with IRQs on in CONTEXT_KERNEL.
  */
index fada857f0a1edf8cabfbd0ca15aaf6b11daf1ea8..5a2ae24b1204f932e15ff3d5f08232e541e54be5 100644 (file)
@@ -68,6 +68,20 @@ extern void ia32_pick_mmap_layout(struct mm_struct *mm);
 
 #endif
 
-#endif /* CONFIG_IA32_EMULATION */
+extern bool __ia32_enabled;
+
+static inline bool ia32_enabled(void)
+{
+       return __ia32_enabled;
+}
+
+#else /* !CONFIG_IA32_EMULATION */
+
+static inline bool ia32_enabled(void)
+{
+       return IS_ENABLED(CONFIG_X86_32);
+}
+
+#endif
 
 #endif /* _ASM_X86_IA32_H */