[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aWkgFv_allv34JYY@google.com>
Date: Thu, 15 Jan 2026 09:12:54 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Borislav Petkov <bp@...en8.de>
Cc: Paolo Bonzini <pbonzini@...hat.com>,
"Kernel Mailing List, Linux" <linux-kernel@...r.kernel.org>, kvm <kvm@...r.kernel.org>,
"the arch/x86 maintainers" <x86@...nel.org>
Subject: Re: [PATCH v2 0/4] x86, fpu/kvm: fix crash with AMX
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).
Powered by blists - more mailing lists