From: Keir Fraser Subject: Re: [PATCH] xen: add assertions in default_vcpu0_location to protect against broken masks Date: Tue, 26 Jun 2012 13:46:08 +0100 Message-ID: References: <1340704026-20406-1-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1340704026-20406-1-git-send-email-ian.campbell@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell , xen-devel@lists.xen.org Cc: Jan Beulich List-Id: xen-devel@lists.xenproject.org On 26/06/2012 10:47, "Ian Campbell" wrote: > When setting up the cpu sibling/etc masks on ARM I accidentally and > incorrectly omitted a CPU from it's own sibling mask which caused this > function to scribble over the heap. Add a couple of asserts to catch this in > the future. I'm happy with either or both the assertions you add. Acked-by: Keir Fraser > Signed-off-by: Ian Campbell > Cc: Keir (Xen.org) > Cc: Jan Beulich > --- > xen/common/domctl.c | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) > > diff --git a/xen/common/domctl.c b/xen/common/domctl.c > index 9f1a9ad..c1acd1d 100644 > --- a/xen/common/domctl.c > +++ b/xen/common/domctl.c > @@ -190,10 +190,12 @@ static unsigned int default_vcpu0_location(cpumask_t > *online) > */ > cpumask_copy(&cpu_exclude_map, per_cpu(cpu_sibling_mask, 0)); > cpu = cpumask_first(&cpu_exclude_map); > + ASSERT(cpu < nr_cpus); > if ( cpumask_weight(&cpu_exclude_map) > 1 ) > cpu = cpumask_next(cpu, &cpu_exclude_map); > for_each_cpu(i, online) > { > + ASSERT(i < nr_cpus); > if ( cpumask_test_cpu(i, &cpu_exclude_map) ) > continue; > if ( (i == cpumask_first(per_cpu(cpu_sibling_mask, i))) &&