mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 10:34:58 -06:00
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>
This commit is contained in:
parent
ebbfef2f34
commit
fd13f23b8c
6 changed files with 187 additions and 24 deletions
|
@ -605,7 +605,9 @@ static void hvf_store_events(CPUState *cpu, uint32_t ins_len, uint64_t idtvec_in
|
|||
X86CPU *x86_cpu = X86_CPU(cpu);
|
||||
CPUX86State *env = &x86_cpu->env;
|
||||
|
||||
env->exception_injected = -1;
|
||||
env->exception_nr = -1;
|
||||
env->exception_pending = 0;
|
||||
env->exception_injected = 0;
|
||||
env->interrupt_injected = -1;
|
||||
env->nmi_injected = false;
|
||||
if (idtvec_info & VMCS_IDT_VEC_VALID) {
|
||||
|
@ -619,7 +621,8 @@ static void hvf_store_events(CPUState *cpu, uint32_t ins_len, uint64_t idtvec_in
|
|||
break;
|
||||
case VMCS_IDT_VEC_HWEXCEPTION:
|
||||
case VMCS_IDT_VEC_SWEXCEPTION:
|
||||
env->exception_injected = idtvec_info & VMCS_IDT_VEC_VECNUM;
|
||||
env->exception_nr = idtvec_info & VMCS_IDT_VEC_VECNUM;
|
||||
env->exception_injected = 1;
|
||||
break;
|
||||
case VMCS_IDT_VEC_PRIV_SWEXCEPTION:
|
||||
default:
|
||||
|
@ -912,7 +915,8 @@ int hvf_vcpu_exec(CPUState *cpu)
|
|||
macvm_set_rip(cpu, rip + ins_len);
|
||||
break;
|
||||
case VMX_REASON_VMCALL:
|
||||
env->exception_injected = EXCP0D_GPF;
|
||||
env->exception_nr = EXCP0D_GPF;
|
||||
env->exception_injected = 1;
|
||||
env->has_error_code = true;
|
||||
env->error_code = 0;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue