[patch 16/18] x86/entry: Get rid of the sys_ni_syscall() indirection
Sebastian Andrzej Siewior
bigeasy at linutronix.de
Thu Oct 22 07:24:25 PDT 2026
On 2026-07-07 21:07:01 [+0200], Thomas Gleixner wrote:
> Invoking sys_ni_syscall() from a code path, which already knows that the
> syscall number is invalid just to assign -ENOSYS to regs->ax is a pointless
> exercise. It's even redundant as the low level entry code already has set
> regs->ax to -ENOSYS on entry.
>
> Remove the extra conditionals and the function calls.
Since this patch, tools/testing/selftests/x86/syscall_numbering_64
throws in this:
|[RUN] Running tests under ptrace: modifying the default return
|[RUN] Checking system calls with msb = 0 (0x0)
|[RUN] Checking some common syscalls as 64 bit
|[OK] x64 syscall 0:0 returned 0 as expected
|[OK] x64 syscall 0:1 returned 0 as expected
|[RUN] Checking some 64-bit only syscalls as 64 bit
|[OK] x64 syscall 0:19 returned 0 as expected
|[OK] x64 syscall 0:20 returned 0 as expected
|[RUN] Checking out of range system calls
|[FAIL] x32 syscall 0:-64 returned -9999, but it should have returned -ENOSYS
…
|[FAIL] x32 syscall 0:-2 returned -9999, but it should have returned -ENOSYS
|[FAIL] x32 syscalls 0:-64..-2 had 63 failure
|[OK] x32 syscall 0:-1 returned MODIFIED_BY_PTRACE as expected
|[FAIL] x64 syscall 0:1073741760 returned -9999, but it should have returned -ENOSYS
…
|[FAIL] x64 syscall 0:1073741823 returned -9999, but it should have returned -ENOSYS
|[FAIL] x64 syscalls 0:1073741760..1073741823 had 64 failure
|[FAIL] x64 syscall 0:-64 returned -9999, but it should have returned -ENOSYS
…
|[FAIL] x64 syscall 0:547 returned -9999, but it should have returned -ENOSYS
|[FAIL] x64 syscalls 0:512..547 had 36 failure
|[RUN] Checking some common syscalls as x32
|[OK] x32 syscall 0:0 returned 0 as expected
…
|[RUN] Checking out of range system calls
|[FAIL] x32 syscall 1:-64 returned -9999, but it should have returned -ENOSYS
|[FAIL] x32 syscalls 1:-64..-2 had 63 failure
|[OK] x32 syscall 1:-1 returned MODIFIED_BY_PTRACE as expected
|[FAIL] x64 syscall 1:1073741760 returned -9999, but it should have returned -ENOSYS
…
and so on… The test has
| #define MODIFIED_BY_PTRACE -9999
and the ptracer modifies the return code. However not always. Not sure
if this was indeed a pointless exercise or not.
The test could be updated via the hunk below in case the new behaviour
is what is expected. hpa made the extension to the test in commit
795e2a023b808 ("selftests/x86/syscall: Add tests under ptrace to
syscall_numbering_64").
diff --git a/tools/testing/selftests/x86/syscall_numbering.c b/tools/testing/selftests/x86/syscall_numbering.c
index ca0eca7b9dced..1435394fba022 100644
--- a/tools/testing/selftests/x86/syscall_numbering.c
+++ b/tools/testing/selftests/x86/syscall_numbering.c
@@ -250,6 +250,7 @@ static bool test_x32(void)
static void test_syscalls_common(int msb)
{
enum ptrace_pass pass = sh->ptrace_pass;
+ int expected_ret = -ENOSYS;
run("Checking some common syscalls as 64 bit\n");
check_zero(msb, SYS_READ);
@@ -260,18 +261,22 @@ static void test_syscalls_common(int msb)
check_zero(msb, X64_WRITEV);
run("Checking out of range system calls\n");
- check_for(msb, -64, -2, -ENOSYS);
if (pass >= PTP_FUZZRET)
- check_for(msb, -1, -1, MODIFIED_BY_PTRACE);
- else
- check_for(msb, -1, -1, -ENOSYS);
- check_for(msb, X32_BIT-64, X32_BIT-1, -ENOSYS);
- check_for(msb, -64-X32_BIT, -1-X32_BIT, -ENOSYS);
- check_for(msb, INT_MAX-64, INT_MAX-1, -ENOSYS);
+ expected_ret = MODIFIED_BY_PTRACE;
+ check_for(msb, -64, -2, expected_ret);
+ check_for(msb, -1, -1, expected_ret);
+ check_for(msb, X32_BIT-64, X32_BIT-1, expected_ret);
+ check_for(msb, -64-X32_BIT, -1-X32_BIT, expected_ret);
+ check_for(msb, INT_MAX-64, INT_MAX-1, expected_ret);
}
static void test_syscalls_with_x32(int msb)
{
+ enum ptrace_pass pass = sh->ptrace_pass;
+ int expected_ret = -ENOSYS;
+
+ if (pass >= PTP_FUZZRET)
+ expected_ret = MODIFIED_BY_PTRACE;
/*
* Syscalls 512-547 are "x32" syscalls. They are
* intended to be called with the x32 (0x40000000) bit
@@ -279,7 +284,7 @@ static void test_syscalls_with_x32(int msb)
* nonsense and should not work.
*/
run("Checking x32 syscalls as 64 bit\n");
- check_for(msb, 512, 547, -ENOSYS);
+ check_for(msb, 512, 547, expected_ret);
run("Checking some common syscalls as x32\n");
check_zero(msb, SYS_READ | X32_BIT);
Sebastian
More information about the linux-riscv
mailing list