diff mbox series

[kvm-unit-tests,v8,07/12] lib/x86: Move xsave helpers to lib/

Message ID 20240612144539.16147-8-vsntk18@gmail.com (mailing list archive)
State New, archived
Headers show
Series Add #VC exception handling for AMD SEV-ES | expand

Commit Message

Vasant Karasulli June 12, 2024, 2:45 p.m. UTC
From: Vasant Karasulli <vkarasulli@suse.de>

Processing CPUID #VC for AMD SEV-ES requires copying xcr0 into GHCB.
Move the xsave read/write helpers used by xsave testcase to lib/x86
to share as common code.

Signed-off-by: Vasant Karasulli <vkarasulli@suse.de>
---
 lib/x86/processor.h | 8 ++++++++
 x86/xsave.c         | 7 -------
 2 files changed, 8 insertions(+), 7 deletions(-)

--
2.34.1
diff mbox series

Patch

diff --git a/lib/x86/processor.h b/lib/x86/processor.h
index b324cbf0..e85f9e0e 100644
--- a/lib/x86/processor.h
+++ b/lib/x86/processor.h
@@ -477,6 +477,14 @@  static inline uint64_t rdpmc(uint32_t index)
 	return val;
 }

+/* XCR0 related definitions */
+#define XCR_XFEATURE_ENABLED_MASK       0x00000000
+#define XCR_XFEATURE_ILLEGAL_MASK       0x00000010
+
+#define XSTATE_FP       0x1
+#define XSTATE_SSE      0x2
+#define XSTATE_YMM      0x4
+
 static inline int xgetbv_safe(u32 index, u64 *result)
 {
 	return rdreg64_safe(".byte 0x0f,0x01,0xd0", index, result);
diff --git a/x86/xsave.c b/x86/xsave.c
index 5d80f245..feb8db28 100644
--- a/x86/xsave.c
+++ b/x86/xsave.c
@@ -17,13 +17,6 @@  static uint64_t get_supported_xcr0(void)
     return r.a + ((u64)r.d << 32);
 }

-#define XCR_XFEATURE_ENABLED_MASK       0x00000000
-#define XCR_XFEATURE_ILLEGAL_MASK       0x00000010
-
-#define XSTATE_FP       0x1
-#define XSTATE_SSE      0x2
-#define XSTATE_YMM      0x4
-
 static void test_xsave(void)
 {
     unsigned long cr4;