thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 6 months ago
Clone

Blame SOURCES/kvm-i386-cpu-Expose-AVX_VNNI-instruction-to-guest.patch

a83cc2
From c24fcdf0712ef81ec25ca3a4a1144cca18303fbe Mon Sep 17 00:00:00 2001
a83cc2
From: "plai@redhat.com" <plai@redhat.com>
a83cc2
Date: Thu, 29 Jul 2021 07:42:19 -0400
a83cc2
Subject: [PATCH 13/39] i386/cpu: Expose AVX_VNNI instruction to guest
a83cc2
a83cc2
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
a83cc2
RH-MergeRequest: 32: Synchronize with RHEL-AV 8.5 release 27 to RHEL 9
a83cc2
RH-Commit: [5/15] 56381e35a1dc06af7d457d1fe61b1c108dd25d06 (mrezanin/centos-src-qemu-kvm)
a83cc2
RH-Bugzilla: 1957194
a83cc2
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
a83cc2
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
a83cc2
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
a83cc2
RH-Acked-by: Andrew Jones <drjones@redhat.com>
a83cc2
a83cc2
Expose AVX (VEX-encoded) versions of the Vector Neural Network
a83cc2
Instructions to guest.
a83cc2
a83cc2
The bit definition:
a83cc2
CPUID.(EAX=7,ECX=1):EAX[bit 4] AVX_VNNI
a83cc2
a83cc2
The following instructions are available when this feature is
a83cc2
present in the guest.
a83cc2
  1. VPDPBUS: Multiply and Add Unsigned and Signed Bytes
a83cc2
  2. VPDPBUSDS: Multiply and Add Unsigned and Signed Bytes with Saturation
a83cc2
  3. VPDPWSSD: Multiply and Add Signed Word Integers
a83cc2
  4. VPDPWSSDS: Multiply and Add Signed Integers with Saturation
a83cc2
a83cc2
As for the kvm related code, please reference Linux commit id 1085a6b585d7.
a83cc2
a83cc2
The release document ref below link:
a83cc2
https://software.intel.com/content/www/us/en/develop/download/\
a83cc2
intel-architecture-instruction-set-extensions-programming-reference.html
a83cc2
a83cc2
Signed-off-by: Yang Zhong <yang.zhong@intel.com>
a83cc2
Message-Id: <20210407015609.22936-1-yang.zhong@intel.com>
a83cc2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
a83cc2
(cherry picked from commit c1826ea6a052084f2e6a0bae9dd5932a727df039)
a83cc2
Signed-off-by: Paul Lai <plai@redhat.com>
a83cc2
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
a83cc2
---
a83cc2
 target/i386/cpu.c | 4 ++--
a83cc2
 target/i386/cpu.h | 2 ++
a83cc2
 2 files changed, 4 insertions(+), 2 deletions(-)
a83cc2
a83cc2
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
a83cc2
index da47c3e50e..0de2932c79 100644
a83cc2
--- a/target/i386/cpu.c
a83cc2
+++ b/target/i386/cpu.c
a83cc2
@@ -996,7 +996,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
a83cc2
         .type = CPUID_FEATURE_WORD,
a83cc2
         .feat_names = {
a83cc2
             NULL, NULL, NULL, NULL,
a83cc2
-            NULL, "avx512-bf16", NULL, NULL,
a83cc2
+            "avx-vnni", "avx512-bf16", NULL, NULL,
a83cc2
             NULL, NULL, NULL, NULL,
a83cc2
             NULL, NULL, NULL, NULL,
a83cc2
             NULL, NULL, NULL, NULL,
a83cc2
@@ -3284,7 +3284,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
a83cc2
             MSR_ARCH_CAP_SKIP_L1DFL_VMENTRY | MSR_ARCH_CAP_MDS_NO |
a83cc2
             MSR_ARCH_CAP_PSCHANGE_MC_NO | MSR_ARCH_CAP_TAA_NO,
a83cc2
         .features[FEAT_7_1_EAX] =
a83cc2
-            CPUID_7_1_EAX_AVX512_BF16,
a83cc2
+            CPUID_7_1_EAX_AVX_VNNI | CPUID_7_1_EAX_AVX512_BF16,
a83cc2
         /* XSAVES is added in version 2 */
a83cc2
         .features[FEAT_XSAVE] =
a83cc2
             CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC |
a83cc2
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
a83cc2
index 570f916878..edc8984448 100644
a83cc2
--- a/target/i386/cpu.h
a83cc2
+++ b/target/i386/cpu.h
a83cc2
@@ -804,6 +804,8 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS];
a83cc2
 /* Speculative Store Bypass Disable */
a83cc2
 #define CPUID_7_0_EDX_SPEC_CTRL_SSBD    (1U << 31)
a83cc2
 
a83cc2
+/* AVX VNNI Instruction */
a83cc2
+#define CPUID_7_1_EAX_AVX_VNNI          (1U << 4)
a83cc2
 /* AVX512 BFloat16 Instruction */
a83cc2
 #define CPUID_7_1_EAX_AVX512_BF16       (1U << 5)
a83cc2
 
a83cc2
-- 
a83cc2
2.27.0
a83cc2