Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1519636

[PATCH v6 3/3] x86/kvm: Add AVX512_4VNNIW and AVX512_4FMAPS support

From He Chen <he.chen@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH v6 3/3] x86/kvm: Add AVX512_4VNNIW and AVX512_4FMAPS support
Date 2016-11-11 10:30 +0100
Message-ID <sCgjL-2rf-9@gated-at.bofh.it> (permalink)
References <sCgjL-2rf-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Add two new AVX512 subfeatures support for KVM guest.

AVX512_4VNNIW:
Vector instructions for deep learning enhanced word variable precision.

AVX512_4FMAPS:
Vector instructions for deep learning floating-point single precision.

Reviewed-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Luwei Kang <luwei.kang@intel.com>
Signed-off-by: He Chen <he.chen@linux.intel.com>
---
 arch/x86/kvm/cpuid.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index afa7bbb..ddcdf7c 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -16,6 +16,7 @@
 #include <linux/export.h>
 #include <linux/vmalloc.h>
 #include <linux/uaccess.h>
+#include <asm/processor.h>
 #include <asm/fpu/internal.h> /* For use_eager_fpu.  Ugh! */
 #include <asm/user.h>
 #include <asm/fpu/xstate.h>
@@ -65,6 +66,11 @@ u64 kvm_supported_xcr0(void)
 
 #define F(x) bit(X86_FEATURE_##x)
 
+/* These are scattered features in cpufeatures.h. */
+#define KVM_CPUID_BIT_AVX512_4VNNIW     2
+#define KVM_CPUID_BIT_AVX512_4FMAPS     3
+#define KF(x) bit(KVM_CPUID_BIT_##x)
+
 int kvm_update_cpuid(struct kvm_vcpu *vcpu)
 {
 	struct kvm_cpuid_entry2 *best;
@@ -376,6 +382,10 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 	/* cpuid 7.0.ecx*/
 	const u32 kvm_cpuid_7_0_ecx_x86_features = F(PKU) | 0 /*OSPKE*/;
 
+	/* cpuid 7.0.edx*/
+	const u32 kvm_cpuid_7_0_edx_x86_features =
+		KF(AVX512_4VNNIW) | KF(AVX512_4FMAPS);
+
 	/* all calls to cpuid_count() should be made on the same cpu */
 	get_cpu();
 
@@ -458,12 +468,14 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 			/* PKU is not yet implemented for shadow paging. */
 			if (!tdp_enabled)
 				entry->ecx &= ~F(PKU);
+			entry->edx &= kvm_cpuid_7_0_edx_x86_features;
+			entry->edx &= get_scattered_cpuid_leaf(7, 0, CPUID_EDX);
 		} else {
 			entry->ebx = 0;
 			entry->ecx = 0;
+			entry->edx = 0;
 		}
 		entry->eax = 0;
-		entry->edx = 0;
 		break;
 	}
 	case 9:
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v6 0/3] x86/kvm: Support AVX512_4VNNIW and AVX512_4FMAPS for KVM guest He Chen <he.chen@linux.intel.com> - 2016-11-11 10:30 +0100
  [PATCH v6 3/3] x86/kvm: Add AVX512_4VNNIW and AVX512_4FMAPS support He Chen <he.chen@linux.intel.com> - 2016-11-11 10:30 +0100
    Re: [PATCH v6 3/3] x86/kvm: Add AVX512_4VNNIW and AVX512_4FMAPS  support Borislav Petkov <bp@alien8.de> - 2016-11-12 14:00 +0100
      Re: [PATCH v6 3/3] x86/kvm: Add AVX512_4VNNIW and AVX512_4FMAPS  support He Chen <he.chen@linux.intel.com> - 2016-11-14 02:50 +0100
        Re: [PATCH v6 3/3] x86/kvm: Add AVX512_4VNNIW and AVX512_4FMAPS  support Borislav Petkov <bp@alien8.de> - 2016-11-14 07:00 +0100
          [Patch v6.1] x86/kvm: Add AVX512_4VNNIW and AVX512_4FMAPS support He Chen <he.chen@linux.intel.com> - 2016-11-14 09:50 +0100
            Re: [Patch v6.1] x86/kvm: Add AVX512_4VNNIW and AVX512_4FMAPS support kbuild test robot <lkp@intel.com> - 2016-11-14 21:30 +0100
              Re: [Patch v6.1] x86/kvm: Add AVX512_4VNNIW and AVX512_4FMAPS support He Chen <he.chen@linux.intel.com> - 2016-11-15 07:10 +0100
                Re: [kbuild-all] [Patch v6.1] x86/kvm: Add AVX512_4VNNIW and  AVX512_4FMAPS support Fengguang Wu <lkp@intel.com> - 2016-11-15 07:50 +0100
                Re: [kbuild-all] [Patch v6.1] x86/kvm: Add AVX512_4VNNIW and  AVX512_4FMAPS support Ye Xiaolong <xiaolong.ye@intel.com> - 2016-11-21 04:20 +0100
            Re: [Patch v6.1] x86/kvm: Add AVX512_4VNNIW and AVX512_4FMAPS support Radim Krčmář <rkrcmar@redhat.com> - 2016-11-16 22:30 +0100
          Re: [PATCH v6 3/3] x86/kvm: Add AVX512_4VNNIW and AVX512_4FMAPS  support He Chen <he.chen@linux.intel.com> - 2016-11-14 10:00 +0100
  [PATCH v6 1/3] x86/cpuid: Cleanup cpuid_regs definitions He Chen <he.chen@linux.intel.com> - 2016-11-11 10:30 +0100
    [tip:x86/cpufeature] x86/cpuid: Cleanup cpuid_regs definitions tip-bot for He Chen <tipbot@zytor.com> - 2016-11-16 11:20 +0100
  [PATCH v6 2/3] x86/cpuid: Add a helper in scattered.c to return cpuid He Chen <he.chen@linux.intel.com> - 2016-11-11 10:30 +0100
    [tip:x86/cpufeature] x86/cpuid: Provide get_scattered_cpuid_leaf() tip-bot for He Chen <tipbot@zytor.com> - 2016-11-16 11:30 +0100
  Re: [PATCH v6 0/3] x86/kvm: Support AVX512_4VNNIW and AVX512_4FMAPS  for KVM guest Thomas Gleixner <tglx@linutronix.de> - 2016-11-16 11:20 +0100
    Re: [PATCH v6 0/3] x86/kvm: Support AVX512_4VNNIW and AVX512_4FMAPS  for KVM guest Radim Krčmář <rkrcmar@redhat.com> - 2016-11-16 22:20 +0100

csiph-web