diff options
| -rw-r--r-- | drivers/firmware/efi/efi-stub-helper.c | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/efi-stub-helper.c index 8c7839437c14..5cea5d5a9a1f 100644 --- a/drivers/firmware/efi/efi-stub-helper.c +++ b/drivers/firmware/efi/efi-stub-helper.c | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | */ | 11 | */ |
| 12 | #define EFI_READ_CHUNK_SIZE (1024 * 1024) | 12 | #define EFI_READ_CHUNK_SIZE (1024 * 1024) |
| 13 | 13 | ||
| 14 | struct initrd { | 14 | struct file_info { |
| 15 | efi_file_handle_t *handle; | 15 | efi_file_handle_t *handle; |
| 16 | u64 size; | 16 | u64 size; |
| 17 | }; | 17 | }; |
| @@ -264,10 +264,10 @@ static void efi_free(efi_system_table_t *sys_table_arg, unsigned long size, | |||
| 264 | 264 | ||
| 265 | 265 | ||
| 266 | /* | 266 | /* |
| 267 | * Check the cmdline for a LILO-style initrd= arguments. | 267 | * Check the cmdline for a LILO-style file= arguments. |
| 268 | * | 268 | * |
| 269 | * We only support loading an initrd from the same filesystem as the | 269 | * We only support loading a file from the same filesystem as |
| 270 | * kernel image. | 270 | * the kernel image. |
| 271 | */ | 271 | */ |
| 272 | static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, | 272 | static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, |
| 273 | efi_loaded_image_t *image, | 273 | efi_loaded_image_t *image, |
| @@ -276,19 +276,19 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, | |||
| 276 | unsigned long *load_addr, | 276 | unsigned long *load_addr, |
| 277 | unsigned long *load_size) | 277 | unsigned long *load_size) |
| 278 | { | 278 | { |
| 279 | struct initrd *initrds; | 279 | struct file_info *files; |
| 280 | unsigned long initrd_addr; | 280 | unsigned long file_addr; |
| 281 | efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; | 281 | efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; |
| 282 | u64 initrd_total; | 282 | u64 file_size_total; |
| 283 | efi_file_io_interface_t *io; | 283 | efi_file_io_interface_t *io; |
| 284 | efi_file_handle_t *fh; | 284 | efi_file_handle_t *fh; |
| 285 | efi_status_t status; | 285 | efi_status_t status; |
| 286 | int nr_initrds; | 286 | int nr_files; |
| 287 | char *str; | 287 | char *str; |
| 288 | int i, j, k; | 288 | int i, j, k; |
| 289 | 289 | ||
| 290 | initrd_addr = 0; | 290 | file_addr = 0; |
| 291 | initrd_total = 0; | 291 | file_size_total = 0; |
| 292 | 292 | ||
| 293 | str = cmd_line; | 293 | str = cmd_line; |
| 294 | 294 | ||
| @@ -303,7 +303,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, | |||
| 303 | if (!str || !*str) | 303 | if (!str || !*str) |
| 304 | return EFI_SUCCESS; | 304 | return EFI_SUCCESS; |
| 305 | 305 | ||
| 306 | for (nr_initrds = 0; *str; nr_initrds++) { | 306 | for (nr_files = 0; *str; nr_files++) { |
| 307 | str = strstr(str, option_string); | 307 | str = strstr(str, option_string); |
| 308 | if (!str) | 308 | if (!str) |
| 309 | break; | 309 | break; |
| @@ -318,21 +318,21 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, | |||
| 318 | str++; | 318 | str++; |
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | if (!nr_initrds) | 321 | if (!nr_files) |
| 322 | return EFI_SUCCESS; | 322 | return EFI_SUCCESS; |
| 323 | 323 | ||
| 324 | status = efi_call_phys3(sys_table_arg->boottime->allocate_pool, | 324 | status = efi_call_phys3(sys_table_arg->boottime->allocate_pool, |
| 325 | EFI_LOADER_DATA, | 325 | EFI_LOADER_DATA, |
| 326 | nr_initrds * sizeof(*initrds), | 326 | nr_files * sizeof(*files), |
| 327 | &initrds); | 327 | &files); |
| 328 | if (status != EFI_SUCCESS) { | 328 | if (status != EFI_SUCCESS) { |
| 329 | efi_printk(sys_table_arg, "Failed to alloc mem for file load\n"); | 329 | efi_printk(sys_table_arg, "Failed to alloc mem for file handle list\n"); |
| 330 | goto fail; | 330 | goto fail; |
| 331 | } | 331 | } |
| 332 | 332 | ||
| 333 | str = cmd_line; | 333 | str = cmd_line; |
| 334 | for (i = 0; i < nr_initrds; i++) { | 334 | for (i = 0; i < nr_files; i++) { |
| 335 | struct initrd *initrd; | 335 | struct file_info *file; |
| 336 | efi_file_handle_t *h; | 336 | efi_file_handle_t *h; |
| 337 | efi_file_info_t *info; | 337 | efi_file_info_t *info; |
| 338 | efi_char16_t filename_16[256]; | 338 | efi_char16_t filename_16[256]; |
| @@ -347,7 +347,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, | |||
| 347 | 347 | ||
| 348 | str += strlen(option_string); | 348 | str += strlen(option_string); |
| 349 | 349 | ||
| 350 | initrd = &initrds[i]; | 350 | file = &files[i]; |
| 351 | p = filename_16; | 351 | p = filename_16; |
| 352 | 352 | ||
| 353 | /* Skip any leading slashes */ | 353 | /* Skip any leading slashes */ |
| @@ -378,13 +378,13 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, | |||
| 378 | image->device_handle, &fs_proto, &io); | 378 | image->device_handle, &fs_proto, &io); |
| 379 | if (status != EFI_SUCCESS) { | 379 | if (status != EFI_SUCCESS) { |
| 380 | efi_printk(sys_table_arg, "Failed to handle fs_proto\n"); | 380 | efi_printk(sys_table_arg, "Failed to handle fs_proto\n"); |
| 381 | goto free_initrds; | 381 | goto free_files; |
| 382 | } | 382 | } |
| 383 | 383 | ||
| 384 | status = efi_call_phys2(io->open_volume, io, &fh); | 384 | status = efi_call_phys2(io->open_volume, io, &fh); |
| 385 | if (status != EFI_SUCCESS) { | 385 | if (status != EFI_SUCCESS) { |
| 386 | efi_printk(sys_table_arg, "Failed to open volume\n"); | 386 | efi_printk(sys_table_arg, "Failed to open volume\n"); |
| 387 | goto free_initrds; | 387 | goto free_files; |
| 388 | } | 388 | } |
| 389 | } | 389 | } |
| 390 | 390 | ||
| @@ -397,7 +397,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, | |||
| 397 | goto close_handles; | 397 | goto close_handles; |
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | initrd->handle = h; | 400 | file->handle = h; |
| 401 | 401 | ||
| 402 | info_sz = 0; | 402 | info_sz = 0; |
| 403 | status = efi_call_phys4(h->get_info, h, &info_guid, | 403 | status = efi_call_phys4(h->get_info, h, &info_guid, |
| @@ -431,37 +431,37 @@ grow: | |||
| 431 | goto close_handles; | 431 | goto close_handles; |
| 432 | } | 432 | } |
| 433 | 433 | ||
| 434 | initrd->size = file_sz; | 434 | file->size = file_sz; |
| 435 | initrd_total += file_sz; | 435 | file_size_total += file_sz; |
| 436 | } | 436 | } |
| 437 | 437 | ||
| 438 | if (initrd_total) { | 438 | if (file_size_total) { |
| 439 | unsigned long addr; | 439 | unsigned long addr; |
| 440 | 440 | ||
| 441 | /* | 441 | /* |
| 442 | * Multiple initrd's need to be at consecutive | 442 | * Multiple files need to be at consecutive addresses in memory, |
| 443 | * addresses in memory, so allocate enough memory for | 443 | * so allocate enough memory for all the files. This is used |
| 444 | * all the initrd's. | 444 | * for loading multiple files. |
| 445 | */ | 445 | */ |
| 446 | status = efi_high_alloc(sys_table_arg, initrd_total, 0x1000, | 446 | status = efi_high_alloc(sys_table_arg, file_size_total, 0x1000, |
| 447 | &initrd_addr, max_addr); | 447 | &file_addr, max_addr); |
| 448 | if (status != EFI_SUCCESS) { | 448 | if (status != EFI_SUCCESS) { |
| 449 | efi_printk(sys_table_arg, "Failed to alloc highmem for initrds\n"); | 449 | efi_printk(sys_table_arg, "Failed to alloc highmem for files\n"); |
| 450 | goto close_handles; | 450 | goto close_handles; |
| 451 | } | 451 | } |
| 452 | 452 | ||
| 453 | /* We've run out of free low memory. */ | 453 | /* We've run out of free low memory. */ |
| 454 | if (initrd_addr > max_addr) { | 454 | if (file_addr > max_addr) { |
| 455 | efi_printk(sys_table_arg, "We've run out of free low memory\n"); | 455 | efi_printk(sys_table_arg, "We've run out of free low memory\n"); |
| 456 | status = EFI_INVALID_PARAMETER; | 456 | status = EFI_INVALID_PARAMETER; |
| 457 | goto free_initrd_total; | 457 | goto free_file_total; |
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | addr = initrd_addr; | 460 | addr = file_addr; |
| 461 | for (j = 0; j < nr_initrds; j++) { | 461 | for (j = 0; j < nr_files; j++) { |
| 462 | u64 size; | 462 | u64 size; |
| 463 | 463 | ||
| 464 | size = initrds[j].size; | 464 | size = files[j].size; |
| 465 | while (size) { | 465 | while (size) { |
| 466 | u64 chunksize; | 466 | u64 chunksize; |
| 467 | if (size > EFI_READ_CHUNK_SIZE) | 467 | if (size > EFI_READ_CHUNK_SIZE) |
| @@ -469,36 +469,36 @@ grow: | |||
| 469 | else | 469 | else |
| 470 | chunksize = size; | 470 | chunksize = size; |
| 471 | status = efi_call_phys3(fh->read, | 471 | status = efi_call_phys3(fh->read, |
| 472 | initrds[j].handle, | 472 | files[j].handle, |
| 473 | &chunksize, addr); | 473 | &chunksize, addr); |
| 474 | if (status != EFI_SUCCESS) { | 474 | if (status != EFI_SUCCESS) { |
| 475 | efi_printk(sys_table_arg, "Failed to read file\n"); | 475 | efi_printk(sys_table_arg, "Failed to read file\n"); |
| 476 | goto free_initrd_total; | 476 | goto free_file_total; |
| 477 | } | 477 | } |
| 478 | addr += chunksize; | 478 | addr += chunksize; |
| 479 | size -= chunksize; | 479 | size -= chunksize; |
| 480 | } | 480 | } |
| 481 | 481 | ||
| 482 | efi_call_phys1(fh->close, initrds[j].handle); | 482 | efi_call_phys1(fh->close, files[j].handle); |
| 483 | } | 483 | } |
| 484 | 484 | ||
| 485 | } | 485 | } |
| 486 | 486 | ||
| 487 | efi_call_phys1(sys_table_arg->boottime->free_pool, initrds); | 487 | efi_call_phys1(sys_table_arg->boottime->free_pool, files); |
| 488 | 488 | ||
| 489 | *load_addr = initrd_addr; | 489 | *load_addr = file_addr; |
| 490 | *load_size = initrd_total; | 490 | *load_size = file_size_total; |
| 491 | 491 | ||
| 492 | return status; | 492 | return status; |
| 493 | 493 | ||
| 494 | free_initrd_total: | 494 | free_file_total: |
| 495 | efi_free(sys_table_arg, initrd_total, initrd_addr); | 495 | efi_free(sys_table_arg, file_size_total, file_addr); |
| 496 | 496 | ||
| 497 | close_handles: | 497 | close_handles: |
| 498 | for (k = j; k < i; k++) | 498 | for (k = j; k < i; k++) |
| 499 | efi_call_phys1(fh->close, initrds[k].handle); | 499 | efi_call_phys1(fh->close, files[k].handle); |
| 500 | free_initrds: | 500 | free_files: |
| 501 | efi_call_phys1(sys_table_arg->boottime->free_pool, initrds); | 501 | efi_call_phys1(sys_table_arg->boottime->free_pool, files); |
| 502 | fail: | 502 | fail: |
| 503 | *load_addr = 0; | 503 | *load_addr = 0; |
| 504 | *load_size = 0; | 504 | *load_size = 0; |
