lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aNLSwWM98jzs8NZh@google.com>
Date: Tue, 23 Sep 2025 10:02:57 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Chao Gao <chao.gao@...el.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>, kvm@...r.kernel.org, linux-kernel@...r.kernel.org, 
	Tom Lendacky <thomas.lendacky@....com>, Mathias Krause <minipli@...ecurity.net>, 
	John Allen <john.allen@....com>, Rick Edgecombe <rick.p.edgecombe@...el.com>, 
	Binbin Wu <binbin.wu@...ux.intel.com>, Xiaoyao Li <xiaoyao.li@...el.com>, 
	Maxim Levitsky <mlevitsk@...hat.com>, Zhang Yi Z <yi.z.zhang@...ux.intel.com>, Xin Li <xin@...or.com>
Subject: Re: [PATCH v16 50/51] KVM: selftests: Verify MSRs are (not) in
 save/restore list when (un)supported

On Tue, Sep 23, 2025, Chao Gao wrote:
> On Fri, Sep 19, 2025 at 03:32:57PM -0700, Sean Christopherson wrote:
> >Add a check in the MSRs test to verify that KVM's reported support for
> >MSRs with feature bits is consistent between KVM's MSR save/restore lists
> >and KVM's supported CPUID.
> >
> 
> >To deal with Intel's wonderful decision to bundle IBT and SHSTK under CET,
> >track the "second" feature to avoid false failures when running on a CPU
> >with only one of IBT or SHSTK.
> 
> is this paragraph related to this patch? the tracking is done in a previous
> patch instead of this patch. So maybe just drop this paragraph.
> 
> >
> >Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> >---
> > tools/testing/selftests/kvm/x86/msrs_test.c | 22 ++++++++++++++++++++-
> > 1 file changed, 21 insertions(+), 1 deletion(-)
> >
> >diff --git a/tools/testing/selftests/kvm/x86/msrs_test.c b/tools/testing/selftests/kvm/x86/msrs_test.c
> >index 7c6d846e42dd..91dc66bfdac2 100644
> >--- a/tools/testing/selftests/kvm/x86/msrs_test.c
> >+++ b/tools/testing/selftests/kvm/x86/msrs_test.c
> >@@ -437,12 +437,32 @@ static void test_msrs(void)
> > 	}
> > 
> > 	for (idx = 0; idx < ARRAY_SIZE(__msrs); idx++) {
> >-		if (msrs[idx].is_kvm_defined) {
> >+		struct kvm_msr *msr = &msrs[idx];
> >+
> >+		if (msr->is_kvm_defined) {
> > 			for (i = 0; i < NR_VCPUS; i++)
> > 				host_test_kvm_reg(vcpus[i]);
> > 			continue;
> > 		}
> > 
> >+		/*
> >+		 * Verify KVM_GET_SUPPORTED_CPUID and KVM_GET_MSR_INDEX_LIST
> >+		 * are consistent with respect to MSRs whose existence is
> >+		 * enumerated via CPUID.  Note, using LM as a dummy feature
> >+		 * is a-ok here as well, as all MSRs that abuse LM should be
> >+		 * unconditionally reported in the save/restore list (and
> 
> I am not sure why LM is mentioned here. Is it a leftover from one of your
> previous attempts?

Yeah, at one point I was using LM as the NONE feature.  I'll delete the entire
sentence.

> 
> >+		 * selftests are 64-bit only).  Note #2, skip the check for
> >+		 * FS/GS.base MSRs, as they aren't reported in the save/restore
> >+		 * list since their state is managed via SREGS.
> >+		 */
> >+		TEST_ASSERT(msr->index == MSR_FS_BASE || msr->index == MSR_GS_BASE ||
> >+			    kvm_msr_is_in_save_restore_list(msr->index) ==
> >+			    (kvm_cpu_has(msr->feature) || kvm_cpu_has(msr->feature2)),
> >+			    "%s %s save/restore list, but %s according to CPUID", msr->name,
> 
> 				  ^ an "in" is missing here.

Heh, I had added this in a local version when debugging, but forgot to push the
fix.  Added now. 

diff --git a/tools/testing/selftests/kvm/x86/msrs_test.c b/tools/testing/selftests/kvm/x86/msrs_test.c
index c2ab75e5d9ea..40d918aedce6 100644
--- a/tools/testing/selftests/kvm/x86/msrs_test.c
+++ b/tools/testing/selftests/kvm/x86/msrs_test.c
@@ -455,17 +455,14 @@ static void test_msrs(void)
                /*
                 * Verify KVM_GET_SUPPORTED_CPUID and KVM_GET_MSR_INDEX_LIST
                 * are consistent with respect to MSRs whose existence is
-                * enumerated via CPUID.  Note, using LM as a dummy feature
-                * is a-ok here as well, as all MSRs that abuse LM should be
-                * unconditionally reported in the save/restore list (and
-                * selftests are 64-bit only).  Note #2, skip the check for
-                * FS/GS.base MSRs, as they aren't reported in the save/restore
-                * list since their state is managed via SREGS.
+                * enumerated via CPUID.  Skip the check for FS/GS.base MSRs,
+                * as they aren't reported in the save/restore list since their
+                * state is managed via SREGS.
                 */
                TEST_ASSERT(msr->index == MSR_FS_BASE || msr->index == MSR_GS_BASE ||
                            kvm_msr_is_in_save_restore_list(msr->index) ==
                            (kvm_cpu_has(msr->feature) || kvm_cpu_has(msr->feature2)),
-                           "%s %s save/restore list, but %s according to CPUID", msr->name,
+                           "%s %s in save/restore list, but %s according to CPUID", msr->name,
                            kvm_msr_is_in_save_restore_list(msr->index) ? "is" : "isn't",
                            (kvm_cpu_has(msr->feature) || kvm_cpu_has(msr->feature2)) ?
                            "supported" : "unsupported");

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ