From patchwork Fri Feb 10 12:33:50 2017 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: 9566683 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 02D9060572 for ; Fri, 10 Feb 2017 12:36:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E155D283E2 for ; Fri, 10 Feb 2017 12:36:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D41C728569; Fri, 10 Feb 2017 12:36:38 +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 CE75F283E2 for ; Fri, 10 Feb 2017 12:36:37 +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 1ccAP2-0002ps-DQ; Fri, 10 Feb 2017 12:34:16 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ccAP1-0002pJ-Gy for xen-devel@lists.xenproject.org; Fri, 10 Feb 2017 12:34:15 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 1D/56-27165-643BD985; Fri, 10 Feb 2017 12:34:14 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEIsWRWlGSWpSXmKPExsXitHRDpK7b5rk RBnMnyFp83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBlNbfvYCr5JVJyZ8pa5gfGJUBcjJ4eEgL/E p+1LmUFsNgEdiYtzd7KB2CICsRLrGq8ydTFycDALlEvMuBEPEhYWMJOYdPk0K4jNIqAq0X9tG QtICa+ApcTfS9EQE/Ukdh35zQoS5hSwkni03R8kLARU8eVjDxOIzSsgKHFy5hMWEJtZQFOidf tvdghbXqJ562xmiHpFif55D9gmMPLNQtIyC0nLLCQtCxiZVzFqFKcWlaUW6Rqa6SUVZaZnlOQ mZuboGhqY6eWmFhcnpqfmJCYV6yXn525iBIYZAxDsYLy/MeAQoyQHk5Io7/cZcyOE+JLyUyoz Eosz4otKc1KLDzFqcHAIbF67+gKjFEtefl6qkgSvziagOsGi1PTUirTMHGAkwJRKcPAoifC+2 AiU5i0uSMwtzkyHSJ1i1OU4deP0SyYhsBlS4rxXQYoEQIoySvPgRsCi8hKjrJQwLyPQgUI8Ba lFuZklqPKvGMU5GJWEee1ALuHJzCuB2/QK6AgmoCOun54FckRJIkJKqoExmXOm602Vbe/i4hW vNPGx6141vuzQLJWcsHeZVdPEbGmvMj025rAVJ/kVAzW3e8YdcdBsCJvFmraN92bqrslyjxVM 5GPPL9RWDhRNkirY1GomJqnH8MH43KmJ0Z/eqb/82Hauh8l4re+OUzn3b1epPotMCoqZxmKze f7+t9MqNab2Fk98M12JpTgj0VCLuag4EQAMDFLoxQIAAA== X-Env-Sender: prvs=2075b848f=roger.pau@citrix.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1486730053!86121493!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25372 invoked from network); 10 Feb 2017 12:34:14 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-3.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 10 Feb 2017 12:34:14 -0000 X-IronPort-AV: E=Sophos;i="5.35,141,1484006400"; d="scan'208";a="406062266" From: Roger Pau Monne To: , , Date: Fri, 10 Feb 2017 12:33:50 +0000 Message-ID: <20170210123351.73526-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20170210123351.73526-1-roger.pau@citrix.com> References: <20170210123351.73526-1-roger.pau@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Jan Beulich , Roger Pau Monne Subject: [Xen-devel] [PATCH v6 6/7] xen/x86: Setup PVHv2 Dom0 CPUs 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 Initialize Dom0 BSP/APs and setup the memory and IO permissions. This also sets the initial BSP state in order to match the protocol specified in docs/misc/hvmlite.markdown. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper --- Changes since v5: - Make cpus and i unsigned ints. - Use an initializer for cpu_ctx (and remove the memset). - Move the clear_bit of vcpu 0 the end of pvh_setup_cpus. --- xen/arch/x86/domain_build.c | 61 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c index 407e479..1ff2ddb 100644 --- a/xen/arch/x86/domain_build.c +++ b/xen/arch/x86/domain_build.c @@ -41,6 +41,7 @@ #include #include #include +#include static long __initdata dom0_nrpages; static long __initdata dom0_min_nrpages; @@ -2142,6 +2143,59 @@ static int __init pvh_load_kernel(struct domain *d, const module_t *image, return 0; } +static int __init pvh_setup_cpus(struct domain *d, paddr_t entry, + paddr_t start_info) +{ + struct vcpu *v = d->vcpu[0]; + unsigned int cpu, i; + int rc; + /* + * This sets the vCPU state according to the state described in + * docs/misc/hvmlite.markdown. + */ + vcpu_hvm_context_t cpu_ctx = { + .mode = VCPU_HVM_MODE_32B, + .cpu_regs.x86_32.ebx = start_info, + .cpu_regs.x86_32.eip = entry, + .cpu_regs.x86_32.cr0 = X86_CR0_PE | X86_CR0_ET, + .cpu_regs.x86_32.cs_limit = ~0u, + .cpu_regs.x86_32.ds_limit = ~0u, + .cpu_regs.x86_32.ss_limit = ~0u, + .cpu_regs.x86_32.tr_limit = 0x67, + .cpu_regs.x86_32.cs_ar = 0xc9b, + .cpu_regs.x86_32.ds_ar = 0xc93, + .cpu_regs.x86_32.ss_ar = 0xc93, + .cpu_regs.x86_32.tr_ar = 0x8b, + }; + + cpu = v->processor; + for ( i = 1; i < d->max_vcpus; i++ ) + { + cpu = cpumask_cycle(cpu, &dom0_cpus); + setup_dom0_vcpu(d, i, cpu); + } + + rc = arch_set_info_hvm_guest(v, &cpu_ctx); + if ( rc ) + { + printk("Unable to setup Dom0 BSP context: %d\n", rc); + return rc; + } + + rc = setup_permissions(d); + if ( rc ) + { + panic("Unable to setup Dom0 permissions: %d\n", rc); + return rc; + } + + update_domain_wallclock_time(d); + + clear_bit(_VPF_down, &v->pause_flags); + + return 0; +} + static int __init construct_dom0_pvh(struct domain *d, const module_t *image, unsigned long image_headroom, module_t *initrd, @@ -2170,6 +2224,13 @@ static int __init construct_dom0_pvh(struct domain *d, const module_t *image, return rc; } + rc = pvh_setup_cpus(d, entry, start_info); + if ( rc ) + { + printk("Failed to setup Dom0 CPUs: %d\n", rc); + return rc; + } + panic("Building a PVHv2 Dom0 is not yet supported."); return 0; }