ia64/xen-unstable
changeset 8575:821368442403
Fix cpu_affinity memcpy() (bytes not longs!) add add a better
affinity map sanity check to avoid blowing up Xen if no
online cpu is included in the map.
Signed-off-by: Keir Fraser <keir@xensource.com>
affinity map sanity check to avoid blowing up Xen if no
online cpu is included in the map.
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Thu Jan 12 12:45:49 2006 +0100 (2006-01-12) |
parents | 08d2a74dce81 |
children | 4b8919585039 |
files | xen/common/dom0_ops.c xen/common/schedule.c |
line diff
1.1 --- a/xen/common/dom0_ops.c Thu Jan 12 10:37:10 2006 +0000 1.2 +++ b/xen/common/dom0_ops.c Thu Jan 12 12:45:49 2006 +0100 1.3 @@ -323,7 +323,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op) 1.4 new_affinity = v->cpu_affinity; 1.5 memcpy(cpus_addr(new_affinity), 1.6 &op->u.setvcpuaffinity.cpumap, 1.7 - min((int)BITS_TO_LONGS(NR_CPUS), 1.8 + min((int)(BITS_TO_LONGS(NR_CPUS) * sizeof(long)), 1.9 (int)sizeof(op->u.setvcpuaffinity.cpumap))); 1.10 1.11 ret = vcpu_set_affinity(v, &new_affinity); 1.12 @@ -501,7 +501,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op) 1.13 op->u.getvcpuinfo.cpumap = 0; 1.14 memcpy(&op->u.getvcpuinfo.cpumap, 1.15 cpus_addr(v->cpu_affinity), 1.16 - min((int)BITS_TO_LONGS(NR_CPUS), 1.17 + min((int)(BITS_TO_LONGS(NR_CPUS) * sizeof(long)), 1.18 (int)sizeof(op->u.getvcpuinfo.cpumap))); 1.19 ret = 0; 1.20
2.1 --- a/xen/common/schedule.c Thu Jan 12 10:37:10 2006 +0000 2.2 +++ b/xen/common/schedule.c Thu Jan 12 12:45:49 2006 +0100 2.3 @@ -207,7 +207,10 @@ void vcpu_wake(struct vcpu *v) 2.4 2.5 int vcpu_set_affinity(struct vcpu *v, cpumask_t *affinity) 2.6 { 2.7 - if ( cpus_empty(*affinity) ) 2.8 + cpumask_t online_affinity; 2.9 + 2.10 + cpus_and(online_affinity, *affinity, cpu_online_map); 2.11 + if ( cpus_empty(online_affinity) ) 2.12 return -EINVAL; 2.13 2.14 return SCHED_OP(set_affinity, v, affinity);