On 20/06/2022, 09:01:05, Sourabh Jain wrote: > A common crash hotplug handler is used for both kexec_load and > kexec_file_load, which is already implemented in earlier patches while > adding support for kexec_file_load. > > To enable the crash hotplug handler to work for kexec_load case the > fdt_index attribute of kimage_arch needs to be populated with index of > FDT segment in kexec segment array. > > After loading kexec segments the FDT segment is identified by looping > through all the kexec segments and fdt_index is updated accordingly. > > Signed-off-by: Sourabh Jain <sourabhjain@xxxxxxxxxxxxx> > --- > arch/powerpc/kexec/core_64.c | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c > index 6d448b55dfad..373cb46bcc0e 100644 > --- a/arch/powerpc/kexec/core_64.c > +++ b/arch/powerpc/kexec/core_64.c > @@ -74,6 +74,31 @@ int machine_kexec_prepare(struct kimage *image) > return 0; > } > > +#if defined(CONFIG_HOTPLUG_CPU) > +int machine_kexec_post_load(struct kimage *kimage) > +{ > + int i; > + void *ptr; > + unsigned long mem; > + > + if (kimage->type != KEXEC_TYPE_CRASH) > + return 0; > + > + /* Mark fdt_index invalid */ > + kimage->arch.fdt_index = -1; If fdt_index should be set to -1, this should be done in machine_kexec_prepare(). Anyway, there is no need to set it to -1 because this image will not be registered in do_kexec_load() before the following loop is complete. > + > + for (i = 0; i < kimage->nr_segments; i++) { > + mem = kimage->segment[i].mem; > + ptr = __va(mem); > + > + if (ptr && fdt_magic(ptr) == FDT_MAGIC) > + kimage->arch.fdt_index = i; break; there is no need to check the other segments, isn't it? Cheers, Laurent. > + } > + > + return 0; > +} > +#endif > + > /* Called during kexec sequence with MMU off */ > static notrace void copy_segments(unsigned long ind) > { _______________________________________________ kexec mailing list kexec@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/kexec