From: Like Xu <like.xu@linux.intel.com>
To: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>, Len Brown <lenb@kernel.org>,
linux-kernel@vger.kernel.org, like.xu@linux.intel.com
Subject: [PATCH] KVM: x86: Add Intel CPUID.1F cpuid emulation support
Date: Mon, 22 Apr 2019 14:40:34 +0800 [thread overview]
Message-ID: <1555915234-2536-1-git-send-email-like.xu@linux.intel.com> (raw)
Expose Intel V2 Extended Topology Enumeration Leaf to guest only when
host system has multiple software-visible die within each package.
Signed-off-by: Like Xu <like.xu@linux.intel.com>
---
arch/x86/kvm/cpuid.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index fd39516..9fc14f2 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -65,6 +65,16 @@ u64 kvm_supported_xcr0(void)
return xcr0;
}
+/* We need to check if the host cpu has multi-chip packaging technology. */
+static bool kvm_supported_intel_mcp(void)
+{
+ u32 eax, ignored;
+
+ cpuid_count(0x1f, 0, &eax, &ignored, &ignored, &ignored);
+
+ return boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && (eax != 0);
+}
+
#define F(x) bit(X86_FEATURE_##x)
int kvm_update_cpuid(struct kvm_vcpu *vcpu)
@@ -426,6 +436,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
switch (function) {
case 0:
entry->eax = min(entry->eax, (u32)(f_intel_pt ? 0x14 : 0xd));
+ entry->eax = kvm_supported_intel_mcp() ? 0x1f : entry->eax;
break;
case 1:
entry->edx &= kvm_cpuid_1_edx_x86_features;
@@ -544,6 +555,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
entry->edx = edx.full;
break;
}
+ /* function 0x1f has additional index. */
+ case 0x1f:
/* function 0xb has additional index. */
case 0xb: {
int i, level_type;
--
1.8.3.1
next reply other threads:[~2019-04-22 6:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-22 6:40 Like Xu [this message]
2019-04-22 15:53 ` [PATCH] KVM: x86: Add Intel CPUID.1F cpuid emulation support Konrad Rzeszutek Wilk
2019-04-22 16:56 ` Sean Christopherson
2019-04-22 18:35 ` Sean Christopherson
2019-04-23 3:23 ` Like Xu
2019-04-23 17:44 ` Sean Christopherson
2019-04-24 1:59 ` Like Xu
2019-04-24 13:53 ` Sean Christopherson
2019-04-24 14:32 ` Sean Christopherson
2019-04-25 2:58 ` Like Xu
2019-04-25 4:18 ` Xiaoyao Li
2019-04-25 6:02 ` Like Xu
2019-04-25 6:30 ` Xiaoyao Li
2019-04-25 7:07 ` Like Xu
2019-04-25 14:19 ` Sean Christopherson
2019-04-25 15:33 ` Like Xu
2019-04-25 16:28 ` Xiaoyao Li
2019-04-26 1:30 ` Like Xu
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=1555915234-2536-1-git-send-email-like.xu@linux.intel.com \
--to=like.xu@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
/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