On 26/11/20 18:29, David Woodhouse wrote:
On Thu, 2020-11-26 at 11:10 +0000, David Woodhouse wrote:
whether or not there's an IRQ in the
LAPIC should be irrelevant when deciding to exit to userspace. Note, the
reinjection check covers vcpu->arch.interrupt.injected for the case where LAPIC
is in userspace.
return kvm_arch_interrupt_allowed(vcpu) &&
(!lapic_in_kernel(vcpu) || !kvm_cpu_has_extint(vcpu)) &&
!kvm_event_needs_reinjection(vcpu) &&
kvm_cpu_accept_dm_intr(vcpu);
}
Makes sense. I'm putting this version through some testing and will
post it later...
Hm, that survived enough test iterations to persuade me to post it, but
then seems to have fallen over later. I'm reverting to the
kvm_cpu_has_injectable_intr() version to leave that one running too and
be sure it's gone in that.
!kvm_cpu_has_injectable_intr(vcpu) boils down (assuming no nested virt) to
if (!lapic_in_kernel(v))
return !v->arch.interrupt.injected;
if (kvm_cpu_has_extint(v))
return 0;
return 1;
and Sean's proposal instead is the same indeed (the first "if" doesn't
matter), so there may be more than one bug.
But it turns out that with some more inlining and Boolean algebra, we
can actually figure out what the code does. :) I had just finished
writing a looong review of your patch starting from that idea, so I'll
post it.
Paolo