On 5/22/2025 12:20 AM, H. Peter Anvin wrote:
On 5/21/25 23:05, Xin Li (Intel) wrote:
+/*
- To prevent infinite SIGTRAP handler loop if TF is used without an external
 
- debugger, clear the software event flag in the augmented SS, ensuring no
 
- single-step trap is pending upon ERETU completion.
 
- Note, this function should be called in sigreturn() before the original state
 
- is restored to make sure the TF is read from the entry frame.
 - */
 +static __always_inline void prevent_single_step_upon_eretu(struct pt_regs *regs) +{
- /*
 * If the trap flag (TF) is set, i.e., the sigreturn() SYSCALL instruction* is being single-stepped, do not clear the software event flag in the* augmented SS, thus a debugger won't skip over the following instruction.*/- if (IS_ENABLED(CONFIG_X86_FRED) && cpu_feature_enabled(X86_FEATURE_FRED) &&
 !(regs->flags & X86_EFLAGS_TF))regs->fred_ss.swevent = 0;+}
Minor nit (and I should have caught this when I saw your patch earlier):
cpu_feature_enabled(X86_FEATURE_FRED) is unnecessary here, because when FRED is not enabled, regs->fred_ss.swevent will always be 0, and this bit has no function, so there is no point in making that extra test.
Yeah, less conditions, less complexity. I will remove it.
Thanks! Xin