From: George Dunlap Subject: [PATCH] xenalyze: Raise MAX_CPUS to 256 cpus Date: Wed, 20 Jul 2011 16:10:29 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: george.dunlap@eu.citrix.com List-Id: xen-devel@lists.xenproject.org Some systems actually have that many now. (And XenServer builds with MAX_PHYS_CPUS set to 256.) Also, check if a CPU is out of range before using, warn and exit, instead of segfaulting. To-do: Make the size dynamically adjustable. Signed-off-by: George Dunlap diff -r 405fc96c0ec2 -r e11e13e66c62 xenalyze.c --- a/xenalyze.c Thu Jul 14 12:55:17 2011 +0100 +++ b/xenalyze.c Wed Jul 20 16:10:20 2011 +0100 @@ -1621,7 +1621,7 @@ struct cr3_value_struct { }; #ifndef MAX_CPUS -#define MAX_CPUS 128 +#define MAX_CPUS 256 #endif typedef uint32_t cpu_mask_t; @@ -7968,6 +7968,14 @@ loff_t scan_for_new_pcpu(loff_t offset) } cd = (typeof(cd))rec.u.notsc.data; + + if ( cd->cpu > MAX_CPUS ) + { + fprintf(stderr, "%s: cpu %d exceeds MAX_CPU %d!\n", + __func__, cd->cpu, MAX_CPUS); + /* FIXME: Figure out if we could handle this more gracefully */ + error(ERR_ASSERT, NULL); + } if(cd->cpu > P.max_active_pcpu || !P.pcpu[cd->cpu].active) { struct pcpu_info *p = P.pcpu + cd->cpu;