Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revert "kvm: x86: Use task structs fpu field for user"

This reverts commit 240c35a3783ab9b3a0afaba0dde7291295680a6b
("kvm: x86: Use task structs fpu field for user", 2018-11-06).
The commit is broken and causes QEMU's FPU state to be destroyed
when KVM_RUN is preempted.

Fixes: 240c35a3783a ("kvm: x86: Use task structs fpu field for user")
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

+6 -5
+4 -3
arch/x86/include/asm/kvm_host.h
··· 607 607 608 608 /* 609 609 * QEMU userspace and the guest each have their own FPU state. 610 - * In vcpu_run, we switch between the user, maintained in the 611 - * task_struct struct, and guest FPU contexts. While running a VCPU, 612 - * the VCPU thread will have the guest FPU context. 610 + * In vcpu_run, we switch between the user and guest FPU contexts. 611 + * While running a VCPU, the VCPU thread will have the guest FPU 612 + * context. 613 613 * 614 614 * Note that while the PKRU state lives inside the fpu registers, 615 615 * it is switched out separately at VMENTER and VMEXIT time. The 616 616 * "guest_fpu" state here contains the guest FPU context, with the 617 617 * host PRKU bits. 618 618 */ 619 + struct fpu user_fpu; 619 620 struct fpu *guest_fpu; 620 621 621 622 u64 xcr0;
+2 -2
arch/x86/kvm/x86.c
··· 8270 8270 { 8271 8271 fpregs_lock(); 8272 8272 8273 - copy_fpregs_to_fpstate(&current->thread.fpu); 8273 + copy_fpregs_to_fpstate(&vcpu->arch.user_fpu); 8274 8274 /* PKRU is separately restored in kvm_x86_ops->run. */ 8275 8275 __copy_kernel_to_fpregs(&vcpu->arch.guest_fpu->state, 8276 8276 ~XFEATURE_MASK_PKRU); ··· 8287 8287 fpregs_lock(); 8288 8288 8289 8289 copy_fpregs_to_fpstate(vcpu->arch.guest_fpu); 8290 - copy_kernel_to_fpregs(&current->thread.fpu.state); 8290 + copy_kernel_to_fpregs(&vcpu->arch.user_fpu.state); 8291 8291 8292 8292 fpregs_mark_activate(); 8293 8293 fpregs_unlock();