From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE6FC2EFDAF for ; Wed, 4 Mar 2026 00:22:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772583751; cv=none; b=O2/3UDkf8OzE8o14uYrynarxoXCCP/SvPjj7fVO9QG8ZPo+8ELWoKsSBVLwRmI/yx2wg0VshFrYnsAY55tTHn1oLQS3HY/oYeig4SE7UfSkzKv/5P5TzZYWCI3x8CVwQ+hqzyTOnnCxS8z1rkEVb5MBOjKP9R0TXrWSKemJhxiI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772583751; c=relaxed/simple; bh=NPX7a4G73+QzySINrUOAjawzHqN9/zKfXL/heyEw3GA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Qfdi85ZQEkXDGAzFmZVGiNi63nMpds2BiaCSSpqFb5+XsKnfhVeN/Hc2g7jmOP0+vd2vaCmBZmt+Ftt45wG0WUZ5yZy3S8P6juGehMXSP85hwfAwqlk0y99gEJqhn4ZAwf17skVjusvIiDEiQCRVPMtineqH0xOoMULHZbLY+T0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=bXhmFLjX; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bXhmFLjX" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-c70f2120583so3532993a12.3 for ; Tue, 03 Mar 2026 16:22:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772583750; x=1773188550; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=kDpA+UvHfqu2KXcEE0BeLwUh8qWoHNo3iiEgddOUlSA=; b=bXhmFLjXMt+jLLcLnKC2YEU2Gnh2U1iyyAa8t65BE5dhOjbRzMMY4b344ChMsOSfMO tFq3Ef2v6rhqpSYBBVRwc9ecplKQ+pHU7e/593QMeaZnY1bFUbI7YVNhbo2DOr+DyvCv e3Gj4L/Hhpb0rmfr/aT3HazUyTYD2Ot00x/vzpod9/SZzPAkjA1/YRqFtEZm1Nvd/RTn 5gl8H/PLZTFwJwxKvp8veQCsl4l/oADvwgex0MYsdDJPJerU76UFrL1j8Eh8RHPIdEWQ 2/3MWAwNSo7elG1HRt9ILmL0LSkZ0iQGN+AfWJFOj5+RvOEjxPZp9EsYu4JsjFgDYhOZ ZdRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772583750; x=1773188550; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kDpA+UvHfqu2KXcEE0BeLwUh8qWoHNo3iiEgddOUlSA=; b=do414Cw2L1H+x0o9ucDUxUh0FdWnk+Qpe39zRFgyykF5Mo15fVAm33drRi6D3Dh1p5 GhugN5AoeV9w10l+8miUuC/OuaTC5t1BHuSsoE2pxI+9Mhi95sLxRTvqqnzi/GqF9f/V mwf1LNH/MIzWCREZsAFF7u0Fh6tIR0cLwf2k5RNNAzJghDOJfTqYa7cKRXdX6g4dU3I7 nUsC7z28n1G4fS/cAvOwLrEhp5+sfJMWJz2kvPzkAn6iFcI4kkdprzPglcM4lpfxR6Y+ 5AP+wLRTgvUW1NfjY5v9YgXypeg4ecaulHsIjpIFbiNNQqOecU9WMprc1RkQzLvxWH7x SQ4g== X-Forwarded-Encrypted: i=1; AJvYcCV150KYM49LMVjDAX6wOe3mTjEv+TSPdj1bTIjdrTooDEgYRZhm5n4lMpJKkD4p+JeGqm5E+hmjv7EkCYU=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+oZrR9g9Y+lRB6LtB1rd+Owsn8H3tERYUT56IXhNu+pPe3oJD 6pw+xypUUGJZ7dvLh+PIEGtf3X6qv3JSiGo6mJtRYVzOhojsizPp1sc8zc6figCwqK/Kwi4ydbz yWklpfg== X-Received: from pgpc1.prod.google.com ([2002:a63:a441:0:b0:bc0:ea34:538]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:4598:b0:395:cb87:dd6b with SMTP id adf61e73a8af0-3982ded303emr99556637.28.1772583749893; Tue, 03 Mar 2026 16:22:29 -0800 (PST) Reply-To: Sean Christopherson Date: Tue, 3 Mar 2026 16:22:23 -0800 In-Reply-To: <20260304002223.1105129-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260304002223.1105129-1-seanjc@google.com> X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260304002223.1105129-3-seanjc@google.com> Subject: [PATCH v5 2/2] KVM: nSVM: Always intercept VMMCALL when L2 is active From: Sean Christopherson To: Vitaly Kuznetsov , Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Kevin Cheng Content-Type: text/plain; charset="UTF-8" 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 Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/hyperv.h | 4 ---- arch/x86/kvm/svm/nested.c | 7 ------- 2 files changed, 11 deletions(-) diff --git a/arch/x86/kvm/svm/hyperv.h b/arch/x86/kvm/svm/hyperv.h index 9af03970d40c..f70d076911a6 100644 --- a/arch/x86/kvm/svm/hyperv.h +++ b/arch/x86/kvm/svm/hyperv.h @@ -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; diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 750bf93c5341..2ac28d2c34ca 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -156,13 +156,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]; -- 2.53.0.473.g4a7958ca14-goog