Received: by 10.213.65.68 with SMTP id h4csp444615imn; Tue, 20 Mar 2018 07:05:32 -0700 (PDT) X-Google-Smtp-Source: AG47ELvywtybBnWI+QOF0YCW3U2kErRWqnjTDVn3shRokJJizf80QiD1cosWuijNiACEYYRYQKu7 X-Received: by 2002:a17:902:bc8b:: with SMTP id bb11-v6mr2893308plb.370.1521554732659; Tue, 20 Mar 2018 07:05:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521554732; cv=none; d=google.com; s=arc-20160816; b=GZ51sPCCY4ZoZOGb0VQdmAzw59xX/QO6uyL5cfxTjx2plY0PusP6NQ2t7GFJSbXv97 yhaVGFPRvImV1EOD4CJizP6THsfghr4VJjWkiySMit6N7PqY1prFDt8GHKIJ4fa8JeQU Pjq+fVrS6Lq1Ugnmu0DG5ie6kTO+pdZ2j8s5MAl084CQT46vs8i/+L3PAWCJ5jEYvFKY 8xn8V6kBKWUDPfc+kYCmylBiOYptMSiGL7LRxbCRhgfPAvA+y8TLzxpdlk7YJWBTVTQg fbYAtlrIp1+6eYfwdDIUgzKyKwXFZ0+UX1HpNsj/FQTtm/83Og+9NHD1UVZ8IpweZRy7 1mbg== 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=s585ZZMt2ML4h+u7EYPCMaFs822V9gThTqEQka0koPE=; b=FCOH8SJMDLdlkv9yDMsIQsGLlAc6O36Oil7TBsZziz0XtiEhTMXediczhRLeps2bmV 9SnO9E1gjlv3EAuixQTpobxTAYL9gDkeOMKp8b6meXHBkC59LtG/YtLGEm+ZZ0fbXHJC pTjgcToiujAWt+0IuqtRYVerMIer8teoHPiH+X25Ue7ttZM879EkHgt2NTQlp7mJiMZm EqcWXUgZn62kDELdZWqmEO530yIQyUS55iVVFy6Ae7g+jTyVMptwi1k5sYBlV+c96jX1 p4SYTyao694qnnDZ901lYDDB+8G5p516NSdcbjob1LxSYOTeO+tGLDzIWVLC18R7b8KN kSwg== 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 d14si1255380pgn.306.2018.03.20.07.05.04; Tue, 20 Mar 2018 07:05:32 -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 S1753735AbeCTOCl (ORCPT + 99 others); Tue, 20 Mar 2018 10:02:41 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59154 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753509AbeCTOC3 (ORCPT ); Tue, 20 Mar 2018 10:02:29 -0400 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 CBAF18163C52; Tue, 20 Mar 2018 14:02:28 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0D68215CDC9; Tue, 20 Mar 2018 14:02:26 +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, Thomas Gleixner , Christoph Hellwig Subject: [PATCH v6 6/7] x86/hyper-v: detect nested features Date: Tue, 20 Mar 2018 15:02:10 +0100 Message-Id: <20180320140211.7600-7-vkuznets@redhat.com> In-Reply-To: <20180320140211.7600-1-vkuznets@redhat.com> References: <20180320140211.7600-1-vkuznets@redhat.com> 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.8]); Tue, 20 Mar 2018 14:02:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 20 Mar 2018 14:02:28 +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 Reviewed-by: Michael Kelley Reviewed-by: Thomas Gleixner --- arch/x86/include/asm/hyperv-tlfs.h | 4 ++++ arch/x86/include/asm/mshyperv.h | 1 + arch/x86/kernel/cpu/mshyperv.c | 5 +++++ 3 files changed, 10 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..1afc0a453bba 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -208,6 +208,11 @@ 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