From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuhAX-0005Gr-Cu for qemu-devel@nongnu.org; Fri, 06 Nov 2015 08:35:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZuhAW-0006U2-Ji for qemu-devel@nongnu.org; Fri, 06 Nov 2015 08:35:05 -0500 Received: from mail-vk0-x22b.google.com ([2607:f8b0:400c:c05::22b]:35850) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuhAW-0006T2-Bk for qemu-devel@nongnu.org; Fri, 06 Nov 2015 08:35:04 -0500 Received: by vkex70 with SMTP id x70so13838210vke.3 for ; Fri, 06 Nov 2015 05:35:04 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20151106132115.GB13308@toto> References: <1446747358-18214-1-git-send-email-peter.maydell@linaro.org> <1446747358-18214-3-git-send-email-peter.maydell@linaro.org> <20151106132115.GB13308@toto> From: Peter Maydell Date: Fri, 6 Nov 2015 13:34:44 +0000 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH 02/16] exec.c: Allow target CPUs to define multiple AddressSpaces List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Edgar E. Iglesias" Cc: Patch Tracking , QEMU Developers , qemu-arm@nongnu.org, Paolo Bonzini , =?UTF-8?B?QWxleCBCZW5uw6ll?= , =?UTF-8?Q?Andreas_F=C3=A4rber?= On 6 November 2015 at 13:21, Edgar E. Iglesias wrote: > On Thu, Nov 05, 2015 at 06:15:44PM +0000, Peter Maydell wrote: >> Allow multiple calls to cpu_address_space_init(); each >> call adds an entry to the cpu->ases array at the specified >> index. It is up to the target-specific CPU code to actually use >> these extra address spaces. >> >> Since this multiple AddressSpace support won't work with >> KVM, add an assertion to avoid confusing failures. >> >> Signed-off-by: Peter Maydell >> + if (asidx >= cpu->num_ases) { >> + if (cpu->num_ases == 0) { >> + cpu->cpu_ases = g_new(CPUAddressSpace, asidx + 1); >> + } else { >> + cpu->cpu_ases = g_renew(CPUAddressSpace, cpu->cpu_ases, asidx + 1); > > IIUC, g_renew may move the entire cpu_ases area. The internals of > memory_listener_register (called below) seem to put away the pointers to listeners > so a renew+move would leave invalid pointers to listeners in memory.c wouldn't it? > > There are various ways of solving this, (e.g dynamic allocation of the listener, > static allocation of the cpu_ases, invalidate all listeners and restore them after > each as init and more). I'm sure you'll figure something out. Oops, yes, you're right. Maybe we should just have the target CPU say in advance what the maximum number of AddressSpaces it will have is -- my expectation is that this will be (a) small (b) known in advance anyway. thanks -- PMM