From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lluon-0007OQ-AQ for qemu-devel@nongnu.org; Mon, 23 Mar 2009 20:48:37 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lluol-0007OE-Ed for qemu-devel@nongnu.org; Mon, 23 Mar 2009 20:48:36 -0400 Received: from [199.232.76.173] (port=49537 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lluol-0007OB-AG for qemu-devel@nongnu.org; Mon, 23 Mar 2009 20:48:35 -0400 Received: from fe02x03-cgp.akado.ru ([77.232.31.165]:55043 helo=akado.ru) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lluok-0001Ww-R9 for qemu-devel@nongnu.org; Mon, 23 Mar 2009 20:48:35 -0400 Received: from [10.0.66.9] ([10.0.66.9] verified) by fe02-cgp.akado.ru (CommuniGate Pro SMTP 5.1.16) with ESMTP id 47908118 for qemu-devel@nongnu.org; Tue, 24 Mar 2009 03:48:31 +0300 Date: Tue, 24 Mar 2009 03:48:29 +0300 (MSK) From: malc Subject: Re: [Qemu-devel] [PATCH] compute checksum for roms bigger than a segment In-Reply-To: <1237850625-15864-1-git-send-email-glommer@redhat.com> Message-ID: References: <1237850625-15864-1-git-send-email-glommer@redhat.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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, 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 = 0xff = 128k = 2 segments) > > Signed-off-by: Glauber Costa > --- > bios/rombios.c | 33 +++++++++++++++++++++++++++------ > 1 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: > ret > > rom_checksum: > - push ax > - push bx > - push cx > + pusha > + push ds > + > xor ax, ax > xor bx, bx > xor cx, cx > + xor dx, dx > + > mov ch, [2] > shl cx, #1 > + > + jnc checksum_loop > + mov dx, cx > + mov cx, #0xffff xchg dx, cx dec cx > + > checksum_loop: > add al, [bx] > inc bx > loop checksum_loop > + > + cmp dx, #0 test dx, dx > + je checksum_out > + > + add al, [bx] DS:[0] is added twice, intended? > + mov cx, dx > + mov dx, ds > + add dx, #0x1000 add dh, #0x10 > + mov ds, dx > + xor dx, dx > + xor bx, bx > + > + jmp checksum_loop > + > +checksum_out: > and al, #0xff > - pop cx > - pop bx > - pop ax > + pop ds > + popa > ret > > > -- mailto:av1474@comtv.ru