|
6 | 6 |
|
7 | 7 | .code32
|
8 | 8 | .text
|
| 9 | +#ifdef CONFIG_X86_32 |
9 | 10 | #define _pa(x) ((x) - __START_KERNEL_map)
|
| 11 | +#endif |
10 | 12 | #define rva(x) ((x) - pvh_start_xen)
|
11 | 13 |
|
12 | 14 | #include <linux/elfnote.h>
|
@@ -72,8 +74,7 @@ SYM_CODE_START(pvh_start_xen)
|
72 | 74 | movl $0, %esp
|
73 | 75 |
|
74 | 76 | leal rva(gdt)(%ebp), %eax
|
75 |
| - leal rva(gdt_start)(%ebp), %ecx |
76 |
| - movl %ecx, 2(%eax) |
| 77 | + addl %eax, 2(%eax) |
77 | 78 | lgdt (%eax)
|
78 | 79 |
|
79 | 80 | mov $PVH_DS_SEL,%eax
|
@@ -103,10 +104,23 @@ SYM_CODE_START(pvh_start_xen)
|
103 | 104 | btsl $_EFER_LME, %eax
|
104 | 105 | wrmsr
|
105 | 106 |
|
| 107 | + /* |
| 108 | + * Reuse the non-relocatable symbol emitted for the ELF note to |
| 109 | + * subtract the build time physical address of pvh_start_xen() from |
| 110 | + * its actual runtime address, without relying on absolute 32-bit ELF |
| 111 | + * relocations, as these are not supported by the linker when running |
| 112 | + * in -pie mode, and should be avoided in .head.text in general. |
| 113 | + */ |
106 | 114 | mov %ebp, %ebx
|
107 |
| - subl $_pa(pvh_start_xen), %ebx /* offset */ |
| 115 | + subl rva(xen_elfnote_phys32_entry)(%ebp), %ebx |
108 | 116 | jz .Lpagetable_done
|
109 | 117 |
|
| 118 | + /* |
| 119 | + * Store the resulting load offset in phys_base. __pa() needs |
| 120 | + * phys_base set to calculate the hypercall page in xen_pvh_init(). |
| 121 | + */ |
| 122 | + movl %ebx, rva(phys_base)(%ebp) |
| 123 | + |
110 | 124 | /* Fixup page-tables for relocation. */
|
111 | 125 | leal rva(pvh_init_top_pgt)(%ebp), %edi
|
112 | 126 | movl $PTRS_PER_PGD, %ecx
|
@@ -165,14 +179,6 @@ SYM_CODE_START(pvh_start_xen)
|
165 | 179 | xor %edx, %edx
|
166 | 180 | wrmsr
|
167 | 181 |
|
168 |
| - /* |
169 |
| - * Calculate load offset and store in phys_base. __pa() needs |
170 |
| - * phys_base set to calculate the hypercall page in xen_pvh_init(). |
171 |
| - */ |
172 |
| - movq %rbp, %rbx |
173 |
| - subq $_pa(pvh_start_xen), %rbx |
174 |
| - movq %rbx, phys_base(%rip) |
175 |
| - |
176 | 182 | /* Call xen_prepare_pvh() via the kernel virtual mapping */
|
177 | 183 | leaq xen_prepare_pvh(%rip), %rax
|
178 | 184 | subq phys_base(%rip), %rax
|
@@ -218,7 +224,7 @@ SYM_CODE_END(pvh_start_xen)
|
218 | 224 | .balign 8
|
219 | 225 | SYM_DATA_START_LOCAL(gdt)
|
220 | 226 | .word gdt_end - gdt_start - 1
|
221 |
| - .long _pa(gdt_start) /* x86-64 will overwrite if relocated. */ |
| 227 | + .long gdt_start - gdt |
222 | 228 | .word 0
|
223 | 229 | SYM_DATA_END(gdt)
|
224 | 230 | SYM_DATA_START_LOCAL(gdt_start)
|
|
0 commit comments