# HG changeset patch # User Tristan Gingold # Date 1181359022 -7200 # Node ID c69dd5d18ce74ec5b5c669364a88eb3b5166e7d2 # Parent 8d5d102017c72fe94fa0090de1ec007191745f29 Use virtualized psr in vcpu context instead of real psr. Signed-off-by: Tristan Gingold diff -r 8d5d102017c7 -r c69dd5d18ce7 tools/libxc/ia64/xc_ia64_hvm_build.c --- a/tools/libxc/ia64/xc_ia64_hvm_build.c Sat Jun 09 04:43:26 2007 +0200 +++ b/tools/libxc/ia64/xc_ia64_hvm_build.c Sat Jun 09 05:17:02 2007 +0200 @@ -886,6 +886,11 @@ xc_hvm_build(int xc_handle, uint32_t dom free(image); ctxt->regs.ip = 0x80000000ffffffb0UL; + ctxt->regs.ar.fpsr = 0x0009804c0270033fUL; + ctxt->regs.cr.isr = 1UL << 63; + ctxt->regs.psr = (1UL << 3) | (1UL << 44); /* AC and BN */ + ctxt->regs.cr.dcr = 0; + ctxt->regs.cr.pta = 15 << 2; memset(&launch_domctl, 0, sizeof(launch_domctl)); diff -r 8d5d102017c7 -r c69dd5d18ce7 tools/libxc/ia64/xc_ia64_linux_restore.c --- a/tools/libxc/ia64/xc_ia64_linux_restore.c Sat Jun 09 04:43:26 2007 +0200 +++ b/tools/libxc/ia64/xc_ia64_linux_restore.c Sat Jun 09 05:17:02 2007 +0200 @@ -227,17 +227,7 @@ xc_domain_restore(int xc_handle, int io_ fprintf(stderr, "ip=%016lx, b0=%016lx\n", ctxt.regs.ip, ctxt.regs.b[0]); - /* First to initialize. */ - domctl.cmd = XEN_DOMCTL_setvcpucontext; - domctl.domain = (domid_t)dom; - domctl.u.vcpucontext.vcpu = 0; - set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt); - if (xc_domctl(xc_handle, &domctl) != 0) { - ERROR("Couldn't set vcpu context"); - goto out; - } - - /* Second to set registers... */ + /* Initialize and set registers. */ ctxt.flags = VGCF_EXTRA_REGS; domctl.cmd = XEN_DOMCTL_setvcpucontext; domctl.domain = (domid_t)dom; diff -r 8d5d102017c7 -r c69dd5d18ce7 tools/libxc/xc_dom_ia64.c --- a/tools/libxc/xc_dom_ia64.c Sat Jun 09 04:43:26 2007 +0200 +++ b/tools/libxc/xc_dom_ia64.c Sat Jun 09 05:17:02 2007 +0200 @@ -105,7 +105,8 @@ static int vcpu_ia64(struct xc_dom_image memset(ctxt, 0, sizeof(*ctxt)); ctxt->flags = 0; - ctxt->regs.psr = 0; /* all necessary bits filled by hypervisor */ + /* PSR is set according to SAL 3.2.4: AC, IC and BN are set. */ + ctxt->regs.psr = (1UL << 3) | (1UL << 13) | (1UL << 44); ctxt->regs.ip = dom->parms.virt_entry; ctxt->regs.cfm = (uint64_t) 1 << 63; #ifdef __ia64__ /* FIXME */ diff -r 8d5d102017c7 -r c69dd5d18ce7 xen/arch/ia64/xen/domain.c --- a/xen/arch/ia64/xen/domain.c Sat Jun 09 04:43:26 2007 +0200 +++ b/xen/arch/ia64/xen/domain.c Sat Jun 09 05:17:02 2007 +0200 @@ -622,12 +622,10 @@ void arch_get_info_guest(struct vcpu *v, c.nat->regs.r[10] = uregs->r10; c.nat->regs.r[11] = uregs->r11; - if (is_hvm) { - c.nat->regs.psr = vmx_vcpu_get_psr (v); - } else { - /* FIXME: get the vpsr. */ - c.nat->regs.psr = uregs->cr_ipsr; - } + if (is_hvm) + c.nat->regs.psr = vmx_vcpu_get_psr(v); + else + c.nat->regs.psr = vcpu_get_psr(v); c.nat->regs.ip = uregs->cr_iip; c.nat->regs.cfm = uregs->cr_ifs; @@ -717,6 +715,26 @@ int arch_set_info_guest(struct vcpu *v, struct domain *d = v->domain; int rc; + /* Finish vcpu initialization. */ + if (!v->is_initialised) { + if (d->arch.is_vti) + rc = vmx_final_setup_guest(v); + else + rc = vcpu_late_initialise(v); + if (rc != 0) + return rc; + + vcpu_init_regs(v); + + v->is_initialised = 1; + /* Auto-online VCPU0 when it is initialised. */ + if (v->vcpu_id == 0) + clear_bit(_VPF_down, &v->pause_flags); + } + + if (c.nat == NULL) + return 0; + uregs->b6 = c.nat->regs.b[6]; uregs->b7 = c.nat->regs.b[7]; @@ -727,8 +745,11 @@ int arch_set_info_guest(struct vcpu *v, uregs->r9 = c.nat->regs.r[9]; uregs->r10 = c.nat->regs.r[10]; uregs->r11 = c.nat->regs.r[11]; - - uregs->cr_ipsr = c.nat->regs.psr; + + if (!d->arch.is_vti) + vcpu_set_psr(v, c.nat->regs.psr); + else + vmx_vcpu_set_psr(v, c.nat->regs.psr); uregs->cr_iip = c.nat->regs.ip; uregs->cr_ifs = c.nat->regs.cfm; @@ -813,32 +834,6 @@ int arch_set_info_guest(struct vcpu *v, v->arch.iva = c.nat->regs.cr.iva; } - if (v->is_initialised) - return 0; - - if (d->arch.is_vti) { - rc = vmx_final_setup_guest(v); - if (rc != 0) - return rc; - } else { - rc = vcpu_late_initialise(v); - if (rc != 0) - return rc; - VCPU(v, interrupt_mask_addr) = - (unsigned char *) d->arch.shared_info_va + - INT_ENABLE_OFFSET(v); - } - - /* This overrides some registers. */ - vcpu_init_regs(v); - - if (!v->is_initialised) { - v->is_initialised = 1; - /* Auto-online VCPU0 when it is initialised. */ - if (v->vcpu_id == 0) - clear_bit(_VPF_down, &v->pause_flags); - } - return 0; } diff -r 8d5d102017c7 -r c69dd5d18ce7 xen/arch/ia64/xen/vcpu.c --- a/xen/arch/ia64/xen/vcpu.c Sat Jun 09 04:43:26 2007 +0200 +++ b/xen/arch/ia64/xen/vcpu.c Sat Jun 09 05:17:02 2007 +0200 @@ -182,8 +182,6 @@ void vcpu_init_regs(struct vcpu *v) INT_ENABLE_OFFSET(v); VCPU(v, itv) = (1 << 16); /* timer vector masked */ - /* SAL specification 3.2.4 */ - VCPU(v, vpsr) = IA64_PSR_AC | IA64_PSR_IC | IA64_PSR_BN; v->vcpu_info->evtchn_upcall_pending = 0; v->vcpu_info->evtchn_upcall_mask = -1; }