From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 31DEB30AD1C for ; Wed, 4 Mar 2026 01:20:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772587208; cv=none; b=O/nRfcgaRF8FGH9oXyNqw/faOjr23ZjqhkYbJkPVxVy5dlJzYCwFCquk//ipYtqRgTfFytiQSa0ICrd1U9sdNlC+MHnE+cXw4RaRcNU07edpmVsh4dSA+9RcTSqjGHf5eqoUp0jgT1g/7fXhVYpQC5HZxWgysQc5JrFMzMi69WA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772587208; c=relaxed/simple; bh=WXtNWyzEy6zmJ8lPvjTixTQyzkBBKDWeUk0mIbYM6lM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=pdVdwQK3DlQOewxhh0n6waawKHNFuU22H12IzZ8LcWohyyaL1Y9um5Fj+O9r72ESQQQv3IH9bICPjZvbFuKj2A6hSjrrrhxoO1Q3+8JsvxLmsUqSmwB3payNaPflmTcuc6rUCGQr0e6XfXDFIVk2CLKjDciUXFp8LMsW19BgqTg= 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=AVYh89Ce; arc=none smtp.client-ip=209.85.216.74 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="AVYh89Ce" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-35980a994d6so16732075a91.1 for ; Tue, 03 Mar 2026 17:20:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772587205; x=1773192005; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=oBoM0J3CXqbdN4xxDEVBLdipwHOmKkbJsAA0VcnSKH4=; b=AVYh89CeKwddx8fOlOVE8Y7ChQOfNPOgOhJPuPyiFE+6TFhQjTe3Ef4T41NcucWf5v oaiou3oPUNz+O82YzVVy1J+RGfIdGo+Kt3Qt6UgTkzhDovwjweyIvoIc99aqokj2l8ez Fbq4cad7mA+zUGkS7Qnpz9bz5q0WDMKt4sMvnYC/PMoUdF+MgGD1MNNTxsEYWZLevZsq FJgMZf0qdPzCQpSR5HW4KydqPAJtch7Mw8HJ5KRRcAv8f0CqwqfmFtDmC6JIBdiTGw9I 4htPb/hiuGQoBaSURxGHsqV5Gzz2qcFqgu2Y2y/Ufq7h7RRznFOOu0a0OqK9VSI/kgee WavQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772587205; x=1773192005; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oBoM0J3CXqbdN4xxDEVBLdipwHOmKkbJsAA0VcnSKH4=; b=reIohpkQm03o0vmCaPn9GzlotNoHrFzToodgV6BaR6mER+P3pY+rJCHvs26QdrL1UX DOcHFHjfNzi+bmYTiM6OVxclxwVzLG6TJISGLAgjTWLkfwrBPHbOJohoV6wVo97XRfpy CLpe9oTLLd2mUqycwgjITDCW4hJhhyNY4dGTd1F4rFhOZt9ofMeHCQ+Gd8CbTT/Y+Ke6 8ZR+zgfwu6t5a8jdr77HSCRLHFPxKzriGP06hFMr4qn8PSYKFhbNaDv5b748IXSiFJ3Y Y/09rZwUFPV9YdWV2XFglPT2g8W32qFOJptpYWp5yKcuf+Nr51bIvwn0A1FlckbOqv4z a1ZQ== X-Forwarded-Encrypted: i=1; AJvYcCUAvyrDYbcQesbolMhbr01b2WVeqSeEwEI8gRzXoLNYt05mWFJ9PHj5XRN708VoVzhqrbGyqfNRKY7rYL4=@vger.kernel.org X-Gm-Message-State: AOJu0Yz27OOATjF476fy0KgEZLDH5cNC/RigFQhPCjA62tgpbNxM/GBt hHyXiANjJqSq+glaqJ2tcaFa+UpLrRodm9LOn3SpfPJu9zIzCBYAKXqEzaaFwZkS11As1DPM8Xk ZPtc2FQ== X-Received: from pjbdj7.prod.google.com ([2002:a17:90a:d2c7:b0:359:81f5:3dea]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3c11:b0:359:94af:586b with SMTP id 98e67ed59e1d1-359a6a7ccc1mr392361a91.33.1772587205387; Tue, 03 Mar 2026 17:20:05 -0800 (PST) Date: Tue, 3 Mar 2026 17:20:04 -0800 In-Reply-To: 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> <20260304002223.1105129-3-seanjc@google.com> Message-ID: Subject: Re: [PATCH v5 2/2] KVM: nSVM: Always intercept VMMCALL when L2 is active From: Sean Christopherson To: Yosry Ahmed Cc: Vitaly Kuznetsov , Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Kevin Cheng Content-Type: text/plain; charset="us-ascii" On Wed, Mar 04, 2026, Yosry Ahmed wrote: > On Tue, Mar 03, 2026 at 04:22:23PM -0800, Sean Christopherson wrote: > > 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; > > -} > > Why is this dropped? We still need it for vmmcall_interception under > !CONFIG_KVM_HYPERV, right? Nope, because vmmcall_interception() uses nested_svm_is_l2_tlb_flush_hcall(), and the previous patch created a stub for that one. I.e. only the non-stub CONFIG_KVM_HYPERV=y version references nested_svm_l2_tlb_flush_enabled().