Liran Alon e6c67d8cf1 KVM: nVMX: Wake blocked vCPU in guest-mode if pending interrupt in virtual APICv
In case L1 do not intercept L2 HLT or enter L2 in HLT activity-state,
it is possible for a vCPU to be blocked while it is in guest-mode.

According to Intel SDM 26.6.5 Interrupt-Window Exiting and
Virtual-Interrupt Delivery: "These events wake the logical processor
if it just entered the HLT state because of a VM entry".
Therefore, if L1 enters L2 in HLT activity-state and L2 has a pending
deliverable interrupt in vmcs12->guest_intr_status.RVI, then the vCPU
should be waken from the HLT state and injected with the interrupt.

In addition, if while the vCPU is blocked (while it is in guest-mode),
it receives a nested posted-interrupt, then the vCPU should also be
waken and injected with the posted interrupt.

To handle these cases, this patch enhances kvm_vcpu_has_events() to also
check if there is a pending interrupt in L2 virtual APICv provided by
L1. That is, it evaluates if there is a pending virtual interrupt for L2
by checking RVI[7:4] > VPPR[7:4] as specified in Intel SDM 29.2.1
Evaluation of Pending Interrupts.

Note that this also handles the case of nested posted-interrupt by the
fact RVI is updated in vmx_complete_nested_posted_interrupt() which is
called from kvm_vcpu_check_block() -> kvm_arch_vcpu_runnable() ->
kvm_vcpu_running() -> vmx_check_nested_events() ->
vmx_complete_nested_posted_interrupt().

Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-09-20 00:51:44 +02:00
..
2018-08-19 10:38:36 -07:00
2018-09-03 12:41:41 +02:00
2018-02-15 01:15:50 +01:00
2018-07-25 11:53:59 +02:00
2018-03-20 10:01:57 +01:00
2018-01-30 15:08:27 +01:00
2018-05-19 13:55:40 +02:00
2018-08-15 13:44:10 -07:00
2017-12-22 20:13:04 +01:00
2017-12-04 10:56:53 +10:00
2017-12-22 20:13:01 +01:00
2018-08-19 10:38:36 -07:00
2017-07-26 13:18:20 +02:00
2018-05-07 07:15:41 +02:00
2018-06-07 10:23:33 -07:00
2018-07-20 01:11:45 +02:00
2017-11-15 18:21:05 -08:00
2018-03-28 22:47:06 +02:00
2018-03-20 10:01:57 +01:00
2018-05-09 21:41:38 +02:00
2018-09-01 23:01:56 +02:00
2017-11-15 18:21:04 -08:00