diff options
-rw-r--r-- | arch/powerpc/kernel/machine_kexec_file_64.c | 12 | ||||
-rw-r--r-- | arch/x86/kernel/crash.c | 18 | ||||
-rw-r--r-- | arch/x86/kernel/pmem.c | 2 | ||||
-rw-r--r-- | include/linux/ioport.h | 4 | ||||
-rw-r--r-- | include/linux/kexec.h | 2 | ||||
-rw-r--r-- | kernel/kexec_file.c | 5 | ||||
-rw-r--r-- | kernel/resource.c | 9 |
7 files changed, 30 insertions, 22 deletions
diff --git a/arch/powerpc/kernel/machine_kexec_file_64.c b/arch/powerpc/kernel/machine_kexec_file_64.c index 992c0d258e5d..e4395f937d63 100644 --- a/arch/powerpc/kernel/machine_kexec_file_64.c +++ b/arch/powerpc/kernel/machine_kexec_file_64.c | |||
@@ -91,11 +91,13 @@ int arch_kimage_file_post_load_cleanup(struct kimage *image) | |||
91 | * and that value will be returned. If all free regions are visited without | 91 | * and that value will be returned. If all free regions are visited without |
92 | * func returning non-zero, then zero will be returned. | 92 | * func returning non-zero, then zero will be returned. |
93 | */ | 93 | */ |
94 | int arch_kexec_walk_mem(struct kexec_buf *kbuf, int (*func)(u64, u64, void *)) | 94 | int arch_kexec_walk_mem(struct kexec_buf *kbuf, |
95 | int (*func)(struct resource *, void *)) | ||
95 | { | 96 | { |
96 | int ret = 0; | 97 | int ret = 0; |
97 | u64 i; | 98 | u64 i; |
98 | phys_addr_t mstart, mend; | 99 | phys_addr_t mstart, mend; |
100 | struct resource res = { }; | ||
99 | 101 | ||
100 | if (kbuf->top_down) { | 102 | if (kbuf->top_down) { |
101 | for_each_free_mem_range_reverse(i, NUMA_NO_NODE, 0, | 103 | for_each_free_mem_range_reverse(i, NUMA_NO_NODE, 0, |
@@ -105,7 +107,9 @@ int arch_kexec_walk_mem(struct kexec_buf *kbuf, int (*func)(u64, u64, void *)) | |||
105 | * range while in kexec, end points to the last byte | 107 | * range while in kexec, end points to the last byte |
106 | * in the range. | 108 | * in the range. |
107 | */ | 109 | */ |
108 | ret = func(mstart, mend - 1, kbuf); | 110 | res.start = mstart; |
111 | res.end = mend - 1; | ||
112 | ret = func(&res, kbuf); | ||
109 | if (ret) | 113 | if (ret) |
110 | break; | 114 | break; |
111 | } | 115 | } |
@@ -117,7 +121,9 @@ int arch_kexec_walk_mem(struct kexec_buf *kbuf, int (*func)(u64, u64, void *)) | |||
117 | * range while in kexec, end points to the last byte | 121 | * range while in kexec, end points to the last byte |
118 | * in the range. | 122 | * in the range. |
119 | */ | 123 | */ |
120 | ret = func(mstart, mend - 1, kbuf); | 124 | res.start = mstart; |
125 | res.end = mend - 1; | ||
126 | ret = func(&res, kbuf); | ||
121 | if (ret) | 127 | if (ret) |
122 | break; | 128 | break; |
123 | } | 129 | } |
diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index 44404e2307bb..815008c9ca18 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c | |||
@@ -209,7 +209,7 @@ void native_machine_crash_shutdown(struct pt_regs *regs) | |||
209 | } | 209 | } |
210 | 210 | ||
211 | #ifdef CONFIG_KEXEC_FILE | 211 | #ifdef CONFIG_KEXEC_FILE |
212 | static int get_nr_ram_ranges_callback(u64 start, u64 end, void *arg) | 212 | static int get_nr_ram_ranges_callback(struct resource *res, void *arg) |
213 | { | 213 | { |
214 | unsigned int *nr_ranges = arg; | 214 | unsigned int *nr_ranges = arg; |
215 | 215 | ||
@@ -342,7 +342,7 @@ static int elf_header_exclude_ranges(struct crash_elf_data *ced, | |||
342 | return ret; | 342 | return ret; |
343 | } | 343 | } |
344 | 344 | ||
345 | static int prepare_elf64_ram_headers_callback(u64 start, u64 end, void *arg) | 345 | static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg) |
346 | { | 346 | { |
347 | struct crash_elf_data *ced = arg; | 347 | struct crash_elf_data *ced = arg; |
348 | Elf64_Ehdr *ehdr; | 348 | Elf64_Ehdr *ehdr; |
@@ -355,7 +355,7 @@ static int prepare_elf64_ram_headers_callback(u64 start, u64 end, void *arg) | |||
355 | ehdr = ced->ehdr; | 355 | ehdr = ced->ehdr; |
356 | 356 | ||
357 | /* Exclude unwanted mem ranges */ | 357 | /* Exclude unwanted mem ranges */ |
358 | ret = elf_header_exclude_ranges(ced, start, end); | 358 | ret = elf_header_exclude_ranges(ced, res->start, res->end); |
359 | if (ret) | 359 | if (ret) |
360 | return ret; | 360 | return ret; |
361 | 361 | ||
@@ -518,14 +518,14 @@ static int add_e820_entry(struct boot_params *params, struct e820_entry *entry) | |||
518 | return 0; | 518 | return 0; |
519 | } | 519 | } |
520 | 520 | ||
521 | static int memmap_entry_callback(u64 start, u64 end, void *arg) | 521 | static int memmap_entry_callback(struct resource *res, void *arg) |
522 | { | 522 | { |
523 | struct crash_memmap_data *cmd = arg; | 523 | struct crash_memmap_data *cmd = arg; |
524 | struct boot_params *params = cmd->params; | 524 | struct boot_params *params = cmd->params; |
525 | struct e820_entry ei; | 525 | struct e820_entry ei; |
526 | 526 | ||
527 | ei.addr = start; | 527 | ei.addr = res->start; |
528 | ei.size = end - start + 1; | 528 | ei.size = res->end - res->start + 1; |
529 | ei.type = cmd->type; | 529 | ei.type = cmd->type; |
530 | add_e820_entry(params, &ei); | 530 | add_e820_entry(params, &ei); |
531 | 531 | ||
@@ -619,12 +619,12 @@ out: | |||
619 | return ret; | 619 | return ret; |
620 | } | 620 | } |
621 | 621 | ||
622 | static int determine_backup_region(u64 start, u64 end, void *arg) | 622 | static int determine_backup_region(struct resource *res, void *arg) |
623 | { | 623 | { |
624 | struct kimage *image = arg; | 624 | struct kimage *image = arg; |
625 | 625 | ||
626 | image->arch.backup_src_start = start; | 626 | image->arch.backup_src_start = res->start; |
627 | image->arch.backup_src_sz = end - start + 1; | 627 | image->arch.backup_src_sz = res->end - res->start + 1; |
628 | 628 | ||
629 | /* Expecting only one range for backup region */ | 629 | /* Expecting only one range for backup region */ |
630 | return 1; | 630 | return 1; |
diff --git a/arch/x86/kernel/pmem.c b/arch/x86/kernel/pmem.c index 3fe690067802..6b07faaa1579 100644 --- a/arch/x86/kernel/pmem.c +++ b/arch/x86/kernel/pmem.c | |||
@@ -7,7 +7,7 @@ | |||
7 | #include <linux/init.h> | 7 | #include <linux/init.h> |
8 | #include <linux/ioport.h> | 8 | #include <linux/ioport.h> |
9 | 9 | ||
10 | static int found(u64 start, u64 end, void *data) | 10 | static int found(struct resource *res, void *data) |
11 | { | 11 | { |
12 | return 1; | 12 | return 1; |
13 | } | 13 | } |
diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 83c8d6530f0f..c0070d7c4b99 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h | |||
@@ -272,10 +272,10 @@ walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, | |||
272 | void *arg, int (*func)(unsigned long, unsigned long, void *)); | 272 | void *arg, int (*func)(unsigned long, unsigned long, void *)); |
273 | extern int | 273 | extern int |
274 | walk_system_ram_res(u64 start, u64 end, void *arg, | 274 | walk_system_ram_res(u64 start, u64 end, void *arg, |
275 | int (*func)(u64, u64, void *)); | 275 | int (*func)(struct resource *, void *)); |
276 | extern int | 276 | extern int |
277 | walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, u64 end, | 277 | walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, u64 end, |
278 | void *arg, int (*func)(u64, u64, void *)); | 278 | void *arg, int (*func)(struct resource *, void *)); |
279 | 279 | ||
280 | /* True if any part of r1 overlaps r2 */ | 280 | /* True if any part of r1 overlaps r2 */ |
281 | static inline bool resource_overlaps(struct resource *r1, struct resource *r2) | 281 | static inline bool resource_overlaps(struct resource *r1, struct resource *r2) |
diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 1c08c925cefb..f16f6ceb3875 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h | |||
@@ -160,7 +160,7 @@ struct kexec_buf { | |||
160 | }; | 160 | }; |
161 | 161 | ||
162 | int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf, | 162 | int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf, |
163 | int (*func)(u64, u64, void *)); | 163 | int (*func)(struct resource *, void *)); |
164 | extern int kexec_add_buffer(struct kexec_buf *kbuf); | 164 | extern int kexec_add_buffer(struct kexec_buf *kbuf); |
165 | int kexec_locate_mem_hole(struct kexec_buf *kbuf); | 165 | int kexec_locate_mem_hole(struct kexec_buf *kbuf); |
166 | #endif /* CONFIG_KEXEC_FILE */ | 166 | #endif /* CONFIG_KEXEC_FILE */ |
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 9f48f4412297..e5bcd94c1efb 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c | |||
@@ -406,9 +406,10 @@ static int locate_mem_hole_bottom_up(unsigned long start, unsigned long end, | |||
406 | return 1; | 406 | return 1; |
407 | } | 407 | } |
408 | 408 | ||
409 | static int locate_mem_hole_callback(u64 start, u64 end, void *arg) | 409 | static int locate_mem_hole_callback(struct resource *res, void *arg) |
410 | { | 410 | { |
411 | struct kexec_buf *kbuf = (struct kexec_buf *)arg; | 411 | struct kexec_buf *kbuf = (struct kexec_buf *)arg; |
412 | u64 start = res->start, end = res->end; | ||
412 | unsigned long sz = end - start + 1; | 413 | unsigned long sz = end - start + 1; |
413 | 414 | ||
414 | /* Returning 0 will take to next memory range */ | 415 | /* Returning 0 will take to next memory range */ |
@@ -437,7 +438,7 @@ static int locate_mem_hole_callback(u64 start, u64 end, void *arg) | |||
437 | * func returning non-zero, then zero will be returned. | 438 | * func returning non-zero, then zero will be returned. |
438 | */ | 439 | */ |
439 | int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf, | 440 | int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf, |
440 | int (*func)(u64, u64, void *)) | 441 | int (*func)(struct resource *, void *)) |
441 | { | 442 | { |
442 | if (kbuf->image->type == KEXEC_TYPE_CRASH) | 443 | if (kbuf->image->type == KEXEC_TYPE_CRASH) |
443 | return walk_iomem_res_desc(crashk_res.desc, | 444 | return walk_iomem_res_desc(crashk_res.desc, |
diff --git a/kernel/resource.c b/kernel/resource.c index 7323c1b636cd..8430042fa77b 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
@@ -402,14 +402,15 @@ static int find_next_iomem_res(struct resource *res, unsigned long desc, | |||
402 | 402 | ||
403 | static int __walk_iomem_res_desc(struct resource *res, unsigned long desc, | 403 | static int __walk_iomem_res_desc(struct resource *res, unsigned long desc, |
404 | bool first_level_children_only, | 404 | bool first_level_children_only, |
405 | void *arg, int (*func)(u64, u64, void *)) | 405 | void *arg, |
406 | int (*func)(struct resource *, void *)) | ||
406 | { | 407 | { |
407 | u64 orig_end = res->end; | 408 | u64 orig_end = res->end; |
408 | int ret = -1; | 409 | int ret = -1; |
409 | 410 | ||
410 | while ((res->start < res->end) && | 411 | while ((res->start < res->end) && |
411 | !find_next_iomem_res(res, desc, first_level_children_only)) { | 412 | !find_next_iomem_res(res, desc, first_level_children_only)) { |
412 | ret = (*func)(res->start, res->end, arg); | 413 | ret = (*func)(res, arg); |
413 | if (ret) | 414 | if (ret) |
414 | break; | 415 | break; |
415 | 416 | ||
@@ -435,7 +436,7 @@ static int __walk_iomem_res_desc(struct resource *res, unsigned long desc, | |||
435 | * <linux/ioport.h> and set it in 'desc' of a target resource entry. | 436 | * <linux/ioport.h> and set it in 'desc' of a target resource entry. |
436 | */ | 437 | */ |
437 | int walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, | 438 | int walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, |
438 | u64 end, void *arg, int (*func)(u64, u64, void *)) | 439 | u64 end, void *arg, int (*func)(struct resource *, void *)) |
439 | { | 440 | { |
440 | struct resource res; | 441 | struct resource res; |
441 | 442 | ||
@@ -454,7 +455,7 @@ int walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, | |||
454 | * ranges. | 455 | * ranges. |
455 | */ | 456 | */ |
456 | int walk_system_ram_res(u64 start, u64 end, void *arg, | 457 | int walk_system_ram_res(u64 start, u64 end, void *arg, |
457 | int (*func)(u64, u64, void *)) | 458 | int (*func)(struct resource *, void *)) |
458 | { | 459 | { |
459 | struct resource res; | 460 | struct resource res; |
460 | 461 | ||