From: Jing Liu <jing2.liu@linux.intel.com>
To: pbonzini@redhat.com, kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, jing2.liu@intel.com,
jing2.liu@linux.intel.com
Subject: [PATCH RFC] kvm: x86: Expose AVX512_BF16 feature to guest
Date: Thu, 20 Jun 2019 19:21:52 +0800 [thread overview]
Message-ID: <1561029712-11848-2-git-send-email-jing2.liu@linux.intel.com> (raw)
In-Reply-To: <1561029712-11848-1-git-send-email-jing2.liu@linux.intel.com>
AVX512 BFLOAT16 instructions support 16-bit BFLOAT16 floating-point
format (BF16) for deep learning optimization.
Intel adds AVX512 BFLOAT16 feature in CooperLake, which is CPUID.7.1.EAX[5].
Detailed information of the CPUID bit can be found here,
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf.
Signed-off-by: Jing Liu <jing2.liu@linux.intel.com>
---
arch/x86/kvm/cpuid.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index e18a9f9..10be53f 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -484,6 +484,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
entry->edx = 0;
break;
case 7: {
+ int i, times = entry->eax;
entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
/* Mask ebx against host capability word 9 */
if (index == 0) {
@@ -507,12 +508,23 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
* if the host doesn't support it.
*/
entry->edx |= F(ARCH_CAPABILITIES);
- } else {
+ } else if (index > times) {
+ entry->eax = 0;
entry->ebx = 0;
entry->ecx = 0;
entry->edx = 0;
}
- entry->eax = 0;
+ for (i = 1; i <= times; i++) {
+ if (*nent >= maxnent)
+ goto out;
+ do_cpuid_1_ent(&entry[i], function, i);
+ entry[i].eax &= F(AVX512_BF16);
+ entry[i].ebx = 0;
+ entry[i].ecx = 0;
+ entry[i].edx = 0;
+ entry[i].flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
+ ++*nent;
+ }
break;
}
case 9:
--
1.8.3.1
next prev parent reply other threads:[~2019-06-20 11:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-20 11:21 [PATCH RFC] kvm: x86: AVX512_BF16 feature support Jing Liu
2019-06-20 11:21 ` Jing Liu [this message]
2019-06-20 12:16 ` [PATCH RFC] kvm: x86: Expose AVX512_BF16 feature to guest Paolo Bonzini
2019-06-20 15:09 ` Liu, Jing2
2019-06-24 3:10 ` Jing Liu
2019-06-24 8:33 ` Paolo Bonzini
2019-06-24 12:06 ` Jing Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1561029712-11848-2-git-send-email-jing2.liu@linux.intel.com \
--to=jing2.liu@linux.intel.com \
--cc=jing2.liu@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox