|
27 | 27 | #include <asm/kexec-bzimage64.h> |
28 | 28 |
|
29 | 29 | #define MAX_ELFCOREHDR_STR_LEN 30 /* elfcorehdr=0x<64bit-value> */ |
| 30 | +#define MAX_DMCRYPTKEYS_STR_LEN 31 /* dmcryptkeys=0x<64bit-value> */ |
| 31 | + |
30 | 32 |
|
31 | 33 | /* |
32 | 34 | * Defines lowest physical address for various segments. Not sure where |
@@ -76,6 +78,10 @@ static int setup_cmdline(struct kimage *image, struct boot_params *params, |
76 | 78 | if (image->type == KEXEC_TYPE_CRASH) { |
77 | 79 | len = sprintf(cmdline_ptr, |
78 | 80 | "elfcorehdr=0x%lx ", image->elf_load_addr); |
| 81 | + |
| 82 | + if (image->dm_crypt_keys_addr != 0) |
| 83 | + len += sprintf(cmdline_ptr + len, |
| 84 | + "dmcryptkeys=0x%lx ", image->dm_crypt_keys_addr); |
79 | 85 | } |
80 | 86 | memcpy(cmdline_ptr + len, cmdline, cmdline_len); |
81 | 87 | cmdline_len += len; |
@@ -441,6 +447,19 @@ static void *bzImage64_load(struct kimage *image, char *kernel, |
441 | 447 | ret = crash_load_segments(image); |
442 | 448 | if (ret) |
443 | 449 | return ERR_PTR(ret); |
| 450 | + ret = crash_load_dm_crypt_keys(image); |
| 451 | + if (ret == -ENOENT) { |
| 452 | + kexec_dprintk("No dm crypt key to load\n"); |
| 453 | + } else if (ret) { |
| 454 | + pr_err("Failed to load dm crypt keys\n"); |
| 455 | + return ERR_PTR(ret); |
| 456 | + } |
| 457 | + if (image->dm_crypt_keys_addr && |
| 458 | + cmdline_len + MAX_ELFCOREHDR_STR_LEN + MAX_DMCRYPTKEYS_STR_LEN > |
| 459 | + header->cmdline_size) { |
| 460 | + pr_err("Appending dmcryptkeys=<addr> to command line exceeds maximum allowed length\n"); |
| 461 | + return ERR_PTR(-EINVAL); |
| 462 | + } |
444 | 463 | } |
445 | 464 | #endif |
446 | 465 |
|
@@ -468,6 +487,8 @@ static void *bzImage64_load(struct kimage *image, char *kernel, |
468 | 487 | efi_map_sz = efi_get_runtime_map_size(); |
469 | 488 | params_cmdline_sz = sizeof(struct boot_params) + cmdline_len + |
470 | 489 | MAX_ELFCOREHDR_STR_LEN; |
| 490 | + if (image->dm_crypt_keys_addr) |
| 491 | + params_cmdline_sz += MAX_DMCRYPTKEYS_STR_LEN; |
471 | 492 | params_cmdline_sz = ALIGN(params_cmdline_sz, 16); |
472 | 493 | kbuf.bufsz = params_cmdline_sz + ALIGN(efi_map_sz, 16) + |
473 | 494 | sizeof(struct setup_data) + |
|
0 commit comments