OSDN Git Service

KVM: nSVM: ignore L1 interrupt window while running L2 with V_INTR_MASKING=1
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 4 Mar 2020 18:12:35 +0000 (13:12 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 16 Mar 2020 16:58:53 +0000 (17:58 +0100)
commit64b5bd27042639dfcc1534f01771b7b871a02ffe
tree2eda1beffeb4165b8733d0294bef91c54d905013
parentb5ec2e020b7015618781d313a4a6f93c2d2b8144
KVM: nSVM: ignore L1 interrupt window while running L2 with V_INTR_MASKING=1

If a nested VM is started while an IRQ was pending and with
V_INTR_MASKING=1, the behavior of the guest depends on host IF.  If it
is 1, the VM should exit immediately, before executing the first
instruction of the guest, because VMRUN sets GIF back to 1.

If it is 0 and the host has VGIF, however, at the time of the VMRUN
instruction L0 is running the guest with a pending interrupt window
request.  This interrupt window request is completely irrelevant to
L2, since IF only controls virtual interrupts, so this patch drops
INTERCEPT_VINTR from the VMCB while running L2 under these circumstances.
To simplify the code, both steps of enabling the interrupt window
(setting the VINTR intercept and requesting a fake virtual interrupt
in svm_inject_irq) are grouped in the svm_set_vintr function, and
likewise for dismissing the interrupt window request in svm_clear_vintr.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm.c