Hi Andrey, First bad commit (maybe != root cause): tree: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-3.16.y head: 2447a018c3226c811528bb70024c6ffd83342a70 commit: 3cb0dc19883f0c69225311d4f76aa8128d3681a4 [2872/2959] module: fix types of device tables aliases config: i386-allmodconfig (attached as .config) compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026 reproduce: git checkout 3cb0dc19883f0c69225311d4f76aa8128d3681a4 # save the attached .config to linux build tree make ARCH=i386 All warnings (new ones prefixed by >>): In file included from arch/x86/boot/compressed/eboot.c:287:0: arch/x86/boot/compressed/../../../../drivers/firmware/efi/efi-stub-helper.c: In function 'efi_relocate_kernel': >> arch/x86/boot/compressed/../../../../drivers/firmware/efi/efi-stub-helper.c:566:2: warning: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration] memcpy((void *)new_addr, (void *)cur_image_addr, image_size); ^~~~~~ vim +/memcpy +566 arch/x86/boot/compressed/../../../../drivers/firmware/efi/efi-stub-helper.c 7721da4c Roy Franz 2013-09-22 321 7721da4c Roy Franz 2013-09-22 322 7721da4c Roy Franz 2013-09-22 323 /* 36f8961c Roy Franz 2013-09-22 324 * Check the cmdline for a LILO-style file= arguments. 7721da4c Roy Franz 2013-09-22 325 * 36f8961c Roy Franz 2013-09-22 326 * We only support loading a file from the same filesystem as 36f8961c Roy Franz 2013-09-22 327 * the kernel image. 7721da4c Roy Franz 2013-09-22 328 */ 46f4582e Roy Franz 2013-09-22 329 static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, 876dc36a Roy Franz 2013-09-22 330 efi_loaded_image_t *image, 46f4582e Roy Franz 2013-09-22 331 char *cmd_line, char *option_string, 46f4582e Roy Franz 2013-09-22 332 unsigned long max_addr, 46f4582e Roy Franz 2013-09-22 333 unsigned long *load_addr, 46f4582e Roy Franz 2013-09-22 334 unsigned long *load_size) 7721da4c Roy Franz 2013-09-22 335 { 36f8961c Roy Franz 2013-09-22 336 struct file_info *files; 36f8961c Roy Franz 2013-09-22 337 unsigned long file_addr; 36f8961c Roy Franz 2013-09-22 338 u64 file_size_total; 9403e462 Leif Lindholm 2014-04-04 339 efi_file_handle_t *fh = NULL; 7721da4c Roy Franz 2013-09-22 340 efi_status_t status; 36f8961c Roy Franz 2013-09-22 341 int nr_files; 7721da4c Roy Franz 2013-09-22 342 char *str; 7721da4c Roy Franz 2013-09-22 343 int i, j, k; 7721da4c Roy Franz 2013-09-22 344 36f8961c Roy Franz 2013-09-22 345 file_addr = 0; 36f8961c Roy Franz 2013-09-22 346 file_size_total = 0; 7721da4c Roy Franz 2013-09-22 347 46f4582e Roy Franz 2013-09-22 348 str = cmd_line; 7721da4c Roy Franz 2013-09-22 349 7721da4c Roy Franz 2013-09-22 350 j = 0; /* See close_handles */ 7721da4c Roy Franz 2013-09-22 351 46f4582e Roy Franz 2013-09-22 352 if (!load_addr || !load_size) 46f4582e Roy Franz 2013-09-22 353 return EFI_INVALID_PARAMETER; 46f4582e Roy Franz 2013-09-22 354 46f4582e Roy Franz 2013-09-22 355 *load_addr = 0; 46f4582e Roy Franz 2013-09-22 356 *load_size = 0; 46f4582e Roy Franz 2013-09-22 357 7721da4c Roy Franz 2013-09-22 358 if (!str || !*str) 7721da4c Roy Franz 2013-09-22 359 return EFI_SUCCESS; 7721da4c Roy Franz 2013-09-22 360 36f8961c Roy Franz 2013-09-22 361 for (nr_files = 0; *str; nr_files++) { 46f4582e Roy Franz 2013-09-22 362 str = strstr(str, option_string); 7721da4c Roy Franz 2013-09-22 363 if (!str) 7721da4c Roy Franz 2013-09-22 364 break; 7721da4c Roy Franz 2013-09-22 365 46f4582e Roy Franz 2013-09-22 366 str += strlen(option_string); 7721da4c Roy Franz 2013-09-22 367 7721da4c Roy Franz 2013-09-22 368 /* Skip any leading slashes */ 7721da4c Roy Franz 2013-09-22 369 while (*str == '/' || *str == '\\') 7721da4c Roy Franz 2013-09-22 370 str++; 7721da4c Roy Franz 2013-09-22 371 7721da4c Roy Franz 2013-09-22 372 while (*str && *str != ' ' && *str != '\n') 7721da4c Roy Franz 2013-09-22 373 str++; 7721da4c Roy Franz 2013-09-22 374 } 7721da4c Roy Franz 2013-09-22 375 36f8961c Roy Franz 2013-09-22 376 if (!nr_files) 7721da4c Roy Franz 2013-09-22 377 return EFI_SUCCESS; 7721da4c Roy Franz 2013-09-22 378 204b0a1a Matt Fleming 2014-03-22 379 status = efi_call_early(allocate_pool, EFI_LOADER_DATA, 54b52d87 Matt Fleming 2014-01-10 380 nr_files * sizeof(*files), (void **)&files); 7721da4c Roy Franz 2013-09-22 381 if (status != EFI_SUCCESS) { f966ea02 Roy Franz 2013-12-13 382 pr_efi_err(sys_table_arg, "Failed to alloc mem for file handle list\n"); 7721da4c Roy Franz 2013-09-22 383 goto fail; 7721da4c Roy Franz 2013-09-22 384 } 7721da4c Roy Franz 2013-09-22 385 46f4582e Roy Franz 2013-09-22 386 str = cmd_line; 36f8961c Roy Franz 2013-09-22 387 for (i = 0; i < nr_files; i++) { 36f8961c Roy Franz 2013-09-22 388 struct file_info *file; 7721da4c Roy Franz 2013-09-22 389 efi_char16_t filename_16[256]; 7721da4c Roy Franz 2013-09-22 390 efi_char16_t *p; 7721da4c Roy Franz 2013-09-22 391 46f4582e Roy Franz 2013-09-22 392 str = strstr(str, option_string); 7721da4c Roy Franz 2013-09-22 393 if (!str) 7721da4c Roy Franz 2013-09-22 394 break; 7721da4c Roy Franz 2013-09-22 395 46f4582e Roy Franz 2013-09-22 396 str += strlen(option_string); 7721da4c Roy Franz 2013-09-22 397 36f8961c Roy Franz 2013-09-22 398 file = &files[i]; 7721da4c Roy Franz 2013-09-22 399 p = filename_16; 7721da4c Roy Franz 2013-09-22 400 7721da4c Roy Franz 2013-09-22 401 /* Skip any leading slashes */ 7721da4c Roy Franz 2013-09-22 402 while (*str == '/' || *str == '\\') 7721da4c Roy Franz 2013-09-22 403 str++; 7721da4c Roy Franz 2013-09-22 404 7721da4c Roy Franz 2013-09-22 405 while (*str && *str != ' ' && *str != '\n') { 7721da4c Roy Franz 2013-09-22 406 if ((u8 *)p >= (u8 *)filename_16 + sizeof(filename_16)) 7721da4c Roy Franz 2013-09-22 407 break; 7721da4c Roy Franz 2013-09-22 408 7721da4c Roy Franz 2013-09-22 409 if (*str == '/') { 7721da4c Roy Franz 2013-09-22 410 *p++ = '\\'; 4e283088 Roy Franz 2013-09-22 411 str++; 7721da4c Roy Franz 2013-09-22 412 } else { 7721da4c Roy Franz 2013-09-22 413 *p++ = *str++; 7721da4c Roy Franz 2013-09-22 414 } 7721da4c Roy Franz 2013-09-22 415 } 7721da4c Roy Franz 2013-09-22 416 7721da4c Roy Franz 2013-09-22 417 *p = '\0'; 7721da4c Roy Franz 2013-09-22 418 7721da4c Roy Franz 2013-09-22 419 /* Only open the volume once. */ 7721da4c Roy Franz 2013-09-22 420 if (!i) { 54b52d87 Matt Fleming 2014-01-10 421 status = efi_open_volume(sys_table_arg, image, 54b52d87 Matt Fleming 2014-01-10 422 (void **)&fh); 54b52d87 Matt Fleming 2014-01-10 423 if (status != EFI_SUCCESS) 36f8961c Roy Franz 2013-09-22 424 goto free_files; 7721da4c Roy Franz 2013-09-22 425 } 7721da4c Roy Franz 2013-09-22 426 54b52d87 Matt Fleming 2014-01-10 427 status = efi_file_size(sys_table_arg, fh, filename_16, 54b52d87 Matt Fleming 2014-01-10 428 (void **)&file->handle, &file->size); 54b52d87 Matt Fleming 2014-01-10 429 if (status != EFI_SUCCESS) 7721da4c Roy Franz 2013-09-22 430 goto close_handles; 7721da4c Roy Franz 2013-09-22 431 54b52d87 Matt Fleming 2014-01-10 432 file_size_total += file->size; 7721da4c Roy Franz 2013-09-22 433 } 7721da4c Roy Franz 2013-09-22 434 36f8961c Roy Franz 2013-09-22 435 if (file_size_total) { 7721da4c Roy Franz 2013-09-22 436 unsigned long addr; 7721da4c Roy Franz 2013-09-22 437 7721da4c Roy Franz 2013-09-22 438 /* 36f8961c Roy Franz 2013-09-22 439 * Multiple files need to be at consecutive addresses in memory, 36f8961c Roy Franz 2013-09-22 440 * so allocate enough memory for all the files. This is used 36f8961c Roy Franz 2013-09-22 441 * for loading multiple files. 7721da4c Roy Franz 2013-09-22 442 */ 36f8961c Roy Franz 2013-09-22 443 status = efi_high_alloc(sys_table_arg, file_size_total, 0x1000, 36f8961c Roy Franz 2013-09-22 444 &file_addr, max_addr); 7721da4c Roy Franz 2013-09-22 445 if (status != EFI_SUCCESS) { f966ea02 Roy Franz 2013-12-13 446 pr_efi_err(sys_table_arg, "Failed to alloc highmem for files\n"); 7721da4c Roy Franz 2013-09-22 447 goto close_handles; 7721da4c Roy Franz 2013-09-22 448 } 7721da4c Roy Franz 2013-09-22 449 7721da4c Roy Franz 2013-09-22 450 /* We've run out of free low memory. */ 36f8961c Roy Franz 2013-09-22 451 if (file_addr > max_addr) { f966ea02 Roy Franz 2013-12-13 452 pr_efi_err(sys_table_arg, "We've run out of free low memory\n"); 7721da4c Roy Franz 2013-09-22 453 status = EFI_INVALID_PARAMETER; 36f8961c Roy Franz 2013-09-22 454 goto free_file_total; 7721da4c Roy Franz 2013-09-22 455 } 7721da4c Roy Franz 2013-09-22 456 36f8961c Roy Franz 2013-09-22 457 addr = file_addr; 36f8961c Roy Franz 2013-09-22 458 for (j = 0; j < nr_files; j++) { 6a5fe770 Roy Franz 2013-09-22 459 unsigned long size; 7721da4c Roy Franz 2013-09-22 460 36f8961c Roy Franz 2013-09-22 461 size = files[j].size; 7721da4c Roy Franz 2013-09-22 462 while (size) { 6a5fe770 Roy Franz 2013-09-22 463 unsigned long chunksize; 7721da4c Roy Franz 2013-09-22 464 if (size > EFI_READ_CHUNK_SIZE) 7721da4c Roy Franz 2013-09-22 465 chunksize = EFI_READ_CHUNK_SIZE; 7721da4c Roy Franz 2013-09-22 466 else 7721da4c Roy Franz 2013-09-22 467 chunksize = size; 54b52d87 Matt Fleming 2014-01-10 468 47514c99 Matt Fleming 2014-04-10 469 status = efi_file_read(files[j].handle, 6a5fe770 Roy Franz 2013-09-22 470 &chunksize, 6a5fe770 Roy Franz 2013-09-22 471 (void *)addr); 7721da4c Roy Franz 2013-09-22 472 if (status != EFI_SUCCESS) { f966ea02 Roy Franz 2013-12-13 473 pr_efi_err(sys_table_arg, "Failed to read file\n"); 36f8961c Roy Franz 2013-09-22 474 goto free_file_total; 7721da4c Roy Franz 2013-09-22 475 } 7721da4c Roy Franz 2013-09-22 476 addr += chunksize; 7721da4c Roy Franz 2013-09-22 477 size -= chunksize; 7721da4c Roy Franz 2013-09-22 478 } 7721da4c Roy Franz 2013-09-22 479 47514c99 Matt Fleming 2014-04-10 480 efi_file_close(files[j].handle); 7721da4c Roy Franz 2013-09-22 481 } 7721da4c Roy Franz 2013-09-22 482 7721da4c Roy Franz 2013-09-22 483 } 7721da4c Roy Franz 2013-09-22 484 204b0a1a Matt Fleming 2014-03-22 485 efi_call_early(free_pool, files); 7721da4c Roy Franz 2013-09-22 486 36f8961c Roy Franz 2013-09-22 487 *load_addr = file_addr; 36f8961c Roy Franz 2013-09-22 488 *load_size = file_size_total; 7721da4c Roy Franz 2013-09-22 489 7721da4c Roy Franz 2013-09-22 490 return status; 7721da4c Roy Franz 2013-09-22 491 36f8961c Roy Franz 2013-09-22 492 free_file_total: 36f8961c Roy Franz 2013-09-22 493 efi_free(sys_table_arg, file_size_total, file_addr); 7721da4c Roy Franz 2013-09-22 494 7721da4c Roy Franz 2013-09-22 495 close_handles: 7721da4c Roy Franz 2013-09-22 496 for (k = j; k < i; k++) 47514c99 Matt Fleming 2014-04-10 497 efi_file_close(files[k].handle); 36f8961c Roy Franz 2013-09-22 498 free_files: 204b0a1a Matt Fleming 2014-03-22 499 efi_call_early(free_pool, files); 7721da4c Roy Franz 2013-09-22 500 fail: 46f4582e Roy Franz 2013-09-22 501 *load_addr = 0; 46f4582e Roy Franz 2013-09-22 502 *load_size = 0; 7721da4c Roy Franz 2013-09-22 503 7721da4c Roy Franz 2013-09-22 504 return status; 7721da4c Roy Franz 2013-09-22 505 } 4a9f3a7c Roy Franz 2013-09-22 506 /* 4a9f3a7c Roy Franz 2013-09-22 507 * Relocate a kernel image, either compressed or uncompressed. 4a9f3a7c Roy Franz 2013-09-22 508 * In the ARM64 case, all kernel images are currently 4a9f3a7c Roy Franz 2013-09-22 509 * uncompressed, and as such when we relocate it we need to 4a9f3a7c Roy Franz 2013-09-22 510 * allocate additional space for the BSS segment. Any low 4a9f3a7c Roy Franz 2013-09-22 511 * memory that this function should avoid needs to be 4a9f3a7c Roy Franz 2013-09-22 512 * unavailable in the EFI memory map, as if the preferred 4a9f3a7c Roy Franz 2013-09-22 513 * address is not available the lowest available address will 4a9f3a7c Roy Franz 2013-09-22 514 * be used. 4a9f3a7c Roy Franz 2013-09-22 515 */ 4a9f3a7c Roy Franz 2013-09-22 516 static efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg, 4a9f3a7c Roy Franz 2013-09-22 517 unsigned long *image_addr, 4a9f3a7c Roy Franz 2013-09-22 518 unsigned long image_size, 4a9f3a7c Roy Franz 2013-09-22 519 unsigned long alloc_size, 4a9f3a7c Roy Franz 2013-09-22 520 unsigned long preferred_addr, 4a9f3a7c Roy Franz 2013-09-22 521 unsigned long alignment) c6866d72 Roy Franz 2013-09-22 522 { 4a9f3a7c Roy Franz 2013-09-22 523 unsigned long cur_image_addr; 4a9f3a7c Roy Franz 2013-09-22 524 unsigned long new_addr = 0; c6866d72 Roy Franz 2013-09-22 525 efi_status_t status; 4a9f3a7c Roy Franz 2013-09-22 526 unsigned long nr_pages; 4a9f3a7c Roy Franz 2013-09-22 527 efi_physical_addr_t efi_addr = preferred_addr; 4a9f3a7c Roy Franz 2013-09-22 528 4a9f3a7c Roy Franz 2013-09-22 529 if (!image_addr || !image_size || !alloc_size) 4a9f3a7c Roy Franz 2013-09-22 530 return EFI_INVALID_PARAMETER; 4a9f3a7c Roy Franz 2013-09-22 531 if (alloc_size < image_size) 4a9f3a7c Roy Franz 2013-09-22 532 return EFI_INVALID_PARAMETER; 4a9f3a7c Roy Franz 2013-09-22 533 4a9f3a7c Roy Franz 2013-09-22 534 cur_image_addr = *image_addr; c6866d72 Roy Franz 2013-09-22 535 c6866d72 Roy Franz 2013-09-22 536 /* c6866d72 Roy Franz 2013-09-22 537 * The EFI firmware loader could have placed the kernel image 4a9f3a7c Roy Franz 2013-09-22 538 * anywhere in memory, but the kernel has restrictions on the 4a9f3a7c Roy Franz 2013-09-22 539 * max physical address it can run at. Some architectures 4a9f3a7c Roy Franz 2013-09-22 540 * also have a prefered address, so first try to relocate 4a9f3a7c Roy Franz 2013-09-22 541 * to the preferred address. If that fails, allocate as low 4a9f3a7c Roy Franz 2013-09-22 542 * as possible while respecting the required alignment. c6866d72 Roy Franz 2013-09-22 543 */ 4a9f3a7c Roy Franz 2013-09-22 544 nr_pages = round_up(alloc_size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; 204b0a1a Matt Fleming 2014-03-22 545 status = efi_call_early(allocate_pages, c6866d72 Roy Franz 2013-09-22 546 EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA, 4a9f3a7c Roy Franz 2013-09-22 547 nr_pages, &efi_addr); 4a9f3a7c Roy Franz 2013-09-22 548 new_addr = efi_addr; 4a9f3a7c Roy Franz 2013-09-22 549 /* 4a9f3a7c Roy Franz 2013-09-22 550 * If preferred address allocation failed allocate as low as 4a9f3a7c Roy Franz 2013-09-22 551 * possible. 4a9f3a7c Roy Franz 2013-09-22 552 */ c6866d72 Roy Franz 2013-09-22 553 if (status != EFI_SUCCESS) { 4a9f3a7c Roy Franz 2013-09-22 554 status = efi_low_alloc(sys_table_arg, alloc_size, alignment, 4a9f3a7c Roy Franz 2013-09-22 555 &new_addr); 4a9f3a7c Roy Franz 2013-09-22 556 } 4a9f3a7c Roy Franz 2013-09-22 557 if (status != EFI_SUCCESS) { f966ea02 Roy Franz 2013-12-13 558 pr_efi_err(sys_table_arg, "Failed to allocate usable memory for kernel.\n"); 4a9f3a7c Roy Franz 2013-09-22 559 return status; c6866d72 Roy Franz 2013-09-22 560 } c6866d72 Roy Franz 2013-09-22 561 4a9f3a7c Roy Franz 2013-09-22 562 /* 4a9f3a7c Roy Franz 2013-09-22 563 * We know source/dest won't overlap since both memory ranges 4a9f3a7c Roy Franz 2013-09-22 564 * have been allocated by UEFI, so we can safely use memcpy. 4a9f3a7c Roy Franz 2013-09-22 565 */ 4a9f3a7c Roy Franz 2013-09-22 @566 memcpy((void *)new_addr, (void *)cur_image_addr, image_size); c6866d72 Roy Franz 2013-09-22 567 4a9f3a7c Roy Franz 2013-09-22 568 /* Return the new address of the relocated image. */ 4a9f3a7c Roy Franz 2013-09-22 569 *image_addr = new_addr; c6866d72 Roy Franz 2013-09-22 570 c6866d72 Roy Franz 2013-09-22 571 return status; c6866d72 Roy Franz 2013-09-22 572 } 5fef3870 Roy Franz 2013-09-22 573 :::::: The code at line 566 was first introduced by commit :::::: 4a9f3a7c336a6b0ffeef2523bef93e67b0921163 efi: Generalize relocate_kernel() for use by other architectures. :::::: TO: Roy Franz <roy.franz@xxxxxxxxxx> :::::: CC: Matt Fleming <matt.fleming@xxxxxxxxx> --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
Attachment:
.config.gz
Description: application/gzip