kexec-tools: Setup CS when booting vmlinux (x86_64)

The purgatory code in kexec-tools does not currently setup CS when booting a
64-bit ELF file such as a vmlinux file. This together with the fact that the 
Linux kernel doesn't reload CS properly if booted from the 64-bit entry point
means that booting a vmlinux may fail under certain conditions.

The only known combination that triggers this problem is when kexec-tools and
kexec are used to load a x86_64 vmlinux under a dom0 Linux running under the
Xen hypervisor.

This patch is needed for sure to reload kernels with version <= 2.6.17. There
are fixes for this problem in the URL below, but if a fix will be included in
2.6.18 or not is unknown at this time.

http://permalink.gmane.org/gmane.linux.kernel/438998

Signed-off-by: Magnus Damm <[EMAIL PROTECTED]>
---

 entry64.S |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

--- 0001/purgatory/arch/x86_64/entry64.S
+++ 0002/purgatory/arch/x86_64/entry64.S        2006-08-23 11:40:56.000000000 
+0900
@@ -37,8 +37,12 @@ entry64:
        movl    %eax, %fs
        movl    %eax, %gs
 
-       /* In 64bit mode the code segment is meaningless */
-
+       movq    $stack_init, %rsp
+       pushq   $0x10 /* CS */
+       pushq   $new_cs_exit
+       lretq
+new_cs_exit:                   
+       
        /* Load the registers */
        movq    rax(%rip), %rax
        movq    rbx(%rip), %rbx
@@ -93,8 +97,10 @@ gdt: /* 0x00 unusable segment 
        .word   0, 0, 0
                        
        /* 0x10 4GB flat code segment */
-       .word   0xFFFF, 0x0000, 0x9A00, 0x00CF
+       .word   0xFFFF, 0x0000, 0x9A00, 0x00AF
        
        /* 0x18 4GB flat data segment */
        .word   0xFFFF, 0x0000, 0x9200, 0x00CF
 gdt_end:
+stack: .quad   0, 0
+stack_init:    
_______________________________________________
fastboot mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/fastboot

Reply via email to