Message ID | 20170119172941.65642-9-roger.pau@citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
>>> On 19.01.17 at 18:29, <roger.pau@citrix.com> wrote: > @@ -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; i and cpu want to be unsigned int. > + 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)); Perhaps better (and shorter) to use an initializer again? > + 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; In fact, all of this could become part of the initializer too as it looks. > @@ -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); Would you mind moving this into the function (where you then can use just v)? Jan
On Thu, Jan 26, 2017 at 06:46:17AM -0700, Jan Beulich wrote: > >>> On 19.01.17 at 18:29, <roger.pau@citrix.com> wrote: > > @@ -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); > > Would you mind moving this into the function (where you then can > use just v)? Fixed all the above, but I'm not sure about this. In v2 you requested me to move the clear_bit outside of pvh_set_cpus: https://www.mail-archive.com/xen-devel@lists.xen.org/msg83714.html Roger.
>>> On 08.02.17 at 13:48, <roger.pau@citrix.com> wrote: > On Thu, Jan 26, 2017 at 06:46:17AM -0700, Jan Beulich wrote: >> >>> On 19.01.17 at 18:29, <roger.pau@citrix.com> wrote: >> > @@ -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); >> >> Would you mind moving this into the function (where you then can >> use just v)? > > Fixed all the above, but I'm not sure about this. In v2 you requested me to > move the clear_bit outside of pvh_set_cpus: > > https://www.mail-archive.com/xen-devel@lists.xen.org/msg83714.html I asked you to move it later, but I did not ask for it to be moved outside. Jan
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; }
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(+)