Blame qemu-bios-bigger-roms.patch

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