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: Wed, 11 Feb 2026 08:26:25 -0800 [thread overview]
Message-ID: <aYytsW06SZ6d2Iqu@google.com> (raw)
In-Reply-To: <3088af31-7ef8-45f3-9e0c-c51274ab9ca0@163.com>
On Wed, Feb 11, 2026, Zhiquan Li wrote:
>
> On 2/11/26 04:02, Sean Christopherson wrote:
> > Gah, I think I tested -rdpid and -rdtscp in a VM on Intel, but not AMD. I think
> > the fix is just this:
> >
> > diff --git a/tools/testing/selftests/kvm/x86/msrs_test.c b/tools/testing/
> > selftests/kvm/x86/msrs_test.c
> > index 40d918aedce6..ebd900e713c1 100644
> > --- a/tools/testing/selftests/kvm/x86/msrs_test.c
> > +++ b/tools/testing/selftests/kvm/x86/msrs_test.c
> > @@ -175,7 +175,7 @@ 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.
> > */
> > - if (!this_cpu_has(msr->feature) ||
> > + if ((!this_cpu_has(msr->feature) && !this_cpu_has(msr->feature2)) ||
> > msr->rsvd_val == fixup_rdmsr_val(msr->index, msr->rsvd_val)) {
> > u8 vec = wrmsr_safe(msr->index, msr->rsvd_val);
>
> Perfect! You found the root cause and fixed it.
> I’ve verified the fix on Hygon platform, I will test it on Intel and AMD
> platforms as well to make sure there is no regression.
> I’m going to include the you fix in the V2 series. Since my modifications are
> totally miss the point, I will remove my SoB and only add my “Reported-by:” tag,
> I suppose the SoB position would be wait for you, Sean :-)
Nice! Here's a full patch for v2.
--
From: Sean Christopherson <seanjc@google.com>
Date: Wed, 11 Feb 2026 08:18:47 -0800
Subject: [PATCH] KVM: selftests: Fix reserved value WRMSR testcase for
multi-feature MSRs
When determining whether or not a WRMSR with reserved bits will #GP or
succeed due to the WRMSR not existing per the guest virtual CPU model,
expect failure if and only if _all_ features associated with the MSR are
unsupported. Checking only the primary feature results in false failures
when running on AMD and Hygon CPUs with only one of RDPID or RDTSCP, as
AMD/Hygon CPUs ignore MSR_TSC_AUX[63:32], i.e. don't treat the bits as
reserved, and so #GP only if the MSR is unsupported.
Fixes: 9c38ddb3df94 ("KVM: selftests: Add an MSR test to exercise guest/host and read/write")
Reported-by: Zhiquan Li <zhiquan_li@163.com>
Closes: https://lore.kernel.org/all/20260209041305.64906-6-zhiquan_li@163.com
Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
tools/testing/selftests/kvm/x86/msrs_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/x86/msrs_test.c b/tools/testing/selftests/kvm/x86/msrs_test.c
index 40d918aedce6..ebd900e713c1 100644
--- a/tools/testing/selftests/kvm/x86/msrs_test.c
+++ b/tools/testing/selftests/kvm/x86/msrs_test.c
@@ -175,7 +175,7 @@ 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.
*/
- if (!this_cpu_has(msr->feature) ||
+ if ((!this_cpu_has(msr->feature) && !this_cpu_has(msr->feature2)) ||
msr->rsvd_val == fixup_rdmsr_val(msr->index, msr->rsvd_val)) {
u8 vec = wrmsr_safe(msr->index, msr->rsvd_val);
base-commit: e944fe2c09f405a2e2d147145c9b470084bc4c9a
--
prev parent reply other threads:[~2026-02-11 16:26 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
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 [this message]
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=aYytsW06SZ6d2Iqu@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox