From patchwork Thu Jan 19 17:29:40 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: 9526525 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 9B6B46020B for ; Thu, 19 Jan 2017 17:32:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D36828623 for ; Thu, 19 Jan 2017 17:32:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8158C2863A; Thu, 19 Jan 2017 17:32: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 785FC28623 for ; Thu, 19 Jan 2017 17:32:36 +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 1cUGXF-00069N-VN; Thu, 19 Jan 2017 17:30:05 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cUGXE-0005xL-8Y for xen-devel@lists.xenproject.org; Thu, 19 Jan 2017 17:30:04 +0000 Received: from [193.109.254.147] by server-1.bemta-6.messagelabs.com id A2/23-27678-B97F0885; Thu, 19 Jan 2017 17:30:03 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCIsWRWlGSWpSXmKPExsXitHRDpO7s7w0 RBq8fMFp83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBlN3x8zFlwUq5iw27CB8ZBgFyMnh4SAv8ST 79+ZQWw2AR2Ji3N3snUxcnCICKhI3N5r0MXIxcEssIFR4tyPvewgNcICZhKn+w6B2SwCqhJz5 61mA7F5BSwlfh7fyQQxU09i15HfrCA2p4CVxMXPG8BqhIBqZrzpYIaoF5Q4OfMJC4jNLKAp0b r9NzuELS/RvHU2M0S9okT/vAdsExj5ZiFpmYWkZRaSlgWMzKsYNYpTi8pSi3SNLPWSijLTM0p yEzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQJDjQEIdjAeWBR4iFGSg0lJlHf3x4YIIb6k/JTK jMTijPii0pzU4kOMGhwcApvXrr7AKMWSl5+XqiTBu/gbUJ1gUWp6akVaZg4wGmBKJTh4lER4o 0DSvMUFibnFmekQqVOMuhynbpx+ySQENkNKnDcHpEgApCijNA9uBCwyLzHKSgnzMgIdKMRTkF qUm1mCKv+KUZyDUUmYNxlkCk9mXgncpldARzABHWGlXA9yREkiQkqqgdF1echO92PPH7ImdvU fKVr/IcQyoOC0ovD8cyZKNzlC3rEt7TuT2h2mFzn/hKzwT18/oaNsvWqMOgGCryaefGCw9Yvc F6Wq7F4m7iUKDd3FK32KbkV8e/JjQcLkLVt+3Tj3J1i1KuLmHuP11tEH1F3sPJyN8zcF7d9a7 CDi77feipsv6Wl4qBJLcUaioRZzUXEiABgsZqXHAgAA X-Env-Sender: prvs=1851ba1ec=roger.pau@citrix.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1484846998!73290184!3 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.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2910 invoked from network); 19 Jan 2017 17:30:02 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-13.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 19 Jan 2017 17:30:02 -0000 X-IronPort-AV: E=Sophos;i="5.33,254,1477958400"; d="scan'208";a="400810809" From: Roger Pau Monne To: Date: Thu, 19 Jan 2017 17:29:40 +0000 Message-ID: <20170119172941.65642-9-roger.pau@citrix.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20170119172941.65642-1-roger.pau@citrix.com> References: <20170119172941.65642-1-roger.pau@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , boris.ostrovsky@oracle.com, Roger Pau Monne , Jan Beulich , konrad.wilk@oracle.com Subject: [Xen-devel] [PATCH v5 8/9] 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 hvm/start_info.h. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- --- xen/arch/x86/domain_build.c | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c index 55caa30..ca5d393 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; @@ -2096,6 +2097,56 @@ 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) +{ + vcpu_hvm_context_t cpu_ctx; + struct vcpu *v = d->vcpu[0]; + int cpu, i, rc; + + cpu = v->processor; + for ( i = 1; i < d->max_vcpus; i++ ) + { + cpu = cpumask_cycle(cpu, &dom0_cpus); + setup_dom0_vcpu(d, i, cpu); + } + + memset(&cpu_ctx, 0, sizeof(cpu_ctx)); + + cpu_ctx.mode = VCPU_HVM_MODE_32B; + + cpu_ctx.cpu_regs.x86_32.ebx = start_info; + cpu_ctx.cpu_regs.x86_32.eip = entry; + cpu_ctx.cpu_regs.x86_32.cr0 = X86_CR0_PE | X86_CR0_ET; + + cpu_ctx.cpu_regs.x86_32.cs_limit = ~0u; + cpu_ctx.cpu_regs.x86_32.ds_limit = ~0u; + cpu_ctx.cpu_regs.x86_32.ss_limit = ~0u; + cpu_ctx.cpu_regs.x86_32.tr_limit = 0x67; + cpu_ctx.cpu_regs.x86_32.cs_ar = 0xc9b; + cpu_ctx.cpu_regs.x86_32.ds_ar = 0xc93; + cpu_ctx.cpu_regs.x86_32.ss_ar = 0xc93; + cpu_ctx.cpu_regs.x86_32.tr_ar = 0x8b; + + 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); + + return 0; +} + static int __init construct_dom0_pvh(struct domain *d, const module_t *image, unsigned long image_headroom, module_t *initrd, @@ -2124,6 +2175,15 @@ 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; + } + + clear_bit(_VPF_down, &d->vcpu[0]->pause_flags); + return 0; }