aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-01-30 07:33:01 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:33:01 -0500
commitc4d9ba6da9f050ebb7e0d70769e3dca0fd45334f (patch)
tree03c771875a9cf2cc2026066f8a686cf53f0739f4
parent2a6648e65a2939b80c44262975176a15bac3a75e (diff)
x86 setup: make PM transition more paranoid; cleanup 32-bit entry
Make the transition to protected mode more paranoid by having back-to-back near jump (to synchronize the 386/486 prefetch queue) and far jump (to set up the code segment.) While we're at it, zero as many registers as practical (for future expandability of the 32-bit entry interface) and enter 32-bit mode with a valid stack. Note that the 32-bit code cannot rely on this stack, or we'll break all other existing users of the 32-bit entrypoint, but it may make debugging hacks easier to write. Signed-off-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--arch/x86/boot/pmjump.S44
1 files changed, 32 insertions, 12 deletions
diff --git a/arch/x86/boot/pmjump.S b/arch/x86/boot/pmjump.S
index fa6bed1fac14..ef0da1f2c7fd 100644
--- a/arch/x86/boot/pmjump.S
+++ b/arch/x86/boot/pmjump.S
@@ -29,12 +29,13 @@
29 */ 29 */
30protected_mode_jump: 30protected_mode_jump:
31 movl %edx, %esi # Pointer to boot_params table 31 movl %edx, %esi # Pointer to boot_params table
32 movl %eax, 2f # Patch ljmpl instruction 32
33 xorl %ebx, %ebx
34 movw %cs, %bx
35 shll $4, %ebx
36 addl %ebx, 2f
33 37
34 movw $__BOOT_DS, %cx 38 movw $__BOOT_DS, %cx
35 xorl %ebx, %ebx # Per the 32-bit boot protocol
36 xorl %ebp, %ebp # Per the 32-bit boot protocol
37 xorl %edi, %edi # Per the 32-bit boot protocol
38 39
39 movl %cr0, %edx 40 movl %cr0, %edx
40 orb $1, %dl # Protected mode (PE) bit 41 orb $1, %dl # Protected mode (PE) bit
@@ -42,15 +43,34 @@ protected_mode_jump:
42 jmp 1f # Short jump to serialize on 386/486 43 jmp 1f # Short jump to serialize on 386/486
431: 441:
44 45
45 movw %cx, %ds 46 # Transition to 32-bit mode
46 movw %cx, %es
47 movw %cx, %fs
48 movw %cx, %gs
49 movw %cx, %ss
50
51 # Jump to the 32-bit entrypoint
52 .byte 0x66, 0xea # ljmpl opcode 47 .byte 0x66, 0xea # ljmpl opcode
532: .long 0 # offset 482: .long in_pm32 # offset
54 .word __BOOT_CS # segment 49 .word __BOOT_CS # segment
55 50
56 .size protected_mode_jump, .-protected_mode_jump 51 .size protected_mode_jump, .-protected_mode_jump
52
53 .code32
54 .type in_pm32, @function
55in_pm32:
56 # Set up data segments for flat 32-bit mode
57 movl %ecx, %ds
58 movl %ecx, %es
59 movl %ecx, %fs
60 movl %ecx, %gs
61 movl %ecx, %ss
62 # The 32-bit code sets up its own stack, but this way we do have
63 # a valid stack if some debugging hack wants to use it.
64 addl %ebx, %esp
65
66 # Clear registers to allow for future extensions to the
67 # 32-bit boot protocol
68 xorl %ecx, %ecx
69 xorl %edx, %edx
70 xorl %ebx, %ebx
71 xorl %ebp, %ebp
72 xorl %edi, %edi
73
74 jmpl *%eax # Jump to the 32-bit entrypoint
75
76 .size in_pm32, .-in_pm32