Received: by 10.223.185.111 with SMTP id b44csp348882wrg; Fri, 9 Mar 2018 06:05:36 -0800 (PST) X-Google-Smtp-Source: AG47ELsx9lWbY2QJlrIPCx7wsd6p0Ddst83EOpDhzBIwu37W/OSjSVoXKCWnk5xKqeflxIwxZdKJ X-Received: by 10.98.206.1 with SMTP id y1mr30253986pfg.196.1520604336243; Fri, 09 Mar 2018 06:05:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520604336; cv=none; d=google.com; s=arc-20160816; b=H524cnUNYyPcRlEAfZQnuCVODqh4IiYWPA/bjxBvxa6DiKNYPkmOTB7mYTOZkfplL/ aIuwwOnlOWwIqOIV79YtfOFPh85k+IeA1nxistwcRQGIWyFj4w6tlSCENuKeczejdHG3 Q9z9gqnMheH5D6TIkLAtxGrkgMbgU4DkVZ4XpFtYc87YcX3JJbUS+vCiK8kxxU6t6WLo tn7N1/otju72nErKDEWcbw2pmXihi61dlf0Uav4/kXNEQ2iSyzN3gj9QR58ZlcZ27Zor Dx2yFwRhuSxDqa0G2cRl+kTb2rubUvSMdnJZ3pgJQWtRHh858dDagMmyouhNnYDNyvl/ 7Uig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=miPXnHSZQMQ7VLtLUvLY5eMururcl+JtgJ6yZZrXSug=; b=oyPtc8i7GfVXLrt1lllNfd/TfVfE8JRSKuxzjUh0k01OBy6Elh6hqK2acteE2l5Ngw vpL3eJVqNj3RveCeSW7aDN1QjsYMVmIVfOq0ROiPT0RMby3XfOtVw1+sFhYD4G7YYj2k BjqghlCuviegQjQhYZ4DfsTJgzaue5Of4p5SLAsUDwXb89xmLarH2yAnHBAvvBwA9JgK FTPhBAIYXE2IqgioWEj2CcmrjR8rEWxiEa2e/x6+YaZKa9iXKsgP1/1kPw4gt/5NdaQ1 +S+BFlaQpKtTy5ZjRMp5MHcRRVd6/VnBPLZLq/C9Py1g5nR+aJibukgFj0nQVIgynInU YG+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k4-v6si928052plt.255.2018.03.09.06.04.59; Fri, 09 Mar 2018 06:05:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932173AbeCIODH (ORCPT + 99 others); Fri, 9 Mar 2018 09:03:07 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54742 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932116AbeCIODF (ORCPT ); Fri, 9 Mar 2018 09:03:05 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BAF23406802D; Fri, 9 Mar 2018 14:03:04 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id EAFE5215CDAA; Fri, 9 Mar 2018 14:03:02 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org Cc: x86@kernel.org, Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "Michael Kelley (EOSG)" , Mohammed Gamal , Cathy Avery , Bandan Das , 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 Message-Id: <20180309140249.2840-7-vkuznets@redhat.com> In-Reply-To: <20180309140249.2840-1-vkuznets@redhat.com> References: <20180309140249.2840-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 09 Mar 2018 14:03:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 09 Mar 2018 14:03:04 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'vkuznets@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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