Received: by 10.213.65.68 with SMTP id h4csp425350imn; Fri, 16 Mar 2018 07:24:28 -0700 (PDT) X-Google-Smtp-Source: AG47ELtCoTnNnjaWdwoqpqgt9PV50rt0T1IKCeN4rSBCEmdFnG9c69wdyPLHd2iRtaKt4zkCHpsk X-Received: by 2002:a17:902:12e:: with SMTP id 43-v6mr2311973plb.77.1521210268156; Fri, 16 Mar 2018 07:24:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521210268; cv=none; d=google.com; s=arc-20160816; b=mShVH5VAFfN3pZ1KNHa7qXD5V1mKa1CQQ5UwlO8ah/hXZpacudVLTL/qXPfmpfVXt6 WIK1i78b6G4focJWCbw1/n3gIEARx5tBq559GDkISUQTmp7Hyi0kXopDy7F7Wv80oI0B f7pXv7tgaaRF0CcT0awT+imT1WFVforQcVF5eIczdNFKct5f1lbxhJNKKYgcthSkJYP1 XtrsMKdXUE+l1fkUuW207HQPRAanjpJAWg8Hsx1Rlj/tWcH93XZs53eJBX4EEyE7Mfbh WxRDVS0lQKBeUtMjtUKhmFk5JcQvfAnVJJp2seGS7SQVE0tE3oBPg7qUVxnqnq3PKMTF N/CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=m8CTv+/SniJrhN/oJ7fpQN6ZquJYYrf60naxosVy0Bc=; b=BgEGDfeXltrRkFRC1xDxfSadskVHgYHCuZqsnkgSq7C7AUfXTDa4H7JdOcZOJPtkX7 HWkcl4NdF3NP2/jO3IcHXKc3y0unms15AqzBP/o4QJPv8rl4Cklvu5Vt8l+9jzW7HUbZ 3SdpjuZ5w58ro63/EmT5NPs49rsqRULnJW2zHF0iLWt+DRerd/K7xUHvyeUS6lC+mj4k NxuYMY7azyTcnMCQP4Ta2xPJrzUYRMZJ67b42rAitPTq/XjPQyFkE49faYFkMRriX1ED C5TcMGIUdaVPEtzqo92gRJLMRVhIn8nfEkThMjsZ2Y+SKth9xVj9rdYeuOzi9mOxSlXQ jJzw== 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-v6si6394239pln.103.2018.03.16.07.24.13; Fri, 16 Mar 2018 07:24:28 -0700 (PDT) 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 S1753253AbeCPOWm (ORCPT + 99 others); Fri, 16 Mar 2018 10:22:42 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60258 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753236AbeCPOWi (ORCPT ); Fri, 16 Mar 2018 10:22:38 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 339A4EAE80; Fri, 16 Mar 2018 14:22:38 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B7BA2026E0E; Fri, 16 Mar 2018 14:22:36 +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 , Thomas Gleixner , Christoph Hellwig , linux-kernel@vger.kernel.org Subject: [PATCH v4 6/7] x86/hyper-v: detect nested features Date: Fri, 16 Mar 2018 15:22:19 +0100 Message-Id: <20180316142220.32506-7-vkuznets@redhat.com> In-Reply-To: <20180316142220.32506-1-vkuznets@redhat.com> References: <20180316142220.32506-1-vkuznets@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 16 Mar 2018 14:22:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 16 Mar 2018 14:22:38 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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 Reviewed-by: Michael Kelley --- 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 07e0547ae8b8..99139c8e952b 100644 --- a/arch/x86/include/asm/hyperv-tlfs.h +++ b/arch/x86/include/asm/hyperv-tlfs.h @@ -21,6 +21,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 @@ -339,6 +340,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 3f162353f180..57c65315b60b 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