public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	 "Kernel Mailing List, Linux" <linux-kernel@vger.kernel.org>,
	kvm <kvm@vger.kernel.org>,
	 "the arch/x86 maintainers" <x86@kernel.org>
Subject: Re: [PATCH v2 0/4] x86, fpu/kvm: fix crash with AMX
Date: Thu, 15 Jan 2026 09:12:54 -0800	[thread overview]
Message-ID: <aWkgFv_allv34JYY@google.com> (raw)
In-Reply-To: <20260115170511.GFaWkeR1TuFMlzy2LJ@fat_crate.local>

On Thu, Jan 15, 2026, Borislav Petkov wrote:
> On Thu, Jan 15, 2026 at 08:39:51AM -0800, Sean Christopherson wrote:
> >  :   1. vCPU loads non-init XTILE data without ever setting XFD to a non-zero value
> >  :      (KVM only disables XFD interception on writes with a non-zero value).
> >  :   2. Guest executes WRMSR(MSR_IA32_XFD) to set XFD[18] = 1
> >  :   3. VM-Exit due to the WRMSR
> >  :   4. Host IRQ arrives and triggers kernel_fpu_begin()
> >  :   5. save_fpregs_to_fpstate() saves guest FPU with XFD[18]=0
> >  :   6. fpu_update_guest_xfd() stuffs guest_fpu->fpstate->xfd = XFD[18]=1
> >  :   7. vcpu_enter_guest() attempts to load XTILE data with XFD[18]=1
> 
> I don't know, maybe I'm missing an important aspect but if not, I'm wondering
> how you folks are not seeing the big honking discrepancy here.
> 
> *Anything* poking in MSRs under the kernel's feet where the kernel doesn't
> know about that poking, is bound to cause trouble. And this is no exception.

KVM isn't poking the MSR, KVM is literally calling a kernel API, fpu_update_guest_xfd(),
to ask/tell the kernel to update the guest's XFD.  It's the FPU code that's buggy,
because it doesn't ensure the state _it_ saved _without KVM's knowledge_ is
consistent with new XFD.

> Step 5. above should use the updated XFD[18]=1. The guest just disabled that
> state! Anything else is bonkers.

As I explained in my previous reply, that's easier said than done:

  In theory we could ensure KVM saved exactly what is resident in hardware, but
  that's quite tricky (and costly!) as it would require doing xfd_update_state()
  before _every_ save_fpregs_to_fpstate(), e.g. not just in fpu_swap_kvm_fpstate().
  E.g. if the host kernel used the FPU from IRQ context (spoiler alert!), then KVM
  wouldn't have a chance to swap in the maximal XFD[18]=0 value (i.e. the userspace
  task's XFD).

  reply	other threads:[~2026-01-15 17:12 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-01  9:05 [PATCH v2 0/4] x86, fpu/kvm: fix crash with AMX Paolo Bonzini
2026-01-01  9:05 ` [PATCH 1/4] x86/fpu: Clear XSTATE_BV[i] in save state whenever XFD[i]=1 Paolo Bonzini
2026-01-03  2:06   ` Yao Yuan
2026-01-05 17:31     ` Sean Christopherson
2026-01-06  5:25       ` Yao Yuan
2026-01-06  0:54   ` Jim Mattson
2026-01-06  1:17     ` Sean Christopherson
2026-01-06 17:56       ` Jim Mattson
2026-01-15 16:07         ` Dave Hansen
2026-01-15 16:12           ` Paolo Bonzini
2026-01-15 16:27             ` Dave Hansen
2026-01-07  0:28   ` Chang S. Bae
2026-01-07 22:33     ` Paolo Bonzini
2026-01-08  3:06   ` Binbin Wu
2026-01-08 16:26     ` Paolo Bonzini
2026-01-15 15:54   ` Dave Hansen
2026-01-15 16:22     ` Paolo Bonzini
2026-01-15 18:19       ` Dave Hansen
2026-01-15 18:26         ` Paolo Bonzini
2026-01-15 23:43         ` Chang S. Bae
2026-01-01  9:05 ` [PATCH 2/4] selftests: kvm: replace numbered sync points with actions Paolo Bonzini
2026-01-06  0:02   ` Sean Christopherson
2026-01-07 22:28     ` Paolo Bonzini
2026-01-08 20:26       ` Sean Christopherson
2026-01-01  9:05 ` [PATCH 3/4] selftests: kvm: try getting XFD and XSAVE state out of sync Paolo Bonzini
2026-01-01  9:05 ` [PATCH 4/4] selftests: kvm: Verify TILELOADD actually #NM faults when XFD[18]=1 Paolo Bonzini
2026-01-06  1:18 ` [PATCH v2 0/4] x86, fpu/kvm: fix crash with AMX Sean Christopherson
2026-01-15 12:22 ` Borislav Petkov
2026-01-15 13:49   ` Paolo Bonzini
2026-01-15 16:39     ` Sean Christopherson
2026-01-15 17:05       ` Borislav Petkov
2026-01-15 17:12         ` Sean Christopherson [this message]
2026-01-16 12:22 ` Borislav Petkov
2026-01-21 11:35   ` Paolo Bonzini
2026-01-22 11:12     ` Borislav Petkov
2026-01-22 12:00       ` Paolo Bonzini
2026-01-23 13:23         ` Borislav Petkov

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=aWkgFv_allv34JYY@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox