From: Sean Christopherson <seanjc@google.com>
To: Zhiquan Li <zhiquan_li@163.com>
Cc: pbonzini@redhat.com, shuah@kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND 5/5] KVM: x86: selftests: Fix write MSR_TSC_AUX reserved bits test failure on Hygon
Date: Mon, 9 Feb 2026 08:41:03 -0800 [thread overview]
Message-ID: <aYoOHzwgxvpZ5Iso@google.com> (raw)
In-Reply-To: <20260209041305.64906-6-zhiquan_li@163.com>
On Mon, Feb 09, 2026, Zhiquan Li wrote:
> Therefore, the expectation of writing MSR_TSC_AUX reserved bits on Hygon
> CPUs should be:
> 1) either RDTSCP or RDPID is supported case, and both are supported
> case, expect success and a truncated value, not #GP.
> 2) neither RDTSCP nor RDPID is supported, expect #GP.
That's how Intel and AMD behave as well. I don't understand why there needs to
be a big pile of special case code for Hygon. Presumably just fixup_rdmsr_val()
needs to be changed?
> Signed-off-by: Zhiquan Li <zhiquan_li@163.com>
> ---
> tools/testing/selftests/kvm/x86/msrs_test.c | 26 +++++++++++++++++----
> 1 file changed, 21 insertions(+), 5 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/x86/msrs_test.c b/tools/testing/selftests/kvm/x86/msrs_test.c
> index 40d918aedce6..2f1e800fe691 100644
> --- a/tools/testing/selftests/kvm/x86/msrs_test.c
> +++ b/tools/testing/selftests/kvm/x86/msrs_test.c
> @@ -77,11 +77,11 @@ static bool ignore_unsupported_msrs;
> static u64 fixup_rdmsr_val(u32 msr, u64 want)
> {
> /*
> - * AMD CPUs drop bits 63:32 on some MSRs that Intel CPUs support. KVM
> - * is supposed to emulate that behavior based on guest vendor model
> + * AMD and Hygon CPUs drop bits 63:32 on some MSRs that Intel CPUs support.
> + * KVM is supposed to emulate that behavior based on guest vendor model
> * (which is the same as the host vendor model for this test).
> */
> - if (!host_cpu_is_amd)
> + if (!host_cpu_is_amd && !host_cpu_is_hygon)
> return want;
>
> switch (msr) {
> @@ -94,6 +94,17 @@ static u64 fixup_rdmsr_val(u32 msr, u64 want)
> }
> }
>
> +/*
> + * On Hygon processors either RDTSCP or RDPID is supported in the host,
> + * MSR_TSC_AUX is able to be accessed.
> + */
> +static bool is_hygon_msr_tsc_aux_supported(const struct kvm_msr *msr)
> +{
> + return host_cpu_is_hygon &&
> + msr->index == MSR_TSC_AUX &&
> + (this_cpu_has(msr->feature) || this_cpu_has(msr->feature2));
Align indentation, but as above, this shouldn't be necessary.
> +}
> +
> static void __rdmsr(u32 msr, u64 want)
> {
> u64 val;
> @@ -174,9 +185,14 @@ void guest_test_reserved_val(const struct kvm_msr *msr)
> /*
> * If the CPU will truncate the written value (e.g. SYSENTER on AMD),
> * expect success and a truncated value, not #GP.
> + *
> + * On Hygon CPUs whether or not RDPID is supported in the host, once RDTSCP
> + * is supported, MSR_TSC_AUX is able to be accessed. So, for either RDTSCP
> + * or RDPID is supported case and both are supported case, expect
> + * success and a truncated value, not #GP.
> */
> - if (!this_cpu_has(msr->feature) ||
> - msr->rsvd_val == fixup_rdmsr_val(msr->index, msr->rsvd_val)) {
> + if (!is_hygon_msr_tsc_aux_supported(msr) && (!this_cpu_has(msr->feature) ||
> + msr->rsvd_val == fixup_rdmsr_val(msr->index, msr->rsvd_val))) {
> u8 vec = wrmsr_safe(msr->index, msr->rsvd_val);
>
> __GUEST_ASSERT(vec == GP_VECTOR,
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-02-09 16:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-09 4:13 [PATCH RESEND 0/5] KVM: x86: selftests: Add Hygon CPUs support and fix failures Zhiquan Li
2026-02-09 4:13 ` [PATCH RESEND 1/5] KVM: x86: selftests: Add CPU vendor detection for Hygon Zhiquan Li
2026-02-09 4:13 ` [PATCH RESEND 2/5] KVM: x86: selftests: Alter the instruction of hypercall on Hygon Zhiquan Li
2026-02-09 16:37 ` Sean Christopherson
2026-02-10 9:04 ` Zhiquan Li
2026-02-09 4:13 ` [PATCH RESEND 3/5] KVM: x86: selftests: Avoid failures due to reserved memory address regions " Zhiquan Li
2026-02-09 4:13 ` [PATCH RESEND 4/5] KVM: x86: selftests: Allow the PMU event filter test for Hygon Zhiquan Li
2026-02-09 16:38 ` Sean Christopherson
2026-02-10 9:07 ` Zhiquan Li
2026-02-09 4:13 ` [PATCH RESEND 5/5] KVM: x86: selftests: Fix write MSR_TSC_AUX reserved bits test failure on Hygon Zhiquan Li
2026-02-09 16:41 ` Sean Christopherson [this message]
2026-02-10 10:17 ` Zhiquan Li
2026-02-10 20:02 ` Sean Christopherson
2026-02-11 9:24 ` Zhiquan Li
2026-02-11 16:26 ` 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=aYoOHzwgxvpZ5Iso@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=shuah@kernel.org \
--cc=zhiquan_li@163.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 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.