Skip to content

Commit 1cec9ac

Browse files
committed
x86/fpu: Delay instruction pointer fixup until after warning
Right now, if XRSTOR fails a console message like this is be printed: Bad FPU state detected at restore_fpregs_from_fpstate+0x9a/0x170, reinitializing FPU registers. However, the text location (...+0x9a in this case) is the instruction *AFTER* the XRSTOR. The highlighted instruction in the "Code:" dump also points one instruction late. The reason is that the "fixup" moves RIP up to pass the bad XRSTOR and keep on running after returning from the #GP handler. But it does this fixup before warning. The resulting warning output is nonsensical because it looks like the non-FPU-related instruction is #GP'ing. Do not fix up RIP until after printing the warning. Do this by using the more generic and standard ex_handler_default(). Fixes: d5c8028 ("x86/fpu: Reinitialize FPU registers if restoring FPU state fails") Signed-off-by: Dave Hansen <[email protected]> Reviewed-by: Chao Gao <[email protected]> Acked-by: Alison Schofield <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Cc:[email protected] Link: https://lore.kernel.org/all/20250624210148.97126F9E%40davehans-spike.ostc.intel.com
1 parent 8b05b3c commit 1cec9ac

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

arch/x86/mm/extable.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,12 @@ static bool ex_handler_sgx(const struct exception_table_entry *fixup,
122122
static bool ex_handler_fprestore(const struct exception_table_entry *fixup,
123123
struct pt_regs *regs)
124124
{
125-
regs->ip = ex_fixup_addr(fixup);
126-
127125
WARN_ONCE(1, "Bad FPU state detected at %pB, reinitializing FPU registers.",
128126
(void *)instruction_pointer(regs));
129127

130128
fpu_reset_from_exception_fixup();
131-
return true;
129+
130+
return ex_handler_default(fixup, regs);
132131
}
133132

134133
/*

0 commit comments

Comments
 (0)