1/* 2 * Copyright (C) 2003,2004 Eric Biederman (ebiederm@xmission.com) 3 * Copyright (C) 2014 Red Hat Inc. 4 5 * Author(s): Vivek Goyal <vgoyal@redhat.com> 6 * 7 * This code has been taken from kexec-tools. 8 * 9 * This source code is licensed under the GNU General Public License, 10 * Version 2. See the file COPYING for more details. 11 */ 12 13 .text 14 .balign 16 15 .code64 16 .globl entry64, entry64_regs 17 18 19entry64: 20 /* Setup a gdt that should be preserved */ 21 lgdt gdt(%rip) 22 23 /* load the data segments */ 24 movl $0x18, %eax /* data segment */ 25 movl %eax, %ds 26 movl %eax, %es 27 movl %eax, %ss 28 movl %eax, %fs 29 movl %eax, %gs 30 31 /* Setup new stack */ 32 leaq stack_init(%rip), %rsp 33 pushq $0x10 /* CS */ 34 leaq new_cs_exit(%rip), %rax 35 pushq %rax 36 lretq 37new_cs_exit: 38 39 /* Load the registers */ 40 movq rax(%rip), %rax 41 movq rbx(%rip), %rbx 42 movq rcx(%rip), %rcx 43 movq rdx(%rip), %rdx 44 movq rsi(%rip), %rsi 45 movq rdi(%rip), %rdi 46 movq rsp(%rip), %rsp 47 movq rbp(%rip), %rbp 48 movq r8(%rip), %r8 49 movq r9(%rip), %r9 50 movq r10(%rip), %r10 51 movq r11(%rip), %r11 52 movq r12(%rip), %r12 53 movq r13(%rip), %r13 54 movq r14(%rip), %r14 55 movq r15(%rip), %r15 56 57 /* Jump to the new code... */ 58 jmpq *rip(%rip) 59 60 .section ".rodata" 61 .balign 4 62entry64_regs: 63rax: .quad 0x0 64rcx: .quad 0x0 65rdx: .quad 0x0 66rbx: .quad 0x0 67rsp: .quad 0x0 68rbp: .quad 0x0 69rsi: .quad 0x0 70rdi: .quad 0x0 71r8: .quad 0x0 72r9: .quad 0x0 73r10: .quad 0x0 74r11: .quad 0x0 75r12: .quad 0x0 76r13: .quad 0x0 77r14: .quad 0x0 78r15: .quad 0x0 79rip: .quad 0x0 80 .size entry64_regs, . - entry64_regs 81 82 /* GDT */ 83 .section ".rodata" 84 .balign 16 85gdt: 86 /* 0x00 unusable segment 87 * 0x08 unused 88 * so use them as gdt ptr 89 */ 90 .word gdt_end - gdt - 1 91 .quad gdt 92 .word 0, 0, 0 93 94 /* 0x10 4GB flat code segment */ 95 .word 0xFFFF, 0x0000, 0x9A00, 0x00AF 96 97 /* 0x18 4GB flat data segment */ 98 .word 0xFFFF, 0x0000, 0x9200, 0x00CF 99gdt_end: 100stack: .quad 0, 0 101stack_init: 102