[PATCH v4 1/6] x86: Introduce ia32_enabled()

Nikolay Borisov posted 6 patches 2 years, 7 months ago
[PATCH v4 1/6] x86: Introduce ia32_enabled()
Posted by Nikolay Borisov 2 years, 7 months ago
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>
---
 arch/x86/entry/common.c     |  4 ++++
 arch/x86/include/asm/ia32.h | 16 +++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index 6c2826417b33..ef5a154a7413 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -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 = true;
+#endif
+
 /*
  * Invoke a 32-bit syscall.  Called with IRQs on in CONTEXT_KERNEL.
  */
diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h
index fada857f0a1e..5a2ae24b1204 100644
--- a/arch/x86/include/asm/ia32.h
+++ b/arch/x86/include/asm/ia32.h
@@ -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 */
-- 
2.34.1
Re: [PATCH v4 1/6] x86: Introduce ia32_enabled()
Posted by Thomas Gleixner 2 years, 7 months ago
On Fri, Jun 23 2023 at 14:14, Nikolay Borisov wrote:
>  
> +#ifdef CONFIG_IA32_EMULATION
> +bool __ia32_enabled = true;

This wants to be __ro_after_init as it can't change during runtime.

Thanks,

        tglx
Re: [PATCH v4 1/6] x86: Introduce ia32_enabled()
Posted by Thomas Gleixner 2 years, 7 months ago
On Fri, Jun 30 2023 at 13:18, Thomas Gleixner wrote:
> On Fri, Jun 23 2023 at 14:14, Nikolay Borisov wrote:
>>  
>> +#ifdef CONFIG_IA32_EMULATION
>> +bool __ia32_enabled = true;
>
> This wants to be __ro_after_init as it can't change during runtime.

Other than this the series is now in acceptable state. No need to
resend. I have fixed it up locally. The series now in the queue for post
merge window processing.

Thanks,

        tglx
[tip: x86/entry] x86: Introduce ia32_enabled()
Posted by tip-bot2 for Nikolay Borisov 2 years, 4 months ago
The following commit has been merged into the x86/entry branch of tip:

Commit-ID:     1da5c9bc119d3a749b519596b93f9b2667e93c4a
Gitweb:        https://git.kernel.org/tip/1da5c9bc119d3a749b519596b93f9b2667e93c4a
Author:        Nikolay Borisov <nik.borisov@suse.com>
AuthorDate:    Fri, 23 Jun 2023 14:14:04 +03:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 14 Sep 2023 13:19:53 +02:00

x86: Introduce ia32_enabled()

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     |  4 ++++
 arch/x86/include/asm/ia32.h | 16 +++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index 6c28264..cfbd3ae 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -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.
  */
diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h
index fada857..5a2ae24 100644
--- a/arch/x86/include/asm/ia32.h
+++ b/arch/x86/include/asm/ia32.h
@@ -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 */