From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjTot-0008MI-MB for qemu-devel@nongnu.org; Thu, 21 Nov 2013 07:57:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VjTon-0002oV-Gc for qemu-devel@nongnu.org; Thu, 21 Nov 2013 07:57:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33762) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjTon-0002n4-8U for qemu-devel@nongnu.org; Thu, 21 Nov 2013 07:57:13 -0500 Date: Thu, 21 Nov 2013 15:00:19 +0200 From: "Michael S. Tsirkin" Message-ID: <20131121130019.GA14894@redhat.com> References: <20131121120822.GA23602@redhat.com> <20131121132413.0af9a66d@gondolin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131121132413.0af9a66d@gondolin> Subject: Re: [Qemu-devel] [PATCH for-1.7] s390x: fix flat rom load on 32 bit systems List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cornelia Huck Cc: Alexander Graf , Dominik Dingel , qemu-devel@nongnu.org, Christian Borntraeger , Andreas =?iso-8859-1?Q?F=E4rber?= , Richard Henderson On Thu, Nov 21, 2013 at 01:24:13PM +0100, Cornelia Huck wrote: > On Thu, 21 Nov 2013 14:08:22 +0200 > "Michael S. Tsirkin" wrote: > > > pc-bios/s390-zipl.rom is a flat image so it's expected that > > loading it as elf will fail. > > It should fall back on loading a flat file, but doesn't > > on 32 bit systems, instead it fails printing: > > qemu: hardware error: could not load bootloader 's390-zipl.rom' > > > > The result is boot failure. > > > > The reason is that a 64 bit unsigned interger which is set > > to -1 on error is compared to -1UL which on a 32 bit system > > with gcc is a 32 bit unsigned interger. > > Since both are unsigned, no sign extension takes place and > > comparison evaluates to non-equal. > > > > There's no reason to do clever tricks: -1 will cause > > sign extension to happen correctly automatically. > > > > Signed-off-by: Michael S. Tsirkin > > --- > > hw/s390x/ipl.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c > > index d69adb2..88115e9 100644 > > --- a/hw/s390x/ipl.c > > +++ b/hw/s390x/ipl.c > > @@ -80,7 +80,7 @@ static int s390_ipl_init(SysBusDevice *dev) > > > > bios_size = load_elf(bios_filename, NULL, NULL, &ipl->start_addr, NULL, > > NULL, 1, ELF_MACHINE, 0); > > - if (bios_size == -1UL) { > > + if (bios_size == -1) { > > bios_size = load_image_targphys(bios_filename, ZIPL_IMAGE_START, > > 4096); > > ipl->start_addr = ZIPL_IMAGE_START; > > Makes sense, but doesn't the kernel loader just below suffer from just > the same problem? Yes, v2 fixes this.