Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Llvps-0003wJ-Vv for qemu-devel@nongnu.org; Mon, 23 Mar 2009 21:53:49 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Llvpo-0003w7-Cj for qemu-devel@nongnu.org; Mon, 23 Mar 2009 21:53:48 -0400 Received: from [199.232.76.173] (port=57117 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Llvpo-0003w4-9J for qemu-devel@nongnu.org; Mon, 23 Mar 2009 21:53:44 -0400 Received: from mail-qy0-f111.google.com ([209.85.221.111]:48243) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Llvpn-0006xV-Td for qemu-devel@nongnu.org; Mon, 23 Mar 2009 21:53:44 -0400 Received: by qyk9 with SMTP id 9so2957573qyk.4 for ; Mon, 23 Mar 2009 18:53:40 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <1237850625-15864-1-git-send-email-glommer@redhat.com> Date: Mon, 23 Mar 2009 22:53:40 -0300 Message-ID: <5d6222a80903231853l1331de5brea477b0801dabfff@mail.gmail.com> Subject: Re: [Qemu-devel] [PATCH] compute checksum for roms bigger than a segment From: Glauber Costa Content-Type: text/plain; charset=UTF-8 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 Mon, Mar 23, 2009 at 9:48 PM, malc wrote: > On Mon, 23 Mar 2009, Glauber Costa wrote: > >> Some option roms (e1000 provided by gpxe project as an example) >> are bigger than a segment. The current algorithm to compute the >> checksum fails in such case. To proper compute the checksum, this >> patch deals with the possibility of the rom's size crossing a >> segment border. >> >> We don't need to worry about it crossing more than one segment >> border, since the option roms format only save one byte to store >> the image size (thus, maximum size =3D 0xff =3D 128k =3D 2 segments) >> >> Signed-off-by: Glauber Costa >> --- >> =C2=A0bios/rombios.c | =C2=A0 33 +++++++++++++++++++++++++++------ >> =C2=A01 files changed, 27 insertions(+), 6 deletions(-) >> >> diff --git a/bios/rombios.c b/bios/rombios.c >> index bc43251..6fede17 100644 >> --- a/bios/rombios.c >> +++ b/bios/rombios.c >> @@ -10162,22 +10162,43 @@ no_serial: >> =C2=A0 =C2=A0ret >> >> =C2=A0rom_checksum: >> - =C2=A0push ax >> - =C2=A0push bx >> - =C2=A0push cx >> + =C2=A0pusha >> + =C2=A0push ds >> + >> =C2=A0 =C2=A0xor =C2=A0ax, ax >> =C2=A0 =C2=A0xor =C2=A0bx, bx >> =C2=A0 =C2=A0xor =C2=A0cx, cx >> + =C2=A0xor =C2=A0dx, dx >> + >> =C2=A0 =C2=A0mov =C2=A0ch, [2] >> =C2=A0 =C2=A0shl =C2=A0cx, #1 >> + >> + =C2=A0jnc checksum_loop >> + =C2=A0mov =C2=A0dx, cx >> + =C2=A0mov =C2=A0cx, #0xffff > > =C2=A0 =C2=A0 xchg dx, cx > =C2=A0 =C2=A0 dec =C2=A0cx I actually skipped this one. Ok for xchg, but cx at this time holds the remaining bytes, so dec cx won't have the effect you think it will. --=20 Glauber Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act."