[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] Avoid stale pointer when moving domain to another cpupool
commit 482300def7d08e773ccd2a0d978bcb9469fdd810 Author: Juergen Gross <juergen.gross@xxxxxxxxxxxxxx> AuthorDate: Thu Feb 28 14:56:45 2013 +0000 Commit: Keir Fraser <keir@xxxxxxx> CommitDate: Thu Feb 28 14:56:45 2013 +0000 Avoid stale pointer when moving domain to another cpupool When a domain is moved to another cpupool the scheduler private data pointers in vcpu and domain structures must never point to an already freed memory area. While at it, simplify sched_init_vcpu() by using DOM2OP instead VCPU2OP. Signed-off-by: Juergen Gross <juergen.gross@xxxxxxxxxxxxxx> --- xen/common/schedule.c | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 9c58b12..1fc9b7d 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -220,7 +220,7 @@ int sched_init_vcpu(struct vcpu *v, unsigned int processor) if ( v->sched_priv == NULL ) return 1; - SCHED_OP(VCPU2OP(v), insert_vcpu, v); + SCHED_OP(DOM2OP(d), insert_vcpu, v); return 0; } @@ -231,6 +231,9 @@ int sched_move_domain(struct domain *d, struct cpupool *c) unsigned int new_p; void **vcpu_priv; void *domdata; + void *vcpudata; + struct scheduler *old_ops; + void *old_domdata; domdata = SCHED_OP(c->sched, alloc_domdata, d); if ( domdata == NULL ) @@ -261,21 +264,22 @@ int sched_move_domain(struct domain *d, struct cpupool *c) domain_pause(d); + old_ops = DOM2OP(d); + old_domdata = d->sched_priv; + for_each_vcpu ( d, v ) { - SCHED_OP(VCPU2OP(v), remove_vcpu, v); - SCHED_OP(VCPU2OP(v), free_vdata, v->sched_priv); - v->sched_priv = NULL; + SCHED_OP(old_ops, remove_vcpu, v); } - SCHED_OP(DOM2OP(d), free_domdata, d->sched_priv); - d->cpupool = c; d->sched_priv = domdata; new_p = cpumask_first(c->cpu_valid); for_each_vcpu ( d, v ) { + vcpudata = v->sched_priv; + migrate_timer(&v->periodic_timer, new_p); migrate_timer(&v->singleshot_timer, new_p); migrate_timer(&v->poll_timer, new_p); @@ -288,12 +292,16 @@ int sched_move_domain(struct domain *d, struct cpupool *c) new_p = cpumask_cycle(new_p, c->cpu_valid); SCHED_OP(c->sched, insert_vcpu, v); + + SCHED_OP(old_ops, free_vdata, vcpudata); } domain_update_node_affinity(d); domain_unpause(d); + SCHED_OP(old_ops, free_domdata, old_domdata); + xfree(vcpu_priv); return 0; -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |