linux/tools/testing/selftests/x86
Matthew Schwartz 96443a53bc selftests/x86: Check signal state for rejected software interrupts
Add a test of the signal ABI for INT instructions in both 32-bit and
64-bit processes. Check the signal number, trap number, error code,
si_code, si_addr, instruction pointer and RF/TF state against legacy
IDT behavior. Include a 15-byte prefixed INT to check that IP uses the
hardware instruction length. Exercise both INT3 encodings, INT4, UD2
and HLT to cover the unchanged trap and fault paths.

Run each instruction with TF clear and set. Resume at a known NOP after
handling the signal and check that single-stepping traps after the NOP.

Also drive INT 0x2d under ptrace, which resumes through the fault frame
rather than sigreturn and so exposes a stale FRED software event flag.
Start from an INT3 stop, whose FRED frame has no software event flag,
instead of the syscall frame of raise(SIGSTOP). Single-step into the INT
and check that the fault reports its address. Then suppress SIGSEGV and
resume at the NOP, once with PTRACE_SINGLESTEP and once with PTRACE_CONT
and TF set. Section 6.2.3 of the Intel FRED specification [1] specifies
the immediate single-step trap caused by returning with both that flag
and TF set. Check that each trap occurs after the NOP, rather than at
its address.

Report whether the CPU supports FRED, since a pass looks the same on
either entry path. INT 0x80 with IA32 emulation disabled and a 64-bit
tracer of a 32-bit tracee are not covered.

Both variants pass all 29 checks on a non-FRED AMD host and on Panther
Lake with FRED enabled and the fix applied. With the same binaries on
unpatched Panther Lake, 16 signal-context checks fail and the first
ptrace check reports the IP after the INT. The two dependent ptrace
resume checks are not reached.

[1] Intel Flexible Return and Event Delivery (FRED) Specification,
revision 9.0 (346446-009US), section 6.2.3.

Signed-off-by: Matthew Schwartz <matthew.schwartz@linux.dev>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://cdrdv2.intel.com/v1/dl/getContent/678938 # [1]
Link: https://patch.msgid.link/20260917230907.2080792-3-matthew.schwartz@linux.dev
2026-09-18 12:33:18 +02:00
..
bugs selftest/x86/bugs: Add selftests for ITS 2025-05-09 13:39:45 -07:00
.gitignore selftests/x86/pkeys: move selftests to arch-neutral directory 2020-06-04 19:06:26 -07:00
amx.c selftests/x86/xstate: Consolidate test invocations into a single entry 2025-02-26 13:05:29 +01:00
apx.c selftests/x86/apx: Add APX test 2025-04-16 09:44:14 +02:00
avx.c selftests/x86/avx: Add AVX tests 2025-02-26 13:05:30 +01:00
check_cc.sh selftests/x86: Add validity check and allow field splitting 2022-02-17 11:55:17 -08:00
check_initial_reg_state.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
clang_helpers_32.S selftests/x86: build fsgsbase_restore.c with clang 2024-07-11 11:23:55 -06:00
clang_helpers_64.S selftests/x86: build sysret_rip.c with clang 2024-07-11 11:23:55 -06:00
corrupt_xstate_header.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
entry_from_vm86.c selftests/x86: Consolidate redundant signal helper functions 2025-02-26 13:05:28 +01:00
fsgsbase_restore.c selftests/x86: build fsgsbase_restore.c with clang 2024-07-11 11:23:55 -06:00
fsgsbase.c selftests/x86: Consolidate redundant signal helper functions 2025-02-26 13:05:28 +01:00
helpers.h selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
int_signal.c selftests/x86: Check signal state for rejected software interrupts 2026-09-18 12:33:18 +02:00
ioperm.c selftests/x86: Consolidate redundant signal helper functions 2025-02-26 13:05:28 +01:00
iopl.c selftests/x86: Consolidate redundant signal helper functions 2025-02-26 13:05:28 +01:00
lam.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
ldt_gdt.c selftests/x86: Consolidate redundant signal helper functions 2025-02-26 13:05:28 +01:00
Makefile selftests/x86: Check signal state for rejected software interrupts 2026-09-18 12:33:18 +02:00
mov_ss_trap.c selftests/x86: Consolidate redundant signal helper functions 2025-02-26 13:05:28 +01:00
nx_stack.c selftests/x86/mm: Add new test that userspace stack is in fact NX 2023-10-03 21:00:45 +02:00
ptrace_syscall.c selftests/x86: Consolidate redundant signal helper functions 2025-02-26 13:05:28 +01:00
raw_syscall_helper_32.S selftests/x86: Add missing .note.GNU-stack sections 2020-11-24 13:55:39 +01:00
sigaltstack.c selftests/x86: Consolidate redundant signal helper functions 2025-02-26 13:05:28 +01:00
sigreturn.c selftests/x86: Consolidate redundant signal helper functions 2025-02-26 13:05:28 +01:00
sigtrap_loop.c selftests/x86: Add a test to detect infinite SIGTRAP handler loop 2025-06-09 08:52:06 -07:00
single_step_syscall.c selftests/x86: Consolidate redundant signal helper functions 2025-02-26 13:05:28 +01:00
srso.c Documentation/srso: Document a method for checking safe RET operates properly 2024-08-27 09:16:35 +02:00
syscall_arg_fault.c selftests/x86: Consolidate redundant signal helper functions 2025-02-26 13:05:28 +01:00
syscall_nt.c selftests/x86: Consolidate redundant signal helper functions 2025-02-26 13:05:28 +01:00
syscall_numbering.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
sysret_rip.c selftests/x86: Clean up sysret_rip coding style 2026-01-19 12:06:11 +01:00
sysret_ss_attrs.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
test_FCMOV.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
test_FCOMI.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
test_FISTTP.c selftests: x86: test_FISTTP: use fisttps instead of ambiguous fisttp 2024-07-11 11:23:55 -06:00
test_mremap_vdso.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
test_shadow_stack.c selftests/x86: Add shadow stack uprobe CALL test 2026-07-02 13:21:49 +02:00
test_syscall_vdso.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
test_vsyscall.c Significant patch series in this pull request: 2025-12-06 14:01:20 -08:00
thunks_32.S selftests/x86: Add a missing .note.GNU-stack section to thunks_32.S 2021-03-18 11:05:14 +01:00
thunks.S selftests/x86: Add missing .note.GNU-stack sections 2020-11-24 13:55:39 +01:00
trivial_32bit_program.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 257 2019-06-05 17:30:27 +02:00
trivial_64bit_program.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 257 2019-06-05 17:30:27 +02:00
trivial_program.c selftests/x86: Detect -no-pie availability 2018-05-30 15:21:51 -06:00
unwind_vdso.c selftests/x86: Consolidate redundant signal helper functions 2025-02-26 13:05:28 +01:00
vdso_restorer.c selftests/x86: remove (or use) unused variables and functions 2024-07-11 11:23:55 -06:00
xstate.c selftests/x86/apx: Add APX test 2025-04-16 09:44:14 +02:00
xstate.h selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00