]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: X86: Fix failure to boost kernel lock holder candidate in SEV-ES guests
authorWanpeng Li <wanpengli@tencent.com>
Thu, 22 Apr 2021 08:34:19 +0000 (16:34 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 May 2021 08:52:11 +0000 (10:52 +0200)
commit b86bb11e3a79ac0db9a6786b1fe80f74321cb076 upstream.

Commit f1c6366e3043 ("KVM: SVM: Add required changes to support intercepts under
SEV-ES") prevents hypervisor accesses guest register state when the guest is
running under SEV-ES. The initial value of vcpu->arch.guest_state_protected
is false, it will not be updated in preemption notifiers after this commit which
means that the kernel spinlock lock holder will always be skipped to boost. Let's
fix it by always treating preempted is in the guest kernel mode, false positive
is better than skip completely.

Fixes: f1c6366e3043 (KVM: SVM: Add required changes to support intercepts under SEV-ES)
Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
Message-Id: <1619080459-30032-1-git-send-email-wanpengli@tencent.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/x86.c

index 280e5492864c541864f655d98e4d361210c84f26..daf5633f27ca9945d7d90e47147f452a43980a28 100644 (file)
@@ -11020,6 +11020,9 @@ bool kvm_arch_dy_runnable(struct kvm_vcpu *vcpu)
 
 bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu)
 {
+       if (vcpu->arch.guest_state_protected)
+               return true;
+
        return vcpu->arch.preempted_in_kernel;
 }