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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Vasant Karasulli <vkarasulli@xxxxxxx>

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@xxxxxxx>
---
 lib/x86/processor.h | 8 ++++++++
 x86/xsave.c         | 7 -------
 2 files changed, 8 insertions(+), 7 deletions(-)

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;
--
2.34.1





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux