Re: [PATCH v5 1/3] crash_dump/dm-crypt: Don't print in arch-specific code

Baoquan He
2026-03-31T07:12:23Z

On 02/25/26 at 02:03pm, Coiby Xu wrote:
> When the vmcore dumping target is not a LUKS-encrypted target, it's
> expected that there is no dm-crypt key thus no need to return -ENOENT.
> Also print more logs in crash_load_dm_crypt_keys. The benefit is
> arch-specific code can be more succinct.
>
> Suggested-by: Will Deacon <will@kernel.org>
> Signed-off-by: Coiby Xu <coxu@redhat.com>
> ---
> arch/x86/kernel/kexec-bzimage64.c | 6 +-----
> kernel/crash_dump_dm_crypt.c | 7 +++++--
> 2 files changed, 6 insertions(+), 7 deletions(-)

Acked-by: Baoquan He <bhe@redhat.com>

>
> diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c
> index 5630c7dca1f3..7e980ea49d8d 100644
> --- a/arch/x86/kernel/kexec-bzimage64.c
> +++ b/arch/x86/kernel/kexec-bzimage64.c
> @@ -525,12 +525,8 @@ static void *bzImage64_load(struct kimage *image, char *kernel,
> if (ret)
> return ERR_PTR(ret);
> ret = crash_load_dm_crypt_keys(image);
> - if (ret == -ENOENT) {
> - kexec_dprintk("No dm crypt key to load\n");
> - } else if (ret) {
> - pr_err("Failed to load dm crypt keys\n");
> + if (ret)
> return ERR_PTR(ret);
> - }
> if (image->dm_crypt_keys_addr &&
> cmdline_len + MAX_ELFCOREHDR_STR_LEN + MAX_DMCRYPTKEYS_STR_LEN >
> header->cmdline_size) {
> diff --git a/kernel/crash_dump_dm_crypt.c b/kernel/crash_dump_dm_crypt.c
> index 1f4067fbdb94..2f7b42b09673 100644
> --- a/kernel/crash_dump_dm_crypt.c
> +++ b/kernel/crash_dump_dm_crypt.c
> @@ -414,14 +414,16 @@ int crash_load_dm_crypt_keys(struct kimage *image)
>
> if (key_count <= 0) {
> kexec_dprintk("No dm-crypt keys\n");
> - return -ENOENT;
> + return 0;
> }
>
> if (!is_dm_key_reused) {
> image->dm_crypt_keys_addr = 0;
> r = build_keys_header();
> - if (r)
> + if (r) {
> + pr_err("Failed to build dm-crypt keys header, ret=%d\n", r);
> return r;
> + }
> }
>
> kbuf.buffer = keys_header;
> @@ -432,6 +434,7 @@ int crash_load_dm_crypt_keys(struct kimage *image)
> kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
> r = kexec_add_buffer(&kbuf);
> if (r) {
> + pr_err("Failed to call kexec_add_buffer, ret=%d\n", r);
> kvfree((void *)kbuf.buffer);
> return r;
> }
> --
> 2.53.0
>