thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
4841a6
From 6eae12166341c236da023e5117b64b842ae72083 Mon Sep 17 00:00:00 2001
4841a6
From: Jing Liu <jing2.liu@intel.com>
4841a6
Date: Wed, 16 Feb 2022 22:04:27 -0800
4841a6
Subject: [PATCH 05/24] x86: Fix the 64-byte boundary enumeration for extended
4841a6
 state
4841a6
4841a6
RH-Author: Paul Lai <plai@redhat.com>
4841a6
RH-MergeRequest: 176: Enable KVM AMX support
4841a6
RH-Commit: [5/13] 64fc93e3b0ad0fc56da9d71b33d9eefd3cbba1d7
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 extended state subleaves (EAX=0Dh, ECX=n, n>1).ECX[1]
4841a6
indicate whether the extended state component locates
4841a6
on the next 64-byte boundary following the preceding state
4841a6
component when the compacted format of an XSAVE area is
4841a6
used.
4841a6
4841a6
Right now, they are all zero because no supported component
4841a6
needed the bit to be set, but the upcoming AMX feature will
4841a6
use it.  Fix the subleaves value according to KVM's supported
4841a6
cpuid.
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-2-yang.zhong@intel.com>
4841a6
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4841a6
(cherry picked from commit 131266b7565bd437127bd231563572696bb27235)
4841a6
Signed-off-by: Paul Lai <plai@redhat.com>
4841a6
---
4841a6
 target/i386/cpu.c         | 1 +
4841a6
 target/i386/cpu.h         | 6 ++++++
4841a6
 target/i386/kvm/kvm-cpu.c | 1 +
4841a6
 3 files changed, 8 insertions(+)
4841a6
4841a6
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
4841a6
index dd6935b1dd..f44fad3a2a 100644
4841a6
--- a/target/i386/cpu.c
4841a6
+++ b/target/i386/cpu.c
4841a6
@@ -5495,6 +5495,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
4841a6
                 const ExtSaveArea *esa = &x86_ext_save_areas[count];
4841a6
                 *eax = esa->size;
4841a6
                 *ebx = esa->offset;
4841a6
+                *ecx = esa->ecx & ESA_FEATURE_ALIGN64_MASK;
4841a6
             }
4841a6
         }
4841a6
         break;
4841a6
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
4841a6
index c6a6c871f1..5d9702a991 100644
4841a6
--- a/target/i386/cpu.h
4841a6
+++ b/target/i386/cpu.h
4841a6
@@ -548,6 +548,11 @@ typedef enum X86Seg {
4841a6
 #define XSTATE_Hi16_ZMM_MASK            (1ULL << XSTATE_Hi16_ZMM_BIT)
4841a6
 #define XSTATE_PKRU_MASK                (1ULL << XSTATE_PKRU_BIT)
4841a6
 
4841a6
+#define ESA_FEATURE_ALIGN64_BIT         1
4841a6
+
4841a6
+#define ESA_FEATURE_ALIGN64_MASK        (1U << ESA_FEATURE_ALIGN64_BIT)
4841a6
+
4841a6
+
4841a6
 /* CPUID feature words */
4841a6
 typedef enum FeatureWord {
4841a6
     FEAT_1_EDX,         /* CPUID[1].EDX */
4841a6
@@ -1354,6 +1359,7 @@ QEMU_BUILD_BUG_ON(sizeof(XSavePKRU) != 0x8);
4841a6
 typedef struct ExtSaveArea {
4841a6
     uint32_t feature, bits;
4841a6
     uint32_t offset, size;
4841a6
+    uint32_t ecx;
4841a6
 } ExtSaveArea;
4841a6
 
4841a6
 #define XSAVE_STATE_AREA_COUNT (XSTATE_PKRU_BIT + 1)
4841a6
diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c
4841a6
index 7b004065ae..86ef7b2712 100644
4841a6
--- a/target/i386/kvm/kvm-cpu.c
4841a6
+++ b/target/i386/kvm/kvm-cpu.c
4841a6
@@ -104,6 +104,7 @@ static void kvm_cpu_xsave_init(void)
4841a6
             if (sz != 0) {
4841a6
                 assert(esa->size == sz);
4841a6
                 esa->offset = kvm_arch_get_supported_cpuid(s, 0xd, i, R_EBX);
4841a6
+                esa->ecx = kvm_arch_get_supported_cpuid(s, 0xd, i, R_ECX);
4841a6
             }
4841a6
         }
4841a6
     }
4841a6
-- 
4841a6
2.35.3
4841a6