x86/entry: Break up common.c
Subsystems (3)
v2 cover x86/entry: Break up common.c
The syscall dispatch code originally was put into entry/common.c so that common code for entry from and exit to userspace could be inlined. That entry code has since been moved to the core kernel. There is no longer a need to keep this code together, so move it to more appropriate places.
No functional changes.
Changes in v2:
- Move Xen inlines to enlighten_pv.c (Juergen Gross)
- Don't copy comments on the code's origins. Git history has that information already (Sohil Mehta)
- Added cleanup patches (Sohil Mehta)
Brian Gerst (7):
x86/xen: Move Xen upcall handler x86/syscall/32: Move 32-bit syscall dispatch code x86/syscall/64: Move 64-bit syscall dispatch code x86/syscall/x32: Move x32 syscall table x86/syscall: Move sys_ni_syscall() x86/syscall: Remove stray semicolons x86/syscall/32: Add comment to conditional
arch/x86/entry/Makefile | 8 +- arch/x86/entry/common.c | 524 ----------------------------------- arch/x86/entry/syscall_32.c | 332 +++++++++++++++++++++- arch/x86/entry/syscall_64.c | 111 +++++++- arch/x86/entry/syscall_x32.c | 25 -- arch/x86/kernel/process.c | 5 + arch/x86/xen/enlighten_pv.c | 69 +++++ 7 files changed, 515 insertions(+), 559 deletions(-) delete mode 100644 arch/x86/entry/common.c delete mode 100644 arch/x86/entry/syscall_x32.c
base-commit: d08c0d55110b7cbac186e5fa94b0c6d5f4d7905e
Signature · 1 line
2.48.1
PATCH v2 1/7 x86/xen: Move Xen upcall handler
Move the upcall handler to Xen-specific files.
No functional changes.
--- arch/x86/entry/common.c | 72 ------------------------------------- arch/x86/xen/enlighten_pv.c | 69 +++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 72 deletions(-)
arch/x86/entry/common.c +0 -72
@@ -21,11 +21,6 @@#include <linux/uaccess.h> #include <linux/init.h> -#ifdef CONFIG_XEN_PV -#include <xen/xen-ops.h> -#include <xen/events.h> -#endif -#include <asm/apic.h> #include <asm/desc.h> #include <asm/traps.h>
@@ -455,70 +450,3 @@ SYSCALL_DEFINE0(ni_syscall) {return -ENOSYS ; } - -#ifdef CONFIG_XEN_PV -#ifndef CONFIG_PREEMPTION -/* -* Some hypercalls issued by the toolstack can take many 10s of -* seconds. Allow tasks running hypercalls via the privcmd driver to -* be voluntarily preempted even if full kernel preemption is -* disabled. -* -* Such preemptible hypercalls are bracketed by -* xen_preemptible_hcall_begin() and xen_preemptible_hcall_end() -* calls. -*/ -DEFINE_PER_CPU (bool, xen_in_preemptible_hcall); -EXPORT_SYMBOL_GPL (xen_in_preemptible_hcall); - -/* -* In case of scheduling the flag must be cleared and restored after -* returning from schedule as the task might move to a different CPU. -*/ -static __always_inline bool get_and_clear_inhcall(void) -{ -bool inhcall =__this_cpu_read (xen_in_preemptible_hcall); - -__this_cpu_write (xen_in_preemptible_hcall, false); -return inhcall; -} - -static __always_inline void restore_inhcall(bool inhcall) -{ -__this_cpu_write (xen_in_preemptible_hcall, inhcall); -} -#else -static __always_inline bool get_and_clear_inhcall(void) { return false; } -static __always_inline void restore_inhcall(bool inhcall) { } -#endif - -static void __xen_pv_evtchn_do_upcall (struct pt_regs *regs) -{ -struct pt_regs *old_regs =set_irq_regs (regs); - -inc_irq_stat (irq_hv_callback_count); - -xen_evtchn_do_upcall (); - -set_irq_regs (old_regs); -} - -__visible noinstr void xen_pv_evtchn_do_upcall(struct pt_regs *regs) -{ -irqentry_state_t state =irqentry_enter (regs); -bool inhcall; - -instrumentation_begin (); -run_sysvec_on_irqstack_cond (__xen_pv_evtchn_do_upcall, regs); - - inhcall =get_and_clear_inhcall (); -if (inhcall && !WARN_ON_ONCE (state.exit_rcu)) { -irqentry_exit_cond_resched (); -instrumentation_end (); -restore_inhcall (inhcall); - }else { -instrumentation_end (); -irqentry_exit (regs, state); - } -} -#endif /* CONFIG_XEN_PV */
arch/x86/xen/enlighten_pv.c +69 -0
87 lines not on this page · raw message
Signature · 1 line
2.48.1
Re: [PATCH v2 1/7] x86/xen: Move Xen upcall handler
Quoted 7 lines · Brian Gerst
Move the upcall handler to Xen-specific files.
No functional changes.
Signed-off-by Brian Gerst <[email protected]>Cc Juergen Gross <[email protected]>Cc Boris Ostrovsky <[email protected]>
Juergen
[tip: x86/cpu] x86/xen: Move Xen upcall handler
In reply to Brian GerstThe following commit has been merged into the x86/cpu branch of tip:
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: 82d829091f62721166d3f1af93c4c94fc9afa13e Gitweb: https://git.kernel.org/tip/82d829091f62721166d3f1af93c4c94fc9afa13e Author: Brian Gerst <[email protected]> AuthorDate: Fri, 14 Mar 2025 11:12:14 -04:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sun, 16 Mar 2025 11:49:41 +01:00
x86/xen: Move Xen upcall handler
Move the upcall handler to Xen-specific files.
No functional changes.
--- arch/x86/entry/common.c | 72 +------------------------------------ arch/x86/xen/enlighten_pv.c | 69 +++++++++++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 72 deletions(-)
arch/x86/entry/common.c +0 -72
@@ -21,11 +21,6 @@#include <linux/uaccess.h> #include <linux/init.h> -#ifdef CONFIG_XEN_PV -#include <xen/xen-ops.h> -#include <xen/events.h> -#endif -#include <asm/apic.h> #include <asm/desc.h> #include <asm/traps.h>
@@ -455,70 +450,3 @@ SYSCALL_DEFINE0(ni_syscall) {return -ENOSYS ; } - -#ifdef CONFIG_XEN_PV -#ifndef CONFIG_PREEMPTION -/* -* Some hypercalls issued by the toolstack can take many 10s of -* seconds. Allow tasks running hypercalls via the privcmd driver to -* be voluntarily preempted even if full kernel preemption is -* disabled. -* -* Such preemptible hypercalls are bracketed by -* xen_preemptible_hcall_begin() and xen_preemptible_hcall_end() -* calls. -*/ -DEFINE_PER_CPU (bool, xen_in_preemptible_hcall); -EXPORT_SYMBOL_GPL (xen_in_preemptible_hcall); - -/* -* In case of scheduling the flag must be cleared and restored after -* returning from schedule as the task might move to a different CPU. -*/ -static __always_inline bool get_and_clear_inhcall(void) -{ -bool inhcall =__this_cpu_read (xen_in_preemptible_hcall); - -__this_cpu_write (xen_in_preemptible_hcall, false); -return inhcall; -} - -static __always_inline void restore_inhcall(bool inhcall) -{ -__this_cpu_write (xen_in_preemptible_hcall, inhcall); -} -#else -static __always_inline bool get_and_clear_inhcall(void) { return false; } -static __always_inline void restore_inhcall(bool inhcall) { } -#endif - -static void __xen_pv_evtchn_do_upcall (struct pt_regs *regs) -{ -struct pt_regs *old_regs =set_irq_regs (regs); - -inc_irq_stat (irq_hv_callback_count); - -xen_evtchn_do_upcall (); - -set_irq_regs (old_regs); -} - -__visible noinstr void xen_pv_evtchn_do_upcall(struct pt_regs *regs) -{ -irqentry_state_t state =irqentry_enter (regs); -bool inhcall; - -instrumentation_begin (); -run_sysvec_on_irqstack_cond (__xen_pv_evtchn_do_upcall, regs); - - inhcall =get_and_clear_inhcall (); -if (inhcall && !WARN_ON_ONCE (state.exit_rcu)) { -irqentry_exit_cond_resched (); -instrumentation_end (); -restore_inhcall (inhcall); - }else { -instrumentation_end (); -irqentry_exit (regs, state); - } -} -#endif /* CONFIG_XEN_PV */
arch/x86/xen/enlighten_pv.c +69 -0
87 lines not on this page · raw message
[tip: x86/core] x86/xen: Move Xen upcall handler
In reply to Brian GerstThe following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 1ab7b5ed44ba9bce581e225f40219b793bc779d6 Gitweb: https://git.kernel.org/tip/1ab7b5ed44ba9bce581e225f40219b793bc779d6 Author: Brian Gerst <[email protected]> AuthorDate: Fri, 14 Mar 2025 11:12:14 -04:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Wed, 19 Mar 2025 11:18:58 +01:00
x86/xen: Move Xen upcall handler
Move the upcall handler to Xen-specific files.
No functional changes.
--- arch/x86/entry/common.c | 72 +------------------------------------ arch/x86/xen/enlighten_pv.c | 69 +++++++++++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 72 deletions(-)
arch/x86/entry/common.c +0 -72
@@ -21,11 +21,6 @@#include <linux/uaccess.h> #include <linux/init.h> -#ifdef CONFIG_XEN_PV -#include <xen/xen-ops.h> -#include <xen/events.h> -#endif -#include <asm/apic.h> #include <asm/desc.h> #include <asm/traps.h>
@@ -455,70 +450,3 @@ SYSCALL_DEFINE0(ni_syscall) {return -ENOSYS ; } - -#ifdef CONFIG_XEN_PV -#ifndef CONFIG_PREEMPTION -/* -* Some hypercalls issued by the toolstack can take many 10s of -* seconds. Allow tasks running hypercalls via the privcmd driver to -* be voluntarily preempted even if full kernel preemption is -* disabled. -* -* Such preemptible hypercalls are bracketed by -* xen_preemptible_hcall_begin() and xen_preemptible_hcall_end() -* calls. -*/ -DEFINE_PER_CPU (bool, xen_in_preemptible_hcall); -EXPORT_SYMBOL_GPL (xen_in_preemptible_hcall); - -/* -* In case of scheduling the flag must be cleared and restored after -* returning from schedule as the task might move to a different CPU. -*/ -static __always_inline bool get_and_clear_inhcall(void) -{ -bool inhcall =__this_cpu_read (xen_in_preemptible_hcall); - -__this_cpu_write (xen_in_preemptible_hcall, false); -return inhcall; -} - -static __always_inline void restore_inhcall(bool inhcall) -{ -__this_cpu_write (xen_in_preemptible_hcall, inhcall); -} -#else -static __always_inline bool get_and_clear_inhcall(void) { return false; } -static __always_inline void restore_inhcall(bool inhcall) { } -#endif - -static void __xen_pv_evtchn_do_upcall (struct pt_regs *regs) -{ -struct pt_regs *old_regs =set_irq_regs (regs); - -inc_irq_stat (irq_hv_callback_count); - -xen_evtchn_do_upcall (); - -set_irq_regs (old_regs); -} - -__visible noinstr void xen_pv_evtchn_do_upcall(struct pt_regs *regs) -{ -irqentry_state_t state =irqentry_enter (regs); -bool inhcall; - -instrumentation_begin (); -run_sysvec_on_irqstack_cond (__xen_pv_evtchn_do_upcall, regs); - - inhcall =get_and_clear_inhcall (); -if (inhcall && !WARN_ON_ONCE (state.exit_rcu)) { -irqentry_exit_cond_resched (); -instrumentation_end (); -restore_inhcall (inhcall); - }else { -instrumentation_end (); -irqentry_exit (regs, state); - } -} -#endif /* CONFIG_XEN_PV */
arch/x86/xen/enlighten_pv.c +69 -0
87 lines not on this page · raw message
PATCH v2 2/7 x86/syscall/32: Move 32-bit syscall dispatch code
In reply to Brian GerstMove the 32-bit syscall dispatch code to syscall_32.c.
No functional changes.
--- arch/x86/entry/Makefile | 2 + arch/x86/entry/common.c | 321 ----------------------------------- arch/x86/entry/syscall_32.c | 329 +++++++++++++++++++++++++++++++++++- 3 files changed, 329 insertions(+), 323 deletions(-)
arch/x86/entry/Makefile +2 -0
@@ -8,8 +8,10 @@ UBSAN_SANITIZE := n KCOV_INSTRUMENT := n CFLAGS_REMOVE_common.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_syscall_32.o = $(CC_FLAGS_FTRACE) CFLAGS_common.o += -fno-stack-protector +CFLAGS_syscall_32.o += -fno-stack-protector obj-y := entry.o entry_$(BITS).o syscall_$(BITS).o obj-y += common.o
arch/x86/entry/common.c +0 -321
327 lines not on this page · raw message
arch/x86/entry/syscall_32.c +327 -2
340 lines not on this page · raw message
Signature · 1 line
2.48.1
[tip: x86/cpu] x86/syscall/32: Move 32-bit syscall dispatch code
The following commit has been merged into the x86/cpu branch of tip:
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: 50cf87f662b0798bfa17b952b630f74ea8517f64 Gitweb: https://git.kernel.org/tip/50cf87f662b0798bfa17b952b630f74ea8517f64 Author: Brian Gerst <[email protected]> AuthorDate: Fri, 14 Mar 2025 11:12:15 -04:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sun, 16 Mar 2025 11:49:41 +01:00
x86/syscall/32: Move 32-bit syscall dispatch code
Move the 32-bit syscall dispatch code to syscall_32.c.
No functional changes.
--- arch/x86/entry/Makefile | 2 +- arch/x86/entry/common.c | 321 +---------------------------------- arch/x86/entry/syscall_32.c | 329 ++++++++++++++++++++++++++++++++++- 3 files changed, 329 insertions(+), 323 deletions(-)
arch/x86/entry/Makefile +2 -0
@@ -8,8 +8,10 @@ UBSAN_SANITIZE := n KCOV_INSTRUMENT := n CFLAGS_REMOVE_common.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_syscall_32.o = $(CC_FLAGS_FTRACE) CFLAGS_common.o += -fno-stack-protector +CFLAGS_syscall_32.o += -fno-stack-protector obj-y := entry.o entry_$(BITS).o syscall_$(BITS).o obj-y += common.o
arch/x86/entry/common.c +0 -321
327 lines not on this page · raw message
arch/x86/entry/syscall_32.c +327 -2
340 lines not on this page · raw message
[tip: x86/core] x86/syscall/32: Move 32-bit syscall dispatch code
In reply to Brian GerstThe following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: b634b02e2bf9767f1f8c194a7dcd5c28f868ac10 Gitweb: https://git.kernel.org/tip/b634b02e2bf9767f1f8c194a7dcd5c28f868ac10 Author: Brian Gerst <[email protected]> AuthorDate: Fri, 14 Mar 2025 11:12:15 -04:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Wed, 19 Mar 2025 11:19:01 +01:00
x86/syscall/32: Move 32-bit syscall dispatch code
Move the 32-bit syscall dispatch code to syscall_32.c.
No functional changes.
--- arch/x86/entry/Makefile | 2 +- arch/x86/entry/common.c | 321 +---------------------------------- arch/x86/entry/syscall_32.c | 329 ++++++++++++++++++++++++++++++++++- 3 files changed, 329 insertions(+), 323 deletions(-)
arch/x86/entry/Makefile +2 -0
@@ -8,8 +8,10 @@ UBSAN_SANITIZE := n KCOV_INSTRUMENT := n CFLAGS_REMOVE_common.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_syscall_32.o = $(CC_FLAGS_FTRACE) CFLAGS_common.o += -fno-stack-protector +CFLAGS_syscall_32.o += -fno-stack-protector obj-y := entry.o entry_$(BITS).o syscall_$(BITS).o obj-y += common.o
arch/x86/entry/common.c +0 -321
327 lines not on this page · raw message
arch/x86/entry/syscall_32.c +327 -2
340 lines not on this page · raw message
PATCH v2 3/7 x86/syscall/64: Move 64-bit syscall dispatch code
In reply to Brian GerstMove the 64-bit syscall dispatch code to syscall_64.c.
No functional changes.
--- arch/x86/entry/Makefile | 2 + arch/x86/entry/common.c | 93 ----------------------------------- arch/x86/entry/syscall_64.c | 96 ++++++++++++++++++++++++++++++++++++- 3 files changed, 96 insertions(+), 95 deletions(-)
arch/x86/entry/Makefile +2 -0
@@ -9,9 +9,11 @@ KCOV_INSTRUMENT := n CFLAGS_REMOVE_common.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_syscall_32.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_syscall_64.o = $(CC_FLAGS_FTRACE) CFLAGS_common.o += -fno-stack-protector CFLAGS_syscall_32.o += -fno-stack-protector +CFLAGS_syscall_64.o += -fno-stack-protector obj-y := entry.o entry_$(BITS).o syscall_$(BITS).o obj-y += common.o
arch/x86/entry/common.c +0 -93
99 lines not on this page · raw message
arch/x86/entry/syscall_64.c +94 -2
107 lines not on this page · raw message
Signature · 1 line
2.48.1
[tip: x86/cpu] x86/syscall/64: Move 64-bit syscall dispatch code
The following commit has been merged into the x86/cpu branch of tip:
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: 43060b4ddd586eff95c37bc7f307f6d973d790a5 Gitweb: https://git.kernel.org/tip/43060b4ddd586eff95c37bc7f307f6d973d790a5 Author: Brian Gerst <[email protected]> AuthorDate: Fri, 14 Mar 2025 11:12:16 -04:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sun, 16 Mar 2025 11:49:41 +01:00
x86/syscall/64: Move 64-bit syscall dispatch code
Move the 64-bit syscall dispatch code to syscall_64.c.
No functional changes.
--- arch/x86/entry/Makefile | 2 +- arch/x86/entry/common.c | 93 +----------------------------------- arch/x86/entry/syscall_64.c | 96 +++++++++++++++++++++++++++++++++++- 3 files changed, 96 insertions(+), 95 deletions(-)
arch/x86/entry/Makefile +2 -0
@@ -9,9 +9,11 @@ KCOV_INSTRUMENT := n CFLAGS_REMOVE_common.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_syscall_32.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_syscall_64.o = $(CC_FLAGS_FTRACE) CFLAGS_common.o += -fno-stack-protector CFLAGS_syscall_32.o += -fno-stack-protector +CFLAGS_syscall_64.o += -fno-stack-protector obj-y := entry.o entry_$(BITS).o syscall_$(BITS).o obj-y += common.o
arch/x86/entry/common.c +0 -93
99 lines not on this page · raw message
arch/x86/entry/syscall_64.c +94 -2
107 lines not on this page · raw message
[tip: x86/core] x86/syscall/64: Move 64-bit syscall dispatch code
In reply to Brian GerstThe following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 01dfb4805420291966b75b208d66c88c62579649 Gitweb: https://git.kernel.org/tip/01dfb4805420291966b75b208d66c88c62579649 Author: Brian Gerst <[email protected]> AuthorDate: Fri, 14 Mar 2025 11:12:16 -04:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Wed, 19 Mar 2025 11:19:04 +01:00
x86/syscall/64: Move 64-bit syscall dispatch code
Move the 64-bit syscall dispatch code to syscall_64.c.
No functional changes.
--- arch/x86/entry/Makefile | 2 +- arch/x86/entry/common.c | 93 +----------------------------------- arch/x86/entry/syscall_64.c | 96 +++++++++++++++++++++++++++++++++++- 3 files changed, 96 insertions(+), 95 deletions(-)
arch/x86/entry/Makefile +2 -0
@@ -9,9 +9,11 @@ KCOV_INSTRUMENT := n CFLAGS_REMOVE_common.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_syscall_32.o = $(CC_FLAGS_FTRACE) +CFLAGS_REMOVE_syscall_64.o = $(CC_FLAGS_FTRACE) CFLAGS_common.o += -fno-stack-protector CFLAGS_syscall_32.o += -fno-stack-protector +CFLAGS_syscall_64.o += -fno-stack-protector obj-y := entry.o entry_$(BITS).o syscall_$(BITS).o obj-y += common.o
arch/x86/entry/common.c +0 -93
99 lines not on this page · raw message
arch/x86/entry/syscall_64.c +94 -2
107 lines not on this page · raw message
PATCH v2 4/7 x86/syscall/x32: Move x32 syscall table
In reply to Brian GerstSince commit:
2e958a8a510d ("x86/entry/x32: Rename __x32_compat_sys_* to
__x64_compat_sys_*"),
the ABI prefix for x32 syscalls is the same as native 64-bit syscalls. Move the x32 syscall table to syscall_64.c
No functional changes.
--- arch/x86/entry/Makefile | 1 - arch/x86/entry/syscall_64.c | 13 +++++++++++++ arch/x86/entry/syscall_x32.c | 25 ------------------------- 3 files changed, 13 insertions(+), 26 deletions(-) delete mode 100644 arch/x86/entry/syscall_x32.c
arch/x86/entry/Makefile +0 -1
@@ -27,4 +27,3 @@ CFLAGS_REMOVE_entry_fred.o += -pg $(CC_FLAGS_FTRACE) obj-$(CONFIG_X86_FRED) += entry_64_fred.o entry_fred.o obj-$(CONFIG_IA32_EMULATION) += entry_64_compat.o syscall_32.o -obj-$(CONFIG_X86_X32_ABI) += syscall_x32.o
arch/x86/entry/syscall_64.c +13 -0
@@ -12,6 +12,9 @@#define __SYSCALL (nr, sym) extern long __x64_##sym(const struct pt_regs *);#define __SYSCALL_NORETURN (nr, sym) extern long __noreturn __x64_##sym(const struct pt_regs *);#include <asm/syscalls_64.h> +#ifdef CONFIG_X86_X32_ABI +#include <asm/syscalls_x32.h> +#endif #undef __SYSCALL#undef __SYSCALL_NORETURN
@@ -37,6 +40,16 @@ long x64_sys_call(const struct pt_regs *regs, unsigned int nr) } }; +#ifdef CONFIG_X86_X32_ABI +long x32_sys_call (const struct pt_regs *regs,unsigned int nr) +{ +switch (nr) { +#include <asm/syscalls_x32.h> +default :return __x64_sys_ni_syscall (regs); + } +}; +#endif + static __always_inline bool do_syscall_x64(struct pt_regs *regs, int nr) {/*
arch/x86/entry/syscall_x32.c deleted +0 -25
@@ -1,25 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* System call table for x32 ABI. */ - -#include <linux/linkage.h> -#include <linux/sys.h> -#include <linux/cache.h> -#include <linux/syscalls.h> -#include <asm/syscall.h> - -#define __SYSCALL (nr, sym) extern long __x64_##sym(const struct pt_regs *); -#define __SYSCALL_NORETURN (nr, sym) extern long __noreturn __x64_##sym(const struct pt_regs *); -#include <asm/syscalls_x32.h> -#undef __SYSCALL - -#undef __SYSCALL_NORETURN -#define __SYSCALL_NORETURN __SYSCALL - -#define __SYSCALL (nr, sym) case nr: return __x64_##sym(regs); -long x32_sys_call (const struct pt_regs *regs,unsigned int nr) -{ -switch (nr) { -#include <asm/syscalls_x32.h> -default :return __x64_sys_ni_syscall (regs); - } -};
Signature · 1 line
2.48.1
[tip: x86/cpu] x86/syscall/x32: Move x32 syscall table
The following commit has been merged into the x86/cpu branch of tip:
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: 0b9358963319e6d8f0ed49e3669e629a4efbd384 Gitweb: https://git.kernel.org/tip/0b9358963319e6d8f0ed49e3669e629a4efbd384 Author: Brian Gerst <[email protected]> AuthorDate: Fri, 14 Mar 2025 11:12:17 -04:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sun, 16 Mar 2025 11:49:41 +01:00
x86/syscall/x32: Move x32 syscall table
Since commit:
2e958a8a510d ("x86/entry/x32: Rename __x32_compat_sys_* to __x64_compat_sys_*")
the ABI prefix for x32 syscalls is the same as native 64-bit syscalls. Move the x32 syscall table to syscall_64.c
No functional changes.
--- arch/x86/entry/Makefile | 1 - arch/x86/entry/syscall_64.c | 13 +++++++++++++ arch/x86/entry/syscall_x32.c | 25 ------------------------- 3 files changed, 13 insertions(+), 26 deletions(-) delete mode 100644 arch/x86/entry/syscall_x32.c
arch/x86/entry/Makefile +0 -1
@@ -27,4 +27,3 @@ CFLAGS_REMOVE_entry_fred.o += -pg $(CC_FLAGS_FTRACE) obj-$(CONFIG_X86_FRED) += entry_64_fred.o entry_fred.o obj-$(CONFIG_IA32_EMULATION) += entry_64_compat.o syscall_32.o -obj-$(CONFIG_X86_X32_ABI) += syscall_x32.o
arch/x86/entry/syscall_64.c +13 -0
@@ -12,6 +12,9 @@#define __SYSCALL (nr, sym) extern long __x64_##sym(const struct pt_regs *);#define __SYSCALL_NORETURN (nr, sym) extern long __noreturn __x64_##sym(const struct pt_regs *);#include <asm/syscalls_64.h> +#ifdef CONFIG_X86_X32_ABI +#include <asm/syscalls_x32.h> +#endif #undef __SYSCALL#undef __SYSCALL_NORETURN
@@ -37,6 +40,16 @@ long x64_sys_call(const struct pt_regs *regs, unsigned int nr) } }; +#ifdef CONFIG_X86_X32_ABI +long x32_sys_call (const struct pt_regs *regs,unsigned int nr) +{ +switch (nr) { +#include <asm/syscalls_x32.h> +default :return __x64_sys_ni_syscall (regs); + } +}; +#endif + static __always_inline bool do_syscall_x64(struct pt_regs *regs, int nr) {/*
arch/x86/entry/syscall_x32.c deleted +0 -25
@@ -1,25 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* System call table for x32 ABI. */ - -#include <linux/linkage.h> -#include <linux/sys.h> -#include <linux/cache.h> -#include <linux/syscalls.h> -#include <asm/syscall.h> - -#define __SYSCALL (nr, sym) extern long __x64_##sym(const struct pt_regs *); -#define __SYSCALL_NORETURN (nr, sym) extern long __noreturn __x64_##sym(const struct pt_regs *); -#include <asm/syscalls_x32.h> -#undef __SYSCALL - -#undef __SYSCALL_NORETURN -#define __SYSCALL_NORETURN __SYSCALL - -#define __SYSCALL (nr, sym) case nr: return __x64_##sym(regs); -long x32_sys_call (const struct pt_regs *regs,unsigned int nr) -{ -switch (nr) { -#include <asm/syscalls_x32.h> -default :return __x64_sys_ni_syscall (regs); - } -};
[tip: x86/core] x86/syscall/x32: Move x32 syscall table
In reply to Brian GerstThe following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 21832247f2df4f636b0f2ae6939819e8dd2ed35f Gitweb: https://git.kernel.org/tip/21832247f2df4f636b0f2ae6939819e8dd2ed35f Author: Brian Gerst <[email protected]> AuthorDate: Fri, 14 Mar 2025 11:12:17 -04:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Wed, 19 Mar 2025 11:19:15 +01:00
x86/syscall/x32: Move x32 syscall table
Since commit:
2e958a8a510d ("x86/entry/x32: Rename __x32_compat_sys_* to __x64_compat_sys_*")
the ABI prefix for x32 syscalls is the same as native 64-bit syscalls. Move the x32 syscall table to syscall_64.c
No functional changes.
--- arch/x86/entry/Makefile | 1 - arch/x86/entry/syscall_64.c | 13 +++++++++++++ arch/x86/entry/syscall_x32.c | 25 ------------------------- 3 files changed, 13 insertions(+), 26 deletions(-) delete mode 100644 arch/x86/entry/syscall_x32.c
arch/x86/entry/Makefile +0 -1
@@ -27,4 +27,3 @@ CFLAGS_REMOVE_entry_fred.o += -pg $(CC_FLAGS_FTRACE) obj-$(CONFIG_X86_FRED) += entry_64_fred.o entry_fred.o obj-$(CONFIG_IA32_EMULATION) += entry_64_compat.o syscall_32.o -obj-$(CONFIG_X86_X32_ABI) += syscall_x32.o
arch/x86/entry/syscall_64.c +13 -0
@@ -12,6 +12,9 @@#define __SYSCALL (nr, sym) extern long __x64_##sym(const struct pt_regs *);#define __SYSCALL_NORETURN (nr, sym) extern long __noreturn __x64_##sym(const struct pt_regs *);#include <asm/syscalls_64.h> +#ifdef CONFIG_X86_X32_ABI +#include <asm/syscalls_x32.h> +#endif #undef __SYSCALL#undef __SYSCALL_NORETURN
@@ -37,6 +40,16 @@ long x64_sys_call(const struct pt_regs *regs, unsigned int nr) } }; +#ifdef CONFIG_X86_X32_ABI +long x32_sys_call (const struct pt_regs *regs,unsigned int nr) +{ +switch (nr) { +#include <asm/syscalls_x32.h> +default :return __x64_sys_ni_syscall (regs); + } +}; +#endif + static __always_inline bool do_syscall_x64(struct pt_regs *regs, int nr) {/*
arch/x86/entry/syscall_x32.c deleted +0 -25
@@ -1,25 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* System call table for x32 ABI. */ - -#include <linux/linkage.h> -#include <linux/sys.h> -#include <linux/cache.h> -#include <linux/syscalls.h> -#include <asm/syscall.h> - -#define __SYSCALL (nr, sym) extern long __x64_##sym(const struct pt_regs *); -#define __SYSCALL_NORETURN (nr, sym) extern long __noreturn __x64_##sym(const struct pt_regs *); -#include <asm/syscalls_x32.h> -#undef __SYSCALL - -#undef __SYSCALL_NORETURN -#define __SYSCALL_NORETURN __SYSCALL - -#define __SYSCALL (nr, sym) case nr: return __x64_##sym(regs); -long x32_sys_call (const struct pt_regs *regs,unsigned int nr) -{ -switch (nr) { -#include <asm/syscalls_x32.h> -default :return __x64_sys_ni_syscall (regs); - } -};
PATCH v2 5/7 x86/syscall: Move sys_ni_syscall()
In reply to Brian GerstMove sys_ni_syscall() to kernel/process.c, and remove the now empty entry/common.c
No functional changes.
--- arch/x86/entry/Makefile | 3 --- arch/x86/entry/common.c | 38 -------------------------------------- arch/x86/kernel/process.c | 5 +++++ 3 files changed, 5 insertions(+), 41 deletions(-) delete mode 100644 arch/x86/entry/common.c
arch/x86/entry/Makefile +0 -3
@@ -7,16 +7,13 @@ KASAN_SANITIZE := n UBSAN_SANITIZE := n KCOV_INSTRUMENT := n -CFLAGS_REMOVE_common.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_syscall_32.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_syscall_64.o = $(CC_FLAGS_FTRACE) -CFLAGS_common.o += -fno-stack-protector CFLAGS_syscall_32.o += -fno-stack-protector CFLAGS_syscall_64.o += -fno-stack-protector obj-y := entry.o entry_$(BITS).o syscall_$(BITS).o -obj-y += common.o obj-y += vdso/ obj-y += vsyscall/
arch/x86/entry/common.c deleted +0 -38
@@ -1,38 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* -* common.c - C code for kernel entry and exit -* Copyright (c) 2015 Andrew Lutomirski -* -* Based on asm and ptrace code by many authors. The code here originated -* in ptrace.c and signal.c. -*/ - -#include <linux/kernel.h> -#include <linux/sched.h> -#include <linux/sched/task_stack.h> -#include <linux/entry-common.h> -#include <linux/mm.h> -#include <linux/smp.h> -#include <linux/errno.h> -#include <linux/ptrace.h> -#include <linux/export.h> -#include <linux/nospec.h> -#include <linux/syscalls.h> -#include <linux/uaccess.h> -#include <linux/init.h> - -#include <asm/apic.h> -#include <asm/desc.h> -#include <asm/traps.h> -#include <asm/vdso.h> -#include <asm/cpufeature.h> -#include <asm/fpu/api.h> -#include <asm/nospec-branch.h> -#include <asm/io_bitmap.h> -#include <asm/syscall.h> -#include <asm/irq_stack.h> - -SYSCALL_DEFINE0 (ni_syscall) -{ -return -ENOSYS ; -}
arch/x86/kernel/process.c +5 -0
@@ -1068,3 +1068,8 @@ SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)return -EINVAL ; } + +SYSCALL_DEFINE0 (ni_syscall) +{ +return -ENOSYS ; +}
Signature · 1 line
2.48.1
[tip: x86/cpu] x86/syscall: Move sys_ni_syscall()
The following commit has been merged into the x86/cpu branch of tip:
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: 7abd22188d76307aea7956cc7723f8ef20c1a606 Gitweb: https://git.kernel.org/tip/7abd22188d76307aea7956cc7723f8ef20c1a606 Author: Brian Gerst <[email protected]> AuthorDate: Fri, 14 Mar 2025 11:12:18 -04:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sun, 16 Mar 2025 11:49:42 +01:00
x86/syscall: Move sys_ni_syscall()
Move sys_ni_syscall() to kernel/process.c, and remove the now empty entry/common.c
No functional changes.
--- arch/x86/entry/Makefile | 3 +--- arch/x86/entry/common.c | 38 +-------------------------------------- arch/x86/kernel/process.c | 5 +++++- 3 files changed, 5 insertions(+), 41 deletions(-) delete mode 100644 arch/x86/entry/common.c
arch/x86/entry/Makefile +0 -3
@@ -7,16 +7,13 @@ KASAN_SANITIZE := n UBSAN_SANITIZE := n KCOV_INSTRUMENT := n -CFLAGS_REMOVE_common.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_syscall_32.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_syscall_64.o = $(CC_FLAGS_FTRACE) -CFLAGS_common.o += -fno-stack-protector CFLAGS_syscall_32.o += -fno-stack-protector CFLAGS_syscall_64.o += -fno-stack-protector obj-y := entry.o entry_$(BITS).o syscall_$(BITS).o -obj-y += common.o obj-y += vdso/ obj-y += vsyscall/
arch/x86/entry/common.c deleted +0 -38
@@ -1,38 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* -* common.c - C code for kernel entry and exit -* Copyright (c) 2015 Andrew Lutomirski -* -* Based on asm and ptrace code by many authors. The code here originated -* in ptrace.c and signal.c. -*/ - -#include <linux/kernel.h> -#include <linux/sched.h> -#include <linux/sched/task_stack.h> -#include <linux/entry-common.h> -#include <linux/mm.h> -#include <linux/smp.h> -#include <linux/errno.h> -#include <linux/ptrace.h> -#include <linux/export.h> -#include <linux/nospec.h> -#include <linux/syscalls.h> -#include <linux/uaccess.h> -#include <linux/init.h> - -#include <asm/apic.h> -#include <asm/desc.h> -#include <asm/traps.h> -#include <asm/vdso.h> -#include <asm/cpufeature.h> -#include <asm/fpu/api.h> -#include <asm/nospec-branch.h> -#include <asm/io_bitmap.h> -#include <asm/syscall.h> -#include <asm/irq_stack.h> - -SYSCALL_DEFINE0 (ni_syscall) -{ -return -ENOSYS ; -}
arch/x86/kernel/process.c +5 -0
@@ -1060,3 +1060,8 @@ long do_arch_prctl_common(int option, unsigned long arg2)return -EINVAL ; } + +SYSCALL_DEFINE0 (ni_syscall) +{ +return -ENOSYS ; +}
[tip: x86/core] x86/syscall: Move sys_ni_syscall()
In reply to Brian GerstThe following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 9a93e29f16bbba90a63faad0abbc6dea3b2f0c63 Gitweb: https://git.kernel.org/tip/9a93e29f16bbba90a63faad0abbc6dea3b2f0c63 Author: Brian Gerst <[email protected]> AuthorDate: Fri, 14 Mar 2025 11:12:18 -04:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Wed, 19 Mar 2025 11:19:17 +01:00
x86/syscall: Move sys_ni_syscall()
Move sys_ni_syscall() to kernel/process.c, and remove the now empty entry/common.c
No functional changes.
--- arch/x86/entry/Makefile | 3 +--- arch/x86/entry/common.c | 38 +-------------------------------------- arch/x86/kernel/process.c | 5 +++++- 3 files changed, 5 insertions(+), 41 deletions(-) delete mode 100644 arch/x86/entry/common.c
arch/x86/entry/Makefile +0 -3
@@ -7,16 +7,13 @@ KASAN_SANITIZE := n UBSAN_SANITIZE := n KCOV_INSTRUMENT := n -CFLAGS_REMOVE_common.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_syscall_32.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_syscall_64.o = $(CC_FLAGS_FTRACE) -CFLAGS_common.o += -fno-stack-protector CFLAGS_syscall_32.o += -fno-stack-protector CFLAGS_syscall_64.o += -fno-stack-protector obj-y := entry.o entry_$(BITS).o syscall_$(BITS).o -obj-y += common.o obj-y += vdso/ obj-y += vsyscall/
arch/x86/entry/common.c deleted +0 -38
@@ -1,38 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* -* common.c - C code for kernel entry and exit -* Copyright (c) 2015 Andrew Lutomirski -* -* Based on asm and ptrace code by many authors. The code here originated -* in ptrace.c and signal.c. -*/ - -#include <linux/kernel.h> -#include <linux/sched.h> -#include <linux/sched/task_stack.h> -#include <linux/entry-common.h> -#include <linux/mm.h> -#include <linux/smp.h> -#include <linux/errno.h> -#include <linux/ptrace.h> -#include <linux/export.h> -#include <linux/nospec.h> -#include <linux/syscalls.h> -#include <linux/uaccess.h> -#include <linux/init.h> - -#include <asm/apic.h> -#include <asm/desc.h> -#include <asm/traps.h> -#include <asm/vdso.h> -#include <asm/cpufeature.h> -#include <asm/fpu/api.h> -#include <asm/nospec-branch.h> -#include <asm/io_bitmap.h> -#include <asm/syscall.h> -#include <asm/irq_stack.h> - -SYSCALL_DEFINE0 (ni_syscall) -{ -return -ENOSYS ; -}
arch/x86/kernel/process.c +5 -0
@@ -1063,3 +1063,8 @@ SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)return -EINVAL ; } + +SYSCALL_DEFINE0 (ni_syscall) +{ +return -ENOSYS ; +}
PATCH v2 6/7 x86/syscall: Remove stray semicolons
In reply to Brian GerstNo functional change.
--- arch/x86/entry/syscall_32.c | 2 +- arch/x86/entry/syscall_64.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/entry/syscall_32.c +1 -1
@@ -47,7 +47,7 @@ long ia32_sys_call(const struct pt_regs *regs, unsigned int nr)#include <asm/syscalls_32.h> default :return __ia32_sys_ni_syscall (regs); } -}; +} static __always_inline int syscall_32_enter(struct pt_regs *regs) {
arch/x86/entry/syscall_64.c +2 -2
@@ -38,7 +38,7 @@ long x64_sys_call(const struct pt_regs *regs, unsigned int nr)#include <asm/syscalls_64.h> default :return __x64_sys_ni_syscall (regs); } -}; +}#ifdef CONFIG_X86_X32_ABI long x32_sys_call (const struct pt_regs *regs,unsigned int nr)
@@ -47,7 +47,7 @@ long x32_sys_call(const struct pt_regs *regs, unsigned int nr)#include <asm/syscalls_x32.h> default: return __x64_sys_ni_syscall(regs); } -}; +}#endif static __always_inline bool do_syscall_x64(struct pt_regs *regs, int nr)
Signature · 1 line
2.48.1
[tip: x86/cpu] x86/syscall: Remove stray semicolons
The following commit has been merged into the x86/cpu branch of tip:
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: 11743519c8c82a8a08552337168bdc6561ea0165 Gitweb: https://git.kernel.org/tip/11743519c8c82a8a08552337168bdc6561ea0165 Author: Brian Gerst <[email protected]> AuthorDate: Fri, 14 Mar 2025 11:12:19 -04:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sun, 16 Mar 2025 11:49:42 +01:00
x86/syscall: Remove stray semicolons
No functional change.
--- arch/x86/entry/syscall_32.c | 2 +- arch/x86/entry/syscall_64.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/entry/syscall_32.c +1 -1
@@ -47,7 +47,7 @@ long ia32_sys_call(const struct pt_regs *regs, unsigned int nr)#include <asm/syscalls_32.h> default :return __ia32_sys_ni_syscall (regs); } -}; +} static __always_inline int syscall_32_enter(struct pt_regs *regs) {
arch/x86/entry/syscall_64.c +2 -2
@@ -38,7 +38,7 @@ long x64_sys_call(const struct pt_regs *regs, unsigned int nr)#include <asm/syscalls_64.h> default :return __x64_sys_ni_syscall (regs); } -}; +}#ifdef CONFIG_X86_X32_ABI long x32_sys_call (const struct pt_regs *regs,unsigned int nr)
@@ -47,7 +47,7 @@ long x32_sys_call(const struct pt_regs *regs, unsigned int nr)#include <asm/syscalls_x32.h> default: return __x64_sys_ni_syscall(regs); } -}; +}#endif static __always_inline bool do_syscall_x64(struct pt_regs *regs, int nr)
[tip: x86/core] x86/syscall: Remove stray semicolons
In reply to Brian GerstThe following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 604939552231730c52b823b178e9080877b20851 Gitweb: https://git.kernel.org/tip/604939552231730c52b823b178e9080877b20851 Author: Brian Gerst <[email protected]> AuthorDate: Fri, 14 Mar 2025 11:12:19 -04:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Wed, 19 Mar 2025 11:19:18 +01:00
x86/syscall: Remove stray semicolons
No functional change.
--- arch/x86/entry/syscall_32.c | 2 +- arch/x86/entry/syscall_64.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/entry/syscall_32.c +1 -1
@@ -47,7 +47,7 @@ long ia32_sys_call(const struct pt_regs *regs, unsigned int nr)#include <asm/syscalls_32.h> default :return __ia32_sys_ni_syscall (regs); } -}; +} static __always_inline int syscall_32_enter(struct pt_regs *regs) {
arch/x86/entry/syscall_64.c +2 -2
@@ -38,7 +38,7 @@ long x64_sys_call(const struct pt_regs *regs, unsigned int nr)#include <asm/syscalls_64.h> default :return __x64_sys_ni_syscall (regs); } -}; +}#ifdef CONFIG_X86_X32_ABI long x32_sys_call (const struct pt_regs *regs,unsigned int nr)
@@ -47,7 +47,7 @@ long x32_sys_call(const struct pt_regs *regs, unsigned int nr)#include <asm/syscalls_x32.h> default: return __x64_sys_ni_syscall(regs); } -}; +}#endif static __always_inline bool do_syscall_x64(struct pt_regs *regs, int nr)
PATCH v2 7/7 x86/syscall/32: Add comment to conditional
In reply to Brian GerstAdd a CONFIG_X86_FRED comment, since this conditional is nested.
--- arch/x86/entry/syscall_32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/entry/syscall_32.c +2 -1
@@ -238,7 +238,8 @@ DEFINE_FREDENTRY_RAW(int80_emulation)instrumentation_end (); syscall_exit_to_user_mode(regs); } -#endif +#endif /* CONFIG_X86_FRED */ +#else /* CONFIG_IA32_EMULATION */ /* Handles int $0x80 on a 32bit kernel */
Signature · 1 line
2.48.1
Re: [PATCH v2 7/7] x86/syscall/32: Add comment to conditional
Quoted 13 lines · Brian Gerst
Add a
CONFIG_X86_FREDcomment, since this conditional is nested.Signed-off-by Brian Gerst <[email protected]>Suggested-by Sohil Mehta <[email protected]>--- arch/x86/entry/syscall_32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/x86/entry/syscall_32.c +0
-0
arch/x86/entry/syscall_32.c DEFINE_FREDENTRY_RAW(int80_emulation) · line 245
Quoted 9 lines
arch/x86/entry/syscall_32.c +2
-1@@ -238,7 +238,8 @@ DEFINE_FREDENTRY_RAW(int80_emulation)instrumentation_end (); syscall_exit_to_user_mode(regs); } -#endif +#endif /* CONFIG_X86_FRED */ +#else /* CONFIG_IA32_EMULATION */ /* Handles int $0x80 on a 32bit kernel */
Also, there seem to be a couple of adjacent CONFIG_IA32_EMULATION sections in the file. It might be better to bring them together under one section in this patch or a follow-up. Something like below:
Quoted 36 lines
arch/x86/entry/syscall_32.c +8
-10@@ -57,16 +57,6 @@ 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 = !IS_ENABLED (CONFIG_IA32_EMULATION_DEFAULT_DISABLED ); - -static int __init ia32_emulation_override_cmdline (char *arg) -{ -return kstrtobool (arg, &__ia32_enabled); -} -early_param ("ia32_emulation" , ia32_emulation_override_cmdline); -#endif -/* * Invoke a 32-bit syscall. Called with IRQs on in CT_STATE_KERNEL. */ @@ -87,6 +77,14 @@ static __always_inline void do_syscall_32_irqs_on(struct pt_regs *regs, int nr) }#ifdef CONFIG_IA32_EMULATION +bool __ia32_enabled__ro_after_init = !IS_ENABLED (CONFIG_IA32_EMULATION_DEFAULT_DISABLED ); + +static int __init ia32_emulation_override_cmdline (char *arg) +{ +return kstrtobool (arg, &__ia32_enabled); +} +early_param ("ia32_emulation" , ia32_emulation_override_cmdline); + static __always_inline bool int80_is_external(void) {const unsigned int offs = (0x80 /32 ) *0x10 ;
Re: [PATCH v2 7/7] x86/syscall/32: Add comment to conditional
Quoted 53 lines · Sohil Mehta
Quoted 13 lines · Brian Gerst
Add a
CONFIG_X86_FREDcomment, since this conditional is nested.Signed-off-by Brian Gerst <[email protected]>Suggested-by Sohil Mehta <[email protected]>--- arch/x86/entry/syscall_32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/x86/entry/syscall_32.c +0
-0arch/x86/entry/syscall_32.c DEFINE_FREDENTRY_RAW(int80_emulation) · line 245
Quoted 9 lines
arch/x86/entry/syscall_32.c +2
-1@@ -238,7 +238,8 @@ DEFINE_FREDENTRY_RAW(int80_emulation)instrumentation_end (); syscall_exit_to_user_mode(regs); } -#endif +#endif /* CONFIG_X86_FRED */ +#else /* CONFIG_IA32_EMULATION */ /* Handles int $0x80 on a 32bit kernel */ Also, there seem to be a couple of adjacent
CONFIG_IA32_EMULATIONsections in the file. It might be better to bring them together under one section in this patch or a follow-up. Something like below:Quoted 24 lines
arch/x86/entry/syscall_32.c +0
-10@@ -57,16 +57,6 @@ 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 = !IS_ENABLED (CONFIG_IA32_EMULATION_DEFAULT_DISABLED ); - -static int __init ia32_emulation_override_cmdline (char *arg) -{ -return kstrtobool (arg, &__ia32_enabled); -} -early_param ("ia32_emulation" , ia32_emulation_override_cmdline); -#endif -/* * Invoke a 32-bit syscall. Called with IRQs on in CT_STATE_KERNEL. */ @@ -87,6 +77,14 @@ static __always_inline void do_syscall_32_irqs_on(struct pt_regs *regs, int nr) }
Quoted 12 lines
arch/x86/entry/syscall_32.c static __always_inline void do_syscall_32_irqs_on(struct pt_regs *regs, int nr) · line 90
Quoted 12 lines
arch/x86/entry/syscall_32.c +8
-0#ifdef CONFIG_IA32_EMULATION +bool __ia32_enabled__ro_after_init = !IS_ENABLED (CONFIG_IA32_EMULATION_DEFAULT_DISABLED ); + +static int __init ia32_emulation_override_cmdline (char *arg) +{ +return kstrtobool (arg, &__ia32_enabled); +} +early_param ("ia32_emulation" , ia32_emulation_override_cmdline); + static __always_inline bool int80_is_external(void) {const unsigned int offs = (0x80 /32 ) *0x10 ;
The 32-bit syscall code is a bit of a mess right now, and it was hard to see its state while it was lumped in with everything else in common.c. I'd like to see the INT80 code merged back into one function, but that will probably have to wait until the dust settles with FRED.
Brian Gerst
H. Peter Anvin
reviewerRe: [PATCH v2 7/7] x86/syscall/32: Add comment to conditional
Quoted 74 lines · Brian Gerst
Quoted 53 lines · Sohil Mehta
Quoted 13 lines · Brian Gerst
Add a
CONFIG_X86_FREDcomment, since this conditional is nested.Signed-off-by Brian Gerst <[email protected]>Suggested-by Sohil Mehta <[email protected]>--- arch/x86/entry/syscall_32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/x86/entry/syscall_32.c +0
-0arch/x86/entry/syscall_32.c DEFINE_FREDENTRY_RAW(int80_emulation) · line 245
Quoted 9 lines
arch/x86/entry/syscall_32.c +2
-1@@ -238,7 +238,8 @@ DEFINE_FREDENTRY_RAW(int80_emulation)instrumentation_end (); syscall_exit_to_user_mode(regs); } -#endif +#endif /* CONFIG_X86_FRED */ +#else /* CONFIG_IA32_EMULATION */ /* Handles int $0x80 on a 32bit kernel */ Also, there seem to be a couple of adjacent
CONFIG_IA32_EMULATIONsections in the file. It might be better to bring them together under one section in this patch or a follow-up. Something like below:Quoted 24 lines
arch/x86/entry/syscall_32.c +0
-10@@ -57,16 +57,6 @@ 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 = !IS_ENABLED (CONFIG_IA32_EMULATION_DEFAULT_DISABLED ); - -static int __init ia32_emulation_override_cmdline (char *arg) -{ -return kstrtobool (arg, &__ia32_enabled); -} -early_param ("ia32_emulation" , ia32_emulation_override_cmdline); -#endif -/* * Invoke a 32-bit syscall. Called with IRQs on in CT_STATE_KERNEL. */ @@ -87,6 +77,14 @@ static __always_inline void do_syscall_32_irqs_on(struct pt_regs *regs, int nr) }Quoted 12 lines
arch/x86/entry/syscall_32.c static __always_inline void do_syscall_32_irqs_on(struct pt_regs *regs, int nr) · line 90
Quoted 12 lines
arch/x86/entry/syscall_32.c +8
-0#ifdef CONFIG_IA32_EMULATION +bool __ia32_enabled__ro_after_init = !IS_ENABLED (CONFIG_IA32_EMULATION_DEFAULT_DISABLED ); + +static int __init ia32_emulation_override_cmdline (char *arg) +{ +return kstrtobool (arg, &__ia32_enabled); +} +early_param ("ia32_emulation" , ia32_emulation_override_cmdline); + static __always_inline bool int80_is_external(void) {const unsigned int offs = (0x80 /32 ) *0x10 ;The 32-bit syscall code is a bit of a mess right now, and it was hard to see its state while it was lumped in with everything else in
common.c. I'd like to see the INT80 code merged back into one function, but that will probably have to wait until the dust settles with FRED.
Quoted 2 lines
Brian Gerst
That function gets really, really ugly. The reason we factored out the FRED code is that the number of conditionals ended up grotesque, *and* that they are part of completely separate flows – they should have separate every points, not dynamic conditionals.
[tip: x86/cpu] x86/syscall/32: Add comment to conditional
In reply to Brian GerstThe following commit has been merged into the x86/cpu branch of tip:
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: fe35c87ad8e7795e1ab020ce2023e952806353d0 Gitweb: https://git.kernel.org/tip/fe35c87ad8e7795e1ab020ce2023e952806353d0 Author: Brian Gerst <[email protected]> AuthorDate: Fri, 14 Mar 2025 11:12:20 -04:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sun, 16 Mar 2025 11:49:42 +01:00
x86/syscall/32: Add comment to conditional
Add a CONFIG_X86_FRED comment, since this conditional is nested.
--- arch/x86/entry/syscall_32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/entry/syscall_32.c +2 -1
@@ -238,7 +238,8 @@ DEFINE_FREDENTRY_RAW(int80_emulation)instrumentation_end (); syscall_exit_to_user_mode(regs); } -#endif +#endif /* CONFIG_X86_FRED */ +#else /* CONFIG_IA32_EMULATION */ /* Handles int $0x80 on a 32bit kernel */
[tip: x86/core] x86/syscall/32: Add comment to conditional
In reply to Brian GerstThe following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 82070bc0425db949b406ede1c7f066346f5b3eb9 Gitweb: https://git.kernel.org/tip/82070bc0425db949b406ede1c7f066346f5b3eb9 Author: Brian Gerst <[email protected]> AuthorDate: Fri, 14 Mar 2025 11:12:20 -04:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Wed, 19 Mar 2025 11:19:20 +01:00
x86/syscall/32: Add comment to conditional
Add a CONFIG_X86_FRED comment, since this conditional is nested.
--- arch/x86/entry/syscall_32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/entry/syscall_32.c +2 -1
@@ -238,7 +238,8 @@ DEFINE_FREDENTRY_RAW(int80_emulation)instrumentation_end (); syscall_exit_to_user_mode(regs); } -#endif +#endif /* CONFIG_X86_FRED */ +#else /* CONFIG_IA32_EMULATION */ /* Handles int $0x80 on a 32bit kernel */
Quoted 14 lines · Brian Gerst
The syscall dispatch code originally was put into
entry/common.cso that common code for entry from and exit to userspace could be inlined. That entry code has since been moved to the core kernel. There is no longer a need to keep this code together, so move it to more appropriate places.No functional changes.
Changes in v2:
- Move Xen inlines toenlighten_pv.c(Juergen Gross)
- Don't copy comments on the code's origins. Git history has that information already (Sohil Mehta)
- Added cleanup patches (Sohil Mehta)
Quoted 9 lines
Brian Gerst (7):
x86/xen: Move Xen upcall handler x86/syscall/32: Move 32-bit syscall dispatch code x86/syscall/64: Move 64-bit syscall dispatch code x86/syscall/x32: Move x32 syscall table x86/syscall: Movesys_ni_syscall()x86/syscall: Remove stray semicolons x86/syscall/32: Add comment to conditional
This series looks good to me. The minor comments in patch 7 can be addressed separately if they seem useful.
Quoted 13 lines
arch/x86/entry/Makefile | 8 +- arch/x86/entry/common.c | 524 ----------------------------------- arch/x86/entry/syscall_32.c | 332 +++++++++++++++++++++- arch/x86/entry/syscall_64.c | 111 +++++++- arch/x86/entry/syscall_x32.c | 25 -- arch/x86/kernel/process.c | 5 + arch/x86/xen/enlighten_pv.c | 69 +++++ 7 files changed, 515 insertions(+), 559 deletions(-) delete mode 100644 arch/x86/entry/common.c delete mode 100644 arch/x86/entry/syscall_x32.cbase-commit:
d08c0d55110b7cbac186e5fa94b0c6d5f4d7905e