diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-21 13:41:29 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-21 13:41:29 -0500 |
| commit | 5fbe4c224ce3e2e62bd487158dfd1e89f9ae3e11 (patch) | |
| tree | aee3c146fb7dd3dd10cb71f44affa9c680481f08 /arch/x86/platform | |
| parent | e2defd02717ebc54ae2f4862271a3093665b426a (diff) | |
| parent | 570e1aa84c376ff39809442f09c7606ddf62cfd1 (diff) | |
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull misc x86 fixes from Ingo Molnar:
"This contains:
- EFI fixes
- a boot printout fix
- ASLR/kASLR fixes
- intel microcode driver fixes
- other misc fixes
Most of the linecount comes from an EFI revert"
* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/mm/ASLR: Avoid PAGE_SIZE redefinition for UML subarch
x86/microcode/intel: Handle truncated microcode images more robustly
x86/microcode/intel: Guard against stack overflow in the loader
x86, mm/ASLR: Fix stack randomization on 64-bit systems
x86/mm/init: Fix incorrect page size in init_memory_mapping() printks
x86/mm/ASLR: Propagate base load address calculation
Documentation/x86: Fix path in zero-page.txt
x86/apic: Fix the devicetree build in certain configs
Revert "efi/libstub: Call get_memory_map() to obtain map and desc sizes"
x86/efi: Avoid triple faults during EFI mixed mode calls
Diffstat (limited to 'arch/x86/platform')
| -rw-r--r-- | arch/x86/platform/efi/efi_stub_64.S | 161 | ||||
| -rw-r--r-- | arch/x86/platform/efi/efi_thunk_64.S | 121 |
2 files changed, 104 insertions, 178 deletions
diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S index 5fcda7272550..86d0f9e08dd9 100644 --- a/arch/x86/platform/efi/efi_stub_64.S +++ b/arch/x86/platform/efi/efi_stub_64.S | |||
| @@ -91,167 +91,6 @@ ENTRY(efi_call) | |||
| 91 | ret | 91 | ret |
| 92 | ENDPROC(efi_call) | 92 | ENDPROC(efi_call) |
| 93 | 93 | ||
| 94 | #ifdef CONFIG_EFI_MIXED | ||
| 95 | |||
| 96 | /* | ||
| 97 | * We run this function from the 1:1 mapping. | ||
| 98 | * | ||
| 99 | * This function must be invoked with a 1:1 mapped stack. | ||
| 100 | */ | ||
| 101 | ENTRY(__efi64_thunk) | ||
| 102 | movl %ds, %eax | ||
| 103 | push %rax | ||
| 104 | movl %es, %eax | ||
| 105 | push %rax | ||
| 106 | movl %ss, %eax | ||
| 107 | push %rax | ||
| 108 | |||
| 109 | subq $32, %rsp | ||
| 110 | movl %esi, 0x0(%rsp) | ||
| 111 | movl %edx, 0x4(%rsp) | ||
| 112 | movl %ecx, 0x8(%rsp) | ||
| 113 | movq %r8, %rsi | ||
| 114 | movl %esi, 0xc(%rsp) | ||
| 115 | movq %r9, %rsi | ||
| 116 | movl %esi, 0x10(%rsp) | ||
| 117 | |||
| 118 | sgdt save_gdt(%rip) | ||
| 119 | |||
| 120 | leaq 1f(%rip), %rbx | ||
| 121 | movq %rbx, func_rt_ptr(%rip) | ||
| 122 | |||
| 123 | /* Switch to gdt with 32-bit segments */ | ||
| 124 | movl 64(%rsp), %eax | ||
| 125 | lgdt (%rax) | ||
| 126 | |||
| 127 | leaq efi_enter32(%rip), %rax | ||
| 128 | pushq $__KERNEL_CS | ||
| 129 | pushq %rax | ||
| 130 | lretq | ||
| 131 | |||
| 132 | 1: addq $32, %rsp | ||
| 133 | |||
| 134 | lgdt save_gdt(%rip) | ||
| 135 | |||
| 136 | pop %rbx | ||
| 137 | movl %ebx, %ss | ||
| 138 | pop %rbx | ||
| 139 | movl %ebx, %es | ||
| 140 | pop %rbx | ||
| 141 | movl %ebx, %ds | ||
| 142 | |||
| 143 | /* | ||
| 144 | * Convert 32-bit status code into 64-bit. | ||
| 145 | */ | ||
| 146 | test %rax, %rax | ||
| 147 | jz 1f | ||
| 148 | movl %eax, %ecx | ||
| 149 | andl $0x0fffffff, %ecx | ||
| 150 | andl $0xf0000000, %eax | ||
| 151 | shl $32, %rax | ||
| 152 | or %rcx, %rax | ||
| 153 | 1: | ||
| 154 | ret | ||
| 155 | ENDPROC(__efi64_thunk) | ||
| 156 | |||
| 157 | ENTRY(efi_exit32) | ||
| 158 | movq func_rt_ptr(%rip), %rax | ||
| 159 | push %rax | ||
| 160 | mov %rdi, %rax | ||
| 161 | ret | ||
| 162 | ENDPROC(efi_exit32) | ||
| 163 | |||
| 164 | .code32 | ||
| 165 | /* | ||
| 166 | * EFI service pointer must be in %edi. | ||
| 167 | * | ||
| 168 | * The stack should represent the 32-bit calling convention. | ||
| 169 | */ | ||
| 170 | ENTRY(efi_enter32) | ||
| 171 | movl $__KERNEL_DS, %eax | ||
| 172 | movl %eax, %ds | ||
| 173 | movl %eax, %es | ||
| 174 | movl %eax, %ss | ||
| 175 | |||
| 176 | /* Reload pgtables */ | ||
| 177 | movl %cr3, %eax | ||
| 178 | movl %eax, %cr3 | ||
| 179 | |||
| 180 | /* Disable paging */ | ||
| 181 | movl %cr0, %eax | ||
| 182 | btrl $X86_CR0_PG_BIT, %eax | ||
| 183 | movl %eax, %cr0 | ||
| 184 | |||
| 185 | /* Disable long mode via EFER */ | ||
| 186 | movl $MSR_EFER, %ecx | ||
| 187 | rdmsr | ||
| 188 | btrl $_EFER_LME, %eax | ||
| 189 | wrmsr | ||
| 190 | |||
| 191 | call *%edi | ||
| 192 | |||
| 193 | /* We must preserve return value */ | ||
| 194 | movl %eax, %edi | ||
| 195 | |||
| 196 | /* | ||
| 197 | * Some firmware will return with interrupts enabled. Be sure to | ||
| 198 | * disable them before we switch GDTs. | ||
| 199 | */ | ||
| 200 | cli | ||
| 201 | |||
| 202 | movl 68(%esp), %eax | ||
| 203 | movl %eax, 2(%eax) | ||
| 204 | lgdtl (%eax) | ||
| 205 | |||
| 206 | movl %cr4, %eax | ||
| 207 | btsl $(X86_CR4_PAE_BIT), %eax | ||
| 208 | movl %eax, %cr4 | ||
| 209 | |||
| 210 | movl %cr3, %eax | ||
| 211 | movl %eax, %cr3 | ||
| 212 | |||
| 213 | movl $MSR_EFER, %ecx | ||
| 214 | rdmsr | ||
| 215 | btsl $_EFER_LME, %eax | ||
| 216 | wrmsr | ||
| 217 | |||
| 218 | xorl %eax, %eax | ||
| 219 | lldt %ax | ||
| 220 | |||
| 221 | movl 72(%esp), %eax | ||
| 222 | pushl $__KERNEL_CS | ||
| 223 | pushl %eax | ||
| 224 | |||
| 225 | /* Enable paging */ | ||
| 226 | movl %cr0, %eax | ||
| 227 | btsl $X86_CR0_PG_BIT, %eax | ||
| 228 | movl %eax, %cr0 | ||
| 229 | lret | ||
| 230 | ENDPROC(efi_enter32) | ||
| 231 | |||
| 232 | .data | ||
| 233 | .balign 8 | ||
| 234 | .global efi32_boot_gdt | ||
| 235 | efi32_boot_gdt: .word 0 | ||
| 236 | .quad 0 | ||
| 237 | |||
| 238 | save_gdt: .word 0 | ||
| 239 | .quad 0 | ||
| 240 | func_rt_ptr: .quad 0 | ||
| 241 | |||
| 242 | .global efi_gdt64 | ||
| 243 | efi_gdt64: | ||
| 244 | .word efi_gdt64_end - efi_gdt64 | ||
| 245 | .long 0 /* Filled out by user */ | ||
| 246 | .word 0 | ||
| 247 | .quad 0x0000000000000000 /* NULL descriptor */ | ||
| 248 | .quad 0x00af9a000000ffff /* __KERNEL_CS */ | ||
| 249 | .quad 0x00cf92000000ffff /* __KERNEL_DS */ | ||
| 250 | .quad 0x0080890000000000 /* TS descriptor */ | ||
| 251 | .quad 0x0000000000000000 /* TS continued */ | ||
| 252 | efi_gdt64_end: | ||
| 253 | #endif /* CONFIG_EFI_MIXED */ | ||
| 254 | |||
| 255 | .data | 94 | .data |
| 256 | ENTRY(efi_scratch) | 95 | ENTRY(efi_scratch) |
| 257 | .fill 3,8,0 | 96 | .fill 3,8,0 |
diff --git a/arch/x86/platform/efi/efi_thunk_64.S b/arch/x86/platform/efi/efi_thunk_64.S index 8806fa73e6e6..ff85d28c50f2 100644 --- a/arch/x86/platform/efi/efi_thunk_64.S +++ b/arch/x86/platform/efi/efi_thunk_64.S | |||
| @@ -1,9 +1,26 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2014 Intel Corporation; author Matt Fleming | 2 | * Copyright (C) 2014 Intel Corporation; author Matt Fleming |
| 3 | * | ||
| 4 | * Support for invoking 32-bit EFI runtime services from a 64-bit | ||
| 5 | * kernel. | ||
| 6 | * | ||
| 7 | * The below thunking functions are only used after ExitBootServices() | ||
| 8 | * has been called. This simplifies things considerably as compared with | ||
| 9 | * the early EFI thunking because we can leave all the kernel state | ||
| 10 | * intact (GDT, IDT, etc) and simply invoke the the 32-bit EFI runtime | ||
| 11 | * services from __KERNEL32_CS. This means we can continue to service | ||
| 12 | * interrupts across an EFI mixed mode call. | ||
| 13 | * | ||
| 14 | * We do however, need to handle the fact that we're running in a full | ||
