Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fixes from Thomas Gleixner:
"A small set of x86 fixes:

- Prevent a NULL pointer dereference in the X2APIC code in case of a
CPU hotplug failure.

- Prevent boot failures on HP superdome machines by invalidating the
level2 kernel pagetable entries outside of the kernel area as
invalid so BIOS reserved space won't be touched unintentionally.

Also ensure that memory holes are rounded up to the next PMD
boundary correctly.

- Enable X2APIC support on Hyper-V to prevent boot failures.

- Set the paravirt name when running on Hyper-V for consistency

- Move a function under the appropriate ifdef guard to prevent build
warnings"

* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/boot/acpi: Move get_cmdline_acpi_rsdp() under #ifdef guard
x86/hyperv: Set pv_info.name to "Hyper-V"
x86/apic/x2apic: Fix a NULL pointer deref when handling a dying cpu
x86/hyperv: Make vapic support x2apic mode
x86/boot/64: Round memory hole size up to next PMD page
x86/boot/64: Make level2_kernel_pgt pages invalid outside kernel area

Changed files
+84 -38
arch
x86
boot
compressed
hyperv
kernel
+24 -24
arch/x86/boot/compressed/acpi.c
··· 21 21 struct mem_vector immovable_mem[MAX_NUMNODES*2]; 22 22 23 23 /* 24 - * Max length of 64-bit hex address string is 19, prefix "0x" + 16 hex 25 - * digits, and '\0' for termination. 26 - */ 27 - #define MAX_ADDR_LEN 19 28 - 29 - static acpi_physical_address get_cmdline_acpi_rsdp(void) 30 - { 31 - acpi_physical_address addr = 0; 32 - 33 - #ifdef CONFIG_KEXEC 34 - char val[MAX_ADDR_LEN] = { }; 35 - int ret; 36 - 37 - ret = cmdline_find_option("acpi_rsdp", val, MAX_ADDR_LEN); 38 - if (ret < 0) 39 - return 0; 40 - 41 - if (kstrtoull(val, 16, &addr)) 42 - return 0; 43 - #endif 44 - return addr; 45 - } 46 - 47 - /* 48 24 * Search EFI system tables for RSDP. If both ACPI_20_TABLE_GUID and 49 25 * ACPI_TABLE_GUID are found, take the former, which has more features. 50 26 */ ··· 274 298 } 275 299 276 300 #if defined(CONFIG_RANDOMIZE_BASE) && defined(CONFIG_MEMORY_HOTREMOVE) 301 + /* 302 + * Max length of 64-bit hex address string is 19, prefix "0x" + 16 hex 303 + * digits, and '\0' for termination. 304 + */ 305 + #define MAX_ADDR_LEN 19 306 + 307 + static acpi_physical_address get_cmdline_acpi_rsdp(void) 308 + { 309 + acpi_physical_address addr = 0; 310 + 311 + #ifdef CONFIG_KEXEC 312 + char val[MAX_ADDR_LEN] = { }; 313 + int ret; 314 + 315 + ret = cmdline_find_option("acpi_rsdp", val, MAX_ADDR_LEN); 316 + if (ret < 0) 317 + return 0; 318 + 319 + if (kstrtoull(val, 16, &addr)) 320 + return 0; 321 + #endif 322 + return addr; 323 + } 324 + 277 325 /* Compute SRAT address from RSDP. */ 278 326 static unsigned long get_acpi_srat_table(void) 279 327 {
+19 -6
arch/x86/boot/compressed/misc.c
··· 345 345 { 346 346 const unsigned long kernel_total_size = VO__end - VO__text; 347 347 unsigned long virt_addr = LOAD_PHYSICAL_ADDR; 348 + unsigned long needed_size; 348 349 349 350 /* Retain x86 boot parameters pointer passed from startup_32/64. */ 350 351 boot_params = rmode; ··· 380 379 free_mem_ptr = heap; /* Heap */ 381 380 free_mem_end_ptr = heap + BOOT_HEAP_SIZE; 382 381 382 + /* 383 + * The memory hole needed for the kernel is the larger of either 384 + * the entire decompressed kernel plus relocation table, or the 385 + * entire decompressed kernel plus .bss and .brk sections. 386 + * 387 + * On X86_64, the memory is mapped with PMD pages. Round the 388 + * size up so that the full extent of PMD pages mapped is 389 + * included in the check against the valid memory table 390 + * entries. This ensures the full mapped area is usable RAM 391 + * and doesn't include any reserved areas. 392 + */ 393 + needed_size = max(output_len, kernel_total_size); 394 + #ifdef CONFIG_X86_64 395 + needed_size = ALIGN(needed_size, MIN_KERNEL_ALIGN); 396 + #endif 397 + 383 398 /* Report initial kernel position details. */ 384 399 debug_putaddr(input_data); 385 400 debug_putaddr(input_len); 386 401 debug_putaddr(output); 387 402 debug_putaddr(output_len); 388 403 debug_putaddr(kernel_total_size); 404 + debug_putaddr(needed_size); 389 405 390 406 #ifdef CONFIG_X86_64 391 407 /* Report address of 32-bit trampoline */ 392 408 debug_putaddr(trampoline_32bit); 393 409 #endif 394 410 395 - /* 396 - * The memory hole needed for the kernel is the larger of either 397 - * the entire decompressed kernel plus relocation table, or the 398 - * entire decompressed kernel plus .bss and .brk sections. 399 - */ 400 411 choose_random_location((unsigned long)input_data, input_len, 401 412 (unsigned long *)&output, 402 - max(output_len, kernel_total_size), 413 + needed_size, 403 414 &virt_addr); 404 415 405 416 /* Validate memory location choices. */
+15 -5
arch/x86/hyperv/hv_apic.c
··· 260 260 } 261 261 262 262 if (ms_hyperv.hints & HV_X64_APIC_ACCESS_RECOMMENDED) { 263 - pr_info("Hyper-V: Using MSR based APIC access\n"); 263 + pr_info("Hyper-V: Using enlightened APIC (%s mode)", 264 + x2apic_enabled() ? "x2apic" : "xapic"); 265 + /* 266 + * With x2apic, architectural x2apic MSRs are equivalent to the 267 + * respective synthetic MSRs, so there's no need to override 268 + * the apic accessors. The only exception is 269 + * hv_apic_eoi_write, because it benefits from lazy EOI when 270 + * available, but it works for both xapic and x2apic modes. 271 + */ 264 272 apic_set_eoi_write(hv_apic_eoi_write); 265 - apic->read = hv_apic_read; 266 - apic->write = hv_apic_write; 267 - apic->icr_write = hv_apic_icr_write; 268 - apic->icr_read = hv_apic_icr_read; 273 + if (!x2apic_enabled()) { 274 + apic->read = hv_apic_read; 275 + apic->write = hv_apic_write; 276 + apic->icr_write = hv_apic_icr_write; 277 + apic->icr_read = hv_apic_icr_read; 278 + } 269 279 } 270 280 }
+2 -1
arch/x86/kernel/apic/x2apic_cluster.c
··· 156 156 { 157 157 struct cluster_mask *cmsk = per_cpu(cluster_masks, dead_cpu); 158 158 159 - cpumask_clear_cpu(dead_cpu, &cmsk->mask); 159 + if (cmsk) 160 + cpumask_clear_cpu(dead_cpu, &cmsk->mask); 160 161 free_cpumask_var(per_cpu(ipi_mask, dead_cpu)); 161 162 return 0; 162 163 }
+4
arch/x86/kernel/cpu/mshyperv.c
··· 216 216 int hv_host_info_ecx; 217 217 int hv_host_info_edx; 218 218 219 + #ifdef CONFIG_PARAVIRT 220 + pv_info.name = "Hyper-V"; 221 + #endif 222 + 219 223 /* 220 224 * Extract the features and hints 221 225 */
+20 -2
arch/x86/kernel/head64.c
··· 222 222 * we might write invalid pmds, when the kernel is relocated 223 223 * cleanup_highmap() fixes this up along with the mappings 224 224 * beyond _end. 225 + * 226 + * Only the region occupied by the kernel image has so far 227 + * been checked against the table of usable memory regions 228 + * provided by the firmware, so invalidate pages outside that 229 + * region. A page table entry that maps to a reserved area of 230 + * memory would allow processor speculation into that area, 231 + * and on some hardware (particularly the UV platform) even 232 + * speculative access to some reserved areas is caught as an 233 + * error, causing the BIOS to halt the system. 225 234 */ 226 235 227 236 pmd = fixup_pointer(level2_kernel_pgt, physaddr); 228 - for (i = 0; i < PTRS_PER_PMD; i++) { 237 + 238 + /* invalidate pages before the kernel image */ 239 + for (i = 0; i < pmd_index((unsigned long)_text); i++) 240 + pmd[i] &= ~_PAGE_PRESENT; 241 + 242 + /* fixup pages that are part of the kernel image */ 243 + for (; i <= pmd_index((unsigned long)_end); i++) 229 244 if (pmd[i] & _PAGE_PRESENT) 230 245 pmd[i] += load_delta; 231 - } 246 + 247 + /* invalidate pages after the kernel image */ 248 + for (; i < PTRS_PER_PMD; i++) 249 + pmd[i] &= ~_PAGE_PRESENT; 232 250 233 251 /* 234 252 * Fixup phys_base - remove the memory encryption mask to obtain