From: Sourabh Jain <sourabhjain@linux.ibm.com>
To: Baoquan He <bhe@redhat.com>
Cc: David Hildenbrand <david@redhat.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Mimi Zohar <zohar@linux.ibm.com>,
linuxppc-dev@ozlabs.org, Eric DeVolder <eric.devolder@oracle.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Valentin Schneider <vschneid@redhat.com>,
x86@kernel.org, "Aneesh Kumar K . V" <aneesh.kumar@kernel.org>,
Laurent Dufour <laurent.dufour@fr.ibm.com>,
Dave Young <dyoung@redhat.com>, Vivek Goyal <vgoyal@redhat.com>,
Naveen N Rao <naveen@kernel.org>, Borislav Petkov <bp@alien8.de>,
Thomas Gleixner <tglx@linutronix.de>,
Hari Bathini <hbathini@linux.ibm.com>,
Oscar Salvador <osalvador@suse.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
kexec@lists.infradead.org,
Mahesh Salgaonkar <mahesh@linux.ibm.com>,
Akhil Raj <lf32.dev@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v14 3/6] crash: add a new kexec flag for FDT update
Date: Fri, 15 Dec 2023 12:17:54 +0530 [thread overview]
Message-ID: <7fe7b62f-d3fc-4035-96fe-1ab0e3e743c0@linux.ibm.com> (raw)
In-Reply-To: <ZXu55ZXVSMeQDE/e@MiWiFi-R3L-srv>
Hello Baoquan,
On 15/12/23 07:58, Baoquan He wrote:
> On 12/11/23 at 02:00pm, Sourabh Jain wrote:
>> The commit a72bbec70da2 ("crash: hotplug support for kexec_load()")
>> introduced a new kexec flag, `KEXEC_UPDATE_ELFCOREHDR`. Kexec tool uses
>> this flag to indicate kernel that it is safe to modify the elfcorehdr
>> of kdump image loaded using kexec_load system call.
>>
>> Similarly, add a new kexec flag, `KEXEC_UPDATE_FDT`, for another kdump
>> component named FDT (Flatten Device Tree). Architectures like PowerPC
>> need to update FDT kdump image component on CPU hotplug events. Kexec
>> tool passing `KEXEC_UPDATE_FDT` will be an indication to kernel that FDT
>> segment is not part of SHA calculation hence it is safe to update it.
>>
>> With the `KEXEC_UPDATE_ELFCOREHDR` and `KEXEC_UPDATE_FDT` kexec flags,
>> crash hotplug support can be added to PowerPC for the kexec_load syscall
>> while maintaining the backward compatibility with older kexec tools that
>> do not have these newly introduced flags.
>>
>> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
>> Cc: Akhil Raj <lf32.dev@gmail.com>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
>> Cc: Baoquan He <bhe@redhat.com>
>> Cc: Borislav Petkov (AMD) <bp@alien8.de>
>> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
>> Cc: Dave Hansen <dave.hansen@linux.intel.com>
>> Cc: Dave Young <dyoung@redhat.com>
>> Cc: David Hildenbrand <david@redhat.com>
>> Cc: Eric DeVolder <eric.devolder@oracle.com>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: Hari Bathini <hbathini@linux.ibm.com>
>> Cc: Laurent Dufour <laurent.dufour@fr.ibm.com>
>> Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
>> Cc: Michael Ellerman <mpe@ellerman.id.au>
>> Cc: Mimi Zohar <zohar@linux.ibm.com>
>> Cc: Naveen N Rao <naveen@kernel.org>
>> Cc: Oscar Salvador <osalvador@suse.de>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Valentin Schneider <vschneid@redhat.com>
>> Cc: Vivek Goyal <vgoyal@redhat.com>
>> Cc: kexec@lists.infradead.org
>> Cc: x86@kernel.org
>> ---
>> include/linux/kexec.h | 6 ++++--
>> include/uapi/linux/kexec.h | 1 +
>> kernel/kexec.c | 2 ++
>> 3 files changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/linux/kexec.h b/include/linux/kexec.h
>> index 0f6ea35879ee..bcedb7625b1f 100644
>> --- a/include/linux/kexec.h
>> +++ b/include/linux/kexec.h
>> @@ -319,6 +319,7 @@ struct kimage {
>> #ifdef CONFIG_CRASH_HOTPLUG
>> /* If set, allow changes to elfcorehdr of kexec_load'd image */
>> unsigned int update_elfcorehdr:1;
>> + unsigned int update_fdt:1;
> Can we unify this to one flag, e.g hotplug_update?
>
> With this, on x86_64, we will skip the sha calculation for elfcorehdr.
> On ppc, we will skip the sha calculation for elfcorehdr and fdt.
Yeah, that's what I suggested to Eric. I can do that, but I see one
problem with powerpc or other platforms that need to skip SHA
for more kexec segments in addition to elfcorehdr.
`update_elfcorehdr` is set when the kexec tool sends the
`KEXEC_UPDATE_ELFCOREHDR`
flag to the kernel for the `kexec_load` system call.
Given that the kexec tool has already been updated to send the
`KEXEC_UPDATE_ELFCOREHDR` flag only when elfcorehdr is skipped from
SHA verification in generic code, now it would be tricky for
architectures to
determine whether kexec has skipped SHA verification for just elfcorehdr
or all segments needed on the platform with the same flag.
Code snippet from the kexec tool:
main() {
...
/* NOTE: Xen KEXEC_LIVE_UPDATE and KEXEC_UPDATE_ELFCOREHDR collide */
if (do_hotplug) {
...
/* Indicate to the kernel it is ok to modify the elfcorehdr */
kexec_flags |= KEXEC_UPDATE_ELFCOREHDR;
}
...
}
Any suggestion how to handle this with just one kexec flag?
Thanks for the review.
Thanks,
Sourabh Jain
>
>> #endif
>>
>> #ifdef ARCH_HAS_KIMAGE_ARCH
>> @@ -396,9 +397,10 @@ bool kexec_load_permitted(int kexec_image_type);
>>
>> /* List of defined/legal kexec flags */
>> #ifndef CONFIG_KEXEC_JUMP
>> -#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_UPDATE_ELFCOREHDR)
>> +#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_UPDATE_ELFCOREHDR | KEXEC_UPDATE_FDT)
>> #else
>> -#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT | KEXEC_UPDATE_ELFCOREHDR)
>> +#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT | KEXEC_UPDATE_ELFCOREHDR | \
>> + KEXEC_UPDATE_FDT)
>> #endif
>>
>> /* List of defined/legal kexec file flags */
>> diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h
>> index 01766dd839b0..3d5b3d757bed 100644
>> --- a/include/uapi/linux/kexec.h
>> +++ b/include/uapi/linux/kexec.h
>> @@ -13,6 +13,7 @@
>> #define KEXEC_ON_CRASH 0x00000001
>> #define KEXEC_PRESERVE_CONTEXT 0x00000002
>> #define KEXEC_UPDATE_ELFCOREHDR 0x00000004
>> +#define KEXEC_UPDATE_FDT 0x00000008
>> #define KEXEC_ARCH_MASK 0xffff0000
>>
>> /*
>> diff --git a/kernel/kexec.c b/kernel/kexec.c
>> index 8f35a5a42af8..97eb151cd931 100644
>> --- a/kernel/kexec.c
>> +++ b/kernel/kexec.c
>> @@ -132,6 +132,8 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments,
>> #ifdef CONFIG_CRASH_HOTPLUG
>> if (flags & KEXEC_UPDATE_ELFCOREHDR)
>> image->update_elfcorehdr = 1;
>> + if (flags & KEXEC_UPDATE_FDT)
>> + image->update_fdt = 1;
>> #endif
>>
>> ret = machine_kexec_prepare(image);
>> --
>> 2.41.0
>>
next prev parent reply other threads:[~2023-12-15 6:49 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-11 8:30 [PATCH v14 0/6] powerpc/crash: Kernel handling of CPU and memory hotplug Sourabh Jain
2023-12-11 8:30 ` [PATCH v14 1/6] crash: forward memory_notify arg to arch crash hotplug handler Sourabh Jain
2023-12-11 8:30 ` [PATCH v14 2/6] crash: make CPU and Memory hotplug support reporting flexible Sourabh Jain
2023-12-14 14:13 ` Baoquan He
2023-12-15 5:46 ` Sourabh Jain
2023-12-11 8:30 ` [PATCH v14 3/6] crash: add a new kexec flag for FDT update Sourabh Jain
2023-12-15 2:28 ` Baoquan He
2023-12-15 6:47 ` Sourabh Jain [this message]
2023-12-16 9:41 ` Baoquan He
2023-12-16 18:57 ` Sourabh Jain
2023-12-17 0:59 ` Baoquan He
2023-12-17 15:50 ` Sourabh Jain
2023-12-21 6:06 ` Sourabh Jain
2023-12-22 0:28 ` Baoquan He
2023-12-11 8:30 ` [PATCH v14 4/6] powerpc/kexec: turn some static helper functions public Sourabh Jain
2023-12-11 8:30 ` [PATCH v14 5/6] powerpc: add crash CPU hotplug support Sourabh Jain
2023-12-19 10:35 ` Hari Bathini
2023-12-11 8:30 ` [PATCH v14 6/6] powerpc: add crash memory " Sourabh Jain
2023-12-15 1:23 ` Baoquan He
2023-12-15 5:59 ` Sourabh Jain
2023-12-16 3:11 ` Baoquan He
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=7fe7b62f-d3fc-4035-96fe-1ab0e3e743c0@linux.ibm.com \
--to=sourabhjain@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@kernel.org \
--cc=bhe@redhat.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=david@redhat.com \
--cc=dyoung@redhat.com \
--cc=eric.devolder@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=hbathini@linux.ibm.com \
--cc=kexec@lists.infradead.org \
--cc=laurent.dufour@fr.ibm.com \
--cc=lf32.dev@gmail.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=mahesh@linux.ibm.com \
--cc=naveen@kernel.org \
--cc=osalvador@suse.de \
--cc=tglx@linutronix.de \
--cc=vgoyal@redhat.com \
--cc=vschneid@redhat.com \
--cc=x86@kernel.org \
--cc=zohar@linux.ibm.com \
/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).