diff options
Diffstat (limited to 'arch/x86/kernel/relocate_kernel_64.S')
-rw-r--r-- | arch/x86/kernel/relocate_kernel_64.S | 129 |
1 files changed, 5 insertions, 124 deletions
diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S index f5afe665a82b..d32cfb27a479 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S | |||
@@ -7,10 +7,10 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/linkage.h> | 9 | #include <linux/linkage.h> |
10 | #include <asm/page.h> | 10 | #include <asm/page_types.h> |
11 | #include <asm/kexec.h> | 11 | #include <asm/kexec.h> |
12 | #include <asm/processor-flags.h> | 12 | #include <asm/processor-flags.h> |
13 | #include <asm/pgtable.h> | 13 | #include <asm/pgtable_types.h> |
14 | 14 | ||
15 | /* | 15 | /* |
16 | * Must be relocatable PIC code callable as a C function | 16 | * Must be relocatable PIC code callable as a C function |
@@ -29,122 +29,6 @@ relocate_kernel: | |||
29 | * %rdx start address | 29 | * %rdx start address |
30 | */ | 30 | */ |
31 | 31 | ||
32 | /* map the control page at its virtual address */ | ||
33 | |||
34 | movq $0x0000ff8000000000, %r10 /* mask */ | ||
35 | mov $(39 - 3), %cl /* bits to shift */ | ||
36 | movq PTR(VA_CONTROL_PAGE)(%rsi), %r11 /* address to map */ | ||
37 | |||
38 | movq %r11, %r9 | ||
39 | andq %r10, %r9 | ||
40 | shrq %cl, %r9 | ||
41 | |||
42 | movq PTR(VA_PGD)(%rsi), %r8 | ||
43 | addq %r8, %r9 | ||
44 | movq PTR(PA_PUD_0)(%rsi), %r8 | ||
45 | orq $PAGE_ATTR, %r8 | ||
46 | movq %r8, (%r9) | ||
47 | |||
48 | shrq $9, %r10 | ||
49 | sub $9, %cl | ||
50 | |||
51 | movq %r11, %r9 | ||
52 | andq %r10, %r9 | ||
53 | shrq %cl, %r9 | ||
54 | |||
55 | movq PTR(VA_PUD_0)(%rsi), %r8 | ||
56 | addq %r8, %r9 | ||
57 | movq PTR(PA_PMD_0)(%rsi), %r8 | ||
58 | orq $PAGE_ATTR, %r8 | ||
59 | movq %r8, (%r9) | ||
60 | |||
61 | shrq $9, %r10 | ||
62 | sub $9, %cl | ||
63 | |||
64 | movq %r11, %r9 | ||
65 | andq %r10, %r9 | ||
66 | shrq %cl, %r9 | ||
67 | |||
68 | movq PTR(VA_PMD_0)(%rsi), %r8 | ||
69 | addq %r8, %r9 | ||
70 | movq PTR(PA_PTE_0)(%rsi), %r8 | ||
71 | orq $PAGE_ATTR, %r8 | ||
72 | movq %r8, (%r9) | ||
73 | |||
74 | shrq $9, %r10 | ||
75 | sub $9, %cl | ||
76 | |||
77 | movq %r11, %r9 | ||
78 | andq %r10, %r9 | ||
79 | shrq %cl, %r9 | ||
80 | |||
81 | movq PTR(VA_PTE_0)(%rsi), %r8 | ||
82 | addq %r8, %r9 | ||
83 | movq PTR(PA_CONTROL_PAGE)(%rsi), %r8 | ||
84 | orq $PAGE_ATTR, %r8 | ||
85 | movq %r8, (%r9) | ||
86 | |||
87 | /* identity map the control page at its physical address */ | ||
88 | |||
89 | movq $0x0000ff8000000000, %r10 /* mask */ | ||
90 | mov $(39 - 3), %cl /* bits to shift */ | ||
91 | movq PTR(PA_CONTROL_PAGE)(%rsi), %r11 /* address to map */ | ||
92 | |||
93 | movq %r11, %r9 | ||
94 | andq %r10, %r9 | ||
95 | shrq %cl, %r9 | ||
96 | |||
97 | movq PTR(VA_PGD)(%rsi), %r8 | ||
98 | addq %r8, %r9 | ||
99 | movq PTR(PA_PUD_1)(%rsi), %r8 | ||
100 | orq $PAGE_ATTR, %r8 | ||
101 | movq %r8, (%r9) | ||
102 | |||
103 | shrq $9, %r10 | ||
104 | sub $9, %cl | ||
105 | |||
106 | movq %r11, %r9 | ||
107 | andq %r10, %r9 | ||
108 | shrq %cl, %r9 | ||
109 | |||
110 | movq PTR(VA_PUD_1)(%rsi), %r8 | ||
111 | addq %r8, %r9 | ||
112 | movq PTR(PA_PMD_1)(%rsi), %r8 | ||
113 | orq $PAGE_ATTR, %r8 | ||
114 | movq %r8, (%r9) | ||
115 | |||
116 | shrq $9, %r10 | ||
117 | sub $9, %cl | ||
118 | |||
119 | movq %r11, %r9 | ||
120 | andq %r10, %r9 | ||
121 | shrq %cl, %r9 | ||
122 | |||
123 | movq PTR(VA_PMD_1)(%rsi), %r8 | ||
124 | addq %r8, %r9 | ||
125 | movq PTR(PA_PTE_1)(%rsi), %r8 | ||
126 | orq $PAGE_ATTR, %r8 | ||
127 | movq %r8, (%r9) | ||
128 | |||
129 | shrq $9, %r10 | ||
130 | sub $9, %cl | ||
131 | |||
132 | movq %r11, %r9 | ||
133 | andq %r10, %r9 | ||
134 | shrq %cl, %r9 | ||
135 | |||
136 | movq PTR(VA_PTE_1)(%rsi), %r8 | ||
137 | addq %r8, %r9 | ||
138 | movq PTR(PA_CONTROL_PAGE)(%rsi), %r8 | ||
139 | orq $PAGE_ATTR, %r8 | ||
140 | movq %r8, (%r9) | ||
141 | |||
142 | relocate_new_kernel: | ||
143 | /* %rdi indirection_page | ||
144 | * %rsi page_list | ||
145 | * %rdx start address | ||
146 | */ | ||
147 | |||
148 | /* zero out flags, and disable interrupts */ | 32 | /* zero out flags, and disable interrupts */ |
149 | pushq $0 | 33 | pushq $0 |
150 | popfq | 34 | popfq |
@@ -156,9 +40,8 @@ relocate_new_kernel: | |||
156 | /* get physical address of page table now too */ | 40 | /* get physical address of page table now too */ |
157 | movq PTR(PA_TABLE_PAGE)(%rsi), %rcx | 41 | movq PTR(PA_TABLE_PAGE)(%rsi), %rcx |
158 | 42 | ||
159 | /* switch to new set of page tables */ | 43 | /* Switch to the identity mapped page tables */ |
160 | movq PTR(PA_PGD)(%rsi), %r9 | 44 | movq %rcx, %cr3 |
161 | movq %r9, %cr3 | ||
162 | 45 | ||
163 | /* setup a new stack at the end of the physical control page */ | 46 | /* setup a new stack at the end of the physical control page */ |
164 | lea PAGE_SIZE(%r8), %rsp | 47 | lea PAGE_SIZE(%r8), %rsp |
@@ -194,9 +77,7 @@ identity_mapped: | |||
194 | jmp 1f | 77 | jmp 1f |
195 | 1: | 78 | 1: |
196 | 79 | ||
197 | /* Switch to the identity mapped page tables, | 80 | /* Flush the TLB (needed?) */ |
198 | * and flush the TLB. | ||
199 | */ | ||
200 | movq %rcx, %cr3 | 81 | movq %rcx, %cr3 |
201 | 82 | ||
202 | /* Do the copies */ | 83 | /* Do the copies */ |