[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220604012058.1972195-3-seanjc@google.com>
Date: Sat, 4 Jun 2022 01:20:18 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: kvm@...r.kernel.org, Vitaly Kuznetsov <vkuznets@...hat.com>,
David Matlack <dmatlack@...gle.com>,
Jim Mattson <jmattson@...gle.com>, linux-kernel@...r.kernel.org
Subject: [PATCH 02/42] KVM: sefltests: Use CPUID_XSAVE and CPUID_OSXAVE
instead of X86_FEATURE_*
Rename X86_FEATURE_* macros to CPUID_* in the AMX and CR4/CPUID sync
tests to free up the X86_FEATURE_* names for KVM-Unit-Tests style CPUID
automagic where the function, leaf, register, and bit for the feature is
embedded in its macro value.
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@...gle.com>
---
tools/testing/selftests/kvm/include/x86_64/processor.h | 4 ++++
tools/testing/selftests/kvm/x86_64/amx_test.c | 9 +++------
tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c | 7 ++-----
.../selftests/kvm/x86_64/svm_nested_soft_inject_test.c | 3 +--
4 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h
index 974d08746b39..e47eba48744e 100644
--- a/tools/testing/selftests/kvm/include/x86_64/processor.h
+++ b/tools/testing/selftests/kvm/include/x86_64/processor.h
@@ -48,6 +48,7 @@
#define CPUID_SMX (1ul << 6)
#define CPUID_PCID (1ul << 17)
#define CPUID_XSAVE (1ul << 26)
+#define CPUID_OSXSAVE (1ul << 27)
/* CPUID.7.EBX */
#define CPUID_FSGSBASE (1ul << 0)
@@ -62,6 +63,9 @@
/* CPUID.0x8000_0001.EDX */
#define CPUID_GBPAGES (1ul << 26)
+/* CPUID.0x8000_000A.EDX */
+#define CPUID_NRIPS BIT(3)
+
/* Page table bitfield declarations */
#define PTE_PRESENT_MASK BIT_ULL(0)
#define PTE_WRITABLE_MASK BIT_ULL(1)
diff --git a/tools/testing/selftests/kvm/x86_64/amx_test.c b/tools/testing/selftests/kvm/x86_64/amx_test.c
index 95f59653dbce..7127873bb0cb 100644
--- a/tools/testing/selftests/kvm/x86_64/amx_test.c
+++ b/tools/testing/selftests/kvm/x86_64/amx_test.c
@@ -25,9 +25,6 @@
# error This test is 64-bit only
#endif
-#define X86_FEATURE_XSAVE (1 << 26)
-#define X86_FEATURE_OSXSAVE (1 << 27)
-
#define NUM_TILES 8
#define TILE_SIZE 1024
#define XSAVE_SIZE ((NUM_TILES * TILE_SIZE) + PAGE_SIZE)
@@ -128,9 +125,9 @@ static inline void check_cpuid_xsave(void)
eax = 1;
ecx = 0;
cpuid(&eax, &ebx, &ecx, &edx);
- if (!(ecx & X86_FEATURE_XSAVE))
+ if (!(ecx & CPUID_XSAVE))
GUEST_ASSERT(!"cpuid: no CPU xsave support!");
- if (!(ecx & X86_FEATURE_OSXSAVE))
+ if (!(ecx & CPUID_OSXSAVE))
GUEST_ASSERT(!"cpuid: no OS xsave support!");
}
@@ -333,7 +330,7 @@ int main(int argc, char *argv[])
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
entry = kvm_get_supported_cpuid_entry(1);
- TEST_REQUIRE(entry->ecx & X86_FEATURE_XSAVE);
+ TEST_REQUIRE(entry->ecx & CPUID_XSAVE);
TEST_REQUIRE(kvm_get_cpuid_max_basic() >= 0xd);
diff --git a/tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c b/tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c
index a80940ac420f..8b0bb36205d9 100644
--- a/tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c
+++ b/tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c
@@ -19,9 +19,6 @@
#include "kvm_util.h"
#include "processor.h"
-#define X86_FEATURE_XSAVE (1<<26)
-#define X86_FEATURE_OSXSAVE (1<<27)
-
static inline bool cr4_cpuid_is_sync(void)
{
int func, subfunc;
@@ -36,7 +33,7 @@ static inline bool cr4_cpuid_is_sync(void)
cr4 = get_cr4();
- return (!!(ecx & X86_FEATURE_OSXSAVE)) == (!!(cr4 & X86_CR4_OSXSAVE));
+ return (!!(ecx & CPUID_OSXSAVE)) == (!!(cr4 & X86_CR4_OSXSAVE));
}
static void guest_code(void)
@@ -70,7 +67,7 @@ int main(int argc, char *argv[])
struct ucall uc;
entry = kvm_get_supported_cpuid_entry(1);
- TEST_REQUIRE(entry->ecx & X86_FEATURE_XSAVE);
+ TEST_REQUIRE(entry->ecx & CPUID_XSAVE);
/* Tell stdout not to buffer its content */
setbuf(stdout, NULL);
diff --git a/tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c b/tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c
index 1c3f457aa3aa..051f70167074 100644
--- a/tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c
+++ b/tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c
@@ -19,7 +19,6 @@
#include "test_util.h"
#define INT_NR 0x20
-#define X86_FEATURE_NRIPS BIT(3)
static_assert(ATOMIC_INT_LOCK_FREE == 2, "atomic int is not lockless");
@@ -204,7 +203,7 @@ int main(int argc, char *argv[])
nested_svm_check_supported();
cpuid = kvm_get_supported_cpuid_entry(0x8000000a);
- TEST_ASSERT(cpuid->edx & X86_FEATURE_NRIPS,
+ TEST_ASSERT(cpuid->edx & CPUID_NRIPS,
"KVM with nSVM is supposed to unconditionally advertise nRIP Save\n");
atomic_init(&nmi_stage, 0);
--
2.36.1.255.ge46751e96f-goog
Powered by blists - more mailing lists