]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: nSVM: Always intercept VMMCALL when L2 is active
authorSean Christopherson <seanjc@google.com>
Wed, 4 Mar 2026 00:22:23 +0000 (16:22 -0800)
committerSean Christopherson <seanjc@google.com>
Thu, 5 Mar 2026 00:08:56 +0000 (16:08 -0800)
Always intercept VMMCALL now that KVM properly synthesizes a #UD as
appropriate, i.e. when L1 doesn't want to intercept VMMCALL, to avoid
putting L2 into an infinite #UD loop if KVM_X86_QUIRK_FIX_HYPERCALL_INSN
is enabled.

By letting L2 execute VMMCALL natively and thus #UD, for all intents and
purposes KVM morphs the VMMCALL intercept into a #UD intercept (KVM always
intercepts #UD).  When the hypercall quirk is enabled, KVM "emulates"
VMMCALL in response to the #UD by trying to fixup the opcode to the "right"
vendor, then restarts the guest, without skipping the VMMCALL.  As a
result, the guest sees an endless stream of #UDs since it's already
executing the correct vendor hypercall instruction, i.e. the emulator
doesn't anticipate that the #UD could be due to lack of interception, as
opposed to a truly undefined opcode.

Fixes: 0d945bd93511 ("KVM: SVM: Don't allow nested guest to VMMCALL into host")
Cc: stable@vger.kernel.org
Reviewed-by: Yosry Ahmed <yosry@kernel.org>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Link: https://patch.msgid.link/20260304002223.1105129-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/hyperv.h
arch/x86/kvm/svm/nested.c

index 9af03970d40c287601afe00207c1c220c5a9c246..f70d076911a63da811906bf64e94bfade39b6bde 100644 (file)
@@ -51,10 +51,6 @@ static inline bool nested_svm_is_l2_tlb_flush_hcall(struct kvm_vcpu *vcpu)
 void svm_hv_inject_synthetic_vmexit_post_tlb_flush(struct kvm_vcpu *vcpu);
 #else /* CONFIG_KVM_HYPERV */
 static inline void nested_svm_hv_update_vm_vp_ids(struct kvm_vcpu *vcpu) {}
-static inline bool nested_svm_l2_tlb_flush_enabled(struct kvm_vcpu *vcpu)
-{
-       return false;
-}
 static inline bool nested_svm_is_l2_tlb_flush_hcall(struct kvm_vcpu *vcpu)
 {
        return false;
index 0f7893a7cb040a291485782ec64be358d226a6ca..fb86f09985e7b71f6acd9702647bbd2f9b6c6f15 100644 (file)
@@ -158,13 +158,6 @@ void recalc_intercepts(struct vcpu_svm *svm)
                        vmcb_clr_intercept(c, INTERCEPT_VINTR);
        }
 
-       /*
-        * We want to see VMMCALLs from a nested guest only when Hyper-V L2 TLB
-        * flush feature is enabled.
-        */
-       if (!nested_svm_l2_tlb_flush_enabled(&svm->vcpu))
-               vmcb_clr_intercept(c, INTERCEPT_VMMCALL);
-
        for (i = 0; i < MAX_INTERCEPT; i++)
                c->intercepts[i] |= g->intercepts[i];