From patchwork Wed Mar 25 15:06:46 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 14354 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2PFAS9g001560 for ; Wed, 25 Mar 2009 15:10:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754116AbZCYPK1 (ORCPT ); Wed, 25 Mar 2009 11:10:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752531AbZCYPK1 (ORCPT ); Wed, 25 Mar 2009 11:10:27 -0400 Received: from mx2.redhat.com ([66.187.237.31]:51434 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753265AbZCYPK0 (ORCPT ); Wed, 25 Mar 2009 11:10:26 -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 n2PFAKgu012216; Wed, 25 Mar 2009 11:10:22 -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 n2PFAEAA029425; Wed, 25 Mar 2009 11:10:14 -0400 Received: from localhost.localdomain (vpn-10-153.bos.redhat.com [10.16.10.153]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n2PFAHqs025173; Wed, 25 Mar 2009 11:10:19 -0400 From: Glauber Costa To: bochs-developers@lists.sourcefourge.net Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [PATCH] compute checksum for roms bigger than a segment Date: Wed, 25 Mar 2009 12:06:46 -0300 Message-Id: <1237993606-7729-1-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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) [ including improvements suggested by malc ] 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..5e7ad24 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 + xchg dx, cx + dec cx + checksum_loop: add al, [bx] inc bx loop checksum_loop + + test dx, dx + je checksum_out + + add al, [bx] + mov cx, dx + mov dx, ds + 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