[Devel] [PATCH 10/11] KVM: x86: track manually whether an event has been injected
Alexander Mikhalitsyn
alexander.mikhalitsyn at virtuozzo.com
Thu Jun 23 12:55:22 MSK 2022
From: Paolo Bonzini <pbonzini at redhat.com>
Instead of calling kvm_event_needs_reinjection, track its
future return value in a variable. This will be useful in
the next patch.
Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
(cherry picked from commit c6b22f59d694d0caf61aefb262d9639b3d9661d5)
Replaced vcpu->arch.interrupt.injected -> vcpu->arch.interrupt.pending
https://jira.sw.ru/browse/PSBM-139278
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
---
arch/x86/kvm/x86.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index e09926e02826..9cabc1c7914e 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6625,20 +6625,26 @@ static void update_cr8_intercept(struct kvm_vcpu *vcpu)
static int inject_pending_event(struct kvm_vcpu *vcpu)
{
int r;
+ bool can_inject = true;
/* try to reinject previous events if any */
- if (vcpu->arch.exception.injected)
+ if (vcpu->arch.exception.injected) {
kvm_x86_ops->queue_exception(vcpu);
+ can_inject = false;
+ }
/*
* Exceptions must be injected immediately, or the exception
* frame will have the address of the NMI or interrupt handler.
*/
else if (!vcpu->arch.exception.pending) {
- if (vcpu->arch.nmi_injected)
+ if (vcpu->arch.nmi_injected) {
kvm_x86_ops->set_nmi(vcpu);
- else if (vcpu->arch.interrupt.pending)
+ can_inject = false;
+ } else if (vcpu->arch.interrupt.pending) {
kvm_x86_ops->set_irq(vcpu);
+ can_inject = false;
+ }
}
/*
@@ -6674,10 +6680,11 @@ static int inject_pending_event(struct kvm_vcpu *vcpu)
}
kvm_x86_ops->queue_exception(vcpu);
+ can_inject = false;
}
- /* Don't consider new event if we re-injected an event */
- if (kvm_event_needs_reinjection(vcpu))
+ /* Finish re-injection before considering new events */
+ if (!can_inject)
return 0;
if (vcpu->arch.smi_pending && kvm_x86_ops->smi_allowed(vcpu, true)) {
--
2.36.1
More information about the Devel
mailing list