All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Alison Schofield <alison.schofield@intel.com>,
	Dave Hansen <dave.hansen@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org, tglx@linutronix.de,
	bp@alien8.de, mingo@kernel.org,
	"Chang S. Bae" <chang.seok.bae@intel.com>,
	Eric Biggers <ebiggers@google.com>,
	Rik van Riel <riel@redhat.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] x86/fpu: Delay instruction pointer fixup until after after warning
Date: Wed, 18 Jun 2025 12:58:09 -0700	[thread overview]
Message-ID: <71c1c545-da20-42ba-9249-0946d9c9edec@intel.com> (raw)
In-Reply-To: <aFMYsfwyALoi_X_x@aschofie-mobl2.lan>

[-- Attachment #1: Type: text/plain, Size: 625 bytes --]

On 6/18/25 12:51, Alison Schofield wrote:
>> Do not fix up RIP until after printing the warning.
> How was this found and how is the change verified?

Good questions.

I found it from an Intel-internal bug report. It's not clear what's
causing the underlying XRSTOR #GP. But I spent some time scratching my
head about how RIP got pointing to the wrong place. I was blaming the
simulator at first.

I validated the fix using the attached patch. It waits until there's a
program named "dave" running, then corrupts the XSAVE buffer in a way
that will cause XRSTOR to #GP, triggering the warning that was off by an
instruction.

[-- Attachment #2: os_rstor_fun.patch --]
[-- Type: text/x-patch, Size: 576 bytes --]



---

 b/arch/x86/kernel/fpu/core.c |    3 +++
 1 file changed, 3 insertions(+)

diff -puN arch/x86/kernel/fpu/core.c~os_rstor_fun arch/x86/kernel/fpu/core.c
--- a/arch/x86/kernel/fpu/core.c~os_rstor_fun	2025-06-18 11:22:58.583510842 -0700
+++ b/arch/x86/kernel/fpu/core.c	2025-06-18 11:23:46.626730032 -0700
@@ -202,6 +202,9 @@ void restore_fpregs_from_fpstate(struct
 		 */
 		mask = fpu_kernel_cfg.max_features & mask;
 
+		if (!strncmp(current->comm, "dave", 4))
+			fpstate->regs.xsave.header.xcomp_bv = 0;
+
 		os_xrstor(fpstate, mask);
 	} else {
 		if (use_fxsr())
_

  reply	other threads:[~2025-06-18 19:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-18 19:33 [PATCH] x86/fpu: Delay instruction pointer fixup until after after warning Dave Hansen
2025-06-18 19:51 ` Alison Schofield
2025-06-18 19:58   ` Dave Hansen [this message]
2025-06-19  2:37 ` Chao Gao
2025-06-24 20:59   ` Dave Hansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=71c1c545-da20-42ba-9249-0946d9c9edec@intel.com \
    --to=dave.hansen@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=bp@alien8.de \
    --cc=chang.seok.bae@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=ebiggers@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=riel@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.