On 27/12/17 13:31, Paolo Bonzini wrote:
On 24/12/2017 17:13, Liran Alon wrote:
If L1 doesn't intercept L2 HLT (doesn't set CPU_BASED_HLT_EXITING),
then when L2 executes HLT instruction, KVM will block vCPU from
further execution (just like what happens when L1 executes HLT).
Thus, when some CPU sends nested-posted-interrupt to a halted
L2 vCPU, vmx_deliver_nested_posted_interrupt() notes that
vcpu->mode != IN_GUEST_MODE and therefore doesn't send a physical IPI.
Because the dest vCPU is blocked by HLT, we should kick it.
In patch 9, you write "in addition, assume that dest CPU passes the
checks for pending kvm requests before sender sets KVM_REQ_EVENT". But,
this is pretty much the same scenario that you are fixing here (except
without KVM_REQ_EVENT involvement).
So patch 10 should be placed *before patch 9* and it should do something
like this:
- kvm_vcpu_trigger_posted_interrupt(vcpu, true);
...
kvm_make_request(KVM_REQ_EVENT, vcpu);
+ if (!kvm_vcpu_trigger_posted_interrupt(vcpu, true))
+ kvm_vcpu_kick(vcpu);
with patch 9's commit message adjusted.
Paolo
I think that current patch series makes more sense than reordering them.
This is because the patch you are suggesting will actually, as a
side-effect, fix the bug that is fixed in commit "KVM: nVMX: Deliver
missed nested-PI notification-vector via self-IPI while interrupts
disabled". This is actually the same as the first patch I suggested for
fixing the bug in v1 of this series:
http://lkml.kernel.org/r/1510252040-5609-1-git-send-email-liran.alon@xxxxxxxxxx
After I submitted v1, Radim mentioned that even though the fix is
correct, it is awkward and error-prone. I agreed and therefore we have
written another fix using self-IPI.
Therefore, to preserve each commit fixing only one problem, I prefer to
keep the orders of commits as they are now.
Regards,
-Liran