From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LUHDw-0004MR-Sh for qemu-devel@nongnu.org; Tue, 03 Feb 2009 04:05:40 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LUHDw-0004MF-9y for qemu-devel@nongnu.org; Tue, 03 Feb 2009 04:05:40 -0500 Received: from [199.232.76.173] (port=45764 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUHDw-0004MC-73 for qemu-devel@nongnu.org; Tue, 03 Feb 2009 04:05:40 -0500 Received: from fg-out-1718.google.com ([72.14.220.157]:31784) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LUHDv-0003JK-LW for qemu-devel@nongnu.org; Tue, 03 Feb 2009 04:05:39 -0500 Received: by fg-out-1718.google.com with SMTP id e21so859497fga.8 for ; Tue, 03 Feb 2009 01:05:38 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <49880773.5000203@exactcode.de> References: <49880773.5000203@exactcode.de> Date: Tue, 3 Feb 2009 10:05:38 +0100 Message-ID: <761ea48b0902030105me6f491csa0728c0ab15e3e26@mail.gmail.com> Subject: Re: [Qemu-devel] [PATCH] fix loading tiny kernels From: Laurent Desnogues Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Tue, Feb 3, 2009 at 9:59 AM, Ren=E9 Rebe wrote: > Further testing / polishing the multi-boot kernel loading support I found > the existing code fails to load unusual small kernels, less than 8192 byt= es > - > for example the example multi-boot kernel shipped within GRUB that > compiles to just 7121 bytes on my system. > > Signed-off-by: Ren=E9 Rebe > > --- hw/pc.c (revision 6501) > +++ hw/pc.c (working copy) > @@ -554,7 +989,7 @@ > /* load the kernel header */ > f =3D fopen(kernel_filename, "rb"); > if (!f || !(kernel_size =3D get_file_size(f)) || > - fread(header, 1, 1024, f) !=3D 1024) { > + fread(header, 1, MIN(8192, kernel_size), f) !=3D MIN(8192, kernel_si= ze)) That's wrong: 'header' size is 1024 bytes. Laurent