a8abd8e
From c9aea972de34bad96814301988df698063ccf608 Mon Sep 17 00:00:00 2001
da7d236
From: Glauber Costa <glommer@redhat.com>
da7d236
Date: Wed, 24 Jun 2009 14:31:41 +0100
a8abd8e
Subject: [PATCH 1/4] compute checksum for roms bigger than a segment
da7d236
da7d236
Some option roms (e1000 provided by gpxe project as an example)
da7d236
are bigger than a segment. The current algorithm to compute the
da7d236
checksum fails in such case. To proper compute the checksum, this
da7d236
patch deals with the possibility of the rom's size crossing a
da7d236
segment border.
da7d236
da7d236
We don't need to worry about it crossing more than one segment
da7d236
border, since the option roms format only save one byte to store
da7d236
the image size (thus, maximum size = 0xff = 128k = 2 segments)
da7d236
da7d236
[ including improvements suggested by malc ]
da7d236
da7d236
Signed-off-by: Glauber Costa <glommer@redhat.com>
da7d236
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
da7d236
---
da7d236
 kvm/bios/rombios.c |   33 +++++++++++++++++++++++++++------
da7d236
 1 files changed, 27 insertions(+), 6 deletions(-)
da7d236
ccf76b7
diff --git a/kvm/bios/rombios.c b/kvm/bios/rombios.c
da7d236
index 6186199..fc289c0 100644
ccf76b7
--- a/kvm/bios/rombios.c
ccf76b7
+++ b/kvm/bios/rombios.c
da7d236
@@ -10170,22 +10170,43 @@ no_serial:
Glauber Costa 3afbf09
   ret
Glauber Costa 3afbf09
 
Glauber Costa 3afbf09
 rom_checksum:
Glauber Costa 3afbf09
-  push ax
Glauber Costa 3afbf09
-  push bx
Glauber Costa 3afbf09
-  push cx
Glauber Costa 3afbf09
+  pusha
Glauber Costa 3afbf09
+  push ds
Glauber Costa 3afbf09
+
Glauber Costa 3afbf09
   xor  ax, ax
Glauber Costa 3afbf09
   xor  bx, bx
Glauber Costa 3afbf09
   xor  cx, cx
Glauber Costa 3afbf09
+  xor  dx, dx
Glauber Costa 3afbf09
+
Glauber Costa 3afbf09
   mov  ch, [2]
Glauber Costa 3afbf09
   shl  cx, #1
Glauber Costa 3afbf09
+
Glauber Costa 3afbf09
+  jnc checksum_loop
Glauber Costa 3afbf09
+  xchg dx, cx
Glauber Costa 3afbf09
+  dec  cx
Glauber Costa 3afbf09
+
Glauber Costa 3afbf09
 checksum_loop:
Glauber Costa 3afbf09
   add  al, [bx]
Glauber Costa 3afbf09
   inc  bx
Glauber Costa 3afbf09
   loop checksum_loop
Glauber Costa 3afbf09
+
Glauber Costa 3afbf09
+  test dx, dx 
Glauber Costa 3afbf09
+  je checksum_out
Glauber Costa 3afbf09
+
Glauber Costa 3afbf09
+  add  al, [bx]
Glauber Costa 3afbf09
+  mov  cx, dx
Glauber Costa 3afbf09
+  mov  dx, ds
Glauber Costa 3afbf09
+  add  dh, #0x10
Glauber Costa 3afbf09
+  mov  ds, dx
Glauber Costa 3afbf09
+  xor  dx, dx 
Glauber Costa 3afbf09
+  xor  bx, bx
Glauber Costa 3afbf09
+
Glauber Costa 3afbf09
+  jmp  checksum_loop
Glauber Costa 3afbf09
+
Glauber Costa 3afbf09
+checksum_out:
Glauber Costa 3afbf09
   and  al, #0xff
Glauber Costa 3afbf09
-  pop  cx
Glauber Costa 3afbf09
-  pop  bx
Glauber Costa 3afbf09
-  pop  ax
Glauber Costa 3afbf09
+  pop  ds
Glauber Costa 3afbf09
+  popa 
Glauber Costa 3afbf09
   ret
da7d236
 
da7d236
 
da7d236
-- 
a8abd8e
1.6.3.3
da7d236