~ubuntu-branches/ubuntu/trusty/seabios/trusty-proposed

« back to all changes in this revision

Viewing changes to debian/patches/vgabios-attempt-to-detect-old-x86emu-and-force-a-fault.diff

  • Committer: Package Import Robot
  • Author(s): Michael Tokarev
  • Date: 2014-02-17 21:35:59 UTC
  • Revision ID: package-import@ubuntu.com-20140217213559-cuhrmak46sc5121g
Tags: 1.7.4-4
apply vgabios-attempt-to-detect-old-x86emu-and-force-a-fault.diff:
a patch from upstream to work around apparently broken x86 emulation
in some software.  (Closes: #737142)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From: Kevin O'Connor <kevin@koconnor.net>
 
2
Date: Wed Feb 5 22:47:29 2014 -0500
 
3
Subject: vgabios: Attempt to detect old x86emu and force a fault.
 
4
Upstream-Commit: 8032b8a0fec550de5cb2f7d37aa031cebc2200c3
 
5
Bug-Debian: http://bugs.debian.org/737142
 
6
 
 
7
Check for cases where the leal instruction does not work.  This
 
8
instruction is known to not be emulated properly on old versions of
 
9
x86emu.  If a broken version of x86emu is found, force a fault that
 
10
x86emu will easily detect.  This should help prevent soft failures
 
11
when running old software.
 
12
    
 
13
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
 
14
 
 
15
diff --git a/vgasrc/vgaentry.S b/vgasrc/vgaentry.S
 
16
index 9854448..6e31c4e 100644
 
17
--- a/vgasrc/vgaentry.S
 
18
+++ b/vgasrc/vgaentry.S
 
19
@@ -45,9 +45,26 @@ _rom_header_signature:
 
20
  * Entry points
 
21
  ****************************************************************/
 
22
 
 
23
-        // This macro is the same as ENTRY_ARG except the "calll"
 
24
-        // instruction is avoided to work around known issues in the
 
25
-        // emulation of some versions of x86emu.
 
26
+        // Force a fault if found to be running on broken x86emu versions.
 
27
+        DECLFUNC x86emu_fault
 
28
+x86emu_fault:
 
29
+1:      hlt
 
30
+        jmp 1b
 
31
+
 
32
+        // This macro implements a call while avoiding instructions
 
33
+        // that old versions of x86emu have problems with.
 
34
+        .macro VGA_CALLL cfunc
 
35
+        // Make sure leal instruction works.
 
36
+        movl $0x8000, %ecx
 
37
+        leal (%ecx, %ecx, 1), %ecx
 
38
+        cmpl $0x10000, %ecx
 
39
+        jne x86emu_fault
 
40
+        // Use callw instead of calll
 
41
+        push %ax
 
42
+        callw \cfunc
 
43
+        .endm
 
44
+
 
45
+        // This macro is the same as ENTRY_ARG except VGA_CALLL is used.
 
46
         .macro ENTRY_ARG_VGA cfunc
 
47
         cli
 
48
         cld
 
49
@@ -57,7 +74,7 @@ _rom_header_signature:
 
50
         movl %esp, %ebx         // Backup %esp, then zero high bits
 
51
         movzwl %sp, %esp
 
52
         movl %esp, %eax         // First arg is pointer to struct bregs
 
53
-        pushw %ax ; callw \cfunc
 
54
+        VGA_CALLL \cfunc
 
55
         movl %ebx, %esp         // Restore %esp (including high bits)
 
56
         POPBREGS
 
57
         .endm
 
58
@@ -103,7 +120,7 @@ entry_10_extrastack:
 
59
         movw %ds, %dx           // Setup %ss/%esp and call function
 
60
         movw %dx, %ss
 
61
         movl %eax, %esp
 
62
-        pushw %ax ; callw handle_10
 
63
+        VGA_CALLL handle_10
 
64
 
 
65
         movl %esp, %eax         // Restore registers and return
 
66
         movw BREGS_size+4(%eax), %ss