Commit cade589f authored by Li Chen's avatar Li Chen Committed by Andrew Morton

kexec: replace crash_mem_range with range

We already have struct range, so just use it.

Link: https://lkml.kernel.org/r/20220929042936.22012-4-bhe@redhat.comSigned-off-by: default avatarLi Chen <lchen@ambarella.com>
Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
Acked-by: default avatarBaoquan He <bhe@redhat.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Chen Lifu <chenlifu@huawei.com>
Cc: "Eric W . Biederman" <ebiederm@xmission.com>
Cc: Jianglei Nie <niejianglei2021@163.com>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: ye xingchen <ye.xingchen@zte.com.cn>
Cc: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 32d0c98e
...@@ -35,7 +35,7 @@ struct umem_info { ...@@ -35,7 +35,7 @@ struct umem_info {
/* usable memory ranges to look up */ /* usable memory ranges to look up */
unsigned int nr_ranges; unsigned int nr_ranges;
const struct crash_mem_range *ranges; const struct range *ranges;
}; };
const struct kexec_file_ops * const kexec_file_loaders[] = { const struct kexec_file_ops * const kexec_file_loaders[] = {
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
static inline unsigned int get_max_nr_ranges(size_t size) static inline unsigned int get_max_nr_ranges(size_t size)
{ {
return ((size - sizeof(struct crash_mem)) / return ((size - sizeof(struct crash_mem)) /
sizeof(struct crash_mem_range)); sizeof(struct range));
} }
/** /**
...@@ -51,7 +51,7 @@ static inline size_t get_mem_rngs_size(struct crash_mem *mem_rngs) ...@@ -51,7 +51,7 @@ static inline size_t get_mem_rngs_size(struct crash_mem *mem_rngs)
return 0; return 0;
size = (sizeof(struct crash_mem) + size = (sizeof(struct crash_mem) +
(mem_rngs->max_nr_ranges * sizeof(struct crash_mem_range))); (mem_rngs->max_nr_ranges * sizeof(struct range)));
/* /*
* Memory is allocated in size multiple of MEM_RANGE_CHUNK_SZ. * Memory is allocated in size multiple of MEM_RANGE_CHUNK_SZ.
...@@ -98,7 +98,7 @@ static int __add_mem_range(struct crash_mem **mem_ranges, u64 base, u64 size) ...@@ -98,7 +98,7 @@ static int __add_mem_range(struct crash_mem **mem_ranges, u64 base, u64 size)
*/ */
static void __merge_memory_ranges(struct crash_mem *mem_rngs) static void __merge_memory_ranges(struct crash_mem *mem_rngs)
{ {
struct crash_mem_range *ranges; struct range *ranges;
int i, idx; int i, idx;
if (!mem_rngs) if (!mem_rngs)
...@@ -123,7 +123,7 @@ static void __merge_memory_ranges(struct crash_mem *mem_rngs) ...@@ -123,7 +123,7 @@ static void __merge_memory_ranges(struct crash_mem *mem_rngs)
/* cmp_func_t callback to sort ranges with sort() */ /* cmp_func_t callback to sort ranges with sort() */
static int rngcmp(const void *_x, const void *_y) static int rngcmp(const void *_x, const void *_y)
{ {
const struct crash_mem_range *x = _x, *y = _y; const struct range *x = _x, *y = _y;
if (x->start > y->start) if (x->start > y->start)
return 1; return 1;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/crash_core.h> #include <linux/crash_core.h>
#include <asm/io.h> #include <asm/io.h>
#include <linux/range.h>
#include <uapi/linux/kexec.h> #include <uapi/linux/kexec.h>
#include <linux/verification.h> #include <linux/verification.h>
...@@ -240,14 +241,10 @@ static inline int arch_kexec_locate_mem_hole(struct kexec_buf *kbuf) ...@@ -240,14 +241,10 @@ static inline int arch_kexec_locate_mem_hole(struct kexec_buf *kbuf)
/* Alignment required for elf header segment */ /* Alignment required for elf header segment */
#define ELF_CORE_HEADER_ALIGN 4096 #define ELF_CORE_HEADER_ALIGN 4096
struct crash_mem_range {
u64 start, end;
};
struct crash_mem { struct crash_mem {
unsigned int max_nr_ranges; unsigned int max_nr_ranges;
unsigned int nr_ranges; unsigned int nr_ranges;
struct crash_mem_range ranges[]; struct range ranges[];
}; };
extern int crash_exclude_mem_range(struct crash_mem *mem, extern int crash_exclude_mem_range(struct crash_mem *mem,
......
...@@ -1141,7 +1141,7 @@ int crash_exclude_mem_range(struct crash_mem *mem, ...@@ -1141,7 +1141,7 @@ int crash_exclude_mem_range(struct crash_mem *mem,
{ {
int i, j; int i, j;
unsigned long long start, end, p_start, p_end; unsigned long long start, end, p_start, p_end;
struct crash_mem_range temp_range = {0, 0}; struct range temp_range = {0, 0};
for (i = 0; i < mem->nr_ranges; i++) { for (i = 0; i < mem->nr_ranges; i++) {
start = mem->ranges[i].start; start = mem->ranges[i].start;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment