diff options
| author | Dave Hansen <dave.hansen@linux.intel.com> | 2025-06-24 14:01:48 -0700 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-08-15 12:05:13 +0200 |
| commit | f5d093ba71529ae50b3786a2af83fd394df98e63 (patch) | |
| tree | 18021d4d1029225b2d25c8bf8ba5519029a39e02 | |
| parent | 57c0b846a364ae2c98c594071bddc3e98c303f03 (diff) | |
| download | linux-f5d093ba71529ae50b3786a2af83fd394df98e63.tar.gz linux-f5d093ba71529ae50b3786a2af83fd394df98e63.tar.bz2 linux-f5d093ba71529ae50b3786a2af83fd394df98e63.zip | |
x86/fpu: Delay instruction pointer fixup until after warning
commit 1cec9ac2d071cfd2da562241aab0ef701355762a upstream.
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: d5c8028b4788 ("x86/fpu: Reinitialize FPU registers if restoring FPU state fails")
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Chao Gao <chao.gao@intel.com>
Acked-by: Alison Schofield <alison.schofield@intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc:stable@vger.kernel.org
Link: https://lore.kernel.org/all/20250624210148.97126F9E%40davehans-spike.ostc.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | arch/x86/mm/extable.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c index 60814e110a54..fcb8e7af5b4d 100644 --- a/arch/x86/mm/extable.c +++ b/arch/x86/mm/extable.c @@ -121,13 +121,12 @@ static bool ex_handler_sgx(const struct exception_table_entry *fixup, static bool ex_handler_fprestore(const struct exception_table_entry *fixup, struct pt_regs *regs) { - regs->ip = ex_fixup_addr(fixup); - WARN_ONCE(1, "Bad FPU state detected at %pB, reinitializing FPU registers.", (void *)instruction_pointer(regs)); fpu_reset_from_exception_fixup(); - return true; + + return ex_handler_default(fixup, regs); } static bool ex_handler_uaccess(const struct exception_table_entry *fixup, |
