Skip to content

Commit fe55ea8

Browse files
Pingfan Liuakpm00
authored andcommitted
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: 07d2490 ("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>
1 parent 8de5247 commit fe55ea8

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

include/linux/kexec.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ extern bool kexec_file_dbg_print;
530530
#define kexec_dprintk(fmt, arg...) \
531531
do { if (kexec_file_dbg_print) pr_info(fmt, ##arg); } while (0)
532532

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);
534534
extern void kimage_unmap_segment(void *buffer);
535535
#else /* !CONFIG_KEXEC_CORE */
536536
struct pt_regs;
@@ -540,7 +540,7 @@ static inline void __crash_kexec(struct pt_regs *regs) { }
540540
static inline void crash_kexec(struct pt_regs *regs) { }
541541
static inline int kexec_should_crash(struct task_struct *p) { return 0; }
542542
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)
544544
{ return NULL; }
545545
static inline void kimage_unmap_segment(void *buffer) { }
546546
#define kexec_in_progress false

kernel/kexec_core.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -953,17 +953,20 @@ int kimage_load_segment(struct kimage *image, int idx)
953953
return result;
954954
}
955955

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)
958957
{
958+
unsigned long addr, size, eaddr;
959959
unsigned long src_page_addr, dest_page_addr = 0;
960-
unsigned long eaddr = addr + size;
961960
kimage_entry_t *ptr, entry;
962961
struct page **src_pages;
963962
unsigned int npages;
964963
void *vaddr = NULL;
965964
int i;
966965

966+
addr = image->segment[idx].mem;
967+
size = image->segment[idx].memsz;
968+
eaddr = addr + size;
969+
967970
/*
968971
* Collect the source pages and map them in a contiguous VA range.
969972
*/

security/integrity/ima/ima_kexec.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,7 @@ void ima_kexec_post_load(struct kimage *image)
250250
if (!image->ima_buffer_addr)
251251
return;
252252

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);
256254
if (!ima_kexec_buffer) {
257255
pr_err("Could not map measurements buffer.\n");
258256
return;

0 commit comments

Comments
 (0)