mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 0/2] x86/fred: Prevent single-step upon ERETU completion
@ 2025-06-05 18:10 Xin Li (Intel)
  2025-06-05 18:10 ` [PATCH v4 1/2] x86/fred/signal: " Xin Li (Intel)
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Xin Li (Intel) @ 2025-06-05 18:10 UTC (permalink / raw)
  To: linux-kernel, linux-kselftest
  Cc: tglx, mingo, bp, dave.hansen, x86, hpa, shuah, andrew.cooper3,
	sohil.mehta

IDT event delivery has a debug hole in which it does not generate #DB
upon returning to userspace before the first userspace instruction is
executed if the Trap Flag (TF) is set.

FRED closes this hole by introducing a software event flag, i.e., bit
17 of the augmented SS: if the bit is set and ERETU would result in
RFLAGS.TF = 1, a single-step trap will be pending upon completion of
ERETU.

However I overlooked properly setting and clearing the bit in different
situations.  Thus when FRED is enabled, if the Trap Flag (TF) is set
without an external debugger attached, it can lead to an infinite loop
in the SIGTRAP handler.  To avoid this, the software event flag in the
augmented SS must be cleared, ensuring that no single-step trap remains
pending when ERETU completes.

This patch set combines the fix [1] and its corresponding selftest [2]
(requested by Dave Hansen) into one patch set.

[1] https://lore.kernel.org/lkml/20250523050153.3308237-1-xin@zytor.com/
[2] https://lore.kernel.org/lkml/20250530230707.2528916-1-xin@zytor.com/


This patch set is based on tip/x86/urgent branch as of today.


Xin Li (Intel) (2):
  x86/fred/signal: Prevent single-step upon ERETU completion
  selftests/x86: Add a test to detect infinite sigtrap handler loop

 arch/x86/include/asm/sighandling.h         | 22 +++++
 arch/x86/kernel/signal_32.c                |  4 +
 arch/x86/kernel/signal_64.c                |  4 +
 tools/testing/selftests/x86/Makefile       |  2 +-
 tools/testing/selftests/x86/sigtrap_loop.c | 97 ++++++++++++++++++++++
 5 files changed, 128 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/x86/sigtrap_loop.c


base-commit: dd2922dcfaa3296846265e113309e5f7f138839f
-- 
2.49.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-06-12 18:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-05 18:10 [PATCH v4 0/2] x86/fred: Prevent single-step upon ERETU completion Xin Li (Intel)
2025-06-05 18:10 ` [PATCH v4 1/2] x86/fred/signal: " Xin Li (Intel)
2025-06-05 18:46   ` H. Peter Anvin
2025-06-05 18:10 ` [PATCH v4 2/2] selftests/x86: Add a test to detect infinite sigtrap handler loop Xin Li (Intel)
2025-06-05 19:32 ` [PATCH v4 0/2] x86/fred: Prevent single-step upon ERETU completion Sohil Mehta
2025-06-05 21:51   ` Sohil Mehta
2025-06-12 18:12     ` Xin Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®