thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-x86-Add-AMX-XTILECFG-and-XTILEDATA-components.patch

4841a6
From 3ba6092159b6e3b25505af2a49c0f6ac99043db9 Mon Sep 17 00:00:00 2001
4841a6
From: Jing Liu <jing2.liu@intel.com>
4841a6
Date: Wed, 16 Feb 2022 22:04:28 -0800
4841a6
Subject: [PATCH 06/24] x86: Add AMX XTILECFG and XTILEDATA components
4841a6
4841a6
RH-Author: Paul Lai <plai@redhat.com>
4841a6
RH-MergeRequest: 176: Enable KVM AMX support
4841a6
RH-Commit: [6/13] 95229f87b4494631d57232f374a174f7bc95843a
4841a6
RH-Bugzilla: 1916415
4841a6
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
4841a6
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
4841a6
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
4841a6
4841a6
The AMX TILECFG register and the TMMx tile data registers are
4841a6
saved/restored via XSAVE, respectively in state component 17
4841a6
(64 bytes) and state component 18 (8192 bytes).
4841a6
4841a6
Add AMX feature bits to x86_ext_save_areas array to set
4841a6
up AMX components. Add structs that define the layout of
4841a6
AMX XSAVE areas and use QEMU_BUILD_BUG_ON to validate the
4841a6
structs sizes.
4841a6
4841a6
Signed-off-by: Jing Liu <jing2.liu@intel.com>
4841a6
Signed-off-by: Yang Zhong <yang.zhong@intel.com>
4841a6
Message-Id: <20220217060434.52460-3-yang.zhong@intel.com>
4841a6
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4841a6
(cherry picked from commit 1f16764f7d4515bfd5e4ae0aae814fa280a7d0c8)
4841a6
Signed-off-by: Paul Lai <plai@redhat.com>
4841a6
---
4841a6
 target/i386/cpu.c |  8 ++++++++
4841a6
 target/i386/cpu.h | 18 +++++++++++++++++-
4841a6
 2 files changed, 25 insertions(+), 1 deletion(-)
4841a6
4841a6
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
4841a6
index f44fad3a2a..0453c27c9d 100644
4841a6
--- a/target/i386/cpu.c
4841a6
+++ b/target/i386/cpu.c
4841a6
@@ -1401,6 +1401,14 @@ ExtSaveArea x86_ext_save_areas[XSAVE_STATE_AREA_COUNT] = {
4841a6
     [XSTATE_PKRU_BIT] =
4841a6
           { .feature = FEAT_7_0_ECX, .bits = CPUID_7_0_ECX_PKU,
4841a6
             .size = sizeof(XSavePKRU) },
4841a6
+    [XSTATE_XTILE_CFG_BIT] = {
4841a6
+        .feature = FEAT_7_0_EDX, .bits = CPUID_7_0_EDX_AMX_TILE,
4841a6
+        .size = sizeof(XSaveXTILECFG),
4841a6
+    },
4841a6
+    [XSTATE_XTILE_DATA_BIT] = {
4841a6
+        .feature = FEAT_7_0_EDX, .bits = CPUID_7_0_EDX_AMX_TILE,
4841a6
+        .size = sizeof(XSaveXTILEDATA)
4841a6
+    },
4841a6
 };
4841a6
 
4841a6
 static uint32_t xsave_area_size(uint64_t mask)
4841a6
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
4841a6
index 5d9702a991..e1dd8b9555 100644
4841a6
--- a/target/i386/cpu.h
4841a6
+++ b/target/i386/cpu.h
4841a6
@@ -537,6 +537,8 @@ typedef enum X86Seg {
4841a6
 #define XSTATE_ZMM_Hi256_BIT            6
4841a6
 #define XSTATE_Hi16_ZMM_BIT             7
4841a6
 #define XSTATE_PKRU_BIT                 9
4841a6
+#define XSTATE_XTILE_CFG_BIT            17
4841a6
+#define XSTATE_XTILE_DATA_BIT           18
4841a6
 
4841a6
 #define XSTATE_FP_MASK                  (1ULL << XSTATE_FP_BIT)
4841a6
 #define XSTATE_SSE_MASK                 (1ULL << XSTATE_SSE_BIT)
4841a6
@@ -845,6 +847,8 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS];
4841a6
 #define CPUID_7_0_EDX_TSX_LDTRK         (1U << 16)
4841a6
 /* AVX512_FP16 instruction */
4841a6
 #define CPUID_7_0_EDX_AVX512_FP16       (1U << 23)
4841a6
+/* AMX tile (two-dimensional register) */
4841a6
+#define CPUID_7_0_EDX_AMX_TILE          (1U << 24)
4841a6
 /* Speculation Control */
4841a6
 #define CPUID_7_0_EDX_SPEC_CTRL         (1U << 26)
4841a6
 /* Single Thread Indirect Branch Predictors */
4841a6
@@ -1348,6 +1352,16 @@ typedef struct XSavePKRU {
4841a6
     uint32_t padding;
4841a6
 } XSavePKRU;
4841a6
 
4841a6
+/* Ext. save area 17: AMX XTILECFG state */
4841a6
+typedef struct XSaveXTILECFG {
4841a6
+    uint8_t xtilecfg[64];
4841a6
+} XSaveXTILECFG;
4841a6
+
4841a6
+/* Ext. save area 18: AMX XTILEDATA state */
4841a6
+typedef struct XSaveXTILEDATA {
4841a6
+    uint8_t xtiledata[8][1024];
4841a6
+} XSaveXTILEDATA;
4841a6
+
4841a6
 QEMU_BUILD_BUG_ON(sizeof(XSaveAVX) != 0x100);
4841a6
 QEMU_BUILD_BUG_ON(sizeof(XSaveBNDREG) != 0x40);
4841a6
 QEMU_BUILD_BUG_ON(sizeof(XSaveBNDCSR) != 0x40);
4841a6
@@ -1355,6 +1369,8 @@ QEMU_BUILD_BUG_ON(sizeof(XSaveOpmask) != 0x40);
4841a6
 QEMU_BUILD_BUG_ON(sizeof(XSaveZMM_Hi256) != 0x200);
4841a6
 QEMU_BUILD_BUG_ON(sizeof(XSaveHi16_ZMM) != 0x400);
4841a6
 QEMU_BUILD_BUG_ON(sizeof(XSavePKRU) != 0x8);
4841a6
+QEMU_BUILD_BUG_ON(sizeof(XSaveXTILECFG) != 0x40);
4841a6
+QEMU_BUILD_BUG_ON(sizeof(XSaveXTILEDATA) != 0x2000);
4841a6
 
4841a6
 typedef struct ExtSaveArea {
4841a6
     uint32_t feature, bits;
4841a6
@@ -1362,7 +1378,7 @@ typedef struct ExtSaveArea {
4841a6
     uint32_t ecx;
4841a6
 } ExtSaveArea;
4841a6
 
4841a6
-#define XSAVE_STATE_AREA_COUNT (XSTATE_PKRU_BIT + 1)
4841a6
+#define XSAVE_STATE_AREA_COUNT (XSTATE_XTILE_DATA_BIT + 1)
4841a6
 
4841a6
 extern ExtSaveArea x86_ext_save_areas[XSAVE_STATE_AREA_COUNT];
4841a6
 
4841a6
-- 
4841a6
2.35.3
4841a6