From: Sourabh Jain <sourabhjain@linux.ibm.com> To: linuxppc-dev@ozlabs.org, mpe@ellerman.id.au Cc: eric.devolder@oracle.com, bhe@redhat.com, mahesh@linux.vnet.ibm.com, kexec@lists.infradead.org, ldufour@linux.ibm.com, hbathini@linux.ibm.com Subject: [RFC v4 PATCH 5/5] powerpc/crash hp: add crash hotplug support for kexec_load Date: Mon, 11 Apr 2022 14:13:57 +0530 [thread overview] Message-ID: <20220411084357.157308-6-sourabhjain@linux.ibm.com> (raw) In-Reply-To: <20220411084357.157308-1-sourabhjain@linux.ibm.com> The kernel changes needed for crash hotplug support for kexec_load system calls are similar to kexec_file_load (which has already been implemented in earlier patches) except for finding the index of the FDT segment in the kexec segment array. Since the kexec segment array is prepared by the kexec tool in the userspace, the kernel is not aware of at which index FDT segment is present. Now to enable crash hotplug support for the kexec_load case, the crash hotplug handler is updated to identify the index at which the FDT segment is present in the kexec segment array by comparing the first 32 bits of every kexec segment with the FDT magic number. Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com> --- arch/powerpc/kexec/core_64.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c index 62f77cc86407..e3f224f8eb3a 100644 --- a/arch/powerpc/kexec/core_64.c +++ b/arch/powerpc/kexec/core_64.c @@ -480,7 +480,9 @@ int update_cpus_node(void *fdt) void arch_crash_hotplug_handler(struct kimage *image, unsigned int hp_action, unsigned long a, unsigned long b) { - void *fdt; + void *fdt, *ptr; + unsigned int n; + unsigned long mem, memsz; /* No action needed for CPU hot-unplug */ if (hp_action == KEXEC_CRASH_HP_REMOVE_CPU) @@ -492,6 +494,24 @@ void arch_crash_hotplug_handler(struct kimage *image, unsigned int hp_action, return; } + /* Sine kexec segments for kexec_load system call is prepred by + * kexec tool in userspace we need loop through all the segments + * to find out segment index corresponds FDT segment. In case of + * kexec_file_load it is discovered during the load itself. + */ + if (!image->arch.fdt_index_valid) { + for (n = 0; n < image->nr_segments; n++) { + mem = image->segment[n].mem; + memsz = image->segment[n].memsz; + ptr = __va(mem); + if (ptr && fdt_magic(ptr) == FDT_MAGIC) { + image->arch.fdt_index = n; + image->arch.fdt_index_valid = true; + break; + } + } + } + /* Must have valid FDT index */ if (!image->arch.fdt_index_valid) { pr_err("crash hp: unable to locate FDT segment"); -- 2.35.1
WARNING: multiple messages have this Message-ID (diff)
From: Sourabh Jain <sourabhjain@linux.ibm.com> To: kexec@lists.infradead.org Subject: [RFC v4 PATCH 5/5] powerpc/crash hp: add crash hotplug support for kexec_load Date: Mon, 11 Apr 2022 14:13:57 +0530 [thread overview] Message-ID: <20220411084357.157308-6-sourabhjain@linux.ibm.com> (raw) In-Reply-To: <20220411084357.157308-1-sourabhjain@linux.ibm.com> The kernel changes needed for crash hotplug support for kexec_load system calls are similar to kexec_file_load (which has already been implemented in earlier patches) except for finding the index of the FDT segment in the kexec segment array. Since the kexec segment array is prepared by the kexec tool in the userspace, the kernel is not aware of at which index FDT segment is present. Now to enable crash hotplug support for the kexec_load case, the crash hotplug handler is updated to identify the index at which the FDT segment is present in the kexec segment array by comparing the first 32 bits of every kexec segment with the FDT magic number. Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com> --- arch/powerpc/kexec/core_64.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c index 62f77cc86407..e3f224f8eb3a 100644 --- a/arch/powerpc/kexec/core_64.c +++ b/arch/powerpc/kexec/core_64.c @@ -480,7 +480,9 @@ int update_cpus_node(void *fdt) void arch_crash_hotplug_handler(struct kimage *image, unsigned int hp_action, unsigned long a, unsigned long b) { - void *fdt; + void *fdt, *ptr; + unsigned int n; + unsigned long mem, memsz; /* No action needed for CPU hot-unplug */ if (hp_action == KEXEC_CRASH_HP_REMOVE_CPU) @@ -492,6 +494,24 @@ void arch_crash_hotplug_handler(struct kimage *image, unsigned int hp_action, return; } + /* Sine kexec segments for kexec_load system call is prepred by + * kexec tool in userspace we need loop through all the segments + * to find out segment index corresponds FDT segment. In case of + * kexec_file_load it is discovered during the load itself. + */ + if (!image->arch.fdt_index_valid) { + for (n = 0; n < image->nr_segments; n++) { + mem = image->segment[n].mem; + memsz = image->segment[n].memsz; + ptr = __va(mem); + if (ptr && fdt_magic(ptr) == FDT_MAGIC) { + image->arch.fdt_index = n; + image->arch.fdt_index_valid = true; + break; + } + } + } + /* Must have valid FDT index */ if (!image->arch.fdt_index_valid) { pr_err("crash hp: unable to locate FDT segment"); -- 2.35.1
next prev parent reply other threads:[~2022-04-11 8:48 UTC|newest] Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-11 8:43 [RFC v4 PATCH 0/5] In kernel handling of CPU hotplug events for crash kernel Sourabh Jain 2022-04-11 8:43 ` Sourabh Jain 2022-04-11 8:43 ` [RFC v4 PATCH 1/5] powerpc/kexec: make update_cpus_node non-static Sourabh Jain 2022-04-11 8:43 ` Sourabh Jain 2022-04-11 8:43 ` [RFC v4 PATCH 2/5] powerpc/crash hp: introduce a new config option CRASH_HOTPLUG Sourabh Jain 2022-04-11 8:43 ` Sourabh Jain 2022-04-14 16:40 ` Laurent Dufour 2022-04-14 16:40 ` Laurent Dufour 2022-04-19 8:20 ` Sourabh Jain 2022-04-19 8:20 ` Sourabh Jain 2022-04-21 11:34 ` Michael Ellerman 2022-04-21 11:34 ` Michael Ellerman 2022-04-21 15:29 ` Eric DeVolder 2022-04-21 15:29 ` Eric DeVolder 2022-04-22 4:22 ` Michael Ellerman 2022-04-22 4:22 ` Michael Ellerman 2022-04-26 4:10 ` Sourabh Jain 2022-04-26 4:10 ` Sourabh Jain 2022-04-26 3:47 ` Sourabh Jain 2022-04-26 3:47 ` Sourabh Jain 2022-04-11 8:43 ` [RFC v4 PATCH 3/5] powrepc/crash hp: update kimage_arch struct Sourabh Jain 2022-04-11 8:43 ` Sourabh Jain 2022-04-14 16:35 ` Laurent Dufour 2022-04-14 16:35 ` Laurent Dufour 2022-04-19 8:21 ` Sourabh Jain 2022-04-19 8:21 ` Sourabh Jain 2022-04-11 8:43 ` [RFC v4 PATCH 4/5] powerpc/crash hp: add crash hotplug support for kexec_file_load Sourabh Jain 2022-04-11 8:43 ` Sourabh Jain 2022-04-14 16:32 ` Laurent Dufour 2022-04-14 16:32 ` Laurent Dufour 2022-04-19 8:31 ` Sourabh Jain 2022-04-19 8:31 ` Sourabh Jain 2022-04-21 15:33 ` Eric DeVolder 2022-04-21 15:33 ` Eric DeVolder 2022-04-11 8:43 ` Sourabh Jain [this message] 2022-04-11 8:43 ` [RFC v4 PATCH 5/5] powerpc/crash hp: add crash hotplug support for kexec_load Sourabh Jain 2022-04-14 16:39 ` Laurent Dufour 2022-04-14 16:39 ` Laurent Dufour
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=20220411084357.157308-6-sourabhjain@linux.ibm.com \ --to=sourabhjain@linux.ibm.com \ --cc=bhe@redhat.com \ --cc=eric.devolder@oracle.com \ --cc=hbathini@linux.ibm.com \ --cc=kexec@lists.infradead.org \ --cc=ldufour@linux.ibm.com \ --cc=linuxppc-dev@ozlabs.org \ --cc=mahesh@linux.vnet.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.