Skip to content

Commit 6dc272c

Browse files
author
Fox Snowpatch
committed
1 parent 27527b2 commit 6dc272c

File tree

4 files changed

+45
-17
lines changed

4 files changed

+45
-17
lines changed

arch/powerpc/include/asm/kexec.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ struct kimage_arch {
8080
};
8181

8282
char *setup_kdump_cmdline(struct kimage *image, char *cmdline,
83-
unsigned long cmdline_len);
83+
unsigned long cmdline_len,
84+
char *name, unsigned long addr);
8485
int setup_purgatory(struct kimage *image, const void *slave_code,
8586
const void *fdt, unsigned long kernel_load_addr,
8687
unsigned long fdt_load_addr);

arch/powerpc/kexec/elf_64.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,38 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
8181

8282
/* Setup cmdline for kdump kernel case */
8383
modified_cmdline = setup_kdump_cmdline(image, cmdline,
84-
cmdline_len);
84+
cmdline_len,
85+
"elfcorehdr",
86+
image->elf_load_addr);
8587
if (!modified_cmdline) {
8688
pr_err("Setting up cmdline for kdump kernel failed\n");
8789
ret = -EINVAL;
8890
goto out;
8991
}
9092
cmdline = modified_cmdline;
93+
cmdline_len = strlen(cmdline) + 1;
94+
95+
ret = crash_load_dm_crypt_keys(image);
96+
if (ret == -ENOENT) {
97+
kexec_dprintk("No dm crypt key to load\n");
98+
} else if (ret) {
99+
pr_err("Failed to load dm crypt keys\n");
100+
return ERR_PTR(ret);
101+
}
102+
103+
if (image->dm_crypt_keys_addr != 0) {
104+
modified_cmdline = setup_kdump_cmdline(image, cmdline,
105+
cmdline_len,
106+
"dmcryptkeys",
107+
image->dm_crypt_keys_addr);
108+
kfree(cmdline);
109+
if (!modified_cmdline) {
110+
pr_err("Setting up cmdline for kdump kernel failed\n");
111+
ret = -EINVAL;
112+
goto out;
113+
}
114+
cmdline = modified_cmdline;
115+
}
91116
}
92117

93118
if (initrd != NULL) {

arch/powerpc/kexec/file_load.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,38 @@
2323
#define SLAVE_CODE_SIZE 256 /* First 0x100 bytes */
2424

2525
/**
26-
* setup_kdump_cmdline - Prepend "elfcorehdr=<addr> " to command line
26+
* setup_kdump_cmdline - Prepend "<name>=<addr> " to command line
2727
* of kdump kernel for exporting the core.
2828
* @image: Kexec image
2929
* @cmdline: Command line parameters to update.
3030
* @cmdline_len: Length of the cmdline parameters.
31+
* @name: Name e.g elfcorehdr.
32+
* @addr: Memory address.
3133
*
3234
* kdump segment must be setup before calling this function.
3335
*
3436
* Returns new cmdline buffer for kdump kernel on success, NULL otherwise.
3537
*/
3638
char *setup_kdump_cmdline(struct kimage *image, char *cmdline,
37-
unsigned long cmdline_len)
39+
unsigned long cmdline_len,
40+
char *name, unsigned long addr)
3841
{
39-
int elfcorehdr_strlen;
42+
unsigned long parameter_len;
4043
char *cmdline_ptr;
4144

4245
cmdline_ptr = kzalloc(COMMAND_LINE_SIZE, GFP_KERNEL);
4346
if (!cmdline_ptr)
4447
return NULL;
4548

46-
elfcorehdr_strlen = sprintf(cmdline_ptr, "elfcorehdr=0x%lx ",
47-
image->elf_load_addr);
49+
parameter_len = sprintf(cmdline_ptr, "%s=0x%lx ", name, addr);
4850

49-
if (elfcorehdr_strlen + cmdline_len > COMMAND_LINE_SIZE) {
50-
pr_err("Appending elfcorehdr=<addr> exceeds cmdline size\n");
51+
if (parameter_len + cmdline_len > COMMAND_LINE_SIZE) {
52+
pr_err("Appending %s=<addr> exceeds cmdline size\n", name);
5153
kfree(cmdline_ptr);
5254
return NULL;
5355
}
5456

55-
memcpy(cmdline_ptr + elfcorehdr_strlen, cmdline, cmdline_len);
57+
memcpy(cmdline_ptr + parameter_len, cmdline, cmdline_len);
5658
// Ensure it's nul terminated
5759
cmdline_ptr[COMMAND_LINE_SIZE - 1] = '\0';
5860
return cmdline_ptr;

include/linux/crash_core.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ static inline void arch_kexec_protect_crashkres(void) { }
3434
static inline void arch_kexec_unprotect_crashkres(void) { }
3535
#endif
3636

37-
#ifdef CONFIG_CRASH_DM_CRYPT
38-
int crash_load_dm_crypt_keys(struct kimage *image);
39-
ssize_t dm_crypt_keys_read(char *buf, size_t count, u64 *ppos);
40-
#else
41-
static inline int crash_load_dm_crypt_keys(struct kimage *image) {return 0; }
42-
#endif
43-
4437
#ifndef arch_crash_handle_hotplug_event
4538
static inline void arch_crash_handle_hotplug_event(struct kimage *image, void *arg) { }
4639
#endif
@@ -96,4 +89,11 @@ static inline void crash_save_cpu(struct pt_regs *regs, int cpu) {};
9689
static inline int kimage_crash_copy_vmcoreinfo(struct kimage *image) { return 0; };
9790
#endif /* CONFIG_CRASH_DUMP*/
9891

92+
#ifdef CONFIG_CRASH_DM_CRYPT
93+
int crash_load_dm_crypt_keys(struct kimage *image);
94+
ssize_t dm_crypt_keys_read(char *buf, size_t count, u64 *ppos);
95+
#else
96+
static inline int crash_load_dm_crypt_keys(struct kimage *image) { return 0; }
97+
#endif
98+
9999
#endif /* LINUX_CRASH_CORE_H */

0 commit comments

Comments
 (0)