From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=37952 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q76FM-0001gq-VF for qemu-devel@nongnu.org; Tue, 05 Apr 2011 09:24:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q76FL-00065g-Bm for qemu-devel@nongnu.org; Tue, 05 Apr 2011 09:24:40 -0400 Received: from ozlabs.org ([203.10.76.45]:60902) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q76FL-00065M-1F for qemu-devel@nongnu.org; Tue, 05 Apr 2011 09:24:39 -0400 Date: Tue, 5 Apr 2011 23:16:59 +1000 From: David Gibson Message-ID: <20110405131659.GA21368@yookeroo> References: <1301980331-21179-1-git-send-email-david@gibson.dropbear.id.au> <1301980331-21179-2-git-send-email-david@gibson.dropbear.id.au> <3B32EEE0-E931-43A0-8949-D91EF1589AF8@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3B32EEE0-E931-43A0-8949-D91EF1589AF8@suse.de> Subject: [Qemu-devel] Re: [PATCH 1/3] pseries: Abolish envs array List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: qemu-devel@nongnu.org On Tue, Apr 05, 2011 at 10:05:12AM +0200, Alexander Graf wrote: > On 05.04.2011, at 07:12, David Gibson wrote: [snip] > > +struct icp_state *xics_system_init(int nr_irqs) > > { > > + CPUState *env; > > + int max_server_num; > > int i; > > struct icp_state *icp; > > struct ics_state *ics; > > > > + max_server_num = -1; > > + for (env = first_cpu; env != NULL; env = env->next_cpu) { > > + if (env->cpu_index > max_server_num) { > > + max_server_num = env->cpu_index; > > + } > > + } > > + > > icp = qemu_mallocz(sizeof(*icp)); > > - icp->nr_servers = nr_servers; > > - icp->ss = qemu_mallocz(nr_servers * sizeof(struct icp_server_state)); > > + icp->nr_servers = max_server_num + 1; > > + icp->ss = qemu_mallocz(icp->nr_servers*sizeof(struct icp_server_state)); > > + > > + for (i = 0; i < icp->nr_servers; i++) { > > + icp->ss[i].mfrr = 0xff; > > Is ss always big enough to hold all CPUs + 1? Well, it should be. We allocated it just above based on icp->nr_servers, and nr_servers is the largest cpu_index + 1, computer just above that. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson