From patchwork Wed Feb 22 14:24:58 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: 9586915 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 24C84600CA for ; Wed, 22 Feb 2017 14:27:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 064ED2867D for ; Wed, 22 Feb 2017 14:27:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF56D286BB; Wed, 22 Feb 2017 14:27:31 +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 C3EC92867D for ; Wed, 22 Feb 2017 14:27:30 +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 1cgXr4-0008TS-5S; Wed, 22 Feb 2017 14:25:18 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cgXr3-0008SN-8H for xen-devel@lists.xenproject.org; Wed, 22 Feb 2017 14:25:17 +0000 Received: from [85.158.137.68] by server-16.bemta-3.messagelabs.com id AB/5A-20923-C4F9DA85; Wed, 22 Feb 2017 14:25:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMIsWRWlGSWpSXmKPExsXitHSDva7P/LU RBnMvs1p83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmfJ71iLFgsWXH4nEgDY69wFyMnh4SAv8Sq KV9ZQWw2AR2Ji3N3snUxcnCICKhI3N5r0MXIxcEssIFR4tyPvewgNcICZhKHDh9kAbFZBFQlJ rzdDmbzClhK/J+6mglipp7EriO/wWZyClhJrOr7zggyUwio5uqaaIhyQYmTM5+AtTILaEq0bv /NDmHLSzRvnc0MYgsJKEr0z3vANoGRbxaSlllIWmYhaVnAyLyKUaM4tagstUjX0FIvqSgzPaM kNzEzR9fQwFgvN7W4ODE9NScxqVgvOT93EyMw0OoZGBh3MP4+7neIUZKDSUmU92H22gghvqT8 lMqMxOKM+KLSnNTiQ4waHBwCm9euvsAoxZKXn5eqJMErPA+oTrAoNT21Ii0zBxgLMKUSHDxKI rytIGne4oLE3OLMdIjUKUZdjlM3Tr9kEgKbISXOmwlSJABSlFGaBzcCFpeXGGWlhHkZGRgYhH gKUotyM0tQ5V8xinMwKgnzpoBM4cnMK4Hb9AroCCagIyydwY4oSURISTUwShzW4X17m2fZvf+ H/z/86th44PZaFq+K3x2xoVJsh5lnKIqv3fxA9FHzmmsKTrPy4oKMj+SEHEo7xSQbsZXh88VL 3bM7lmnOm8EfMP1c94FLgW8bC48ujP6bw8/wOctQ803cza1yvLXtj+7t37v9qOutyWtNfLbE9 vDz2et8fXwgzFXOifdWsRJLcUaioRZzUXEiAN2F+CbGAgAA X-Env-Sender: prvs=219821433=roger.pau@citrix.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1487773513!79308846!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 48349 invoked from network); 22 Feb 2017 14:25:15 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-16.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 22 Feb 2017 14:25:15 -0000 X-IronPort-AV: E=Sophos;i="5.35,194,1484006400"; d="scan'208";a="417767905" From: Roger Pau Monne To: Date: Wed, 22 Feb 2017 14:24:58 +0000 Message-ID: <20170222142459.28199-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20170222142459.28199-1-roger.pau@citrix.com> References: <20170222142459.28199-1-roger.pau@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , boris.ostrovsky@oracle.com, Roger Pau Monne , Jan Beulich Subject: [Xen-devel] [PATCH v7 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 a47b8d2..d5abc9c 100644 --- a/xen/arch/x86/domain_build.c +++ b/xen/arch/x86/domain_build.c @@ -40,6 +40,7 @@ #include #include #include +#include static long __initdata dom0_nrpages; static long __initdata dom0_min_nrpages; @@ -2146,6 +2147,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, @@ -2174,6 +2228,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; }