[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3ae96202-a121-70a9-fe00-4b5bb4970242@redhat.com>
Date: Fri, 19 Jul 2019 13:09:03 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: Wanpeng Li <kernellwp@...il.com>,
Thomas Lambertz <mail@...maslambertz.de>
Cc: Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Rik van Riel <riel@...riel.com>,
Dave Hansen <dave.hansen@...el.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>,
the arch/x86 maintainers <x86@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
Radim Krcmar <rkrcmar@...hat.com>, kvm <kvm@...r.kernel.org>,
Peter Zijlstra <peterz@...radead.org>,
Marc Orr <marcorr@...gle.com>,
Dave Hansen <dave.hansen@...el.com>
Subject: Re: [5.2 regression] x86/fpu changes cause crashes in KVM guest
On 19/07/19 10:59, Wanpeng Li wrote:
> https://lkml.org/lkml/2017/11/14/891, "The scheduler will save the
> guest fpu context when a vCPU thread is preempted, and restore it when
> it is scheduled back in." But I can't find any scheduler codes do
> this.
That's because applying commit 240c35a37 was completely wrong. The idea
before commit 240c35a37 was that you have the following FPU states:
userspace (QEMU) guest
---------------------------------------------------------------------------
processor vcpu->arch.guest_fpu
>>> KVM_RUN: kvm_load_guest_fpu
vcpu->arch.user_fpu processor
>>> preempt out
vcpu->arch.user_fpu current->thread.fpu
>>> preempt in
vcpu->arch.user_fpu processor
>>> back to userspace
>>> kvm_put_guest_fpu
processor vcpu->arch.guest_fpu
---------------------------------------------------------------------------
After removing user_fpu, QEMU's FPU state is destroyed when KVM_RUN is
preempted. So that's already messed up (I'll send a revert), and given
the diagram above your patch makes total sense.
With the new lazy model we want to hook into kvm_vcpu_arch_load and get
the state back to the processor from current->thread.fpu, and indeed
switch_fpu_return is essentially copy_kernel_to_fpregs(¤t->thread.
fpu->state).
However I would keep the fpregs_assert_state_consistent in
kvm_arch_vcpu_load, and also
WARN_ON_ONCE(test_thread_flag(TIF_NEED_FPU_LOAD)) in vcpu_enter_guest.
Paolo
Powered by blists - more mailing lists