rpms/kvm/F-9 kvm-extboot.patch,NONE,1.1.2.1 kvm.spec,1.58,1.58.2.1

Glauber Costa glommer at fedoraproject.org
Wed Aug 27 18:25:41 UTC 2008


Author: glommer

Update of /cvs/pkgs/rpms/kvm/F-9
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv4184

Modified Files:
      Tag: private-glommer-extboot-branch
	kvm.spec 
Added Files:
      Tag: private-glommer-extboot-branch
	kvm-extboot.patch 
Log Message:
proposed fix for extboot problem



kvm-extboot.patch:

--- NEW FILE kvm-extboot.patch ---
commit f4483969eaa53a74263c8c55e5cf0a41ff97e2aa
Author: H. Peter Anvin <hpa at zytor.com>
Date:   Fri Jul 18 11:22:59 2008 -0700

    kvm: extboot: don't use interrupt vectors $0x2b and $0x2c
    
    extboot's use of interrupt vectors $0x2b and $0x2c is unsafe, as these
    interrupt vectors fall in the OS-use range (0x20-0x3f).  Furthermore,
    it's unnecessary: we can keep a local pointer instead of hooking
    another interrupt as long as we can write to our own segment.
    
    Make the extboot segment writable, and use local variables to hold the
    old link pointers.
    
    If this turns out to cause problems, we should probably switch to
    using vectors in the 0xc0-0xef range, and/or other BIOS-reserved
    memory.
    
    Signed-off-by: H. Peter Anvin <hpa at zytor.com>
    Signed-off-by: Avi Kivity <avi at qumranet.com>

diff --git a/extboot/extboot.S b/extboot/extboot.S
index 9eb9333..2630abb 100644
--- a/extboot/extboot.S
+++ b/extboot/extboot.S
@@ -25,45 +25,36 @@
 _start:
 	.short 0xaa55
 	.byte (_end - _start) / 512
-	push %ax
-	push %bx
-	push %cx
-	push %dx
+	push %eax
 	push %ds
 
 	/* setup ds so we can access the IVT */
 	xor %ax, %ax
 	mov %ax, %ds
 
-	/* save old int 19 at int 2b */
-	mov $(0x19 * 4), %bx
-	mov 0(%bx), %ax
-	mov 2(%bx), %cx
-
-	mov $(0x2b * 4), %bx
-	mov %ax, 0(%bx)
-	mov %cx, 2(%bx)
+	/* save old int 19 */
+	mov (0x19*4), %eax
+	mov %eax, %cs:old_int19
 
 	/* install out int 19 handler */
-	mov $(0x19 * 4), %bx
-	mov $int19_handler, %ax
-	mov %ax, 0(%bx)
-	mov %cs, 2(%bx)
+	movw $int19_handler, (0x19*4)
+	mov %cs, (0x19*4+2)
 
 	pop %ds
-	pop %dx
-	pop %cx
-	pop %bx
-	pop %ax
+	pop %eax
 	lret
 
 int19_handler:
-	push %ax
+	push %eax
 	push %bx
 	push %cx
 	push %dx
 	push %ds
 
+	/* setup ds to access IVT */
+	xor %ax, %ax
+	mov %ax, %ds
+
 	movw $0x404, %dx
 	inb %dx, %al
 	cmp $1, %al
@@ -73,25 +64,13 @@ int19_handler:
 	jmp 3f
 
 1: /* hook int13: intb(0x404) == 1 */
-	/* setup ds to access IVT */
-	xor %ax, %ax
-	mov %ax, %ds
-
 	/* save old int 13 to int 2c */
-	mov $(0x13 * 4), %bx
-	mov 0(%bx), %ax
-	mov 2(%bx), %cx
-
-	mov $(0x2c * 4), %bx
-	mov %ax, 0(%bx)
-	mov %cx, 2(%bx)
+	mov (0x13*4), %eax
+	mov %eax, %cs:old_int13
 
 	/* install our int 13 handler */
-	mov $(0x13 * 4), %bx
-	mov $int13_handler, %ax
-
-	mov %ax, 0(%bx)
-	mov %cs, 2(%bx)
+	movw $int13_handler, (0x13*4)
+	mov %cs, (0x13*4+2)
 	jmp 3f
 
 2: /* linux boot: intb(0x404) == 2 */
@@ -107,12 +86,16 @@ int19_handler:
 	ljmp $0x9000 + 0x20, $0
 
 3: /* fall through: inb(0x404) == 0 */
+	/* restore previous int $0x19 handler */
+	mov %cs:old_int19,%eax
+	mov %eax,(0x19*4)
+	
 	pop %ds
 	pop %dx
 	pop %cx
 	pop %bx
-	pop %ax
-	int $0x2b
+	pop %eax
+	ljmpw *%cs:old_int19
 
 #define FLAGS_CF	0x01
 
@@ -640,8 +623,7 @@ terminate_disk_emulation:
 int13_handler:
 	cmp $0x80, %dl
 	je 1f
-	int $0x2c
-	iret
+	ljmpw *%cs:old_int13
 1:
 	cmp $0x0, %ah
 	jne 1f
@@ -701,5 +683,10 @@ int13_handler:
 	int $0x18  /* boot failed */
 	iret
 
+/* Variables */
+.align 4, 0
+old_int13:	.long 0
+old_int19:	.long 0
+	
 .align 512, 0
 _end:


Index: kvm.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kvm/F-9/kvm.spec,v
retrieving revision 1.58
retrieving revision 1.58.2.1
diff -u -r1.58 -r1.58.2.1
--- kvm.spec	27 May 2008 13:28:35 -0000	1.58
+++ kvm.spec	27 Aug 2008 18:25:10 -0000	1.58.2.1
@@ -1,7 +1,7 @@
 Summary: Kernel-based Virtual Machine
 Name: kvm
 Version: 65
-Release: 7%{?dist}
+Release: 8_private_glommer_extboot%{?dist}
 License: GPLv2+ and LGPLv2+
 Group: Development/Tools
 URL: http://%{name}.sf.net
@@ -15,6 +15,7 @@
 Patch5: %{name}-65-cirrus.patch
 Patch6: %{name}-65-pty-rawmode.patch
 Patch7: %{name}-cirrus-bitblt-overflow.patch
+Patch8: %{name}-extboot.patch
 # patches from upstream qemu
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: SDL-devel
@@ -51,6 +52,7 @@
 %patch5 -p1
 %patch6 -p1
 %patch7 -p1
+%patch8 -p1
 
 %build
 # we need to install the data bits in a different path
@@ -105,6 +107,9 @@
 %{_sysconfdir}/sysconfig/modules/%{name}.modules
 
 %changelog
+* Wed Aug 27 2008 Glauber Costa <gcosta at redhat.com> - 65-8.fc9
+- qemu extboot problem fix.
+
 * Tue May 27 2008 Glauber Costa <gcosta at redhat.com> - 65-7.fc9
 - Fix the build
 




More information about the fedora-extras-commits mailing list