Re: [PATCH v3 1/4] KVM: x86: refactor req_immediate_exit logic
From: Paolo Bonzini
Date: Fri Nov 24 2023 - 11:07:45 EST
On 9/28/23 12:36, Maxim Levitsky wrote:
@@ -4176,6 +4176,9 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu)
clgi();
kvm_load_guest_xsave_state(vcpu);
+ if (vcpu->arch.req_immediate_exit)
+ smp_send_reschedule(vcpu->cpu);
+
This code is in a non-standard situation where IF=1 but interrupts are
effectively disabled. Better something like:
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index beea99c8e8e0..3b945de2d880 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -4148,8 +4148,11 @@ static __no_kcsan fastpath_t svm_vcpu_run(
* is enough to force an immediate vmexit.
*/
disable_nmi_singlestep(svm);
+ vcpu->arch.req_immediate_exit = true;
+ }
+
+ if (vcpu->arch.req_immediate_exit)
smp_send_reschedule(vcpu->cpu);
- }
pre_svm_run(vcpu);
Paolo