mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: seanjc@google.com
Subject: [PATCH v2 4/5] KVM: x86: check that kvm_handle_invpcid is only invoked with shadow paging
Date: Sat, 30 May 2026 12:55:44 -0400	[thread overview]
Message-ID: <20260530165545.25599-5-pbonzini@redhat.com> (raw)
In-Reply-To: <20260530165545.25599-1-pbonzini@redhat.com>

This is true for both Intel and AMD.  On Intel, "enable INVPCID" is
set unconditionally if supported, but the vmexit is triggered by the
"INVLPG exiting" control which is disabled by enable_ept.  On AMD, KVM
can intercept INVPCID if NPT is enabled but only in order to inject #UD
in the guest.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/kvm/x86.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index fc0924389398..1913efef6c39 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -14350,6 +14350,9 @@ int kvm_handle_invpcid(struct kvm_vcpu *vcpu, unsigned long type, gva_t gva)
 		return 1;
 	}
 
+	if (WARN_ON_ONCE(tdp_enabled))
+		return 0;
+
 	pcid_enabled = kvm_is_cr4_bit_set(vcpu, X86_CR4_PCIDE);
 
 	switch (type) {
-- 
2.52.0



  parent reply	other threads:[~2026-05-30 16:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-30 16:55 [PATCH v2 0/5] KVM: x86: small MMU-adjacent cleanups Paolo Bonzini
2026-05-30 16:55 ` [PATCH v2 1/5] KVM: x86: remove nested_mmu from mmu_is_nested() Paolo Bonzini
2026-05-30 16:55 ` [PATCH v2 2/5] KVM: nVMX: remove unnecessary code in prepare_vmcs02_rare Paolo Bonzini
2026-05-30 16:55 ` [PATCH v2 3/5] KVM: nSVM: invalidate cached PDPTRs across nested NPT transitions Paolo Bonzini
2026-05-30 16:55 ` Paolo Bonzini [this message]
2026-05-30 16:55 ` [PATCH v2 5/5] KVM: x86/mmu: move pdptrs out of the MMU Paolo Bonzini
2026-06-12  8:47 ` [PATCH v2 0/5] KVM: x86: small MMU-adjacent cleanups Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260530165545.25599-5-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=seanjc@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®