[PATCH 3/6] x86_64/entry: Make syscall dispatch noinstr
From: Peter Zijlstra
Date: Mon Nov 02 2026 - 06:50:31 EST
Being able to put breakpoints and the like inside syscall dispatch is
'unfortunate'. Simply push noinstr out one more layer.
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
arch/x86/entry/syscall_32.c | 3 ++-
arch/x86/entry/syscall_64.c | 13 +++++++++++--
2 files changed, 13 insertions(+), 3 deletions(-)
--- a/arch/x86/entry/syscall_32.c
+++ b/arch/x86/entry/syscall_32.c
@@ -43,8 +43,9 @@ const sys_call_ptr_t sys_call_table[] =
#define __SYSCALL(nr, sym) case nr: return __ia32_##sym(regs);
/* The unsigned int @nr argument is intentional as it creates denser code in a 64-bit build */
-static noinline long ia32_sys_call(const struct pt_regs *regs, unsigned int nr)
+static noinstr long ia32_sys_call(const struct pt_regs *regs, unsigned int nr)
{
+ instrumentation_weak();
switch (nr) {
#include <asm/syscalls_32.h>
default: return __ia32_sys_ni_syscall(regs);
--- a/arch/x86/entry/syscall_64.c
+++ b/arch/x86/entry/syscall_64.c
@@ -34,17 +34,26 @@ const sys_call_ptr_t sys_call_table[] =
#define __SYSCALL(nr, sym) case nr: return __x64_##sym(regs);
/* The unsigned int @nr argument is intentional as it creates denser code */
-static noinline long x64_sys_call(const struct pt_regs *regs, unsigned int nr)
+static noinstr long x64_sys_call(const struct pt_regs *regs, unsigned int nr)
{
+ /*
+ * Because -fno-jump-tables, this compiles into a binary branch tree
+ * rather than a jump-table. As such @nr is not used as an array
+ * index. Additionally, this is an out-of-line function on purpose,
+ * such that all the actual syscall function calls are tail-calls,
+ * returning to our caller for the common bits.
+ */
+ instrumentation_weak();
switch (nr) {
#include <asm/syscalls_64.h>
default: return __x64_sys_ni_syscall(regs);
}
}
-static noinline long x32_sys_call(const struct pt_regs *regs, unsigned int nr)
+static noinstr long x32_sys_call(const struct pt_regs *regs, unsigned int nr)
{
#ifdef CONFIG_X86_X32_ABI
+ instrumentation_weak();
switch (nr) {
#include <asm/syscalls_x32.h>
default: return __x64_sys_ni_syscall(regs);