diff options
Diffstat (limited to 'arch/x86/purgatory/entry64.S')
-rw-r--r-- | arch/x86/purgatory/entry64.S | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/arch/x86/purgatory/entry64.S b/arch/x86/purgatory/entry64.S new file mode 100644 index 000000000000..be3249d7ed2d --- /dev/null +++ b/arch/x86/purgatory/entry64.S | |||
@@ -0,0 +1,101 @@ | |||
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 | |||
19 | entry64: | ||
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 | ||
37 | new_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 | ||
62 | entry64_regs: | ||
63 | rax: .quad 0x0 | ||
64 | rbx: .quad 0x0 | ||
65 | rcx: .quad 0x0 | ||
66 | rdx: .quad 0x0 | ||
67 | rsi: .quad 0x0 | ||
68 | rdi: .quad 0x0 | ||
69 | rsp: .quad 0x0 | ||
70 | rbp: .quad 0x0 | ||
71 | r8: .quad 0x0 | ||
72 | r9: .quad 0x0 | ||
73 | r10: .quad 0x0 | ||
74 | r11: .quad 0x0 | ||
75 | r12: .quad 0x0 | ||
76 | r13: .quad 0x0 | ||
77 | r14: .quad 0x0 | ||
78 | r15: .quad 0x0 | ||
79 | rip: .quad 0x0 | ||
80 | .size entry64_regs, . - entry64_regs | ||
81 | |||
82 | /* GDT */ | ||
83 | .section ".rodata" | ||
84 | .balign 16 | ||
85 | gdt: | ||
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 | ||
99 | gdt_end: | ||
100 | stack: .quad 0, 0 | ||
101 | stack_init: | ||