From patchwork Wed Mar 22 12:15:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 9638645 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 66CF4602CB for ; Wed, 22 Mar 2017 12:18:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 576012846B for ; Wed, 22 Mar 2017 12:18:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C1392846D; Wed, 22 Mar 2017 12:18:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AF0AB2846C for ; Wed, 22 Mar 2017 12:18:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cqfBN-0003vn-3D; Wed, 22 Mar 2017 12:16:05 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cqfBM-0003vN-Ag for xen-devel@lists.xenproject.org; Wed, 22 Mar 2017 12:16:04 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id EF/3B-23854-30B62D85; Wed, 22 Mar 2017 12:16:03 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMIsWRWlGSWpSXmKPExsXitHSDvS5z9qU Ig/evuSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oy9t1eyFvRpVHzYto+lgfGyfBcjB4eEgL/E kflWXYycHGwCOhJTn15iBQmLCKhI3N5rAGIyC5RLdEyoBakQFgiXuHBzASuIzSKgKrH0/S0wm 1fAXWLhs0tsILaEgJzE+eM/mUFsTgEPidu/p7GBjBECqulZGgkSFgIavn7qLDaIVkGJkzOfsI DYzAISEgdfvGCewMg7C0lqFpLUAkamVYwaxalFZalFuoZGeklFmekZJbmJmTm6hgbGermpxcW J6ak5iUnFesn5uZsYgUHDAAQ7GF91Ox9ilORgUhLlLf9xIkKILyk/pTIjsTgjvqg0J7X4EKMM B4eSBK8ySE6wKDU9tSItMwcYvjBpCQ4eJRHeyyBp3uKCxNzizHSI1ClGY445s3e/YeK41bDnD ZMQS15+XqqUOK8MSKkASGlGaR7cIFhcXWKUlRLmZQQ6TYinILUoN7MEVf4VozgHo5IwbyrIFJ 7MvBK4fa+ATmECOuXtB7BTShIRUlINjDN+W4Svurr0yjoXjjmHp51/HOrP+OaJ2GcOHznupVt Y057ovWfJfrDjTfmm3ojfth4LYk/cf/Zp+Wvhz83ebRrG/lGf5isGN/aUHPj7S29X/0rvKTZ+ YkwrgjJyp2tv28gQx7hUIYIx7mBvdNNHt4UTJ8b0Wn8+cfXsvcPX9lvLyjWwzWh8fk6JpTgj0 VCLuag4EQDfhgcSpgIAAA== X-Env-Sender: prvs=2479a8bc7=Paul.Durrant@citrix.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1490184960!74709977!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 38063 invoked from network); 22 Mar 2017 12:16:02 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-12.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 22 Mar 2017 12:16:02 -0000 X-IronPort-AV: E=Sophos;i="5.36,205,1486425600"; d="scan'208";a="424179049" From: Paul Durrant To: Date: Wed, 22 Mar 2017 12:15:22 +0000 Message-ID: <1490184924-20156-2-git-send-email-paul.durrant@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1490184924-20156-1-git-send-email-paul.durrant@citrix.com> References: <1490184924-20156-1-git-send-email-paul.durrant@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Paul Durrant , Jan Beulich Subject: [Xen-devel] [PATCH v4 1/3] x86/viridian: don't put Xen version information in CPUID leaf 2 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The Hypervisor Top Level Functional Specification v5.0a states in section 2.5: "The hypervisor version information is encoded in leaf 0x40000002. Two version numbers are provided: the main version and the service version. The main version includes a major and minor version number and a build number. These correspond to Microsoft Windows release numbers." It also goes on to advise clients (i.e. guest versions of Windows) to use the following algorithm to determine compatibility with the hypervisor enlightenments: if greater than { your version is compatible } else if equal to and greater than or equal to { your version is compatible } else { your version is NOT compatible } So, clearly putting Xen hypervisor version information in that leaf is spurious, but we probably get away with it because Xen's major version is lower than the major version of Windows in which Hyper-V first appeared (Server 2008). This patch changes the leaf to use the kernel major and minor versions, and build number from Windows Server 2008 (64-bit) by default. These default values can be overriden from the Xen command line using new 'viridian-version' parameter. Signed-off-by: Paul Durrant --- Cc: Jan Beulich Cc: Andrew Cooper v4: - Make elements of viridian-version parameter optional - Use custom_param() - Constify a pointer v3: - Use a combined version parameter v2: - Use full version information (including build number) from Windows Server 2008 - Add command line parameters to allow version information to be overridden --- docs/misc/xen-command-line.markdown | 8 +++++ xen/arch/x86/hvm/viridian.c | 59 +++++++++++++++++++++++++++++++++++-- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown index bad20db..c81d693 100644 --- a/docs/misc/xen-command-line.markdown +++ b/docs/misc/xen-command-line.markdown @@ -1616,6 +1616,14 @@ The optional `keep` parameter causes Xen to continue using the vga console even after dom0 has been started. The default behaviour is to relinquish control to dom0. +### viridian-version +> `= [],[],[]` + +> Default: `6,0,0x1772` + +, and must be integers. The values will be +encoded in guest CPUID 0x40000002 if viridian enlightenments are enabled. + ### vpid (Intel) > `= ` diff --git a/xen/arch/x86/hvm/viridian.c b/xen/arch/x86/hvm/viridian.c index b740224..3d58416 100644 --- a/xen/arch/x86/hvm/viridian.c +++ b/xen/arch/x86/hvm/viridian.c @@ -164,6 +164,16 @@ typedef struct { #define CPUID6A_MSR_BITMAPS (1 << 1) #define CPUID6A_NESTED_PAGING (1 << 3) +/* + * Version and build number reported by CPUID leaf 2 + * + * These numbers are chosen to match the version numbers reported by + * Windows Server 2008. + */ +static uint16_t viridian_major = 6; +static uint16_t viridian_minor = 0; +static uint32_t viridian_build = 0x1772; + void cpuid_viridian_leaves(const struct vcpu *v, uint32_t leaf, uint32_t subleaf, struct cpuid_leaf *res) { @@ -194,8 +204,8 @@ void cpuid_viridian_leaves(const struct vcpu *v, uint32_t leaf, own version number. */ if ( d->arch.hvm_domain.viridian.guest_os_id.raw == 0 ) break; - res->a = 1; /* Build number */ - res->b = (xen_major_version() << 16) | xen_minor_version(); + res->a = viridian_build; + res->b = ((uint32_t)viridian_major << 16) | viridian_minor; res->c = 0; /* SP */ res->d = 0; /* Service branch and number */ break; @@ -990,6 +1000,51 @@ static int viridian_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t *h) HVM_REGISTER_SAVE_RESTORE(VIRIDIAN_VCPU, viridian_save_vcpu_ctxt, viridian_load_vcpu_ctxt, 1, HVMSR_PER_VCPU); +static void __init parse_viridian_version(char *arg) +{ + const char *t; + long n[3]; + unsigned int i = 0; + + if ( !arg ) + return; + + while ( (t = strsep(&arg, ",")) != NULL ) + { + const char *e; + + if ( *t == '\0' ) + { + n[i++] = -1; + continue; + } + + n[i++] = simple_strtoul(t, &e, 0); + if ( *e != '\0' ) + goto fail; + } + if ( i != 3 ) + goto fail; + + if ( n[0] > 0xffff || n[1] > 0xffff || n[2] > 0xffffffff ) + goto fail; + + if ( n[0] >= 0 ) + viridian_major = n[0]; + if ( n[1] >= 0 ) + viridian_minor = n[1]; + if ( n[2] >= 0 ) + viridian_build = n[2]; + + printk("Overriding viridian-version to %#x,%#x,%#x\n", + viridian_major, viridian_minor, viridian_build); + return; + +fail: + printk(XENLOG_WARNING "Invalid viridian-version, using default\n"); +} +custom_param("viridian-version", parse_viridian_version); + /* * Local variables: * mode: C