From patchwork Tue Jun 28 05:51:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luwei Kang X-Patchwork-Id: 9201891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 594736074E for ; Tue, 28 Jun 2016 05:54:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BBB0285D1 for ; Tue, 28 Jun 2016 05:54:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CE72285E9; Tue, 28 Jun 2016 05:54:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1E6A6285D1 for ; Tue, 28 Jun 2016 05:54:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHlwO-0004PE-Dy; Tue, 28 Jun 2016 05:52:08 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHlwN-0004P8-FK for xen-devel@lists.xen.org; Tue, 28 Jun 2016 05:52:07 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 9C/49-18304-58012775; Tue, 28 Jun 2016 05:52:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsXS1tbhqNsqUBR u0LtM1mLJx8UsDoweR3f/ZgpgjGLNzEvKr0hgzWja2sZW0KRW0XRyK3sD43vpLkZODiGBSomr 838xgdgSArwSR5bNYIWw/SUWPz/LCFezcSsziM0moC6x9f1GsBoRAWmJa58vA9VwcTALtDJK/ Dg0GSwhLGAqcf/aXLBmFgFVif4LC4GaOTh4BZwlplwXgZgvJ3HzXCfzBEbuBYwMqxg1ilOLyl KLdI3M9JKKMtMzSnITM3N0DQ2M9XJTi4sT01NzEpOK9ZLzczcxAr1bz8DAuIOxYa/fIUZJDiY lUd4FDEXhQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4p/MD5QSLUtNTK9Iyc4BhBpOW4OBREuH9 wweU5i0uSMwtzkyHSJ1iVJQS55UD6RMASWSU5sG1wUL7EqOslDAvIwMDgxBPQWpRbmYJqvwrR nEORiVh3iCQKTyZeSVw018BLWYCWsxanQ+yuCQRISXVwLjm74Oi07svS32QKJ706Huy8M8psy LfSx9japz8bqLRcV3ZI9L+XRsXT/33MInjcXym+LeYg5nW75MyqhI8o5u2tFe+EuDbnbHrZuj HIxvP7jENlFpUu9KL4ZvZ6xLT8qjomdf0PZ59q2w8eGVKhpvTnP0K/v1tf/VYb5rtz07sVozc NLFg73IlluKMREMt5qLiRACTWgyVaAIAAA== X-Env-Sender: luwei.kang@intel.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1467093124!21376297!1 X-Originating-IP: [134.134.136.65] X-SpamReason: No, hits=0.0 required=7.0 tests=UPPERCASE_25_50 X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37059 invoked from network); 28 Jun 2016 05:52:04 -0000 Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by server-11.tower-31.messagelabs.com with SMTP; 28 Jun 2016 05:52:04 -0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 27 Jun 2016 22:52:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,539,1459839600"; d="scan'208";a="726055744" Received: from vmm-dell.bj.intel.com ([10.238.145.44]) by FMSMGA003.fm.intel.com with ESMTP; 27 Jun 2016 22:51:58 -0700 From: Luwei Kang To: xen-devel@lists.xen.org Date: Tue, 28 Jun 2016 13:51:46 +0800 Message-Id: <1467093106-3444-1-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 2.7.4 Cc: andrew.cooper3@citrix.com, chao.p.peng@intel.com, Luwei Kang , yong.y.wang@intel.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH] x86/cpuid: AVX-512 Feature Detection X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP AVX-512 is an extention of AVX2. Its spec can be found at: https://software.intel.com/sites/default/files/managed/b4/3a/319433-024.pdf This patch detects AVX-512 features by CPUID. Signed-off-by: Luwei Kang --- xen/arch/x86/hvm/hvm.c | 8 ++++++++ xen/arch/x86/traps.c | 17 ++++++++++++++++- xen/include/public/arch-x86/cpufeatureset.h | 9 +++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index c89ab6e..693afd5 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -3474,6 +3474,14 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx, xstate_sizes[_XSTATE_BNDCSR]); } + if ( _ebx & cpufeat_mask(X86_FEATURE_AVX512F) ) + { + xfeature_mask |= XSTATE_OPMASK | XSTATE_ZMM | XSTATE_HI_ZMM; + xstate_size = max(xstate_size, + xstate_offsets[_XSTATE_HI_ZMM] + + xstate_sizes[_XSTATE_HI_ZMM]); + } + if ( _ecx & cpufeat_mask(X86_FEATURE_PKU) ) { xfeature_mask |= XSTATE_PKRU; diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 767d0b0..1c75e93 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -975,7 +975,7 @@ void pv_cpuid(struct cpu_user_regs *regs) switch ( leaf ) { - uint32_t tmp, _ecx; + uint32_t tmp, _ecx, _ebx; case 0x00000001: c &= pv_featureset[FEATURESET_1c]; @@ -1136,9 +1136,16 @@ void pv_cpuid(struct cpu_user_regs *regs) case XSTATE_CPUID: if ( !is_control_domain(currd) && !is_hardware_domain(currd) ) + { domain_cpuid(currd, 1, 0, &tmp, &tmp, &_ecx, &tmp); + domain_cpuid(currd, 0x07, 0, &tmp, &_ebx, &tmp, &tmp); + } else + { _ecx = cpuid_ecx(1); + cpuid_count(0x07, 0, &tmp, &_ebx, &tmp, &tmp); + } + _ecx &= pv_featureset[FEATURESET_1c]; if ( !(_ecx & cpufeat_mask(X86_FEATURE_XSAVE)) || subleaf >= 63 ) @@ -1157,6 +1164,14 @@ void pv_cpuid(struct cpu_user_regs *regs) xstate_sizes[_XSTATE_YMM]); } + if ( _ebx & cpufeat_mask(X86_FEATURE_AVX512F) ) + { + xfeature_mask |= XSTATE_OPMASK | XSTATE_ZMM | XSTATE_HI_ZMM; + xstate_size = max(xstate_size, + xstate_offsets[_XSTATE_HI_ZMM] + + xstate_sizes[_XSTATE_HI_ZMM]); + } + a = (uint32_t)xfeature_mask; d = (uint32_t)(xfeature_mask >> 32); c = xstate_size; diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h index 39acf8c..9320c9e 100644 --- a/xen/include/public/arch-x86/cpufeatureset.h +++ b/xen/include/public/arch-x86/cpufeatureset.h @@ -206,15 +206,24 @@ XEN_CPUFEATURE(PQM, 5*32+12) /* Platform QoS Monitoring */ XEN_CPUFEATURE(NO_FPU_SEL, 5*32+13) /*! FPU CS/DS stored as zero */ XEN_CPUFEATURE(MPX, 5*32+14) /*S Memory Protection Extensions */ XEN_CPUFEATURE(PQE, 5*32+15) /* Platform QoS Enforcement */ +XEN_CPUFEATURE(AVX512F, 5*32+16) /*A AVX-512 Foundation Instructions */ +XEN_CPUFEATURE(AVX512DQ, 5*32+17) /*A AVX-512 Doubleword & Quadword Instrs */ XEN_CPUFEATURE(RDSEED, 5*32+18) /*A RDSEED instruction */ XEN_CPUFEATURE(ADX, 5*32+19) /*A ADCX, ADOX instructions */ XEN_CPUFEATURE(SMAP, 5*32+20) /*S Supervisor Mode Access Prevention */ +XEN_CPUFEATURE(AVX512IFMA, 5*32+21) /*A AVX-512 Integer Fused Multiply Add */ XEN_CPUFEATURE(CLFLUSHOPT, 5*32+23) /*A CLFLUSHOPT instruction */ XEN_CPUFEATURE(CLWB, 5*32+24) /*A CLWB instruction */ +XEN_CPUFEATURE(AVX512PF, 5*32+26) /*A AVX-512 Prefetch Instructions */ +XEN_CPUFEATURE(AVX512ER, 5*32+27) /*A AVX-512 Exponent & Reciprocal Instrs */ +XEN_CPUFEATURE(AVX512CD, 5*32+28) /*A AVX-512 Conflict Detection Instrs */ XEN_CPUFEATURE(SHA, 5*32+29) /*A SHA1 & SHA256 instructions */ +XEN_CPUFEATURE(AVX512BW, 5*32+30) /*A AVX-512 Byte and Word Instructions */ +XEN_CPUFEATURE(AVX512VL, 5*32+31) /*A AVX-512 Vector Length Extensions */ /* Intel-defined CPU features, CPUID level 0x00000007:0.ecx, word 6 */ XEN_CPUFEATURE(PREFETCHWT1, 6*32+ 0) /*A PREFETCHWT1 instruction */ +XEN_CPUFEATURE(AVX512VBMI, 6*32+ 1) /*A AVX-512 Vector Byte Manipulation Instrs */ XEN_CPUFEATURE(PKU, 6*32+ 3) /*H Protection Keys for Userspace */ XEN_CPUFEATURE(OSPKE, 6*32+ 4) /*! OS Protection Keys Enable */