[PATCH v5 11/17] crash: Normalize the kexec_load elfcorehdr at load time

Jinjie Ruan ruanjinjie at huawei.com
Sat Sep 19 20:52:12 PDT 2026



在 2026/9/18 18:27, sashiko-bot at kernel.org 写道:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] kexec: elfcorehdr_updated in struct kimage is write-only and unused
> --
> 
> commit 463b7b7692d8e96dc1be8ffaed1b6d0c8d298c9f
> Author: Jinjie Ruan <ruanjinjie at huawei.com>
> 
> crash: Normalize the kexec_load elfcorehdr at load time
> 
> This commit changes kexec_load to normalize the elfcorehdr at load time
> instead of waiting for the first crash hotplug event. By doing this while
> the device_hotplug_lock can be safely taken, it allows hotplug paths to
> skip CPU events safely and avoid racing with memory hotplug.
> 
>> diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
>> index 3c9f4fbbe7ff0..f34fa8dba0288 100644
>> --- a/arch/x86/kernel/crash.c
>> +++ b/arch/x86/kernel/crash.c
>> @@ -457,9 +457,8 @@ void arch_crash_handle_hotplug_event(struct kimage *image, void *arg)
>>  	 * possible CPUs, there is no need to update the elfcorehdr
>>  	 * for additional CPU changes.
>>  	 */
>> -	if ((image->file_mode || image->elfcorehdr_updated) &&
>> -		((image->hp_action == KEXEC_CRASH_HP_ADD_CPU) ||
>> -		(image->hp_action == KEXEC_CRASH_HP_REMOVE_CPU)))
>> +	if (image->hp_action == KEXEC_CRASH_HP_ADD_CPU ||
>> +	    image->hp_action == KEXEC_CRASH_HP_REMOVE_CPU)
>>  		return;
> 
> [Severity: Low]
> Does this leave elfcorehdr_updated as a write-only and unused field?
> 
> Since this patch removes the last reader of image->elfcorehdr_updated,
> the field is now only written to in crash_handle_hotplug_event() and
> initialized in kernel/kexec_core.c:

Will remove unused  elfcorehdr_updated in v6.

> 
> kernel/crash_core.c:crash_handle_hotplug_event() {
>     ...
>     image->hp_action = KEXEC_CRASH_HP_NONE;
>     image->elfcorehdr_updated = true;
>     ...
> }
> 
> Should the elfcorehdr_updated field be completely removed from struct kimage
> in include/linux/kexec.h along with its assignments to avoid dead code and
> structure overhead?
> 

-- 
Best regards,
Jinjie




More information about the kexec mailing list