From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6AC22FF143 for ; Tue, 6 Jan 2026 06:30:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767681028; cv=none; b=ciKC27nrGcy8LUQuMC09kcT6fpI6KGMpafDLnaYX3mWZWdvhx850I4RskIm0JYmSyKW/O4xy7Dmdc9oEwBvf/a+RgjZ3XszzL7YEgw1Xal8U4roHcS/wWY9nnvCrjfJwbfkUsy63RY3Ty4RYLfLQm6NCd4jlFvmENtbBxdDhGI4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767681028; c=relaxed/simple; bh=URtpKl+nDQi8N7xJ9zlinoyabT4W3jug7oif6Y+a2RI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=h19twyc3NDcQaIS/ia4BSpzKcPqLdhkRPosbP9k/CJt0QueMmNroKAQj4ZMugP/RLEmJ9e4HtY4WiCw/kheQqNEtDzJ0oG4qI6a80Ux8ElK8VJKWTG3YqBs6aXby/UsXHNNDThA2RMEv1wJcvYCgOr43Sxo00JLZfbWf7E1dVQo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=I1EngBiF; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=te4MiWlf; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="I1EngBiF"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="te4MiWlf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767681024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5odIQwPJjuX5od5ef4AjZuxMCllVPli7nQhOJ/OzpYQ=; b=I1EngBiFDOnnvbLjY2nkYiUMqGrkw6B1/wJEghp7522pbUkDo8H9GJpU1Z3i0MUr4iA+JG 1EHw6rTi993KyaaKcPIOGOWjmkl6gAbpkUje/65zPPGuAZXjpiQxyO9NRH/QSf9kfKRlxi AIULZM5kg0EeoHDRYHfS7rliYIxXK2A= Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-100-jpuV7-IVM5KVejuxjz3Qiw-1; Tue, 06 Jan 2026 01:30:23 -0500 X-MC-Unique: jpuV7-IVM5KVejuxjz3Qiw-1 X-Mimecast-MFC-AGG-ID: jpuV7-IVM5KVejuxjz3Qiw_1767681022 Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-7dd05696910so1012704b3a.2 for ; Mon, 05 Jan 2026 22:30:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1767681022; x=1768285822; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=5odIQwPJjuX5od5ef4AjZuxMCllVPli7nQhOJ/OzpYQ=; b=te4MiWlfNEvM1WKCGBTO7P2YZzoMEZLX+VvF5qem7ShR3mhNwbsSju7XJNW6fRmCEf qNzZW6avn5ZZsTHw3excOHMjxWKimPaKpdQQIxXkDojfrDX9t2/xam2LCknBx123eq9l pHdYaZMM+nMA1iqr3MnxZXj8bTHDNnFWrlgyhuthznHViQGI4wDVsNln56AmTxwqZF1G yks11X2VWyyMxVQ7zFO4JBq8qnUFIiBlOl92JfVY/XgdOwZS613FLyhSWEu2k0jXKCQ8 IgdyCDytfdRFhYudX4EMCrxv2SBNEzDMNna4mzCl2+ztq233lD6XPG+1ZLzbByHDp5fs zk2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767681022; x=1768285822; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5odIQwPJjuX5od5ef4AjZuxMCllVPli7nQhOJ/OzpYQ=; b=pT2SFqjyTDU5R1PA3eC7HBGXbXaSNNjL7vLW6mKH5bP2wvyV8qDHPyIXfUeoxfLzrg /rDIwkrRkHzd6HIwHK+O0AFQ/Q5fzPn/iO29EhCrjDor6ZfI85CBi93gj2HY0YeCMV/m v8ipEM0/lvoA6gNfASWx0Dr5yHZnmYZSnQqs7xD1hMubhmvhxHAHA8Ud6aH9dpYjJb/5 qIN8yPISjsP6gKIn4WCl2gP3flYIzgT/45RHroO4Sl9m40bKeNhG74rr1FLPqN/9G68h NpnlURC2wtwaXnFewyi9Ri0I+SZJf746uHCB0TnIU7y8IW7tFAbo7ucNUqE5HHnbfEQx kEhw== X-Forwarded-Encrypted: i=1; AJvYcCXnrDfu8gaeq0W7J2tbvZKFLwXRqstq3SSEhq+aBER7kvJRlAKfI/x+LdnU1GtNmChXRoPBv9ssTWx4qNI=@vger.kernel.org X-Gm-Message-State: AOJu0YzSnHXua4AZwQVj1f/twW+MBDt9vHMBHtqkuTgIlbK08HRAUawE gr5Ua46SXZUD/qAz7ki6J5S/b8VskAq7u7BOHIXyvt8/gqM4lppeQq5bvV8yoR0+Ahu9z7Ptey3 e61YcGCJawoM4Bq2qOqq2eam2D2au/Xqt+vK6bEarev7q4c7u42LuaIYMjkqmCxw+xQ== X-Gm-Gg: AY/fxX5NNOJMGyQQZJfqNjlAIFiQEclS46xRKD/DnpGWEcuM51UrTg9sm4LitQsJb/s rl0am/uK8tvCF1NqxlB326TyMNNgLFWu4zZKSvlzOTQ1K7Zwo60dspQeE1Tk5eEEZbD4veVQK+D XtspLIB4ZLwYfamrG4DoKqZFjlhBT5Wco/tL5yTT052ID2C9GM6EjZigLsPOtYkhvybxQ2CeYUx E/oDDMhinIPohARfBjLhW396CFxXk7ND7YsaS6TpBuj+i3SOHjh4OeUuH9+NxCV6tPcgenwF7o+ V7YFu5UbzPxj1iovOmV3XXoaToGk1hKsJ/DmnkKN3evdL6tFFsNAZRh2yQrhpceLlOpDOcQLW3W P X-Received: by 2002:a05:6a21:33a2:b0:366:14ac:e20d with SMTP id adf61e73a8af0-389823ccaeamr1702275637.75.1767681021944; Mon, 05 Jan 2026 22:30:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IF9cfpUUe1HFlsOEg/hJrnV4Zf0Q08lNkGZQR8DEVWxFHSM5lZqtkm1xu9aYzl5/kpjJzLI2w== X-Received: by 2002:a05:6a21:33a2:b0:366:14ac:e20d with SMTP id adf61e73a8af0-389823ccaeamr1702228637.75.1767681021396; Mon, 05 Jan 2026 22:30:21 -0800 (PST) Received: from localhost ([209.132.188.88]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c4cc8d29592sm1233261a12.22.2026.01.05.22.30.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jan 2026 22:30:20 -0800 (PST) Date: Tue, 6 Jan 2026 14:26:45 +0800 From: Coiby Xu To: Sourabh Jain Cc: kexec@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Thomas Staudt , Arnaud Lefebvre , Baoquan he , Dave Young , Kairui Song , Pingfan Liu , Andrew Morton , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , open list Subject: Re: [PATCH] powerpc/kdump: pass dm-crypt keys to kdump kernel Message-ID: References: <20251226140636.1378505-1-coxu@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: On Thu, Jan 01, 2026 at 08:36:09PM +0530, Sourabh Jain wrote: > > >On 26/12/25 19:36, Coiby Xu wrote: >>Based on the CONFIG_CRASH_DM_CRYPT feature, this patch adds >>LUKS-encrypted device dump target support to PowerPC by addressing two >>challenges [1], >> - Kdump kernel may not be able to decrypt the LUKS partition. For some >> machines, a system administrator may not have a chance to enter the >> password to decrypt the device in kdump initramfs after the 1st kernel >> crashes >> >> - LUKS2 by default use the memory-hard Argon2 key derivation function >> which is quite memory-consuming compared to the limited memory reserved >> for kdump. >> >>1st kernel will build up the kernel command parameter dmcryptkeys as >>similar to elfcorehdr to pass the memory address of the stored info of >>dm-crypt keys to the kdump kernel. >> >>[1] https://lore.kernel.org/all/20250502011246.99238-1-coxu@redhat.com/ >> >>Cc: Thomas Staudt >>Cc: Arnaud Lefebvre >>Cc: Baoquan he >>Cc: Dave Young >>Cc: Kairui Song >>Cc: Pingfan Liu >>Cc: Andrew Morton >>Signed-off-by: Coiby Xu >>--- >> arch/powerpc/include/asm/kexec.h | 3 ++- >> arch/powerpc/kexec/elf_64.c | 26 +++++++++++++++++++++++++- >> arch/powerpc/kexec/file_load.c | 19 +++++++++++-------- >> 3 files changed, 38 insertions(+), 10 deletions(-) >> >>diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h >>index bd4a6c42a5f3..f3d098d543b4 100644 >>--- a/arch/powerpc/include/asm/kexec.h >>+++ b/arch/powerpc/include/asm/kexec.h >>@@ -80,7 +80,8 @@ struct kimage_arch { >> }; >> char *setup_kdump_cmdline(struct kimage *image, char *cmdline, >>- unsigned long cmdline_len); >>+ unsigned long cmdline_len, >>+ char *name, unsigned long addr); >> int setup_purgatory(struct kimage *image, const void *slave_code, >> const void *fdt, unsigned long kernel_load_addr, >> unsigned long fdt_load_addr); >>diff --git a/arch/powerpc/kexec/elf_64.c b/arch/powerpc/kexec/elf_64.c >>index 5d6d616404cf..57cb3361d91b 100644 >>--- a/arch/powerpc/kexec/elf_64.c >>+++ b/arch/powerpc/kexec/elf_64.c >>@@ -81,13 +81,37 @@ static void *elf64_load(struct kimage *image, char *kernel_buf, >> /* Setup cmdline for kdump kernel case */ >> modified_cmdline = setup_kdump_cmdline(image, cmdline, >>- cmdline_len); >>+ cmdline_len, >>+ "elfcorehdr", >>+ image->elf_load_addr); >> if (!modified_cmdline) { >> pr_err("Setting up cmdline for kdump kernel failed\n"); >> ret = -EINVAL; >> goto out; >> } >> cmdline = modified_cmdline; >>+ cmdline_len = strlen(cmdline) + 1; >>+ >>+ 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"); >>+ return ERR_PTR(ret); >>+ } >>+ >>+ if (image->dm_crypt_keys_addr != 0) { >>+ modified_cmdline = setup_kdump_cmdline(image, cmdline, >>+ cmdline_len, >>+ "dmcryptkeys", >>+ image->dm_crypt_keys_addr); >>+ if (!modified_cmdline) { >>+ pr_err("Setting up cmdline for kdump kernel failed\n"); >>+ ret = -EINVAL; >>+ goto out; >>+ } >>+ cmdline = modified_cmdline; >>+ } >> } >> if (initrd != NULL) { >>diff --git a/arch/powerpc/kexec/file_load.c b/arch/powerpc/kexec/file_load.c >>index 4284f76cbef5..e1c08050286d 100644 >>--- a/arch/powerpc/kexec/file_load.c >>+++ b/arch/powerpc/kexec/file_load.c >>@@ -23,38 +23,41 @@ >> #define SLAVE_CODE_SIZE 256 /* First 0x100 bytes */ >> /** >>- * setup_kdump_cmdline - Prepend "elfcorehdr= " to command line >>+ * setup_kdump_cmdline - Prepend "= " to command line >> * of kdump kernel for exporting the core. >> * @image: Kexec image >> * @cmdline: Command line parameters to update. >> * @cmdline_len: Length of the cmdline parameters. >>+ * @name: Name e.g elfcorehdr. >>+ * @addr: Memory address. >> * >> * kdump segment must be setup before calling this function. >> * >> * Returns new cmdline buffer for kdump kernel on success, NULL otherwise. >> */ >> char *setup_kdump_cmdline(struct kimage *image, char *cmdline, >>- unsigned long cmdline_len) >>+ unsigned long cmdline_len, >>+ char *name, unsigned long addr) >> { >>- int elfcorehdr_strlen; >>+ unsigned long parameter_len; >> char *cmdline_ptr; >> cmdline_ptr = kzalloc(COMMAND_LINE_SIZE, GFP_KERNEL); >> if (!cmdline_ptr) >> return NULL; >>- elfcorehdr_strlen = sprintf(cmdline_ptr, "elfcorehdr=0x%lx ", >>- image->elf_load_addr); >>+ parameter_len = sprintf(cmdline_ptr, "%s=0x%lx ", name, addr); >>- if (elfcorehdr_strlen + cmdline_len > COMMAND_LINE_SIZE) { >>- pr_err("Appending elfcorehdr= exceeds cmdline size\n"); >>+ if (parameter_len + cmdline_len > COMMAND_LINE_SIZE) { >>+ pr_err("Appending %s= exceeds cmdline size\n", name); >> kfree(cmdline_ptr); >> return NULL; >> } >>- memcpy(cmdline_ptr + elfcorehdr_strlen, cmdline, cmdline_len); >>+ memcpy(cmdline_ptr + parameter_len, cmdline, cmdline_len); >> // Ensure it's nul terminated >> cmdline_ptr[COMMAND_LINE_SIZE - 1] = '\0'; >>+ kfree(cmdline); > >When setup_kdump_cmdline() is called for elfcorehdr, cmdline holds the >same pointer as image->cmdline_buf. Freeing it here may therefore >cause issues, right? Yes, you are right, I'll drop the above kfree in next version. > >Currently, image->cmdline_buf is not used after calling the >architecture-specific load function (elf64_load on powerpc). >However, kimage_file_post_load_cleanup() later calls kfree() on >the same address. I missed kimage_file_post_load_cleanup. Thanks for pointing it out! -- Best regards, Coiby