[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v4 01/12] xen/arm: basic PSCI support, implement cpu_on and cpu_off
On Fri, 2013-04-26 at 16:28 +0100, Stefano Stabellini wrote: > +int do_psci_cpu_on(uint32_t vcpuid, register_t entry_point) > +{ > + struct vcpu *v; > + struct domain *d = current->domain; > + struct vcpu_guest_context *ctxt; > + int rc; > + > + if ( (vcpuid < 0) || (vcpuid >= MAX_VIRT_CPUS) ) > + return PSCI_EINVAL; > + > + if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL ) > + return PSCI_EINVAL; > + > + if ( (ctxt = alloc_vcpu_guest_context()) == NULL ) > + return PSCI_DENIED; > + > + memset(ctxt, 0, sizeof(*ctxt)); > + ctxt->user_regs.pc64 = (u64) entry_point; > + ctxt->sctlr = SCTLR_BASE; > + ctxt->ttbr0 = 0; > + ctxt->ttbr1 = 0; > + ctxt->ttbcr = 0; /* Defined Reset Value */ > + ctxt->user_regs.cpsr = PSR_GUEST_INIT; > + ctxt->flags = VGCF_online; > + > + domain_lock(d); > + rc = arch_set_info_guest(v, ctxt); > + free_vcpu_guest_context(ctxt); I'm slightly concerned that there might be other state which needs clearing when we are brining up a VCPU which has subsequently been running and blocked via cpu_down. I'm thinking of the sort of things which vcpu_reset clears up. However I guess we'll find those out later. > + if ( rc < 0 ) > + { > + domain_unlock(d); > + return PSCI_DENIED; > + } > + domain_unlock(d); > + > + vcpu_wake(v); > + > + return PSCI_SUCCESS; > +} > + > +int do_psci_cpu_off(uint32_t power_state) > +{ > + struct vcpu *v = current; > + if ( !test_and_set_bit(_VPF_down, &v->pause_flags) ) > + vcpu_sleep_nosync(v); > + return PSCI_SUCCESS; We will return here but not make it back to the guest, because we will call into the scheduler (vcpu_sleep_nosync makes sure this is the case) and block. If cpu_up is subsequently called then it will overwrite the VCPU's guest state and so it will return to the newly selected address. Good! Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |