KVM: X86: Fix always skip to boost kernel lock holder candidate for SEV-ES guests
PATCH 1/1 KVM: X86: Fix always skip to boost kernel lock holder candidate for SEV-ES guests
From: Wanpeng Li <[email protected]>
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.
--- arch/x86/kvm/x86.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/x86.c +3 -0
@@ -11151,6 +11151,9 @@ bool kvm_arch_dy_has_pending_interrupt(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; }
Signature · 1 line
2.7.4
Quoted 22 lines · Wanpeng Li
From: Wanpeng Li <[email protected]>
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 ofvcpu->arch.guest_state_protectedis 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 <[email protected]>--- arch/x86/kvm/x86.c | 3 +++ 1 file changed, 3 insertions(+)arch/x86/kvm/x86.c +0
-0
arch/x86/kvm/x86.c bool kvm_arch_dy_has_pending_interrupt(struct kvm_vcpu *vcpu) · line 11159
Quoted 9 lines
arch/x86/kvm/x86.c +3
-0@@ -11151,6 +11151,9 @@ bool kvm_arch_dy_has_pending_interrupt(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; }
Queued, thanks.
Paolo