linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Sourabh Jain <sourabhjain@linux.ibm.com>
To: Madhavan Srinivasan <maddy@linux.ibm.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	bcollins@kernel.org
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kexec: Include kernel-end even without crashkernel
Date: Sun, 7 Sep 2025 12:27:23 +0530	[thread overview]
Message-ID: <1a0bb291-c670-44c3-af7b-d2b5aac51a18@linux.ibm.com> (raw)
In-Reply-To: <2025042122-inescapable-mandrill-8a5ff2@boujee-and-buff>



On 22/04/25 08:06, Ben Collins wrote:
> Certain versions of kexec don't even work without kernel-end being
> added to the device-tree. Add it even if crash-kernel is disabled.
>
> Signed-off-by: Ben Collins <bcollins@kernel.org>
> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-kernel@vger.kernel.org
> ---
>   arch/powerpc/kexec/core.c | 27 +++++++++++++++------------
>   1 file changed, 15 insertions(+), 12 deletions(-)
>
> diff --git a/arch/powerpc/kexec/core.c b/arch/powerpc/kexec/core.c
> index 00e9c267b912f..7b5958c37f702 100644
> --- a/arch/powerpc/kexec/core.c
> +++ b/arch/powerpc/kexec/core.c
> @@ -22,6 +22,8 @@
>   #include <asm/setup.h>
>   #include <asm/firmware.h>
>   
> +#define cpu_to_be_ulong __PASTE(cpu_to_be, BITS_PER_LONG)
> +
>   #ifdef CONFIG_CRASH_DUMP
>   void machine_crash_shutdown(struct pt_regs *regs)
>   {
> @@ -136,17 +138,10 @@ int __init overlaps_crashkernel(unsigned long start, unsigned long size)
>   }
>   
>   /* Values we need to export to the second kernel via the device tree. */
> -static phys_addr_t kernel_end;
>   static phys_addr_t crashk_base;
>   static phys_addr_t crashk_size;
>   static unsigned long long mem_limit;
>   
> -static struct property kernel_end_prop = {
> -	.name = "linux,kernel-end",
> -	.length = sizeof(phys_addr_t),
> -	.value = &kernel_end,
> -};
> -
>   static struct property crashk_base_prop = {
>   	.name = "linux,crashkernel-base",
>   	.length = sizeof(phys_addr_t),
> @@ -165,8 +160,6 @@ static struct property memory_limit_prop = {
>   	.value = &mem_limit,
>   };
>   
> -#define cpu_to_be_ulong	__PASTE(cpu_to_be, BITS_PER_LONG)
> -
>   static void __init export_crashk_values(struct device_node *node)
>   {
>   	/* There might be existing crash kernel properties, but we can't
> @@ -190,6 +183,15 @@ static void __init export_crashk_values(struct device_node *node)
>   	mem_limit = cpu_to_be_ulong(memory_limit);
>   	of_update_property(node, &memory_limit_prop);
>   }
> +#endif /* CONFIG_CRASH_RESERVE */
> +
> +static phys_addr_t kernel_end;
> +
> +static struct property kernel_end_prop = {
> +	.name = "linux,kernel-end",
> +	.length = sizeof(phys_addr_t),
> +	.value = &kernel_end,
> +};
>   
>   static int __init kexec_setup(void)
>   {
> @@ -200,16 +202,17 @@ static int __init kexec_setup(void)
>   		return -ENOENT;
>   
>   	/* remove any stale properties so ours can be found */
> -	of_remove_property(node, of_find_property(node, kernel_end_prop.name, NULL));
> +	of_remove_property(node, of_find_property(node, kernel_end_prop.name,
> +						  NULL));
>   
>   	/* information needed by userspace when using default_machine_kexec */
>   	kernel_end = cpu_to_be_ulong(__pa(_end));
>   	of_add_property(node, &kernel_end_prop);
>   
> +#ifdef CONFIG_CRASH_RESERVE
>   	export_crashk_values(node);
> -
> +#endif
>   	of_node_put(node);
>   	return 0;
>   }
>   late_initcall(kexec_setup);
> -#endif /* CONFIG_CRASH_RESERVE */

While cleaning up KEXEC and KDUMP configs, the export linux,kernel-end 
was moved under CONFIG_CRASH_DUMP.

commit 5c4233cc0920cc90787aafe950b90f6c57a35b88 (HEAD, tag: powerpc-6.9-2)
Author: Hari Bathini <hbathini@linux.ibm.com>
Date:   Mon Feb 26 16:00:10 2024 +0530

     powerpc/kdump: Split KEXEC_CORE and CRASH_DUMP dependency

So, if kexec is enabled without CONFIG_CRASH_DUMP, the kexec command 
fails to load the kexec kernel using the `kexec_load` system call.

[root]# kexec --initrd=/boot/initramfs-`uname -r`.img 
/boot/vmlinuz-`uname -r` --append="`cat /proc/cmdline`" -lcd
Try gzip decompression.
Try LZMA decompression.
kernel: 0x7fffaef30010 kernel_size: 0x2ccba80
0000000000000000-0000000030000000 : 0
0000000030000000-0000004000000000 : 0
get base memory ranges:2
/proc/device-tree/chosen/linux,kernel-end: No such file or directory
Could not get memory layout
[root]# echo $?
255

So, it is better to call kexec_setup/kexec/core.c even when 
CONFIG_CRASH_DUMP is not enabled and export linux,kernel-end, because kexec
requires this to load the kexec kernel using the kexec_file_load system 
call.

I suggest adding a Fixes tag to the commit I mentioned above and also 
including the logs I shared. That might help others discover
this fix if they run into the same issue.

Rest look good to me.

Reviewed-by: Sourabh Jain <sourabhjain@linux.ibm.com>


  reply	other threads:[~2025-09-07  6:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-22  2:36 [PATCH] kexec: Include kernel-end even without crashkernel Ben Collins
2025-09-07  6:57 ` Sourabh Jain [this message]
2025-11-21  2:52 ` Madhavan Srinivasan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1a0bb291-c670-44c3-af7b-d2b5aac51a18@linux.ibm.com \
    --to=sourabhjain@linux.ibm.com \
    --cc=bcollins@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).