Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Anil Altinay <aaltinay@google.com>
To: stable@vger.kernel.org
Cc: Jim Mattson <jmattson@google.com>,
	Sean Christopherson <seanjc@google.com>,
	 Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org,  Anil Altinay <aaltinay@google.com>
Subject: [PATCH 6.18.y v2 6/6] KVM: selftests: Update hwcr_msr_test for CPUID faulting bit
Date: Thu, 15 Oct 2026 16:03:46 +0000	[thread overview]
Message-ID: <20261015160346.181835-7-aaltinay@google.com> (raw)
In-Reply-To: <20261015160346.181835-1-aaltinay@google.com>

From: Jim Mattson <jmattson@google.com>

commit b16c2aca369d180dc94275343b34966194317528 upstream.

Add BIT_ULL(35) (CpuidUserDis) to the valid mask in hwcr_msr_test, now that
KVM accepts writes to this bit when the guest CPUID advertises
CpuidUserDis.

Signed-off-by: Jim Mattson <jmattson@google.com>
Link: https://patch.msgid.link/20260527174347.2356165-6-jmattson@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
[ 6.18 KVM selftests still use uint64_t rather than u64 ]
Signed-off-by: Anil Altinay <aaltinay@google.com>
---
 tools/testing/selftests/kvm/include/x86/processor.h | 1 +
 tools/testing/selftests/kvm/x86/hwcr_msr_test.c     | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/kvm/include/x86/processor.h b/tools/testing/selftests/kvm/include/x86/processor.h
index 51cd84b9ca66..64e57cbbd6d7 100644
--- a/tools/testing/selftests/kvm/include/x86/processor.h
+++ b/tools/testing/selftests/kvm/include/x86/processor.h
@@ -206,6 +206,7 @@ struct kvm_x86_cpu_feature {
 #define X86_FEATURE_SEV			KVM_X86_CPU_FEATURE(0x8000001F, 0, EAX, 1)
 #define X86_FEATURE_SEV_ES		KVM_X86_CPU_FEATURE(0x8000001F, 0, EAX, 3)
 #define X86_FEATURE_SEV_SNP		KVM_X86_CPU_FEATURE(0x8000001F, 0, EAX, 4)
+#define	X86_FEATURE_GP_ON_USER_CPUID	KVM_X86_CPU_FEATURE(0x80000021, 0, EAX, 17)
 #define	X86_FEATURE_PERFMON_V2		KVM_X86_CPU_FEATURE(0x80000022, 0, EAX, 0)
 #define	X86_FEATURE_LBR_PMC_FREEZE	KVM_X86_CPU_FEATURE(0x80000022, 0, EAX, 2)
 
diff --git a/tools/testing/selftests/kvm/x86/hwcr_msr_test.c b/tools/testing/selftests/kvm/x86/hwcr_msr_test.c
index 10b1b0ba374e..a9ae72279582 100644
--- a/tools/testing/selftests/kvm/x86/hwcr_msr_test.c
+++ b/tools/testing/selftests/kvm/x86/hwcr_msr_test.c
@@ -11,12 +11,17 @@
 void test_hwcr_bit(struct kvm_vcpu *vcpu, unsigned int bit)
 {
 	const uint64_t ignored = BIT_ULL(3) | BIT_ULL(6) | BIT_ULL(8);
-	const uint64_t valid = BIT_ULL(18) | BIT_ULL(24);
-	const uint64_t legal = ignored | valid;
+	uint64_t valid = BIT_ULL(18) | BIT_ULL(24);
 	uint64_t val = BIT_ULL(bit);
 	uint64_t actual;
+	uint64_t legal;
 	int r;
 
+	if (kvm_cpu_has(X86_FEATURE_GP_ON_USER_CPUID))
+		valid |= BIT_ULL(35);
+
+	legal = ignored | valid;
+
 	r = _vcpu_set_msr(vcpu, MSR_K7_HWCR, val);
 	TEST_ASSERT(val & ~legal ? !r : r == 1,
 		    "Expected KVM_SET_MSRS(MSR_K7_HWCR) = 0x%lx to %s",
-- 
2.56.0.385.gd3acb90ef8-goog


  parent reply	other threads:[~2026-10-15 16:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 16:03 [PATCH 6.18.y v2 0/6] KVM: x86: CPUID faulting fixes and AMD CPUID faulting virtualization Anil Altinay
2026-10-15 16:03 ` [PATCH 6.18.y v2 1/6] KVM: x86: Ignore cpuid faulting in SMM Anil Altinay
2026-10-15 16:03 ` [PATCH 6.18.y v2 2/6] KVM: x86: Consolidate CPUID fault handling for emulator and interception logic Anil Altinay
2026-10-15 16:03 ` [PATCH 6.18.y v2 3/6] KVM: x86: Prioritize CPUID faulting over CPUID VM-exits in nested VMX Anil Altinay
2026-10-15 16:03 ` [PATCH 6.18.y v2 4/6] KVM: x86: Remove supports_cpuid_fault() helper Anil Altinay
2026-10-15 16:03 ` [PATCH 6.18.y v2 5/6] KVM: x86: Virtualize AMD CPUID faulting Anil Altinay
2026-10-15 16:03 ` Anil Altinay [this message]
2026-10-16  1:09 ` [PATCH 6.18.y v2 0/6] KVM: x86: CPUID faulting fixes and AMD CPUID faulting virtualization 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=20261015160346.181835-7-aaltinay@google.com \
    --to=aaltinay@google.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=stable@vger.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