|
|
1be5c7 |
From d0826a8c2c3c389eeeed1014d7e316f39f083971 Mon Sep 17 00:00:00 2001
|
|
|
1be5c7 |
From: Jing Liu <jing2.liu@intel.com>
|
|
|
1be5c7 |
Date: Wed, 16 Feb 2022 22:04:31 -0800
|
|
|
1be5c7 |
Subject: [PATCH 09/24] x86: Add AMX CPUIDs enumeration
|
|
|
1be5c7 |
|
|
|
1be5c7 |
RH-Author: Paul Lai <plai@redhat.com>
|
|
|
1be5c7 |
RH-MergeRequest: 176: Enable KVM AMX support
|
|
|
1be5c7 |
RH-Commit: [9/13] fab147992ad927c9538529f018f06e2f48546c5b
|
|
|
1be5c7 |
RH-Bugzilla: 1916415
|
|
|
1be5c7 |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
1be5c7 |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
1be5c7 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
1be5c7 |
|
|
|
1be5c7 |
Add AMX primary feature bits XFD and AMX_TILE to
|
|
|
1be5c7 |
enumerate the CPU's AMX capability. Meanwhile, add
|
|
|
1be5c7 |
AMX TILE and TMUL CPUID leaf and subleaves which
|
|
|
1be5c7 |
exist when AMX TILE is present to provide the maximum
|
|
|
1be5c7 |
capability of TILE and TMUL.
|
|
|
1be5c7 |
|
|
|
1be5c7 |
Signed-off-by: Jing Liu <jing2.liu@intel.com>
|
|
|
1be5c7 |
Signed-off-by: Yang Zhong <yang.zhong@intel.com>
|
|
|
1be5c7 |
Message-Id: <20220217060434.52460-6-yang.zhong@intel.com>
|
|
|
1be5c7 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
1be5c7 |
(cherry picked from commit f21a48171cf3fa39532fc8553fd82e81b88b6474)
|
|
|
1be5c7 |
Signed-off-by: Paul Lai <plai@redhat.com>
|
|
|
1be5c7 |
---
|
|
|
1be5c7 |
target/i386/cpu.c | 55 ++++++++++++++++++++++++++++++++++++++++---
|
|
|
1be5c7 |
target/i386/kvm/kvm.c | 4 +++-
|
|
|
1be5c7 |
2 files changed, 55 insertions(+), 4 deletions(-)
|
|
|
1be5c7 |
|
|
|
1be5c7 |
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
|
|
|
1be5c7 |
index cd27c0eb81..09e08f7f38 100644
|
|
|
1be5c7 |
--- a/target/i386/cpu.c
|
|
|
1be5c7 |
+++ b/target/i386/cpu.c
|
|
|
1be5c7 |
@@ -574,6 +574,18 @@ static CPUCacheInfo legacy_l3_cache = {
|
|
|
1be5c7 |
#define INTEL_PT_CYCLE_BITMAP 0x1fff /* Support 0,2^(0~11) */
|
|
|
1be5c7 |
#define INTEL_PT_PSB_BITMAP (0x003f << 16) /* Support 2K,4K,8K,16K,32K,64K */
|
|
|
1be5c7 |
|
|
|
1be5c7 |
+/* CPUID Leaf 0x1D constants: */
|
|
|
1be5c7 |
+#define INTEL_AMX_TILE_MAX_SUBLEAF 0x1
|
|
|
1be5c7 |
+#define INTEL_AMX_TOTAL_TILE_BYTES 0x2000
|
|
|
1be5c7 |
+#define INTEL_AMX_BYTES_PER_TILE 0x400
|
|
|
1be5c7 |
+#define INTEL_AMX_BYTES_PER_ROW 0x40
|
|
|
1be5c7 |
+#define INTEL_AMX_TILE_MAX_NAMES 0x8
|
|
|
1be5c7 |
+#define INTEL_AMX_TILE_MAX_ROWS 0x10
|
|
|
1be5c7 |
+
|
|
|
1be5c7 |
+/* CPUID Leaf 0x1E constants: */
|
|
|
1be5c7 |
+#define INTEL_AMX_TMUL_MAX_K 0x10
|
|
|
1be5c7 |
+#define INTEL_AMX_TMUL_MAX_N 0x40
|
|
|
1be5c7 |
+
|
|
|
1be5c7 |
void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1,
|
|
|
1be5c7 |
uint32_t vendor2, uint32_t vendor3)
|
|
|
1be5c7 |
{
|
|
|
1be5c7 |
@@ -843,8 +855,8 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
|
|
|
1be5c7 |
"avx512-vp2intersect", NULL, "md-clear", NULL,
|
|
|
1be5c7 |
NULL, NULL, "serialize", NULL,
|
|
|
1be5c7 |
"tsx-ldtrk", NULL, NULL /* pconfig */, NULL,
|
|
|
1be5c7 |
- NULL, NULL, NULL, "avx512-fp16",
|
|
|
1be5c7 |
- NULL, NULL, "spec-ctrl", "stibp",
|
|
|
1be5c7 |
+ NULL, NULL, "amx-bf16", "avx512-fp16",
|
|
|
1be5c7 |
+ "amx-tile", "amx-int8", "spec-ctrl", "stibp",
|
|
|
1be5c7 |
NULL, "arch-capabilities", "core-capability", "ssbd",
|
|
|
1be5c7 |
},
|
|
|
1be5c7 |
.cpuid = {
|
|
|
1be5c7 |
@@ -909,7 +921,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
|
|
|
1be5c7 |
.type = CPUID_FEATURE_WORD,
|
|
|
1be5c7 |
.feat_names = {
|
|
|
1be5c7 |
"xsaveopt", "xsavec", "xgetbv1", "xsaves",
|
|
|
1be5c7 |
- NULL, NULL, NULL, NULL,
|
|
|
1be5c7 |
+ "xfd", NULL, NULL, NULL,
|
|
|
1be5c7 |
NULL, NULL, NULL, NULL,
|
|
|
1be5c7 |
NULL, NULL, NULL, NULL,
|
|
|
1be5c7 |
NULL, NULL, NULL, NULL,
|
|
|
1be5c7 |
@@ -5593,6 +5605,43 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
|
|
|
1be5c7 |
}
|
|
|
1be5c7 |
break;
|
|
|
1be5c7 |
}
|
|
|
1be5c7 |
+ case 0x1D: {
|
|
|
1be5c7 |
+ /* AMX TILE */
|
|
|
1be5c7 |
+ *eax = 0;
|
|
|
1be5c7 |
+ *ebx = 0;
|
|
|
1be5c7 |
+ *ecx = 0;
|
|
|
1be5c7 |
+ *edx = 0;
|
|
|
1be5c7 |
+ if (!(env->features[FEAT_7_0_EDX] & CPUID_7_0_EDX_AMX_TILE)) {
|
|
|
1be5c7 |
+ break;
|
|
|
1be5c7 |
+ }
|
|
|
1be5c7 |
+
|
|
|
1be5c7 |
+ if (count == 0) {
|
|
|
1be5c7 |
+ /* Highest numbered palette subleaf */
|
|
|
1be5c7 |
+ *eax = INTEL_AMX_TILE_MAX_SUBLEAF;
|
|
|
1be5c7 |
+ } else if (count == 1) {
|
|
|
1be5c7 |
+ *eax = INTEL_AMX_TOTAL_TILE_BYTES |
|
|
|
1be5c7 |
+ (INTEL_AMX_BYTES_PER_TILE << 16);
|
|
|
1be5c7 |
+ *ebx = INTEL_AMX_BYTES_PER_ROW | (INTEL_AMX_TILE_MAX_NAMES << 16);
|
|
|
1be5c7 |
+ *ecx = INTEL_AMX_TILE_MAX_ROWS;
|
|
|
1be5c7 |
+ }
|
|
|
1be5c7 |
+ break;
|
|
|
1be5c7 |
+ }
|
|
|
1be5c7 |
+ case 0x1E: {
|
|
|
1be5c7 |
+ /* AMX TMUL */
|
|
|
1be5c7 |
+ *eax = 0;
|
|
|
1be5c7 |
+ *ebx = 0;
|
|
|
1be5c7 |
+ *ecx = 0;
|
|
|
1be5c7 |
+ *edx = 0;
|
|
|
1be5c7 |
+ if (!(env->features[FEAT_7_0_EDX] & CPUID_7_0_EDX_AMX_TILE)) {
|
|
|
1be5c7 |
+ break;
|
|
|
1be5c7 |
+ }
|
|
|
1be5c7 |
+
|
|
|
1be5c7 |
+ if (count == 0) {
|
|
|
1be5c7 |
+ /* Highest numbered palette subleaf */
|
|
|
1be5c7 |
+ *ebx = INTEL_AMX_TMUL_MAX_K | (INTEL_AMX_TMUL_MAX_N << 8);
|
|
|
1be5c7 |
+ }
|
|
|
1be5c7 |
+ break;
|
|
|
1be5c7 |
+ }
|
|
|
1be5c7 |
case 0x40000000:
|
|
|
1be5c7 |
/*
|
|
|
1be5c7 |
* CPUID code in kvm_arch_init_vcpu() ignores stuff
|
|
|
1be5c7 |
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
|
|
|
1be5c7 |
index b5d98c4361..a64a79d870 100644
|
|
|
1be5c7 |
--- a/target/i386/kvm/kvm.c
|
|
|
1be5c7 |
+++ b/target/i386/kvm/kvm.c
|
|
|
1be5c7 |
@@ -1779,7 +1779,9 @@ int kvm_arch_init_vcpu(CPUState *cs)
|
|
|
1be5c7 |
c = &cpuid_data.entries[cpuid_i++];
|
|
|
1be5c7 |
}
|
|
|
1be5c7 |
break;
|
|
|
1be5c7 |
- case 0x14: {
|
|
|
1be5c7 |
+ case 0x14:
|
|
|
1be5c7 |
+ case 0x1d:
|
|
|
1be5c7 |
+ case 0x1e: {
|
|
|
1be5c7 |
uint32_t times;
|
|
|
1be5c7 |
|
|
|
1be5c7 |
c->function = i;
|
|
|
1be5c7 |
--
|
|
|
1be5c7 |
2.35.3
|
|
|
1be5c7 |
|