Received: from eggs.gnu.org ([208.118.235.92]:42012) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S77Zv-0007k5-3L for qemu-devel@nongnu.org; Mon, 12 Mar 2012 11:54:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S77ZU-00074Q-9u for qemu-devel@nongnu.org; Mon, 12 Mar 2012 11:54:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39336) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S77ZT-00072j-Vb for qemu-devel@nongnu.org; Mon, 12 Mar 2012 11:54:04 -0400 From: Markus Armbruster References: <1331225951-31306-1-git-send-email-mark.langsdorf@calxeda.com> <4F5A0288.6090809@calxeda.com> <9A556F7F-2721-4D51-80D2-8B9571E4EC0F@suse.de> <4F5A06C8.7020903@calxeda.com> <88D21EA9-1000-48DB-9D7A-437622BE8745@suse.de> <4F5A1378.5040909@suse.de> <4F5A503D.2090304@suse.de> <4F5B6069.404@suse.de> Date: Mon, 12 Mar 2012 16:53:53 +0100 In-Reply-To: (Peter Maydell's message of "Sat, 10 Mar 2012 15:27:20 +0000") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH] use an unsigned long for the max_sz parameter in load_image_targphys List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Mark Langsdorf , Stefan Weil , "qemu-devel@nongnu.org" , Alexander Graf , Erik Blake , Andreas =?utf-8?Q?F=C3=A4rber?= , David Gibson Peter Maydell writes: [...] > Putting a "restrict to INT_MAX" in the highbank code is definitely > wrong (not least because passing values to load_image_targphys isn't > the only thing we use that field in arm_boot_info for!) > The ARM boot code needs updating because it shouldn't be > using 'int' for arm_boot_info.ram_size, and using target_phys_addr_t > the same as we do for initrd_size is the obvious thing. I have no > particular objection to having some new target_phys_size_t or whatever, > and I could be persuaded that we should follow the memory API in > using uint64_t for sizes, but it needs to be a type that either follows > guest phys addr restrictions or a fixed-width type which we have decreed > is always large enough, There is already a type that is defined to be wide enough for any object size: size_t. > not a type which varies based on host properties. To be honest, the whole debate feels like bikeshedding to me. Yes, load_image_targphys()'s argument max_sz is the size of a slice of guest memory. It's also the size of a host object, allocated with g_malloc0() in rom_add_file(). It's also the size of a disk file. I'd make it size_t and be done with it. If you absolutely must overengineer things, go ahead and create a new type for target sizes. I doubt making it wider than size_t will work in practice without a lot of hoop jumping, though. [...]