Skip to content

Commit 7de373c

Browse files
sean-jcgregkh
authored andcommitted
KVM: x86: Drop WARNs that assert a triple fault never "escapes" from L2
commit 4584666 upstream. Remove WARNs that sanity check that KVM never lets a triple fault for L2 escape and incorrectly end up in L1. In normal operation, the sanity check is perfectly valid, but it incorrectly assumes that it's impossible for userspace to induce KVM_REQ_TRIPLE_FAULT without bouncing through KVM_RUN (which guarantees kvm_check_nested_state() will see and handle the triple fault). The WARN can currently be triggered if userspace injects a machine check while L2 is active and CR4.MCE=0. And a future fix to allow save/restore of KVM_REQ_TRIPLE_FAULT, e.g. so that a synthesized triple fault isn't lost on migration, will make it trivially easy for userspace to trigger the WARN. Clearing KVM_REQ_TRIPLE_FAULT when forcibly leaving guest mode is tempting, but wrong, especially if/when the request is saved/restored, e.g. if userspace restores events (including a triple fault) and then restores nested state (which may forcibly leave guest mode). Ignoring the fact that KVM doesn't currently provide the necessary APIs, it's userspace's responsibility to manage pending events during save/restore. ------------[ cut here ]------------ WARNING: CPU: 7 PID: 1399 at arch/x86/kvm/vmx/nested.c:4522 nested_vmx_vmexit+0x7fe/0xd90 [kvm_intel] Modules linked in: kvm_intel kvm irqbypass CPU: 7 PID: 1399 Comm: state_test Not tainted 5.17.0-rc3+ #808 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 RIP: 0010:nested_vmx_vmexit+0x7fe/0xd90 [kvm_intel] Call Trace: <TASK> vmx_leave_nested+0x30/0x40 [kvm_intel] vmx_set_nested_state+0xca/0x3e0 [kvm_intel] kvm_arch_vcpu_ioctl+0xf49/0x13e0 [kvm] kvm_vcpu_ioctl+0x4b9/0x660 [kvm] __x64_sys_ioctl+0x83/0xb0 do_syscall_64+0x3b/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae </TASK> ---[ end trace 0000000000000000 ]--- Fixes: cb6a32c ("KVM: x86: Handle triple fault in L2 without killing L1") Cc: [email protected] Cc: Chenyi Qiang <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f095b99 commit 7de373c

File tree

2 files changed

+0
-6
lines changed

2 files changed

+0
-6
lines changed

arch/x86/kvm/svm/nested.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,6 @@ int nested_svm_vmexit(struct vcpu_svm *svm)
819819
struct kvm_host_map map;
820820
int rc;
821821

822-
/* Triple faults in L2 should never escape. */
823-
WARN_ON_ONCE(kvm_check_request(KVM_REQ_TRIPLE_FAULT, vcpu));
824-
825822
rc = kvm_vcpu_map(vcpu, gpa_to_gfn(svm->nested.vmcb12_gpa), &map);
826823
if (rc) {
827824
if (rc == -EINVAL)

arch/x86/kvm/vmx/nested.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4518,9 +4518,6 @@ void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 vm_exit_reason,
45184518
/* trying to cancel vmlaunch/vmresume is a bug */
45194519
WARN_ON_ONCE(vmx->nested.nested_run_pending);
45204520

4521-
/* Similarly, triple faults in L2 should never escape. */
4522-
WARN_ON_ONCE(kvm_check_request(KVM_REQ_TRIPLE_FAULT, vcpu));
4523-
45244521
if (kvm_check_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu)) {
45254522
/*
45264523
* KVM_REQ_GET_NESTED_STATE_PAGES is also used to map

0 commit comments

Comments
 (0)