From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LltYB-00086k-MK for qemu-devel@nongnu.org; Mon, 23 Mar 2009 19:27:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LltY6-00084J-VA for qemu-devel@nongnu.org; Mon, 23 Mar 2009 19:27:23 -0400 Received: from [199.232.76.173] (port=42277 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LltY6-00084E-Pt for qemu-devel@nongnu.org; Mon, 23 Mar 2009 19:27:18 -0400 Received: from mx2.redhat.com ([66.187.237.31]:53708) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LltY6-0002Pv-E9 for qemu-devel@nongnu.org; Mon, 23 Mar 2009 19:27:18 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n2NNRHRM014343 for ; Mon, 23 Mar 2009 19:27:17 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n2NNRC0I025678 for ; Mon, 23 Mar 2009 19:27:12 -0400 Received: from localhost.localdomain (vpn-10-93.bos.redhat.com [10.16.10.93]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n2NNRG91031883 for ; Mon, 23 Mar 2009 19:27:16 -0400 From: Glauber Costa Date: Mon, 23 Mar 2009 20:23:45 -0300 Message-Id: <1237850625-15864-1-git-send-email-glommer@redhat.com> Subject: [Qemu-devel] [PATCH] compute checksum for roms bigger than a segment 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 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 + checksum_loop: add al, [bx] inc bx loop checksum_loop + + cmp dx, #0 + je checksum_out + + add al, [bx] + mov cx, dx + mov dx, ds + add dx, #0x1000 + 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 -- 1.6.1.2