All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	boris.ostrovsky@oracle.com,
	Roger Pau Monne <roger.pau@citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	konrad.wilk@oracle.com
Subject: [PATCH v5 8/9] xen/x86: Setup PVHv2 Dom0 CPUs
Date: Thu, 19 Jan 2017 17:29:40 +0000	[thread overview]
Message-ID: <20170119172941.65642-9-roger.pau@citrix.com> (raw)
In-Reply-To: <20170119172941.65642-1-roger.pau@citrix.com>

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é <roger.pau@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
---
 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 <public/version.h>
 #include <public/arch-x86/hvm/start_info.h>
 #include <public/hvm/hvm_info_table.h>
+#include <public/hvm/hvm_vcpu.h>
 
 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;
 }
 
-- 
2.10.1 (Apple Git-78)


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-01-19 17:30 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-19 17:29 [PATCH v5 0/9] Initial PVHv2 Dom0 support Roger Pau Monne
2017-01-19 17:29 ` [PATCH v5 1/9] xen/x86: remove XENFEAT_hvm_pirqs for PVHv2 guests Roger Pau Monne
2017-01-20 18:41   ` Andrew Cooper
2017-01-23 12:28     ` Roger Pau Monne
2017-01-19 17:29 ` [PATCH v5 2/9] x86/iommu: add IOMMU entries for p2m_mmio_direct pages Roger Pau Monne
2017-01-20  6:41   ` Tian, Kevin
2017-01-20 10:28     ` Roger Pau Monne
2017-01-20 18:44   ` Andrew Cooper
2017-01-22  4:45     ` Tian, Kevin
2017-01-19 17:29 ` [PATCH v5 3/9] xen/x86: split Dom0 build into PV and PVHv2 Roger Pau Monne
2017-01-20 19:03   ` Andrew Cooper
2017-01-23 12:58     ` Roger Pau Monne
2017-01-23 12:59       ` Andrew Cooper
2017-01-20 19:13   ` Boris Ostrovsky
2017-01-20 19:27     ` Andrew Cooper
2017-01-26 11:43   ` Jan Beulich
2017-01-26 16:36     ` Roger Pau Monne
2017-01-19 17:29 ` [PATCH v5 4/9] xen/x86: populate PVHv2 Dom0 physical memory map Roger Pau Monne
2017-01-20 19:41   ` Andrew Cooper
2017-01-23 11:23     ` Jan Beulich
2017-01-23 14:11   ` Boris Ostrovsky
2017-01-23 14:43     ` Roger Pau Monne
2017-01-26 12:41   ` Jan Beulich
2017-01-27 11:14     ` Tim Deegan
2017-01-27 12:37       ` Roger Pau Monne
2017-01-27 12:51       ` Andrew Cooper
2017-01-27 13:20         ` Tim Deegan
2017-01-27 13:46           ` Andrew Cooper
2017-01-27 14:01             ` Tim Deegan
2017-01-27 14:35               ` Andrew Cooper
2017-01-27 19:43                 ` Tim Deegan
2017-01-30 10:43                   ` Jan Beulich
2017-01-30 11:06                     ` Andrew Cooper
2017-01-27 16:40           ` Jan Beulich
2017-01-27 18:06             ` Andrew Cooper
2017-02-03 13:57               ` Jan Beulich
2017-01-27 19:48             ` Tim Deegan
2017-02-02 15:38               ` Jan Beulich
2017-01-27 12:23     ` Roger Pau Monne
2017-01-27 15:11       ` Jan Beulich
2017-01-27 16:04         ` Roger Pau Monne
2017-01-27 16:29           ` Jan Beulich
2017-01-19 17:29 ` [PATCH v5 5/9] x86/hvm: add vcpu parameter to guest memory copy function Roger Pau Monne
2017-01-20 19:45   ` Andrew Cooper
2017-01-23 13:50     ` Roger Pau Monne
2017-01-26 12:51   ` Jan Beulich
2017-01-26 13:33   ` Jan Beulich
2017-01-27 14:55     ` Roger Pau Monne
2017-01-19 17:29 ` [PATCH v5 6/9] xen/x86: parse Dom0 kernel for PVHv2 Roger Pau Monne
2017-01-26 13:37   ` Jan Beulich
2017-01-27 17:22     ` Roger Pau Monne
2017-01-27 17:28       ` Roger Pau Monne
2017-01-30 10:20         ` Jan Beulich
2017-01-27 18:03       ` Roger Pau Monne
2017-01-30 10:14       ` Jan Beulich
2017-01-19 17:29 ` [PATCH v5 7/9] x86/PVHv2: fix dom0_max_vcpus so it's capped to 128 for PVHv2 Dom0 Roger Pau Monne
2017-01-19 17:32   ` Andrew Cooper
2017-01-26 13:39   ` Jan Beulich
2017-01-19 17:29 ` Roger Pau Monne [this message]
2017-01-26 13:46   ` [PATCH v5 8/9] xen/x86: Setup PVHv2 Dom0 CPUs Jan Beulich
2017-02-08 12:48     ` Roger Pau Monne
2017-02-08 13:02       ` Jan Beulich
2017-01-19 17:29 ` [PATCH v5 9/9] xen/x86: setup PVHv2 Dom0 ACPI tables Roger Pau Monne
2017-01-26 14:16   ` Jan Beulich
2017-02-08 15:10     ` Roger Pau Monne
2017-02-08 15:50       ` Jan Beulich
2017-02-08 15:58         ` Roger Pau Monne
2017-02-08 16:03           ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170119172941.65642-9-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=jbeulich@suse.com \
    --cc=konrad.wilk@oracle.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.