Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Ewan Hai-oc <ewanhai-oc@zhaoxin.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Shuah Khan <shuah@kernel.org>,  Frank Zhu <frankzhu@zhaoxin.com>,
	kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
	 linux-kernel@vger.kernel.org, ewanhai@zhaoxin.com,
	cobechen@zhaoxin.com
Subject: Re: [PATCH v2 6/9] KVM: selftests: Skip PERF_CAPABILITIES vCPU checks without PDCM
Date: Fri, 11 Sep 2026 09:19:51 -0700	[thread overview]
Message-ID: <aqQqJysVQxS76YIE@google.com> (raw)
In-Reply-To: <20260910115414.3015260-7-ewanhai-oc@zhaoxin.com>

On Thu, Sep 10, 2026, Ewan Hai-oc wrote:
> From: Frank Zhu <frankzhu@zhaoxin.com>
> 
> KVM allows userspace to query MSR_IA32_PERF_CAPABILITIES through
> KVM_GET_MSRS even when PDCM is not exposed in KVM_GET_SUPPORTED_CPUID.
> However, vCPU accesses to the MSR fail without PDCM.

Hrm, no, KVM is supposed to allow reads and drop writes of '0' for MSRs that are
advertised to userspace, but ultimately unsupported.  I'm pretty sure this is a
KVM bug.  I think MSR_IA32_ARCH_CAPABILITIES is also affected.

Completely untested, but I think this?

diff --git a/arch/x86/kvm/msrs.c b/arch/x86/kvm/msrs.c
index dd3bb04878ca..fa77cfdbda7e 100644
--- a/arch/x86/kvm/msrs.c
+++ b/arch/x86/kvm/msrs.c
@@ -512,9 +512,15 @@ static int kvm_get_feature_msr(struct kvm_vcpu *vcpu, u32 index, u64 *data,
 
 	switch (index) {
 	case MSR_IA32_ARCH_CAPABILITIES:
+		if (!kvm_cpu_cap_has(X86_FEATURE_ARCH_CAPABILITIES))
+			return KVM_MSR_RET_UNSUPPORTED;
+
 		*data = kvm_get_arch_capabilities();
 		break;
 	case MSR_IA32_PERF_CAPABILITIES:
+		if (!kvm_cpu_cap_has(X86_FEATURE_PDCM))
+			return KVM_MSR_RET_UNSUPPORTED;
+
 		*data = kvm_caps.supported_perf_cap;
 		break;
 	case MSR_PLATFORM_INFO:

  reply	other threads:[~2026-09-11 16:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10 11:54 [PATCH v2 0/9] KVM: selftests: Add Zhaoxin CPU support Ewan Hai-oc
2026-09-10 11:54 ` [PATCH v2 1/9] KVM: selftests: Add Zhaoxin CPU detection support Ewan Hai-oc
2026-09-10 11:54 ` [PATCH v2 2/9] KVM: selftests: Use host_cpu_is_intel_compatible for mediated PMU Ewan Hai-oc
2026-09-10 11:54 ` [PATCH v2 3/9] KVM: selftests: nx_huge_pages_test: Add TDP detection for Zhaoxin CPUs Ewan Hai-oc
2026-09-10 11:54 ` [PATCH v2 4/9] KVM: selftests: vmx_exception_with_invalid_guest_state: Support " Ewan Hai-oc
2026-09-10 11:54 ` [PATCH v2 5/9] KVM: selftests: fix_hypercall_test: Add Zhaoxin CPU support Ewan Hai-oc
2026-09-10 11:54 ` [PATCH v2 6/9] KVM: selftests: Skip PERF_CAPABILITIES vCPU checks without PDCM Ewan Hai-oc
2026-09-11 16:19   ` Sean Christopherson [this message]
2026-09-10 11:54 ` [PATCH v2 7/9] KVM: selftests: feature_msrs_test: Extend MSR_IA32_UCODE_REV quirk to Zhaoxin Ewan Hai-oc
2026-09-10 11:54 ` [PATCH v2 8/9] KVM: selftests: nested_exceptions_test: Add Zhaoxin CPU support Ewan Hai-oc
2026-09-10 11:54 ` [PATCH v2 9/9] KVM: selftests: vmx_apic_access_test: Check APIC virtualization support Ewan Hai-oc
2026-09-11 16:32   ` Sean Christopherson

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=aqQqJysVQxS76YIE@google.com \
    --to=seanjc@google.com \
    --cc=cobechen@zhaoxin.com \
    --cc=ewanhai-oc@zhaoxin.com \
    --cc=ewanhai@zhaoxin.com \
    --cc=frankzhu@zhaoxin.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=shuah@kernel.org \
    /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