From patchwork Wed Nov 30 16:49:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 9454621 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 B2BB360235 for ; Wed, 30 Nov 2016 16:55:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B8F7219AC for ; Wed, 30 Nov 2016 16:55:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9070028471; Wed, 30 Nov 2016 16:55:32 +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 01406219AC for ; Wed, 30 Nov 2016 16:55:32 +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 1cC88V-0003HB-8K; Wed, 30 Nov 2016 16:53:35 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cC88T-0003FJ-Hy for xen-devel@lists.xenproject.org; Wed, 30 Nov 2016 16:53:33 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 80/07-28694-C040F385; Wed, 30 Nov 2016 16:53:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrIIsWRWlGSWpSXmKPExsXitHSDvS4Pi32 Ewfr14hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bnOXNYC/5pVRy/d5m5gXGiYhcjJ4eEgL/E irenGEFsNgEdiYtzd7KB2CICsRLrGq8ydTFycDALlEvMuBEPYgoLuEo0n5IHqWARUJX4+/YGC 4jNK2AlMe/LHlaIiboSt5ftYgcp5wSKfziqDmIKCVhKtG2uhKgWlDg58wlYJ7OApkTr9t/sEL a8RPPW2cwgtpCAokT/vAdsExj5ZiFpmYWkZRaSlgWMzKsYNYpTi8pSi3SNzPSSijLTM0pyEzN zdA0NzPRyU4uLE9NTcxKTivWS83M3MQKDjAEIdjCeWRB4iFGSg0lJlPcog32EEF9SfkplRmJx RnxRaU5q8SFGDQ4Ogc1rV19glGLJy89LVZLgbWUCqhMsSk1PrUjLzAHGAUypBAePkghvJUiat 7ggMbc4Mx0idYpRl+PfnFcPmITAZkiJ88aBFAmAFGWU5sGNgMXkJUZZKWFeRqADhXgKUotyM0 tQ5V8xinMwKgnzLgCZwpOZVwK36RXQEUxAR7x9bQ1yREkiQkqqgXHOuVmHUqo6Wu6czL7wk1M uuOmWcPn8nfG3l92rOfqQa+eh41+acs+dUQzde9xsoerqn6UqU3PitXYuk8xzK+osLvqnEHBc b4p/qrv5bMUPF79d16y93fRgjfVKrTM+h6+HTb9z9qSGifmn/9an/dsdrvC+UORKZZ539kP2Q oNZTgsts/q4jtcosRRnJBpqMRcVJwIASHojz8QCAAA= X-Env-Sender: prvs=1355645f8=roger.pau@citrix.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1480524808!70346847!3 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.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 59290 invoked from network); 30 Nov 2016 16:53:32 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-7.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 30 Nov 2016 16:53:32 -0000 X-IronPort-AV: E=Sophos;i="5.31,574,1473120000"; d="scan'208";a="401046924" From: Roger Pau Monne To: , , Date: Wed, 30 Nov 2016 16:49:45 +0000 Message-ID: <20161130164950.43543-10-roger.pau@citrix.com> X-Mailer: git-send-email 2.9.3 (Apple Git-75) In-Reply-To: <20161130164950.43543-1-roger.pau@citrix.com> References: <20161130164950.43543-1-roger.pau@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Jan Beulich , Roger Pau Monne Subject: [Xen-devel] [PATCH v4 09/14] xen/x86: split Dom0 build into PV and PVHv2 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 Split the Dom0 builder into two different functions, one for PV (and classic PVH), and another one for PVHv2. Introduce a new command line parameter called 'dom0' that can be used to request the creation of a PVHv2 Dom0 by setting the 'hvm' sub-option. A panic has also been added if a user tries to use dom0=hvm until all the code is in place, then the panic will be removed. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- Changes since v3: - Correctly declare the parameter list. - Add a panic if dom0=hvm is used. This will be removed once all the code is in place. Changes since v2: - Fix coding style. - Introduce a new dom0 option that allows passing several parameters. Currently supported ones are hvm and shadow. Changes since RFC: - Add documentation for the new command line option. - Simplify the logic in construct_dom0. --- docs/misc/xen-command-line.markdown | 17 +++++++++++++++++ xen/arch/x86/domain_build.c | 28 +++++++++++++++++++++++---- xen/arch/x86/setup.c | 38 +++++++++++++++++++++++++++++++++++++ xen/include/asm-x86/setup.h | 6 ++++++ 4 files changed, 85 insertions(+), 4 deletions(-) diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown index 0138978..c9729be 100644 --- a/docs/misc/xen-command-line.markdown +++ b/docs/misc/xen-command-line.markdown @@ -656,6 +656,23 @@ affinities to prefer but be not limited to the specified node(s). Pin dom0 vcpus to their respective pcpus +### dom0 +> `= List of [ hvm | shadow ]` + +> Sub-options: + +> `hvm` + +> Default: `false` + +Flag that makes a dom0 boot in PVHv2 mode. + +> `shadow` + +> Default: `false` + +Flag that makes a dom0 use shadow paging. + ### dom0pvh > `= ` diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c index 1e557b9..2c9ebf2 100644 --- a/xen/arch/x86/domain_build.c +++ b/xen/arch/x86/domain_build.c @@ -191,10 +191,8 @@ struct vcpu *__init alloc_dom0_vcpu0(struct domain *dom0) } #ifdef CONFIG_SHADOW_PAGING -static bool_t __initdata opt_dom0_shadow; +bool __initdata opt_dom0_shadow; boolean_param("dom0_shadow", opt_dom0_shadow); -#else -#define opt_dom0_shadow 0 #endif static char __initdata opt_dom0_ioports_disable[200] = ""; @@ -951,7 +949,7 @@ static int __init setup_permissions(struct domain *d) return rc; } -int __init construct_dom0( +static int __init construct_dom0_pv( struct domain *d, const module_t *image, unsigned long image_headroom, module_t *initrd, @@ -1655,6 +1653,28 @@ out: return rc; } +static int __init construct_dom0_hvm(struct domain *d, const module_t *image, + unsigned long image_headroom, + module_t *initrd, + void *(*bootstrap_map)(const module_t *), + char *cmdline) +{ + + printk("** Building a PVH Dom0 **\n"); + + return 0; +} + +int __init construct_dom0(struct domain *d, const module_t *image, + unsigned long image_headroom, module_t *initrd, + void *(*bootstrap_map)(const module_t *), + char *cmdline) +{ + + return (is_hvm_domain(d) ? construct_dom0_hvm : construct_dom0_pv) + (d, image, image_headroom, initrd,bootstrap_map, cmdline); +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index b130671..255e20c 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -187,6 +187,35 @@ static void __init parse_acpi_param(char *s) } } +/* + * List of parameters that affect Dom0 creation: + * + * - hvm Create a PVHv2 Dom0. + * - shadow Use shadow paging for Dom0. + */ +static bool __initdata dom0_hvm; +static void __init parse_dom0_param(char *s) +{ + char *ss; + + do { + + ss = strchr(s, ','); + if ( ss ) + *ss = '\0'; + + if ( !strcmp(s, "hvm") ) + dom0_hvm = true; +#ifdef CONFIG_SHADOW_PAGING + else if ( !strcmp(s, "shadow") ) + opt_dom0_shadow = true; +#endif + + s = ss + 1; + } while ( ss ); +} +custom_param("dom0", parse_dom0_param); + static const module_t *__initdata initial_images; static unsigned int __initdata nr_initial_images; @@ -1541,6 +1570,15 @@ void __init noreturn __start_xen(unsigned long mbi_p) if ( opt_dom0pvh ) domcr_flags |= DOMCRF_pvh | DOMCRF_hap; + if ( dom0_hvm ) + { + panic("Building a PVHv2 Dom0 is not yet supported."); + domcr_flags |= DOMCRF_hvm | + ((hvm_funcs.hap_supported && !opt_dom0_shadow) ? + DOMCRF_hap : 0); + config.emulation_flags = XEN_X86_EMU_LAPIC|XEN_X86_EMU_IOAPIC; + } + /* Create initial domain 0. */ dom0 = domain_create(0, domcr_flags, 0, &config); if ( IS_ERR(dom0) || (alloc_dom0_vcpu0(dom0) == NULL) ) diff --git a/xen/include/asm-x86/setup.h b/xen/include/asm-x86/setup.h index c65b79c..c4179d1 100644 --- a/xen/include/asm-x86/setup.h +++ b/xen/include/asm-x86/setup.h @@ -57,4 +57,10 @@ extern uint8_t kbd_shift_flags; extern unsigned long highmem_start; #endif +#ifdef CONFIG_SHADOW_PAGING +extern bool opt_dom0_shadow; +#else +#define opt_dom0_shadow 0 +#endif + #endif