]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86: Deliver exception payload on KVM_GET_VCPU_EVENTS
authorOliver Upton <oupton@google.com>
Fri, 7 Feb 2020 10:36:06 +0000 (02:36 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 12 Feb 2020 11:34:10 +0000 (12:34 +0100)
commit48a21e47e9e556bfce1fc02329cfd3af6e5f6605
tree0e93155a12a1ab62d71ec6a3dad55576bc621ddb
parented0a4c2e7b10d927036bcd36045547df1e206578
KVM: x86: Deliver exception payload on KVM_GET_VCPU_EVENTS

KVM allows the deferral of exception payloads when a vCPU is in guest
mode to allow the L1 hypervisor to intercept certain events (#PF, #DB)
before register state has been modified. However, this behavior is
incompatible with the KVM_{GET,SET}_VCPU_EVENTS ABI, as userspace
expects register state to have been immediately modified. Userspace may
opt-in for the payload deferral behavior with the
KVM_CAP_EXCEPTION_PAYLOAD per-VM capability. As such,
kvm_multiple_exception() will immediately manipulate guest registers if
the capability hasn't been requested.

Since the deferral is only necessary if a userspace ioctl were to be
serviced at the same as a payload bearing exception is recognized, this
behavior can be relaxed. Instead, opportunistically defer the payload
from kvm_multiple_exception() and deliver the payload before completing
a KVM_GET_VCPU_EVENTS ioctl.

Signed-off-by: Oliver Upton <oupton@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c