From: Baoquan He <bhe@redhat.com>
To: kexec@lists.infradead.org
Subject: [PATCH v6 8/8] x86/crash: Add x86 crash hotplug support for kexec_load
Date: Wed, 13 Apr 2022 21:13:59 +0800 [thread overview]
Message-ID: <YlbMlw3WJBQN0l8W@MiWiFi-R3L-srv> (raw)
In-Reply-To: <20220401183040.1624-9-eric.devolder@oracle.com>
On 04/01/22 at 02:30pm, Eric DeVolder wrote:
> For kexec_file_load support, the loading of the crash kernel occurs
> entirely within the kernel, and as such the elfcorehdr is readily
> identified (so that it can be modified upon hotplug events).
>
> This change enables support for kexec_load by identifying the
> elfcorehdr segment in the arch_crash_hotplug_handler(), if it has
> not already been identified.
>
> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
LGTM,
Acked-by: Baoquan He <bhe@redhat.com>
> ---
> arch/x86/kernel/crash.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
> index 101c030ac038..682f130b83e3 100644
> --- a/arch/x86/kernel/crash.c
> +++ b/arch/x86/kernel/crash.c
> @@ -486,6 +486,30 @@ void arch_crash_hotplug_handler(struct kimage *image,
> void *elfbuf = NULL;
> unsigned long mem, memsz;
>
> + /*
> + * When the struct kimage is alloced, it is wiped to zero, so
> + * the elfcorehdr_index_valid defaults to false. It is set on the
> + * kexec_file_load path, or here for kexec_load, if not already
> + * identified.
> + */
> + if (!image->elfcorehdr_index_valid) {
> + unsigned int n;
> +
> + for (n = 0; n < image->nr_segments; n++) {
> + mem = image->segment[n].mem;
> + memsz = image->segment[n].memsz;
> + ptr = map_crash_pages(mem, memsz);
> + if (ptr) {
> + /* The segment containing elfcorehdr */
> + if (memcmp(ptr, ELFMAG, SELFMAG) == 0) {
> + image->elfcorehdr_index = (int)n;
> + image->elfcorehdr_index_valid = true;
> + }
> + }
> + unmap_crash_pages((void **)&ptr);
> + }
> + }
> +
> if (!image->elfcorehdr_index_valid) {
> pr_err("crash hp: unable to locate elfcorehdr segment");
> goto out;
> --
> 2.27.0
>
prev parent reply other threads:[~2022-04-13 13:13 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-01 18:30 [PATCH v6 0/8] crash: Kernel handling of CPU and memory hot un/plug Eric DeVolder
2022-04-01 18:30 ` [PATCH v6 1/8] x86/crash: fix minor typo/bug in debug message Eric DeVolder
2022-04-01 18:30 ` [PATCH v6 2/8] x86/crash: Introduce new options to support cpu and memory hotplug Eric DeVolder
2022-04-08 8:07 ` Baoquan He
2022-04-11 13:54 ` Eric DeVolder
2022-04-01 18:30 ` [PATCH v6 3/8] crash: prototype change for crash_prepare_elf64_headers Eric DeVolder
2022-04-01 18:30 ` [PATCH v6 4/8] crash: add generic infrastructure for crash hotplug support Eric DeVolder
2022-04-11 9:20 ` Baoquan He
2022-04-11 13:54 ` Eric DeVolder
2022-04-13 2:41 ` Baoquan He
2022-04-13 12:37 ` Eric DeVolder
2022-04-13 13:24 ` Baoquan He
2022-04-01 18:30 ` [PATCH v6 5/8] kexec: exclude elfcorehdr from the segment digest Eric DeVolder
2022-04-01 18:30 ` [PATCH v6 6/8] kexec: exclude hot remove cpu from elfcorehdr notes Eric DeVolder
2022-04-01 18:30 ` [PATCH v6 7/8] x86/crash: Add x86 crash hotplug support for kexec_file_load Eric DeVolder
2022-04-01 18:30 ` [PATCH v6 8/8] x86/crash: Add x86 crash hotplug support for kexec_load Eric DeVolder
2022-04-13 13:13 ` Baoquan He [this message]
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=YlbMlw3WJBQN0l8W@MiWiFi-R3L-srv \
--to=bhe@redhat.com \
--cc=kexec@lists.infradead.org \
/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