From patchwork Fri Oct 25 09:16:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11211809 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 2E3691390 for ; Fri, 25 Oct 2019 09:18:23 +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 0716D2070B for ; Fri, 25 Oct 2019 09:18:23 +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="cXaqNNMA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0716D2070B 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 1iNviO-0007p0-WA; Fri, 25 Oct 2019 09:17:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNviN-0007oY-Nd for xen-devel@lists.xenproject.org; Fri, 25 Oct 2019 09:16:59 +0000 X-Inumbo-ID: 2aeb47b2-f708-11e9-beca-bc764e2007e4 Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2aeb47b2-f708-11e9-beca-bc764e2007e4; Fri, 25 Oct 2019 09:16:46 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id c22so1241715wmd.1 for ; Fri, 25 Oct 2019 02:16:46 -0700 (PDT) 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=EhsqHaMATtvXE4hbd+Eeu66aFe8FP/Jxe1IdUOxtz0I=; b=cXaqNNMATjfnf//Csgy85n5sfFQ5GaaOMC9FY4AAWj4TcH3tZusKjqY2eGxHZ8DfoO Q+hIOM5DlyZP2Px8OfqP7Ko/+5+7UQ6xfYshHb7cVBx7qrgB0ykb5fZBDAr92hujDrcS DHUgZ8g5YLAB5Ca16VQ+q4Ub6HpRW0BrD5b802aEWxEG5oiLLgMwM8nbnASF4OYFBqQW Nr/cHR7rLwYq8N7FiN5eZckcHtmenfgedpr5GFDvahm3e2cNNskdPGmTiJF6MhH7gZ+a VoR1yezI80LvpJRwt4lwRZmXJo2oRv7r+f052F1yIK0nxWkj/l4P/SRIxpBKyeRP8yAB tf1g== 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=EhsqHaMATtvXE4hbd+Eeu66aFe8FP/Jxe1IdUOxtz0I=; b=DZAvroLU9oBMhgxFlHc6hmLU86uhi5Oxs0hfiJq74yTdGhUqOwa+h4FgCSG42CnF18 g9p5hLScoLK6blTJX1h3f7kmhGYcu9Tmjd7TEegJeEz5S6yRZ6OjLvMg9IuedWGmqhB3 mAeRH3NFo72E17ePC8CXajRU8Wy1rPpq1Y3nFyiBgxpreYCFQ8qLkPy/tBJsjk0MWYCz 4J9knYR/r4Yt+wu8fMcJpKmHcLG+RbkQ6nB1UG4wt38wODcddIjo24zdf753g8A5on1D nG46g/HSfhSVpGSJH/Hvp+WCvVtrmc13fjAAT5YPn1592bZXjMPjXwfzhHoHrIMkUG3d aIAQ== X-Gm-Message-State: APjAAAX+i2WaqIFdoNtCsGd92BMzUXPo7ERJR47wtnkjGl6pgU6MGdm3 IdS1vuNsY0DnTKIX5kxBGp3XjFMCBEg= X-Google-Smtp-Source: APXvYqwxYs/IdBeIJfAqfKEw7+Yqzw9jdJUgPtzZkNr/+Ferlo9A9zAWFAMDffCyXAWUf2jiXIFxSg== X-Received: by 2002:a1c:39c1:: with SMTP id g184mr2507650wma.75.1571995005877; Fri, 25 Oct 2019 02:16:45 -0700 (PDT) Received: from debian.mshome.net (54.163.200.146.dyn.plus.net. [146.200.163.54]) by smtp.gmail.com with ESMTPSA id b62sm1873283wmc.13.2019.10.25.02.16.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 02:16:45 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Fri, 25 Oct 2019 10:16:14 +0100 Message-Id: <20191025091618.10153-4-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191025091618.10153-1-liuwe@microsoft.com> References: <20191025091618.10153-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next 3/7] 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 , Paul Durrant , Andrew Cooper , 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 | 14 ++++++++++++++ xen/include/asm-x86/guest/hyperv.h | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c index 7ab4b127f3..041166f344 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 ms_hyperv; bool __init hyperv_probe(void) { @@ -36,6 +39,17 @@ bool __init hyperv_probe(void) if ( eax != 0x31237648 ) /* Hv#1 */ return false; + /* Extract more information from Hyper-V */ + ms_hyperv.features = cpuid_eax(HYPERV_CPUID_FEATURES); + ms_hyperv.misc_features = cpuid_edx(HYPERV_CPUID_FEATURES); + 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); + + ms_hyperv.max_vp_index = cpuid_eax(HYPERV_CPUID_IMPLEMENT_LIMITS); + ms_hyperv.max_lp_index = cpuid_ebx(HYPERV_CPUID_IMPLEMENT_LIMITS); + return true; } diff --git a/xen/include/asm-x86/guest/hyperv.h b/xen/include/asm-x86/guest/hyperv.h index 4b9cc5a836..0f8800040a 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; + extern struct hypervisor_ops hyperv_ops; bool hyperv_probe(void);