Re: [PATCH 2/5] KVM: x86: do not scan IRR twice on APICv vmentry
From: Paolo Bonzini
Date: Fri Nov 04 2016 - 05:39:56 EST
On 03/11/2016 21:16, Radim KrÄmÃÅ wrote:
> > + if (!pi_test_on(&vmx->pi_desc))
>
> We don't call vmx_hwapic_irr_update() when returning early.
This might be a good start, but it's on purpose: IRR is not changing and
the invariant _should_ be that RVI=highest-bit(IRR):
- IRR cleared by processor: see SDM 29.2.2 Virtual-interrupt delivery
- IRR set by processor: see SDM 29.6 Posted-interrupt processing
- IRR set by KVM: ON=1 so it doesn't exit here
- IRR cleared by KVM: might indeed be buggy here, but the next patch
does add a
+ kvm_x86_ops->hwapic_irr_update(vcpu,
+ apic_find_highest_irr(apic));
to apic_clear_irr, which doesn't fix the bug (and doesn't fix it also if
backported here).
So we're missing a place where IRR has changed but RVI is not being
updated. It should be related to vmx_check_nested_events and
kvm_cpu_has_interrupt as you said, but I cannot really see it.
Paolo
>> > + return;
>> > +
>> > + pi_clear_on(&vmx->pi_desc);
>> > + max_irr = kvm_apic_update_irr(vcpu, vmx->pi_desc.pir);
>> > + vmx_hwapic_irr_update(vcpu, max_irr);
>> > +}