Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull x86 fixes from Ingo Molnar:
"Microcode fixes, a Xen fix and a KASLR boot loading fix with certain
memory layouts"

* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86, microcode, AMD: Fix ucode patch stashing on 32-bit
x86/core, x86/xen/smp: Use 'die_complete' completion when taking CPU down
x86, microcode: Fix accessing dis_ucode_ldr on 32-bit
x86, kaslr: Prevent .bss from overlaping initrd
x86, microcode, AMD: Fix early ucode loading on 32-bit

+94 -26
+3 -1
arch/x86/boot/compressed/Makefile
··· 76 76 suffix-$(CONFIG_KERNEL_LZO) := lzo 77 77 suffix-$(CONFIG_KERNEL_LZ4) := lz4 78 78 79 + RUN_SIZE = $(shell objdump -h vmlinux | \ 80 + perl $(srctree)/arch/x86/tools/calc_run_size.pl) 79 81 quiet_cmd_mkpiggy = MKPIGGY $@ 80 - cmd_mkpiggy = $(obj)/mkpiggy $< > $@ || ( rm -f $@ ; false ) 82 + cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false ) 81 83 82 84 targets += piggy.S 83 85 $(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE
+3 -2
arch/x86/boot/compressed/head_32.S
··· 207 207 * Do the decompression, and jump to the new kernel.. 208 208 */ 209 209 /* push arguments for decompress_kernel: */ 210 - pushl $z_output_len /* decompressed length */ 210 + pushl $z_run_size /* size of kernel with .bss and .brk */ 211 + pushl $z_output_len /* decompressed length, end of relocs */ 211 212 leal z_extract_offset_negative(%ebx), %ebp 212 213 pushl %ebp /* output address */ 213 214 pushl $z_input_len /* input_len */ ··· 218 217 pushl %eax /* heap area */ 219 218 pushl %esi /* real mode pointer */ 220 219 call decompress_kernel /* returns kernel location in %eax */ 221 - addl $24, %esp 220 + addl $28, %esp 222 221 223 222 /* 224 223 * Jump to the decompressed kernel.
+4 -1
arch/x86/boot/compressed/head_64.S
··· 402 402 * Do the decompression, and jump to the new kernel.. 403 403 */ 404 404 pushq %rsi /* Save the real mode argument */ 405 + movq $z_run_size, %r9 /* size of kernel with .bss and .brk */ 406 + pushq %r9 405 407 movq %rsi, %rdi /* real mode address */ 406 408 leaq boot_heap(%rip), %rsi /* malloc area for uncompression */ 407 409 leaq input_data(%rip), %rdx /* input_data */ 408 410 movl $z_input_len, %ecx /* input_len */ 409 411 movq %rbp, %r8 /* output target address */ 410 - movq $z_output_len, %r9 /* decompressed length */ 412 + movq $z_output_len, %r9 /* decompressed length, end of relocs */ 411 413 call decompress_kernel /* returns kernel location in %rax */ 414 + popq %r9 412 415 popq %rsi 413 416 414 417 /*
+10 -3
arch/x86/boot/compressed/misc.c
··· 358 358 unsigned char *input_data, 359 359 unsigned long input_len, 360 360 unsigned char *output, 361 - unsigned long output_len) 361 + unsigned long output_len, 362 + unsigned long run_size) 362 363 { 363 364 real_mode = rmode; 364 365 ··· 382 381 free_mem_ptr = heap; /* Heap */ 383 382 free_mem_end_ptr = heap + BOOT_HEAP_SIZE; 384 383 385 - output = choose_kernel_location(input_data, input_len, 386 - output, output_len); 384 + /* 385 + * The memory hole needed for the kernel is the larger of either 386 + * the entire decompressed kernel plus relocation table, or the 387 + * entire decompressed kernel plus .bss and .brk sections. 388 + */ 389 + output = choose_kernel_location(input_data, input_len, output, 390 + output_len > run_size ? output_len 391 + : run_size); 387 392 388 393 /* Validate memory location choices. */ 389 394 if ((unsigned long)output & (MIN_KERNEL_ALIGN - 1))
+7 -2
arch/x86/boot/compressed/mkpiggy.c
··· 36 36 uint32_t olen; 37 37 long ilen; 38 38 unsigned long offs; 39 + unsigned long run_size; 39 40 FILE *f = NULL; 40 41 int retval = 1; 41 42 42 - if (argc < 2) { 43 - fprintf(stderr, "Usage: %s compressed_file\n", argv[0]); 43 + if (argc < 3) { 44 + fprintf(stderr, "Usage: %s compressed_file run_size\n", 45 + argv[0]); 44 46 goto bail; 45 47 } 46 48 ··· 76 74 offs += olen >> 12; /* Add 8 bytes for each 32K block */ 77 75 offs += 64*1024 + 128; /* Add 64K + 128 bytes slack */ 78 76 offs = (offs+4095) & ~4095; /* Round to a 4K boundary */ 77 + run_size = atoi(argv[2]); 79 78 80 79 printf(".section \".rodata..compressed\",\"a\",@progbits\n"); 81 80 printf(".globl z_input_len\n"); ··· 88 85 /* z_extract_offset_negative allows simplification of head_32.S */ 89 86 printf(".globl z_extract_offset_negative\n"); 90 87 printf("z_extract_offset_negative = -0x%lx\n", offs); 88 + printf(".globl z_run_size\n"); 89 + printf("z_run_size = %lu\n", run_size); 91 90 92 91 printf(".globl input_data, input_data_end\n"); 93 92 printf("input_data:\n");
+1
arch/x86/include/asm/smp.h
··· 150 150 } 151 151 152 152 void cpu_disable_common(void); 153 + void cpu_die_common(unsigned int cpu); 153 154 void native_smp_prepare_boot_cpu(void); 154 155 void native_smp_prepare_cpus(unsigned int max_cpus); 155 156 void native_smp_cpus_done(unsigned int max_cpus);
+21 -12
arch/x86/kernel/cpu/microcode/amd_early.c
··· 108 108 * load_microcode_amd() to save equivalent cpu table and microcode patches in 109 109 * kernel heap memory. 110 110 */ 111 - static void apply_ucode_in_initrd(void *ucode, size_t size) 111 + static void apply_ucode_in_initrd(void *ucode, size_t size, bool save_patch) 112 112 { 113 113 struct equiv_cpu_entry *eq; 114 114 size_t *cont_sz; 115 115 u32 *header; 116 116 u8 *data, **cont; 117 + u8 (*patch)[PATCH_MAX_SIZE]; 117 118 u16 eq_id = 0; 118 119 int offset, left; 119 120 u32 rev, eax, ebx, ecx, edx; ··· 124 123 new_rev = (u32 *)__pa_nodebug(&ucode_new_rev); 125 124 cont_sz = (size_t *)__pa_nodebug(&container_size); 126 125 cont = (u8 **)__pa_nodebug(&container); 126 + patch = (u8 (*)[PATCH_MAX_SIZE])__pa_nodebug(&amd_ucode_patch); 127 127 #else 128 128 new_rev = &ucode_new_rev; 129 129 cont_sz = &container_size; 130 130 cont = &container; 131 + patch = &amd_ucode_patch; 131 132 #endif 132 133 133 134 data = ucode; ··· 216 213 rev = mc->hdr.patch_id; 217 214 *new_rev = rev; 218 215 219 - /* save ucode patch */ 220 - memcpy(amd_ucode_patch, mc, 221 - min_t(u32, header[1], PATCH_MAX_SIZE)); 216 + if (save_patch) 217 + memcpy(patch, mc, 218 + min_t(u32, header[1], PATCH_MAX_SIZE)); 222 219 } 223 220 } 224 221 ··· 249 246 *data = cp.data; 250 247 *size = cp.size; 251 248 252 - apply_ucode_in_initrd(cp.data, cp.size); 249 + apply_ucode_in_initrd(cp.data, cp.size, true); 253 250 } 254 251 255 252 #ifdef CONFIG_X86_32 ··· 266 263 size_t *usize; 267 264 void **ucode; 268 265 269 - mc = (struct microcode_amd *)__pa(amd_ucode_patch); 266 + mc = (struct microcode_amd *)__pa_nodebug(amd_ucode_patch); 270 267 if (mc->hdr.patch_id && mc->hdr.processor_rev_id) { 271 268 __apply_microcode_amd(mc); 272 269 return; ··· 278 275 if (!*ucode || !*usize) 279 276 return; 280 277 281 - apply_ucode_in_initrd(*ucode, *usize); 278 + apply_ucode_in_initrd(*ucode, *usize, false); 282 279 } 283 280 284 281 static void __init collect_cpu_sig_on_bsp(void *arg) ··· 342 339 * AP has a different equivalence ID than BSP, looks like 343 340 * mixed-steppings silicon so go through the ucode blob anew. 344 341 */ 345 - apply_ucode_in_initrd(ucode_cpio.data, ucode_cpio.size); 342 + apply_ucode_in_initrd(ucode_cpio.data, ucode_cpio.size, false); 346 343 } 347 344 } 348 345 #endif ··· 350 347 int __init save_microcode_in_initrd_amd(void) 351 348 { 352 349 unsigned long cont; 350 + int retval = 0; 353 351 enum ucode_state ret; 352 + u8 *cont_va; 354 353 u32 eax; 355 354 356 355 if (!container) ··· 360 355 361 356 #ifdef CONFIG_X86_32 362 357 get_bsp_sig(); 363 - cont = (unsigned long)container; 358 + cont = (unsigned long)container; 359 + cont_va = __va(container); 364 360 #else 365 361 /* 366 362 * We need the physical address of the container for both bitness since 367 363 * boot_params.hdr.ramdisk_image is a physical address. 368 364 */ 369 - cont = __pa(container); 365 + cont = __pa(container); 366 + cont_va = container; 370 367 #endif 371 368 372 369 /* ··· 379 372 if (relocated_ramdisk) 380 373 container = (u8 *)(__va(relocated_ramdisk) + 381 374 (cont - boot_params.hdr.ramdisk_image)); 375 + else 376 + container = cont_va; 382 377 383 378 if (ucode_new_rev) 384 379 pr_info("microcode: updated early to new patch_level=0x%08x\n", ··· 391 382 392 383 ret = load_microcode_amd(eax, container, container_size); 393 384 if (ret != UCODE_OK) 394 - return -EINVAL; 385 + retval = -EINVAL; 395 386 396 387 /* 397 388 * This will be freed any msec now, stash patches for the current ··· 400 391 container = NULL; 401 392 container_size = 0; 402 393 403 - return 0; 394 + return retval; 404 395 }
+1 -1
arch/x86/kernel/cpu/microcode/core_early.c
··· 124 124 static bool check_loader_disabled_ap(void) 125 125 { 126 126 #ifdef CONFIG_X86_32 127 - return __pa_nodebug(dis_ucode_ldr); 127 + return *((bool *)__pa_nodebug(&dis_ucode_ldr)); 128 128 #else 129 129 return dis_ucode_ldr; 130 130 #endif
+11 -4
arch/x86/kernel/smpboot.c
··· 1303 1303 numa_remove_cpu(cpu); 1304 1304 } 1305 1305 1306 + static DEFINE_PER_CPU(struct completion, die_complete); 1307 + 1306 1308 void cpu_disable_common(void) 1307 1309 { 1308 1310 int cpu = smp_processor_id(); 1311 + 1312 + init_completion(&per_cpu(die_complete, smp_processor_id())); 1309 1313 1310 1314 remove_siblinginfo(cpu); 1311 1315 ··· 1320 1316 fixup_irqs(); 1321 1317 } 1322 1318 1323 - static DEFINE_PER_CPU(struct completion, die_complete); 1324 - 1325 1319 int native_cpu_disable(void) 1326 1320 { 1327 1321 int ret; ··· 1329 1327 return ret; 1330 1328 1331 1329 clear_local_APIC(); 1332 - init_completion(&per_cpu(die_complete, smp_processor_id())); 1333 1330 cpu_disable_common(); 1334 1331 1335 1332 return 0; 1336 1333 } 1337 1334 1335 + void cpu_die_common(unsigned int cpu) 1336 + { 1337 + wait_for_completion_timeout(&per_cpu(die_complete, cpu), HZ); 1338 + } 1339 + 1338 1340 void native_cpu_die(unsigned int cpu) 1339 1341 { 1340 1342 /* We don't do anything here: idle task is faking death itself. */ 1341 - wait_for_completion_timeout(&per_cpu(die_complete, cpu), HZ); 1343 + 1344 + cpu_die_common(cpu); 1342 1345 1343 1346 /* They ack this in play_dead() by setting CPU_DEAD */ 1344 1347 if (per_cpu(cpu_state, cpu) == CPU_DEAD) {
+30
arch/x86/tools/calc_run_size.pl
··· 1 + #!/usr/bin/perl 2 + # 3 + # Calculate the amount of space needed to run the kernel, including room for 4 + # the .bss and .brk sections. 5 + # 6 + # Usage: 7 + # objdump -h a.out | perl calc_run_size.pl 8 + use strict; 9 + 10 + my $mem_size = 0; 11 + my $file_offset = 0; 12 + 13 + my $sections=" *[0-9]+ \.(?:bss|brk) +"; 14 + while (<>) { 15 + if (/^$sections([0-9a-f]+) +(?:[0-9a-f]+ +){2}([0-9a-f]+)/) { 16 + my $size = hex($1); 17 + my $offset = hex($2); 18 + $mem_size += $size; 19 + if ($file_offset == 0) { 20 + $file_offset = $offset; 21 + } elsif ($file_offset != $offset) { 22 + die ".bss and .brk lack common file offset\n"; 23 + } 24 + } 25 + } 26 + 27 + if ($file_offset == 0) { 28 + die "Never found .bss or .brk file offset\n"; 29 + } 30 + printf("%d\n", $mem_size + $file_offset);
+3
arch/x86/xen/smp.c
··· 510 510 current->state = TASK_UNINTERRUPTIBLE; 511 511 schedule_timeout(HZ/10); 512 512 } 513 + 514 + cpu_die_common(cpu); 515 + 513 516 xen_smp_intr_free(cpu); 514 517 xen_uninit_lock_cpu(cpu); 515 518 xen_teardown_timer(cpu);