From patchwork Wed Dec 18 14:42:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11300895 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 468A014B7 for ; Wed, 18 Dec 2019 14:43:59 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 223FA21582 for ; Wed, 18 Dec 2019 14:43:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OcgOCgxF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 223FA21582 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ihaXd-0004Z9-8U; Wed, 18 Dec 2019 14:43:09 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ihaXb-0004YR-Qd for xen-devel@lists.xenproject.org; Wed, 18 Dec 2019 14:43:07 +0000 X-Inumbo-ID: a4d68d2c-21a4-11ea-b6f1-bc764e2007e4 Received: from mail-wm1-x344.google.com (unknown [2a00:1450:4864:20::344]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a4d68d2c-21a4-11ea-b6f1-bc764e2007e4; Wed, 18 Dec 2019 14:42:41 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id m24so2097142wmc.3 for ; Wed, 18 Dec 2019 06:42:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BPQxGbYWCz/cDrvGjrtCt3X0aC5XW0YsyQfUDvPNuVA=; b=OcgOCgxFGYca3uDJ6ajjb51HjPU2jYLzYXm26zTldWgmYC5dxl2fTkDg13c3iZYmhg WxieShw19YHzqgPta9RX3LEdSDnyF9NGhPcQFjSRrRicr1EazrVJytdWMavGVlmJl02A +iOaSopGHQkZ0rf2lHtuQpvUI+0NMZjneB6Sn5HI5ivgeuH8IohE8cmBqyhEDTEoe+nB e/xlnd6tlIbCxTQb2CQi6pWqrLVWsbGafsCm2m66hhj6O1Ue6RIG5wgBZusbS3wWjEyH JWsALqkFJcAMpL6/Q2km06tUvFpxu7DozmSddqRZHokJFJBz3LCL2ybmN/LwWz/jTT4e sZ7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=BPQxGbYWCz/cDrvGjrtCt3X0aC5XW0YsyQfUDvPNuVA=; b=knAbfbakrUyXzQTgAQgkvobMVew63aARDEpqGMSivUFFssg1Y0y8LQpsQdC8Sth10K Le9q8A5yCW47kwpSd6RQ8H9bbn45OzeEtvPfPDv3FbvRDeMNB/zJZkpswTxGkgQu0MmT GwEGqMNGk+Cx4jKp6zBM8cr2kGznQaIEyrJkgjMFvyiqFWfy3Gjqb0v3QsdSzk3Er4/v udkJiQSD6jbQ30cO7/C7ZbYqX2/MaYNpaRH6h1a2YXEs3Ybok6DT2F0q2zbhPRPFx1SX h49ApqVCPTzgAAhcpaxdMYpO1kRdC/woGPfLBxC+OoEGgcWOvcCsu5rZnyELzBppbPJ/ ErUQ== X-Gm-Message-State: APjAAAXfzLdSd/g4w/v+SuWHffvYKmUhNlHodqCfrzW6clxmYhrr5SKe sAgYJNh70yaTTg5vFBjdALK7hJq3 X-Google-Smtp-Source: APXvYqyjO7SfPknIFIm91rNcXZ4zuJx78QNgVB54GQEsV6IoxMJRWOKf/pDolK7ViAL7HnjumeVHRg== X-Received: by 2002:a1c:81c9:: with SMTP id c192mr3743069wmd.44.1576680160761; Wed, 18 Dec 2019 06:42:40 -0800 (PST) Received: from debian.mshome.net (38.163.200.146.dyn.plus.net. [146.200.163.38]) by smtp.gmail.com with ESMTPSA id p17sm2724894wmk.30.2019.12.18.06.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2019 06:42:40 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Wed, 18 Dec 2019 14:42:32 +0000 Message-Id: <20191218144233.15372-6-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191218144233.15372-1-liuwe@microsoft.com> References: <20191218144233.15372-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 5/6] x86/hyperv: extract more information from Hyper-V X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Wei Liu , Andrew Cooper , Paul Durrant , Michael Kelley , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Provide a structure to store that information. The structure will be accessed from other places later so make it public. Signed-off-by: Wei Liu Acked-by: Jan Beulich --- xen/arch/x86/guest/hyperv/hyperv.c | 17 +++++++++++++++++ xen/include/asm-x86/guest/hyperv.h | 12 ++++++++++++ 2 files changed, 29 insertions(+) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c index b82ae3833f..2e70b4aa82 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -21,6 +21,9 @@ #include #include +#include + +struct ms_hyperv_info __read_mostly ms_hyperv; static const struct hypervisor_ops ops = { .name = "Hyper-V", @@ -40,6 +43,20 @@ const struct hypervisor_ops *__init hyperv_probe(void) if ( eax != 0x31237648 ) /* Hv#1 */ return NULL; + /* Extract more information from Hyper-V */ + cpuid(HYPERV_CPUID_FEATURES, &eax, &ebx, &ecx, &edx); + ms_hyperv.features = eax; + ms_hyperv.misc_features = edx; + + ms_hyperv.hints = cpuid_eax(HYPERV_CPUID_ENLIGHTMENT_INFO); + + if ( ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED ) + ms_hyperv.nested_features = cpuid_eax(HYPERV_CPUID_NESTED_FEATURES); + + cpuid(HYPERV_CPUID_IMPLEMENT_LIMITS, &eax, &ebx, &ecx, &edx); + ms_hyperv.max_vp_index = eax; + ms_hyperv.max_lp_index = ebx; + return &ops; } diff --git a/xen/include/asm-x86/guest/hyperv.h b/xen/include/asm-x86/guest/hyperv.h index 3f88b94c77..cc21b9abfc 100644 --- a/xen/include/asm-x86/guest/hyperv.h +++ b/xen/include/asm-x86/guest/hyperv.h @@ -21,8 +21,20 @@ #ifdef CONFIG_HYPERV_GUEST +#include + #include +struct ms_hyperv_info { + uint32_t features; + uint32_t misc_features; + uint32_t hints; + uint32_t nested_features; + uint32_t max_vp_index; + uint32_t max_lp_index; +}; +extern struct ms_hyperv_info ms_hyperv; + const struct hypervisor_ops *hyperv_probe(void); #else