target/i386: kvm: Add support for KVM_CAP_EXCEPTION_PAYLOAD
authorLiran Alon <liran.alon@oracle.com>
Wed, 19 Jun 2019 16:21:39 +0000 (19:21 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 21 Jun 2019 11:25:27 +0000 (13:25 +0200)
commitfd13f23b8c95311eff74426921557eee592b0ed3
treeb112c3c639e5f6d4b8fec7d721fa17603972fdd8
parentebbfef2f34cfc749c045a4569dedb4f748ec024a
target/i386: kvm: Add support for KVM_CAP_EXCEPTION_PAYLOAD

Kernel commit c4f55198c7c2 ("kvm: x86: Introduce KVM_CAP_EXCEPTION_PAYLOAD")
introduced a new KVM capability which allows userspace to correctly
distinguish between pending and injected exceptions.

This distinguish is important in case of nested virtualization scenarios
because a L2 pending exception can still be intercepted by the L1 hypervisor
while a L2 injected exception cannot.

Furthermore, when an exception is attempted to be injected by QEMU,
QEMU should specify the exception payload (CR2 in case of #PF or
DR6 in case of #DB) instead of having the payload already delivered in
the respective vCPU register. Because in case exception is injected to
L2 guest and is intercepted by L1 hypervisor, then payload needs to be
reported to L1 intercept (VMExit handler) while still preserving
respective vCPU register unchanged.

This commit adds support for QEMU to properly utilise this new KVM
capability (KVM_CAP_EXCEPTION_PAYLOAD).

Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
Message-Id: <20190619162140.133674-10-liran.alon@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/cpu.c
target/i386/cpu.h
target/i386/hvf/hvf.c
target/i386/hvf/x86hvf.c
target/i386/kvm.c
target/i386/machine.c