Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kernel/kexec: change the prototype of kimage_map_segment()

The kexec segment index will be required to extract the corresponding
information for that segment in kimage_map_segment(). Additionally,
kexec_segment already holds the kexec relocation destination address and
size. Therefore, the prototype of kimage_map_segment() can be changed.

Link: https://lkml.kernel.org/r/20251216014852.8737-1-piliu@redhat.com
Fixes: 07d24902977e ("kexec: enable CMA based contiguous allocation")
Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
Cc: Mimi Zohar <zohar@linux.ibm.com>
Cc: Roberto Sassu <roberto.sassu@huawei.com>
Cc: Alexander Graf <graf@amazon.com>
Cc: Steven Chen <chenste@linux.microsoft.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Pingfan Liu and committed by
Andrew Morton
fe55ea85 8de52477

+9 -8
+2 -2
include/linux/kexec.h
··· 530 530 #define kexec_dprintk(fmt, arg...) \ 531 531 do { if (kexec_file_dbg_print) pr_info(fmt, ##arg); } while (0) 532 532 533 - extern void *kimage_map_segment(struct kimage *image, unsigned long addr, unsigned long size); 533 + extern void *kimage_map_segment(struct kimage *image, int idx); 534 534 extern void kimage_unmap_segment(void *buffer); 535 535 #else /* !CONFIG_KEXEC_CORE */ 536 536 struct pt_regs; ··· 540 540 static inline void crash_kexec(struct pt_regs *regs) { } 541 541 static inline int kexec_should_crash(struct task_struct *p) { return 0; } 542 542 static inline int kexec_crash_loaded(void) { return 0; } 543 - static inline void *kimage_map_segment(struct kimage *image, unsigned long addr, unsigned long size) 543 + static inline void *kimage_map_segment(struct kimage *image, int idx) 544 544 { return NULL; } 545 545 static inline void kimage_unmap_segment(void *buffer) { } 546 546 #define kexec_in_progress false
+6 -3
kernel/kexec_core.c
··· 953 953 return result; 954 954 } 955 955 956 - void *kimage_map_segment(struct kimage *image, 957 - unsigned long addr, unsigned long size) 956 + void *kimage_map_segment(struct kimage *image, int idx) 958 957 { 958 + unsigned long addr, size, eaddr; 959 959 unsigned long src_page_addr, dest_page_addr = 0; 960 - unsigned long eaddr = addr + size; 961 960 kimage_entry_t *ptr, entry; 962 961 struct page **src_pages; 963 962 unsigned int npages; 964 963 void *vaddr = NULL; 965 964 int i; 965 + 966 + addr = image->segment[idx].mem; 967 + size = image->segment[idx].memsz; 968 + eaddr = addr + size; 966 969 967 970 /* 968 971 * Collect the source pages and map them in a contiguous VA range.
+1 -3
security/integrity/ima/ima_kexec.c
··· 250 250 if (!image->ima_buffer_addr) 251 251 return; 252 252 253 - ima_kexec_buffer = kimage_map_segment(image, 254 - image->ima_buffer_addr, 255 - image->ima_buffer_size); 253 + ima_kexec_buffer = kimage_map_segment(image, image->ima_segment_index); 256 254 if (!ima_kexec_buffer) { 257 255 pr_err("Could not map measurements buffer.\n"); 258 256 return;