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: Thu, 21 Dec 2023 11:36:39 +0530 [thread overview]
Message-ID: <cdde877b-e620-45db-ae28-4b691c1ae5b6@linux.ibm.com> (raw)
In-Reply-To: <ZX5H+X9Urz8kuiSG@MiWiFi-R3L-srv>
Hello Baoquan,
While replying to this email earlier, I mistakenly pressed "Reply to List"
instead of "Reply to All." Consequently, my response was sent only to
powerpc
mailing list.
On 17/12/23 06:29, Baoquan He wrote:
> On 12/17/23 at 12:27am, Sourabh Jain wrote:
>> On 16/12/23 15:11, Baoquan He wrote:
>>> On 12/15/23 at 12:17pm, Sourabh Jain wrote:
>>> ......
>>>>>> 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.
>>> In kexec-tools, it's judged by do_hotplug to skip the elfcorehdr
>>> segment. I am wondering how you skip the fdt segment when calculating
>>> and verifying sha, only saw the update_fdt mark.
>> In the kexec tool where we loop through all the kexec segments to calculate
>> the SHA, there will be a arch call made to determine whether the segment
>> needs
>> to be excluded from SHA or not.
> OK, a arch call will be added to exclude segments in the ARCH. And the
> elfcorehdr segment need be excluded in x86 ARCH in case other ARCH later
> may not want to exclude elfcorehdr.
Yes, Arch can choose which segment to exclude.
>> Now in the arch function if decide a specific segment needs to excluded then
>> corresponding flag is also set by arch function to communicate same with the
>> kernel.
> But I don't see how you exclude elfcorehdr and fdt in kernel for
> kexec_file codes. It's not happening in kexec-tools.
On PowerPC, SHA verification is NOT performed for the kexec_file_load
case; hence, you
won't find any code changes in my patch series to exclude FDT in the
kernel code.
However, let's consider a scenario where it gets added in the future, or
other architectures
need to skip the kexec segment, in addition to elfcorehdr. In that case,
we can use the
same setup as you suggested below. For each kexec segment, there should
be an
architecture-specific function call to decide whether the segment needs
to be excluded or not.
>>> About the existing KEXEC_UPDATE_ELFCOREHDR, we only rename the macro,
>>> but still use the same value, could you think of what problem could be
>>> caused between kernel and kexec-tools utility, the old and new version
>>> compatibility?
>> Just changing the macro name will NOT help because the current kexec tool
>> enables the KEXEC_UPDATE_ELFCOREHDR = 0x00000004 kexec flag bit
>> if
>> the command argument --hotplug is passed to the kexec
>> and
>> the /sys/kernel/crash_elfcorehdr_size file exists in the system.
> As we have discussed, excluding will be done in each ARCH's function
> when doing sha calculation in kexec-tools, isn't it?
>
> diff --git a/kexec/kexec.c b/kexec/kexec.c
> index b5393e3b20aa..0095aeec988a 100644
> --- a/kexec/kexec.c
> +++ b/kexec/kexec.c
> @@ -701,10 +701,10 @@ static void update_purgatory(struct kexec_info *info)
> continue;
> }
>
> - /* Don't include elfcorehdr in the checksum, if hotplug
> + /* Don't include unwanted segments in the checksum, if hotplug
> * support enabled.
> - */
> - if (do_hotplug && (info->segment[i].mem == (void *)info->elfcorehdr)) {
> + if (do_hotplug)
> + arch_exclude_segments(info, &i)
> continue;
> }
Yes, something like the above should work.
>> Now, let's say an architecture enables this feature in the kernel with the
>> assumption
>> that the 0x00000004 kexec flag bit is passed from the kexec tool when all
>> the required
>> kexec segments are skipped from SHA calculation. In this case, the current
>> kexec tool,
>> which passes the 0x00000004 kexec flag bit only when the elfcorehdr is
>> skipped, will
>> cause issues for architectures.
>>
>>> If it's about the new header files installed on older kernel, we can
>>> change it like below? Fortunately only one release, 6.6 passed.
>>>
>>> diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h
>>> index 3d5b3d757bed..df6a6505e267 100644
>>> --- a/include/uapi/linux/kexec.h
>>> +++ b/include/uapi/linux/kexec.h
>>> @@ -13,7 +13,7 @@
>>> #define KEXEC_ON_CRASH 0x00000001
>>> #define KEXEC_PRESERVE_CONTEXT 0x00000002
>>> -#define KEXEC_UPDATE_FDT 0x00000008
>>> +#define KEXEC_CRASH_HOTPLUG_UPDATE 0x00000004
>>> #define KEXEC_UPDATE_ELFCOREHDR 0x00000004
>>> #define KEXEC_ARCH_MASK 0xffff0000
>>> /*
>>>
>>> With my understanding, the kexec flag should be indicating the action,
>>> the mem/cpu hotplug, but not relating to any detail. Imagine later
>>> another segment need be skipped on one ARCH again, then another flag
>>> need be added, this sounds not reasonable.
>> I strongly agree with you. The KEXEC_CRASH_HOTPLUG_UPDATE kexec flag
>> should be sufficient to inform the kernel that the kexec tool has been
>> updated
>> to support CPU/Memory hotplug for the kexec_load system call. Unfortunately,
>> we cannot use the 0x00000004 kexec flags bit for KEXEC_CRASH_HOTPLUG_UPDATE
>> at the moment.
> I am fine with 0x00000008 and a new flag, it has the same effect as
> #define KEXEC_CRASH_HOTPLUG_UPDATE 0x00000004
>
> I am worried about the header file incompatiblity.
If we are OK to have KEXEC_CRASH_HOTPLUG_UPDATE 0x00000008 as new bit
to introduce CPU/Memory hotplug feature for kexec_load syscall, we will
not have
compatibility issue.
Let me write next version for this patch with KEXEC_CRASH_HOTPLUG_UPDATE
0x00000008
as new flag bit and show how it will be handled. I will also share kexec
code for clarity.
Thanks,
Sourabh
next prev parent reply other threads:[~2023-12-21 6:08 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
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 [this message]
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=cdde877b-e620-45db-ae28-4b691c1ae5b6@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).