Re: [PATCH] fix i486 boot failure due to stale %ds

From: H. Peter Anvin
Date: Sun Nov 04 2007 - 14:01:20 EST


Urk, -ENOTAWAKEYET. Try *THIS* patch, please.

-hpa

diff --git a/arch/x86/boot/pmjump.S b/arch/x86/boot/pmjump.S
index 2e55923..17e6dec 100644
--- a/arch/x86/boot/pmjump.S
+++ b/arch/x86/boot/pmjump.S
@@ -28,27 +28,37 @@
* void protected_mode_jump(u32 entrypoint, u32 bootparams);
*/
protected_mode_jump:
- xorl %ebx, %ebx # Flag to indicate this is a boot
movl %edx, %esi # Pointer to boot_params table
- movl %eax, 2f # Patch ljmpl instruction
+
+ xorl %edx, %edx
+ movw %cs, %dx
+ shll $4, %edx # Patch ljmpl instruction
+ addl %edx, 2f
jmp 1f # Short jump to flush instruction q.

1:
movw $__BOOT_DS, %cx
+ xorl %ebx, %ebx # Per protocol
+ xorl %ebp, %ebp # Per protocol
+ xorl %edi, %edi # Per protocol

movl %cr0, %edx
orb $1, %dl # Protected mode (PE) bit
movl %edx, %cr0
+
+ .byte 0x66, 0xea # ljmpl opcode
+2: .long 3f # Offset
+ .word __BOOT_CS # Segment

- movw %cx, %ds
- movw %cx, %es
- movw %cx, %fs
- movw %cx, %gs
- movw %cx, %ss
+ .code32
+3:
+ movl %ecx, %ds
+ movl %ecx, %es
+ movl %ecx, %fs
+ movl %ecx, %gs
+ movl %ecx, %ss

# Jump to the 32-bit entrypoint
- .byte 0x66, 0xea # ljmpl opcode
-2: .long 0 # offset
- .word __BOOT_CS # segment
-
+ jmpl *%eax
+
.size protected_mode_jump, .-protected_mode_jump