All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ewan Hai-oc" <ewanhai-oc@zhaoxin.com>
To: Sean Christopherson <seanjc@google.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: Tue, 20 Oct 2026 10:53:29 +0800	[thread overview]
Message-ID: <atbVQZsuClHwaLGo@ewan-server> (raw)
In-Reply-To: <arHesdC4MieHtZUr@ewan-server>

On Tue, Sep 22, 2026 at 09:54:51AM +0800, Ewan Hai-oc wrote:
> On Fri, Sep 11, 2026 at 09:19:51AM -0700, Sean Christopherson wrote:
> > 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:
> >
> 
> I saw that you applied eight patches from the series to the kvm-x86
> selftests branch and skipped patch 6 as a KVM bug.
> 
> We are testing the change you suggested on Zhaoxin systems with and
> without PDCM support. We expect to report the results within the next
> few weeks.
> 

Hi Sean,

Frank tested your suggested change on Zhaoxin systems **without** PDCM,
using kvm_intel. The results support the fix.

MSR_IA32_PERF_CAPABILITIES is no longer listed in
KVM_GET_MSR_FEATURE_INDEX_LIST. A direct KVM_GET_MSRS query on the
/dev/kvm fd still succeeds, with the MSR data changing from 0x2000
to 0 through the existing unsupported-MSR handling. The MSR remains
in KVM_GET_MSR_INDEX_LIST, and the existing vCPU userspace behavior
of allowing reads of zero and writes of zero is unchanged.

We also checked the QEMU behavior. With the MSR absent from the feature
list, QEMU's supported-feature query returns zero for PERF_CAPABILITIES.
The PDCM bit in KVM_GET_SUPPORTED_CPUID is unchanged and was already
clear on these systems. QEMU filters PDCM out of CPU models that request
it, so this resolves our concern about the effect on CPU model selection.

feature_msrs_test passes with the change. vmx_pmu_caps_test is skipped
on these systems, and the other KVM selftests we ran showed no regressions.
Our hardware testing covered systems without PDCM; we have not validated
the change on PDCM-capable hardware.

One observation about the ARCH_CAPABILITIES check: in the code we
checked, EMULATED_F(ARCH_CAPABILITIES) already enables the capability
unconditionally, so the new check does not change its behavior.

Thanks,
Ewan

> Thanks for applying the patches and for looking into the patch 6 issue.
> 


  reply	other threads:[~2026-10-20  2:53 UTC|newest]

Thread overview: 15+ 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
2026-09-22  1:54     ` Ewan Hai-oc
2026-10-20  2:53       ` Ewan Hai-oc [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
2026-09-21 14:05 ` [PATCH v2 0/9] KVM: selftests: Add Zhaoxin CPU support 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=atbVQZsuClHwaLGo@ewan-server \
    --to=ewanhai-oc@zhaoxin.com \
    --cc=cobechen@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=seanjc@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.