From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D54752EE5E8; Tue, 12 Aug 2025 18:26:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755023179; cv=none; b=pRCjudKsF5FuTfhCw3fM8zwX7bn3vzayW/LHO12kqaKofEaRZ+PnHe8XaabhO0VBAuEQ5LvSu+6Oi1aQghmw7MRRocbE5bzu+73GrUxuBKfnFM88oB478f7O1PXq20RtghrCbdg6142QSGfMLumv/Bjq2WnAdOzDpp9QwAeB7ws= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755023179; c=relaxed/simple; bh=/xWrYALAHaejhGBv0Pq8JYDFhlOTAfP2IowSPWMMBcE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TAx1IY5PyrGmafLP2KSpn4c/0iQnk5OSwMgQBQl+dM7BUvudMGPH91ZzQzx/2qNb2ZBHTUD7+0D2G1oR069Oz6wZ9OoQZ88O0PHtz3V+Dgz24orEEQQacjZt7cmcGuE/dRTC78y358jXF3wKCVYlq/zXfpjkN0cXYUqD4pyghs8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=SZygCchs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="SZygCchs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39BCCC4CEF0; Tue, 12 Aug 2025 18:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1755023179; bh=/xWrYALAHaejhGBv0Pq8JYDFhlOTAfP2IowSPWMMBcE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SZygCchsaes+BRxZMfhrzphRPwncuKVNFCBwFJ5fvu2i5BkvX8oIIXU2DVZsZT75B 2BjlopVoYe3o2mhKe+ZoHQzr4J3K2++XkvXPzPhKNun1pHGzreFMPKQuP2DdUbuNTx Eu7y9RQQBVkFL0/JNEiRu4tY6W+3H1BF9OzR/xPU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dave Hansen , Chao Gao , Alison Schofield , "Peter Zijlstra (Intel)" Subject: [PATCH 6.12 359/369] x86/fpu: Delay instruction pointer fixup until after warning Date: Tue, 12 Aug 2025 19:30:56 +0200 Message-ID: <20250812173030.193134057@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250812173014.736537091@linuxfoundation.org> References: <20250812173014.736537091@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dave Hansen 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 Reviewed-by: Chao Gao Acked-by: Alison Schofield Acked-by: Peter Zijlstra (Intel) Cc:stable@vger.kernel.org Link: https://lore.kernel.org/all/20250624210148.97126F9E%40davehans-spike.ostc.intel.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/mm/extable.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/arch/x86/mm/extable.c +++ b/arch/x86/mm/extable.c @@ -122,13 +122,12 @@ static bool ex_handler_sgx(const struct 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); } /*