]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: x86: check that kvm_handle_invpcid is only invoked with shadow paging
authorPaolo Bonzini <pbonzini@redhat.com>
Sat, 30 May 2026 16:55:44 +0000 (12:55 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 12 Jun 2026 08:43:52 +0000 (10:43 +0200)
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>
Message-ID: <20260530165545.25599-5-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c

index a5e09bf431ceef412940b0afdc5b8dc7211d7eda..e369e291f7a40fd0386db95026523a631f070377 100644 (file)
@@ -14289,6 +14289,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) {