All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: kvm@vger.kernel.org
Cc: x86@kernel.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	"Haiyang Zhang" <haiyangz@microsoft.com>,
	"Stephen Hemminger" <sthemmin@microsoft.com>,
	"Michael Kelley (EOSG)" <Michael.H.Kelley@microsoft.com>,
	"Mohammed Gamal" <mmorsy@redhat.com>,
	"Cathy Avery" <cavery@redhat.com>, "Bandan Das" <bsd@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v3 6/7] x86/hyper-v: detect nested features
Date: Fri,  9 Mar 2018 15:02:48 +0100	[thread overview]
Message-ID: <20180309140249.2840-7-vkuznets@redhat.com> (raw)
In-Reply-To: <20180309140249.2840-1-vkuznets@redhat.com>

TLFS 5.0 says: "Support for an enlightened VMCS interface is reported with
CPUID leaf 0x40000004. If an enlightened VMCS interface is supported,
 additional nested enlightenments may be discovered by reading the CPUID
leaf 0x4000000A (see 2.4.11)."

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
Changes since v2:
- define HV_X64_ENLIGHTENED_VMCS_VERSION [Radim Krčmář]
---
 arch/x86/include/asm/hyperv-tlfs.h | 4 ++++
 arch/x86/include/asm/mshyperv.h    | 1 +
 arch/x86/kernel/cpu/mshyperv.c     | 4 ++++
 3 files changed, 9 insertions(+)

diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h
index 472dc38110fa..2e2f0a741e84 100644
--- a/arch/x86/include/asm/hyperv-tlfs.h
+++ b/arch/x86/include/asm/hyperv-tlfs.h
@@ -14,6 +14,7 @@
 #define HYPERV_CPUID_FEATURES			0x40000003
 #define HYPERV_CPUID_ENLIGHTMENT_INFO		0x40000004
 #define HYPERV_CPUID_IMPLEMENT_LIMITS		0x40000005
+#define HYPERV_CPUID_NESTED_FEATURES		0x4000000A
 
 #define HYPERV_HYPERVISOR_PRESENT_BIT		0x80000000
 #define HYPERV_CPUID_MIN			0x40000005
@@ -332,6 +333,9 @@ struct hv_tsc_emulation_status {
 #define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_MASK	\
 		(~((1ull << HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT) - 1))
 
+/* Hyper-V Enlightened VMCS version mask in nested features CPUID */
+#define HV_X64_ENLIGHTENED_VMCS_VERSION		0xff
+
 #define HV_X64_MSR_TSC_REFERENCE_ENABLE		0x00000001
 #define HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT	12
 
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index dcb40567b35e..cc784b1f6bf1 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -13,6 +13,7 @@ struct ms_hyperv_info {
 	u32 features;
 	u32 misc_features;
 	u32 hints;
+	u32 nested_features;
 	u32 max_vp_index;
 	u32 max_lp_index;
 };
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 0dfc568c110c..8432bf215e30 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -208,6 +208,10 @@ static void __init ms_hyperv_init_platform(void)
 		x86_platform.calibrate_cpu = hv_get_tsc_khz;
 	}
 
+	if (ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED)
+		ms_hyperv.nested_features =
+			cpuid_eax(HYPERV_CPUID_NESTED_FEATURES);
+
 #ifdef CONFIG_X86_LOCAL_APIC
 	if (ms_hyperv.features & HV_X64_ACCESS_FREQUENCY_MSRS &&
 	    ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) {
-- 
2.14.3

  parent reply	other threads:[~2018-03-09 14:03 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-09 14:02 [PATCH v3 0/7] Enlightened VMCS support for KVM on Hyper-V Vitaly Kuznetsov
2018-03-09 14:02 ` [PATCH v3 1/7] x86/hyper-v: move hyperv.h out of uapi Vitaly Kuznetsov
2018-03-13 22:46   ` Michael Kelley (EOSG)
2018-03-14  9:35     ` Vitaly Kuznetsov
2018-03-14 16:13   ` Christoph Hellwig
2018-03-14 16:42     ` Joshua R. Poulson
2018-03-15  7:31       ` Christoph Hellwig
2018-03-09 14:02 ` [PATCH v3 2/7] x86/hyper-v: move definitions from TLFS to hyperv-tlfs.h Vitaly Kuznetsov
2018-03-13 22:51   ` Michael Kelley (EOSG)
2018-03-09 14:02 ` [PATCH v3 3/7] x86/kvm: rename HV_X64_MSR_APIC_ASSIST_PAGE to HV_X64_MSR_VP_ASSIST_PAGE Vitaly Kuznetsov
2018-03-09 14:02 ` [PATCH v3 4/7] x86/hyper-v: allocate and use Virtual Processor Assist Pages Vitaly Kuznetsov
2018-03-13 23:08   ` Michael Kelley (EOSG)
2018-03-14 15:15   ` Thomas Gleixner
2018-03-15 10:10     ` Vitaly Kuznetsov
2018-03-15 11:45       ` Thomas Gleixner
2018-03-15 13:48         ` Peter Zijlstra
2018-03-15 13:57           ` Thomas Gleixner
2018-03-09 14:02 ` [PATCH v3 5/7] x86/hyper-v: define struct hv_enlightened_vmcs and clean field bits Vitaly Kuznetsov
2018-03-13 23:09   ` Michael Kelley (EOSG)
2018-03-09 14:02 ` Vitaly Kuznetsov [this message]
2018-03-13 23:11   ` [PATCH v3 6/7] x86/hyper-v: detect nested features Michael Kelley (EOSG)
2018-03-09 14:02 ` [PATCH v3 7/7] x86/kvm: use Enlightened VMCS when running on Hyper-V Vitaly Kuznetsov
2018-03-09 14:08   ` Thomas Gleixner
2018-03-12 14:19     ` Vitaly Kuznetsov
2018-03-13 19:12       ` Radim Krčmář
2018-03-14 17:20         ` Vitaly Kuznetsov
2018-03-14 14:54       ` Paolo Bonzini
2018-03-14 15:19       ` Thomas Gleixner
2018-03-14 17:22         ` Vitaly Kuznetsov
2018-03-14 19:59           ` Thomas Gleixner
2018-03-14 20:06             ` Peter Zijlstra
2018-03-14 14:53   ` Paolo Bonzini
2018-03-15  9:56     ` Vitaly Kuznetsov
2018-03-15 11:01       ` Paolo Bonzini
2018-03-15 15:19     ` Vitaly Kuznetsov
2018-03-15 17:02       ` Radim Krčmář
2018-03-15 17:28         ` Radim Krčmář
2018-03-15 18:04           ` Vitaly Kuznetsov
2018-03-15 19:28         ` Thomas Gleixner
2018-03-15 19:43           ` Radim Krčmář

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=20180309140249.2840-7-vkuznets@redhat.com \
    --to=vkuznets@redhat.com \
    --cc=Michael.H.Kelley@microsoft.com \
    --cc=bsd@redhat.com \
    --cc=cavery@redhat.com \
    --cc=haiyangz@microsoft.com \
    --cc=kvm@vger.kernel.org \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmorsy@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=sthemmin@microsoft.com \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.