Skip to content

Commit cf3215d

Browse files
jsmattsonjrbonzini
authored andcommitted
kvm: nVMX: Fetch VM_INSTRUCTION_ERROR from vmcs02 on vmx->fail
When forwarding a hardware VM-entry failure to L1, fetch the VM_INSTRUCTION_ERROR field from vmcs02 before loading vmcs01. (Note that there is an implicit assumption that the VM-entry failure was on the first VM-entry to vmcs02 after nested_vmx_run; otherwise, L1 is going to be very confused.) Signed-off-by: Jim Mattson <[email protected]> Reviewed-by: Peter Feiner <[email protected]> Signed-off-by: Radim Krčmář <[email protected]>
1 parent 66d73e1 commit cf3215d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

arch/x86/kvm/vmx.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10755,6 +10755,7 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason,
1075510755
{
1075610756
struct vcpu_vmx *vmx = to_vmx(vcpu);
1075710757
struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
10758+
u32 vm_inst_error = 0;
1075810759

1075910760
/* trying to cancel vmlaunch/vmresume is a bug */
1076010761
WARN_ON_ONCE(vmx->nested.nested_run_pending);
@@ -10767,6 +10768,9 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason,
1076710768
vmcs12->vm_exit_msr_store_count))
1076810769
nested_vmx_abort(vcpu, VMX_ABORT_SAVE_GUEST_MSR_FAIL);
1076910770

10771+
if (unlikely(vmx->fail))
10772+
vm_inst_error = vmcs_read32(VM_INSTRUCTION_ERROR);
10773+
1077010774
vmx_load_vmcs01(vcpu);
1077110775

1077210776
if ((exit_reason == EXIT_REASON_EXTERNAL_INTERRUPT)
@@ -10843,7 +10847,7 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason,
1084310847
*/
1084410848
if (unlikely(vmx->fail)) {
1084510849
vmx->fail = 0;
10846-
nested_vmx_failValid(vcpu, vmcs_read32(VM_INSTRUCTION_ERROR));
10850+
nested_vmx_failValid(vcpu, vm_inst_error);
1084710851
} else
1084810852
nested_vmx_succeed(vcpu);
1084910853
if (enable_shadow_vmcs)

0 commit comments

Comments
 (0)