diff --git a/add-secure-compile-options-for-makedumpfile.patch b/add-secure-compile-options-for-makedumpfile.patch index 200068f7f9d9e8cd027cceb4a515003e6449db43..2b7d0fcf8971d1b077b06a476759aa08722dd454 100644 --- a/add-secure-compile-options-for-makedumpfile.patch +++ b/add-secure-compile-options-for-makedumpfile.patch @@ -12,8 +12,8 @@ Signed-off-by: pengyeqing diff --git a/makedumpfile-1.6.7/Makefile b/makedumpfile-1.6.7/Makefile index 612b9d0..180a64f 100644 ---- a/makedumpfile-1.7.0/Makefile -+++ b/makedumpfile-1.7.0/Makefile +--- a/makedumpfile-1.7.2/Makefile ++++ b/makedumpfile-1.7.2/Makefile @@ -10,9 +10,10 @@ endif CFLAGS_BASE := $(CFLAGS) -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \ diff --git a/arm64-crashdump-deduce-paddr-of-_text-based-on-kerne.patch b/arm64-crashdump-deduce-paddr-of-_text-based-on-kerne.patch deleted file mode 100644 index 80c38efd8500ab9c74d1ff681c732748b9da6822..0000000000000000000000000000000000000000 --- a/arm64-crashdump-deduce-paddr-of-_text-based-on-kerne.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 1614959f2f0d79b5f7fdc57d6aa42da1a0298153 Mon Sep 17 00:00:00 2001 -From: Pingfan Liu -Date: Fri, 10 Dec 2021 10:57:33 +0800 -Subject: [PATCH] arm64/crashdump: deduce paddr of _text based on kernel code - size - -kexec-tools commit 61b8c79b0fb7 ("arm64/crashdump-arm64: deduce the -paddr of _text") tries to deduce the paddr of _text, but turns out -partially. - -That commit is based on "The Image must be placed text_offset bytes from -a 2MB aligned base address anywhere in usable system RAM and called -there" in linux/Documentation/arm64/booting.rst, plus text_offset field -is zero. - -But in practice, some boot loaders does not obey the convention, and -still boots up the kernel successfully. - -Revisiting kernel commit e2a073dde921 ("arm64: omit [_text, _stext) from -permanent kernel mapping"), the kernel code size changes from (unsigned -long)__init_begin - (unsigned long)_text to (unsigned long)__init_begin -- (unsigned long)_stext - -And it should be a better factor to decide which label starts the -"Kernel code" in /proc/iomem. - -Signed-off-by: Pingfan Liu -Signed-off-by: Simon Horman ---- - kexec/arch/arm64/crashdump-arm64.c | 14 +++++++++++--- - 1 file changed, 11 insertions(+), 3 deletions(-) - -diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c -index 03d6204..a02019a 100644 ---- a/kexec/arch/arm64/crashdump-arm64.c -+++ b/kexec/arch/arm64/crashdump-arm64.c -@@ -91,14 +91,22 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr), - return mem_regions_alloc_and_add(&system_memory_rgns, - base, length, RANGE_RAM); - else if (strncmp(str, KERNEL_CODE, strlen(KERNEL_CODE)) == 0) { -+ -+ unsigned long long kva_text = get_kernel_sym("_text"); -+ unsigned long long kva_stext = get_kernel_sym("_stext"); -+ unsigned long long kva_text_end = get_kernel_sym("__init_begin"); -+ - /* - * old: kernel_code.start = __pa_symbol(_text); - * new: kernel_code.start = __pa_symbol(_stext); - * -- * By utilizing the fact that paddr(_text) should align on 2MB, plus -- * _stext - _text <= 64K. -+ * For compatibility, deduce by comparing the gap "__init_begin - _stext" -+ * and the res size of "Kernel code" in /proc/iomem - */ -- elf_info.kern_paddr_start = base & ((0xffffffffffffffffUL) << 21); -+ if (kva_text_end - kva_stext == length) -+ elf_info.kern_paddr_start = base - (kva_stext - kva_text); -+ else -+ elf_info.kern_paddr_start = base; - } - else if (strncmp(str, KERNEL_DATA, strlen(KERNEL_DATA)) == 0) - elf_info.kern_size = base + length - elf_info.kern_paddr_start; --- -1.8.3.1 - diff --git a/arm64-crashdump-unify-routine-to-get-page_offset.patch b/arm64-crashdump-unify-routine-to-get-page_offset.patch deleted file mode 100644 index c0aab4aabb9ca403e112c9c09c322bcc2f0b37be..0000000000000000000000000000000000000000 --- a/arm64-crashdump-unify-routine-to-get-page_offset.patch +++ /dev/null @@ -1,113 +0,0 @@ -From bde864387a104137ff3bd5f0871709846d5c7943 Mon Sep 17 00:00:00 2001 -From: Pingfan Liu -Date: Tue, 18 Jan 2022 15:48:10 +0800 -Subject: [PATCH] arm64/crashdump: unify routine to get page_offset - -There are two funcs to get page_offset: - get_kernel_page_offset() - get_page_offset() - -Since get_kernel_page_offset() does not observe the kernel formula, and -remove it. Unify them in order to introduce 52-bits VA kernel more -easily in the coming patch. - -Signed-off-by: Pingfan Liu -Reviewed-by: Philipp Rudo -Signed-off-by: Simon Horman -Conflict:NA -Reference:https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/?id=bde864387a104137ff3bd5f0871709846d5c7943 ---- - kexec/arch/arm64/crashdump-arm64.c | 23 +---------------------- - kexec/arch/arm64/kexec-arm64.c | 8 ++++---- - kexec/arch/arm64/kexec-arm64.h | 1 + - 3 files changed, 6 insertions(+), 26 deletions(-) - -diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c -index d0f2253..7beb1fb 100644 ---- a/kexec/arch/arm64/crashdump-arm64.c -+++ b/kexec/arch/arm64/crashdump-arm64.c -@@ -46,27 +46,6 @@ static struct crash_elf_info elf_info = { - .machine = EM_AARCH64, - }; - --/* -- * Note: The returned value is correct only if !CONFIG_RANDOMIZE_BASE. -- */ --static uint64_t get_kernel_page_offset(void) --{ -- int i; -- -- if (elf_info.kern_vaddr_start == UINT64_MAX) -- return UINT64_MAX; -- -- /* Current max virtual memory range is 48-bits. */ -- for (i = 48; i > 0; i--) -- if (!(elf_info.kern_vaddr_start & (1UL << i))) -- break; -- -- if (i <= 0) -- return UINT64_MAX; -- else -- return UINT64_MAX << i; --} -- - /* - * iomem_range_callback() - callback called for each iomem region - * @data: not used -@@ -203,7 +182,7 @@ int load_crashdump_segments(struct kexec_info *info) - if (err) - return EFAILED; - -- elf_info.page_offset = get_kernel_page_offset(); -+ get_page_offset(&elf_info.page_offset); - dbgprintf("%s: page_offset: %016llx\n", __func__, - elf_info.page_offset); - -diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c -index 9dc1d8f..0f8a768 100644 ---- a/kexec/arch/arm64/kexec-arm64.c -+++ b/kexec/arch/arm64/kexec-arm64.c -@@ -928,7 +928,7 @@ static int get_va_bits(void) - * get_page_offset - Helper for getting PAGE_OFFSET - */ - --static int get_page_offset(void) -+int get_page_offset(unsigned long *page_offset) - { - int ret; - -@@ -936,8 +936,8 @@ static int get_page_offset(void) - if (ret < 0) - return ret; - -- page_offset = (0xffffffffffffffffUL) << (va_bits - 1); -- dbgprintf("page_offset : %lx\n", page_offset); -+ *page_offset = UINT64_MAX << (va_bits - 1); -+ dbgprintf("page_offset : %lx\n", *page_offset); - - return 0; - } -@@ -973,7 +973,7 @@ int get_phys_base_from_pt_load(long *phys_offset) - unsigned long long phys_start; - unsigned long long virt_start; - -- ret = get_page_offset(); -+ ret = get_page_offset(&page_offset); - if (ret < 0) - return ret; - -diff --git a/kexec/arch/arm64/kexec-arm64.h b/kexec/arch/arm64/kexec-arm64.h -index bfd4172..5eb9fc0 100644 ---- a/kexec/arch/arm64/kexec-arm64.h -+++ b/kexec/arch/arm64/kexec-arm64.h -@@ -69,6 +69,7 @@ extern struct arm64_mem arm64_mem; - - uint64_t get_phys_offset(void); - uint64_t get_vp_offset(void); -+int get_page_offset(unsigned long *offset); - - static inline void reset_vp_offset(void) - { --- -2.33.0 - diff --git a/arm64-fix-PAGE_OFFSET-calc-for-flipped-mm.patch b/arm64-fix-PAGE_OFFSET-calc-for-flipped-mm.patch deleted file mode 100644 index 52f4c12abf8be644a3d0f988312ff6ef6e89e0f8..0000000000000000000000000000000000000000 --- a/arm64-fix-PAGE_OFFSET-calc-for-flipped-mm.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 95de9eccf413ece6a86ff6b5a8e47f9b16b64454 Mon Sep 17 00:00:00 2001 -From: Kairui Song -Date: Tue, 18 Jan 2022 15:48:12 +0800 -Subject: [PATCH] arm64: fix PAGE_OFFSET calc for flipped mm - -Since kernel commit 14c127c957c1 ('arm64: mm: Flip kernel VA space'), -the memory layout on arm64 have changed, and kexec-tools can no longer -get the the right PAGE_OFFSET based on _text symbol. - -Prior to that, the kimage (_text) lays above PAGE_END with this layout: -0 -> VA_START : Usespace -VA_START -> VA_START + 256M : BPF JIT, Modules -VA_START + 256M -> PAGE_OFFSET - (~GB misc) : Vmalloc (KERNEL _text HERE) -PAGE_OFFSET -> ... : * Linear map * - -And here we have: -VA_START = -1UL << VA_BITS -PAGE_OFFSET = -1UL << (VA_BITS - 1) -_text < -1UL << (VA_BITS - 1) - -Kernel image lays somewhere between VA_START and PAGE_OFFSET, so we just -calc VA_BITS by getting the highest unset bit of _text symbol address, -and shift one less bit of VA_BITS to get page offset. This works as long -as KASLR don't put kernel in a too high location (which is commented inline). - -And after that commit, kernel layout have changed: -0 -> PAGE_OFFSET : Userspace -PAGE_OFFSET -> PAGE_END : * Linear map * -PAGE_END -> PAGE_END + 128M : bpf jit region -PAGE_END + 128M -> PAGE_END + 256MB : modules -PAGE_END + 256M -> ... : vmalloc (KERNEL _text HERE) - -Here we have: -PAGE_OFFSET = -1UL << VA_BITS -PAGE_END = -1UL << (VA_BITS - 1) -_text > -1UL << (VA_BITS - 1) - -Kernel image now lays above PAGE_END, so we have to shift one more bit to -get the VA_BITS, and shift the exact VA_BITS for PAGE_OFFSET. - -We can simply check if "_text > -1UL << (VA_BITS - 1)" is true to judge -which layout is being used and shift the page offset occordingly. - -Signed-off-by: Kairui Song -(rebased and stripped by Pingfan ) -Signed-off-by: Pingfan Liu -Reviewed-by: Philipp Rudo -Signed-off-by: Simon Horman -Conflict:NA -Reference:https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/?id=95de9eccf413ece6a86ff6b5a8e47f9b16b64454 - ---- - kexec/arch/arm64/kexec-arm64.c | 14 +++++++++++++- - 1 file changed, 13 insertions(+), 1 deletion(-) - -diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c -index e502be0..9dd072c 100644 ---- a/kexec/arch/arm64/kexec-arm64.c -+++ b/kexec/arch/arm64/kexec-arm64.c -@@ -942,13 +942,25 @@ out: - - int get_page_offset(unsigned long *page_offset) - { -+ unsigned long long text_sym_addr, kernel_va_mid; - int ret; - -+ text_sym_addr = get_kernel_sym("_text"); -+ if (text_sym_addr == 0) { -+ fprintf(stderr, "Can't get the symbol of _text to calculate page_offset.\n"); -+ return -1; -+ } -+ - ret = get_va_bits(); - if (ret < 0) - return ret; - -- if (va_bits < 52) -+ /* Since kernel 5.4, kernel image is put above -+ * UINT64_MAX << (va_bits - 1) -+ */ -+ kernel_va_mid = UINT64_MAX << (va_bits - 1); -+ /* older kernel */ -+ if (text_sym_addr < kernel_va_mid) - *page_offset = UINT64_MAX << (va_bits - 1); - else - *page_offset = UINT64_MAX << va_bits; --- -2.33.0 - diff --git a/arm64-make-phys_offset-signed.patch b/arm64-make-phys_offset-signed.patch deleted file mode 100644 index 856f9253945c7e476df082e9266832ca2d5b8e1f..0000000000000000000000000000000000000000 --- a/arm64-make-phys_offset-signed.patch +++ /dev/null @@ -1,124 +0,0 @@ -From 67ea2d99e1356352034dc9d9c7b5ec6dd6b722eb Mon Sep 17 00:00:00 2001 -From: Pingfan Liu -Date: Tue, 18 Jan 2022 15:48:09 +0800 -Subject: [PATCH] arm64: make phys_offset signed - -After kernel commit 7bc1a0f9e176 ("arm64: mm: use single quantity to -represent the PA to VA translation"), phys_offset can be negative if -running 52-bits kernel on 48-bits hardware. - -So changing phys_offset from unsigned to signed. - -Signed-off-by: Pingfan Liu -Reviewed-by: Philipp Rudo -Signed-off-by: Simon Horman -Conflict:NA -Reference:https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/?id=67ea2d99e1356352034dc9d9c7b5ec6dd6b722eb - ---- - kexec/arch/arm64/kexec-arm64.c | 12 ++++++------ - kexec/arch/arm64/kexec-arm64.h | 2 +- - util_lib/elf_info.c | 2 +- - util_lib/include/elf_info.h | 2 +- - 4 files changed, 9 insertions(+), 9 deletions(-) - -diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c -index 44ca3db..9dc1d8f 100644 ---- a/kexec/arch/arm64/kexec-arm64.c -+++ b/kexec/arch/arm64/kexec-arm64.c -@@ -878,7 +878,7 @@ void add_segment(struct kexec_info *info, const void *buf, size_t bufsz, - add_segment_phys_virt(info, buf, bufsz, base, memsz, 1); - } - --static inline void set_phys_offset(uint64_t v, char *set_method) -+static inline void set_phys_offset(int64_t v, char *set_method) - { - if (arm64_mem.phys_offset == arm64_mem_ngv - || v < arm64_mem.phys_offset) { -@@ -947,7 +947,7 @@ static int get_page_offset(void) - * from VMCOREINFO note inside 'kcore'. - */ - --static int get_phys_offset_from_vmcoreinfo_pt_note(unsigned long *phys_offset) -+static int get_phys_offset_from_vmcoreinfo_pt_note(long *phys_offset) - { - int fd, ret = 0; - -@@ -967,7 +967,7 @@ static int get_phys_offset_from_vmcoreinfo_pt_note(unsigned long *phys_offset) - * from PT_LOADs inside 'kcore'. - */ - --int get_phys_base_from_pt_load(unsigned long *phys_offset) -+int get_phys_base_from_pt_load(long *phys_offset) - { - int i, fd, ret; - unsigned long long phys_start; -@@ -1025,7 +1025,7 @@ static bool to_be_excluded(char *str, unsigned long long start, unsigned long lo - int get_memory_ranges(struct memory_range **range, int *ranges, - unsigned long kexec_flags) - { -- unsigned long phys_offset = UINT64_MAX; -+ long phys_offset = -1; - FILE *fp; - const char *iomem = proc_iomem(); - char line[MAX_LINE], *str; -@@ -1047,7 +1047,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges, - */ - ret = get_phys_offset_from_vmcoreinfo_pt_note(&phys_offset); - if (!ret) { -- if (phys_offset != UINT64_MAX) -+ if (phys_offset != -1) - set_phys_offset(phys_offset, - "vmcoreinfo pt_note"); - } else { -@@ -1059,7 +1059,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges, - */ - ret = get_phys_base_from_pt_load(&phys_offset); - if (!ret) -- if (phys_offset != UINT64_MAX) -+ if (phys_offset != -1) - set_phys_offset(phys_offset, - "pt_load"); - } -diff --git a/kexec/arch/arm64/kexec-arm64.h b/kexec/arch/arm64/kexec-arm64.h -index ed447ac..bfd4172 100644 ---- a/kexec/arch/arm64/kexec-arm64.h -+++ b/kexec/arch/arm64/kexec-arm64.h -@@ -58,7 +58,7 @@ extern off_t initrd_size; - */ - - struct arm64_mem { -- uint64_t phys_offset; -+ int64_t phys_offset; - uint64_t text_offset; - uint64_t image_size; - uint64_t vp_offset; -diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c -index 51d8b92..5574c7f 100644 ---- a/util_lib/elf_info.c -+++ b/util_lib/elf_info.c -@@ -1236,7 +1236,7 @@ int read_elf(int fd) - return 0; - } - --int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off) -+int read_phys_offset_elf_kcore(int fd, long *phys_off) - { - int ret; - -diff --git a/util_lib/include/elf_info.h b/util_lib/include/elf_info.h -index 4bc9279..f550d86 100644 ---- a/util_lib/include/elf_info.h -+++ b/util_lib/include/elf_info.h -@@ -28,7 +28,7 @@ int get_pt_load(int idx, - unsigned long long *phys_end, - unsigned long long *virt_start, - unsigned long long *virt_end); --int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off); -+int read_phys_offset_elf_kcore(int fd, long *phys_off); - int read_elf(int fd); - void dump_dmesg(int fd, void (*handler)(char*, unsigned int)); - --- -2.33.0 - diff --git a/arm64-read-VA_BITS-from-kcore-for-52-bits-VA-kernel.patch b/arm64-read-VA_BITS-from-kcore-for-52-bits-VA-kernel.patch deleted file mode 100644 index 1e64cc1220ffeeeb8f2fd5dcd318c7f7cda10331..0000000000000000000000000000000000000000 --- a/arm64-read-VA_BITS-from-kcore-for-52-bits-VA-kernel.patch +++ /dev/null @@ -1,137 +0,0 @@ -From 454395e18ff12d2728ee458695160e9ab4899e33 Mon Sep 17 00:00:00 2001 -From: Pingfan Liu -Date: Tue, 18 Jan 2022 15:48:11 +0800 -Subject: [PATCH] arm64: read VA_BITS from kcore for 52-bits VA kernel - -phys_to_virt() calculates virtual address. As a important factor, -page_offset is excepted to be accurate. - -Since arm64 kernel exposes va_bits through vmcore, using it. - -Signed-off-by: Pingfan Liu -Reviewed-by: Philipp Rudo -Signed-off-by: Simon Horman -Conflict:NA -Reference:https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/?id=454395e18ff12d2728ee458695160e9ab4899e33 ---- - kexec/arch/arm64/kexec-arm64.c | 34 ++++++++++++++++++++++++++++++---- - util_lib/elf_info.c | 5 +++++ - util_lib/include/elf_info.h | 1 + - 3 files changed, 36 insertions(+), 4 deletions(-) - -diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c -index 0f8a768..e502be0 100644 ---- a/kexec/arch/arm64/kexec-arm64.c -+++ b/kexec/arch/arm64/kexec-arm64.c -@@ -54,7 +54,7 @@ - static bool try_read_phys_offset_from_kcore = false; - - /* Machine specific details. */ --static int va_bits; -+static int va_bits = -1; - static unsigned long page_offset; - - /* Global varables the core kexec routines expect. */ -@@ -895,7 +895,18 @@ static inline void set_phys_offset(int64_t v, char *set_method) - - static int get_va_bits(void) - { -- unsigned long long stext_sym_addr = get_kernel_sym("_stext"); -+ unsigned long long stext_sym_addr; -+ -+ /* -+ * if already got from kcore -+ */ -+ if (va_bits != -1) -+ goto out; -+ -+ -+ /* For kernel older than v4.19 */ -+ fprintf(stderr, "Warning, can't get the VA_BITS from kcore\n"); -+ stext_sym_addr = get_kernel_sym("_stext"); - - if (stext_sym_addr == 0) { - fprintf(stderr, "Can't get the symbol of _stext.\n"); -@@ -919,6 +930,7 @@ static int get_va_bits(void) - return -1; - } - -+out: - dbgprintf("va_bits : %d\n", va_bits); - - return 0; -@@ -936,14 +948,27 @@ int get_page_offset(unsigned long *page_offset) - if (ret < 0) - return ret; - -- *page_offset = UINT64_MAX << (va_bits - 1); -+ if (va_bits < 52) -+ *page_offset = UINT64_MAX << (va_bits - 1); -+ else -+ *page_offset = UINT64_MAX << va_bits; -+ - dbgprintf("page_offset : %lx\n", *page_offset); - - return 0; - } - -+static void arm64_scan_vmcoreinfo(char *pos) -+{ -+ const char *str; -+ -+ str = "NUMBER(VA_BITS)="; -+ if (memcmp(str, pos, strlen(str)) == 0) -+ va_bits = strtoul(pos + strlen(str), NULL, 10); -+} -+ - /** -- * get_phys_offset_from_vmcoreinfo_pt_note - Helper for getting PHYS_OFFSET -+ * get_phys_offset_from_vmcoreinfo_pt_note - Helper for getting PHYS_OFFSET (and va_bits) - * from VMCOREINFO note inside 'kcore'. - */ - -@@ -956,6 +981,7 @@ static int get_phys_offset_from_vmcoreinfo_pt_note(long *phys_offset) - return EFAILED; - } - -+ arch_scan_vmcoreinfo = arm64_scan_vmcoreinfo; - ret = read_phys_offset_elf_kcore(fd, phys_offset); - - close(fd); -diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c -index 5574c7f..d252eff 100644 ---- a/util_lib/elf_info.c -+++ b/util_lib/elf_info.c -@@ -310,6 +310,8 @@ int get_pt_load(int idx, - - #define NOT_FOUND_LONG_VALUE (-1) - -+void (*arch_scan_vmcoreinfo)(char *pos); -+ - void scan_vmcoreinfo(char *start, size_t size) - { - char *last = start + size - 1; -@@ -551,6 +553,9 @@ void scan_vmcoreinfo(char *start, size_t size) - } - } - -+ if (arch_scan_vmcoreinfo != NULL) -+ (*arch_scan_vmcoreinfo)(pos); -+ - if (last_line) - break; - } -diff --git a/util_lib/include/elf_info.h b/util_lib/include/elf_info.h -index f550d86..fdf4c3d 100644 ---- a/util_lib/include/elf_info.h -+++ b/util_lib/include/elf_info.h -@@ -31,5 +31,6 @@ int get_pt_load(int idx, - int read_phys_offset_elf_kcore(int fd, long *phys_off); - int read_elf(int fd); - void dump_dmesg(int fd, void (*handler)(char*, unsigned int)); -+extern void (*arch_scan_vmcoreinfo)(char *pos); - - #endif /* ELF_INFO_H */ --- -2.33.0 - diff --git a/arm64-support-more-than-one-crash-kernel-regions.patch b/arm64-support-more-than-one-crash-kernel-regions.patch deleted file mode 100644 index d8b4b332e5bf1eae059671b76d791ba8fb22b45a..0000000000000000000000000000000000000000 --- a/arm64-support-more-than-one-crash-kernel-regions.patch +++ /dev/null @@ -1,308 +0,0 @@ -From 6633170a04b1fc55eb72adc0150ffcd1b85be8ce Mon Sep 17 00:00:00 2001 -From: Chen Zhou -Date: Fri, 29 Mar 2019 21:01:29 +0800 -Subject: [PATCH] kexec-tools: support more than one crash kernel regions - -reason: When crashkernel is reserved above 4G in memory, kernel should -reserve some amount of low memory for swiotlb and some DMA buffers. -So there may be two crash kernel regions, one is below 4G, the other -is above 4G. - -Currently, there is only one crash kernel region on arm64, and pass -"linux,usable-memory-range = " property to crash dump -kernel. Now, we pass -"linux,usable-memory-range = " to crash -dump kernel to support two crash kernel regions and load crash -kernel high. - -This patch paves the way for the use of arm64 reserving crashkernel -above 4G. The details are as below: -Link: https://lore.kernel.org/linux-arm-kernel/20190403030546.23718-1-chenzhou10@huawei.com/T/#t - -Signed-off-by: Chen Zhou ---- - kexec/arch/arm64/crashdump-arm64.c | 44 +++++++++++++++++------------ - kexec/arch/arm64/crashdump-arm64.h | 3 +- - kexec/arch/arm64/kexec-arm64.c | 57 +++++++++++++++++++++++++++++--------- - 3 files changed, 72 insertions(+), 32 deletions(-) - -diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c -index 38d1a0f..d8338eb 100644 ---- a/kexec/arch/arm64/crashdump-arm64.c -+++ b/kexec/arch/arm64/crashdump-arm64.c -@@ -27,11 +27,11 @@ - static struct memory_ranges system_memory_rgns; - - /* memory range reserved for crashkernel */ --struct memory_range crash_reserved_mem; -+struct memory_range crash_reserved_mem[CRASH_MAX_RESERVED_RANGES]; - struct memory_ranges usablemem_rgns = { - .size = 0, -- .max_size = 1, -- .ranges = &crash_reserved_mem, -+ .max_size = CRASH_MAX_RESERVED_RANGES, -+ .ranges = crash_reserved_mem, - }; - - struct memory_range elfcorehdr_mem; -@@ -84,7 +84,10 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr), - char *str, unsigned long long base, - unsigned long long length) - { -- if (strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)) == 0) -+ if (strncmp(str, CRASH_KERNEL_LOW, strlen(CRASH_KERNEL_LOW)) == 0) -+ return mem_regions_alloc_and_add(&usablemem_rgns, -+ base, length, RANGE_RAM); -+ else if (strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)) == 0) - return mem_regions_alloc_and_add(&usablemem_rgns, - base, length, RANGE_RAM); - else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0) -@@ -103,7 +106,7 @@ int is_crashkernel_mem_reserved(void) - if (!usablemem_rgns.size) - kexec_iomem_for_each_line(NULL, iomem_range_callback, NULL); - -- return crash_reserved_mem.start != crash_reserved_mem.end; -+ return usablemem_rgns.size; - } - - /* -@@ -117,6 +120,8 @@ int is_crashkernel_mem_reserved(void) - */ - static int crash_get_memory_ranges(void) - { -+ int i; -+ - /* - * First read all memory regions that can be considered as - * system memory including the crash area. -@@ -124,16 +129,19 @@ static int crash_get_memory_ranges(void) - if (!usablemem_rgns.size) - kexec_iomem_for_each_line(NULL, iomem_range_callback, NULL); - -- /* allow only a single region for crash dump kernel */ -- if (usablemem_rgns.size != 1) -+ /* allow one or two region for crash dump kernel */ -+ if (!usablemem_rgns.size) - return -EINVAL; - -- dbgprint_mem_range("Reserved memory range", &crash_reserved_mem, 1); -+ dbgprint_mem_range("Reserved memory range", -+ usablemem_rgns.ranges, usablemem_rgns.size); - -- if (mem_regions_alloc_and_exclude(&system_memory_rgns, -- &crash_reserved_mem)) { -- fprintf(stderr, "Cannot allocate memory for ranges\n"); -- return -ENOMEM; -+ for (i = 0; i < usablemem_rgns.size; i++) { -+ if (mem_regions_alloc_and_exclude(&system_memory_rgns, -+ &crash_reserved_mem[i])) { -+ fprintf(stderr, "Cannot allocate memory for ranges\n"); -+ return -ENOMEM; -+ } - } - - /* -@@ -194,7 +202,8 @@ int load_crashdump_segments(struct kexec_info *info) - return EFAILED; - - elfcorehdr = add_buffer_phys_virt(info, buf, bufsz, bufsz, 0, -- crash_reserved_mem.start, crash_reserved_mem.end, -+ crash_reserved_mem[usablemem_rgns.size - 1].start, -+ crash_reserved_mem[usablemem_rgns.size - 1].end, - -1, 0); - - elfcorehdr_mem.start = elfcorehdr; -@@ -212,21 +221,23 @@ int load_crashdump_segments(struct kexec_info *info) - * virt_to_phys() in add_segment(). - * So let's fix up those values for later use so the memory base - * (arm64_mm.phys_offset) will be correctly replaced with -- * crash_reserved_mem.start. -+ * crash_reserved_mem[usablemem_rgns.size - 1].start. - */ - void fixup_elf_addrs(struct mem_ehdr *ehdr) - { - struct mem_phdr *phdr; - int i; - -- ehdr->e_entry += - arm64_mem.phys_offset + crash_reserved_mem.start; -+ ehdr->e_entry += -arm64_mem.phys_offset + -+ crash_reserved_mem[usablemem_rgns.size - 1].start; - - for (i = 0; i < ehdr->e_phnum; i++) { - phdr = &ehdr->e_phdr[i]; - if (phdr->p_type != PT_LOAD) - continue; - phdr->p_paddr += -- (-arm64_mem.phys_offset + crash_reserved_mem.start); -+ (-arm64_mem.phys_offset + -+ crash_reserved_mem[usablemem_rgns.size - 1].start); - } - } - -@@ -235,11 +246,11 @@ int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) - if (!usablemem_rgns.size) - kexec_iomem_for_each_line(NULL, iomem_range_callback, NULL); - -- if (!crash_reserved_mem.end) -+ if (!usablemem_rgns.size) - return -1; - -- *start = crash_reserved_mem.start; -- *end = crash_reserved_mem.end; -+ *start = crash_reserved_mem[usablemem_rgns.size - 1].start; -+ *end = crash_reserved_mem[usablemem_rgns.size - 1].end; - - return 0; - } -diff --git a/kexec/arch/arm64/crashdump-arm64.h b/kexec/arch/arm64/crashdump-arm64.h -index 880b83a..12f4308 100644 ---- a/kexec/arch/arm64/crashdump-arm64.h -+++ b/kexec/arch/arm64/crashdump-arm64.h -@@ -16,8 +16,11 @@ - - #define CRASH_MAX_MEMORY_RANGES 32 - -+/* crash dump kernel support at most two regions, low_region and high region. */ -+#define CRASH_MAX_RESERVED_RANGES 2 -+ - extern struct memory_ranges usablemem_rgns; --extern struct memory_range crash_reserved_mem; -+extern struct memory_range crash_reserved_mem[]; - extern struct memory_range elfcorehdr_mem; - - extern int load_crashdump_segments(struct kexec_info *info); -diff --git a/kexec/arch/arm64/iomem.h b/kexec/arch/arm64/iomem.h -index d4864bb..45d7953 100644 ---- a/kexec/arch/arm64/iomem.h -+++ b/kexec/arch/arm64/iomem.h -@@ -4,6 +4,7 @@ - #define SYSTEM_RAM "System RAM\n" - #define KERNEL_CODE "Kernel code\n" - #define KERNEL_DATA "Kernel data\n" -+#define CRASH_KERNEL_LOW "Crash kernel (low)\n" - #define CRASH_KERNEL "Crash kernel\n" - #define IOMEM_RESERVED "reserved\n" - -diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c -index 45ebc54..6346f83 100644 ---- a/kexec/arch/arm64/kexec-arm64.c -+++ b/kexec/arch/arm64/kexec-arm64.c -@@ -418,6 +418,42 @@ static int fdt_setprop_range(void *fdt, int nodeoffset, - return result; - } - -+/* -+ * fdt_setprop_ranges - Used for linux,usable-memory-range -+ */ -+static int fdt_setprop_ranges(void *fdt, int nodeoffset, -+ const char *name, struct memory_ranges *ranges, -+ uint32_t address_cells, uint32_t size_cells) -+{ -+ void *buf, *prop; -+ size_t buf_size; -+ int i, result; -+ -+ buf_size = (address_cells + size_cells) * sizeof(uint32_t) * -+ ranges->size; -+ prop = buf = xmalloc(buf_size); -+ -+ /* -+ * crash dump kernel support at most two regions, low_region and high region. -+ * To make compatibility with existing user-space and older kdump, the low -+ * region is always the last range of linux,usable-memory-range if exist. -+ */ -+ for (i = ranges->size - 1; i >= 0; i--) { -+ fill_property(prop, ranges->ranges[i].start, address_cells); -+ prop += address_cells * sizeof(uint32_t); -+ -+ fill_property(prop, ranges->ranges[i].end - -+ ranges->ranges[i].start + 1, size_cells); -+ prop += size_cells * sizeof(uint32_t); -+ } -+ -+ result = fdt_setprop(fdt, nodeoffset, name, buf, buf_size); -+ -+ free(buf); -+ -+ return result; -+} -+ - /** - * setup_2nd_dtb - Setup the 2nd stage kernel's dtb. - */ -@@ -431,7 +467,7 @@ static int setup_2nd_dtb(struct dtb *dtb, char *command_line, int on_crash) - int len, range_len; - int nodeoffset; - int new_size; -- int result, kaslr_seed; -+ int i, result, kaslr_seed; - - result = fdt_check_header(dtb->buf); - -@@ -462,18 +498,21 @@ static int setup_2nd_dtb(struct dtb *dtb, char *command_line, int on_crash) - goto on_error; - } - -- if (!cells_size_fitted(address_cells, size_cells, -- &crash_reserved_mem)) { -- fprintf(stderr, "kexec: usable memory range doesn't fit cells-size.\n"); -- result = -EINVAL; -- goto on_error; -+ for (i = 0; i < usablemem_rgns.size; i++) { -+ if (!cells_size_fitted(address_cells, size_cells, -+ &crash_reserved_mem[i])) { -+ fprintf(stderr, -+ "kexec: usable memory range doesn't fit cells-size.\n"); -+ result = -EINVAL; -+ goto on_error; -+ } - } - - /* duplicate dt blob */ - range_len = sizeof(uint32_t) * (address_cells + size_cells); - new_size = fdt_totalsize(dtb->buf) - + fdt_prop_len(PROP_ELFCOREHDR, range_len) -- + fdt_prop_len(PROP_USABLE_MEM_RANGE, range_len); -+ + fdt_prop_len(PROP_USABLE_MEM_RANGE, range_len * usablemem_rgns.size); - - new_buf = xmalloc(new_size); - result = fdt_open_into(dtb->buf, new_buf, new_size); -@@ -569,8 +608,8 @@ static int setup_2nd_dtb(struct dtb *dtb, char *command_line, int on_crash) - - /* add linux,usable-memory-range */ - nodeoffset = fdt_path_offset(new_buf, "/chosen"); -- result = fdt_setprop_range(new_buf, nodeoffset, -- PROP_USABLE_MEM_RANGE, &crash_reserved_mem, -+ result = fdt_setprop_ranges(new_buf, nodeoffset, -+ PROP_USABLE_MEM_RANGE, &usablemem_rgns, - address_cells, size_cells); - if (result) { - dbgprintf("%s: fdt_setprop failed: %s\n", __func__, -@@ -603,13 +642,13 @@ unsigned long arm64_locate_kernel_segment(struct kexec_info *info) - if (info->kexec_flags & KEXEC_ON_CRASH) { - unsigned long hole_end; - -- hole = (crash_reserved_mem.start < mem_min ? -- mem_min : crash_reserved_mem.start); -+ hole = (crash_reserved_mem[usablemem_rgns.size - 1].start < mem_min ? -+ mem_min : crash_reserved_mem[usablemem_rgns.size - 1].start); - hole = _ALIGN_UP(hole, MiB(2)); - hole_end = hole + arm64_mem.text_offset + arm64_mem.image_size; - - if ((hole_end > mem_max) || -- (hole_end > crash_reserved_mem.end)) { -+ (hole_end > crash_reserved_mem[usablemem_rgns.size - 1].end)) { - dbgprintf("%s: Crash kernel out of range\n", __func__); - hole = ULONG_MAX; - } -@@ -677,7 +716,7 @@ int arm64_load_other_segments(struct kexec_info *info, - - hole_min = image_base + arm64_mem.image_size; - if (info->kexec_flags & KEXEC_ON_CRASH) -- hole_max = crash_reserved_mem.end; -+ hole_max = crash_reserved_mem[usablemem_rgns.size - 1].end; - else - hole_max = ULONG_MAX; - --- -2.20.1 diff --git a/fix-add-64-bit-loongArch-support-1.patch b/fix-add-64-bit-loongArch-support-1.patch deleted file mode 100644 index ebd99e3dc35a05b56d4aa6ad4273088c21740571..0000000000000000000000000000000000000000 --- a/fix-add-64-bit-loongArch-support-1.patch +++ /dev/null @@ -1,1197 +0,0 @@ -From 2b338585c875753c7d1d555b62c96f14e648ad7f Mon Sep 17 00:00:00 2001 -From: wu-leilei -Date: Tue, 19 Apr 2022 15:54:42 +0800 -Subject: [PATCH] add 64 bit loongArch support - ---- - config/config.guess | 3 + - config/config.sub | 4 + - configure.ac | 3 + - include/elf.h | 1 + - include/image.h | 1 + - kexec/Makefile | 1 + - kexec/arch/loongarch/Makefile | 16 + - kexec/arch/loongarch/crashdump-loongarch.c | 384 ++++++++++++++++++ - kexec/arch/loongarch/crashdump-loongarch.h | 24 ++ - kexec/arch/loongarch/include/arch/options.h | 41 ++ - kexec/arch/loongarch/kexec-elf-loongarch.c | 212 ++++++++++ - .../arch/loongarch/kexec-elf-rel-loongarch.c | 43 ++ - kexec/arch/loongarch/kexec-loongarch.c | 169 ++++++++ - kexec/arch/loongarch/kexec-loongarch.h | 34 ++ - kexec/kexec-syscall.h | 7 + - purgatory/Makefile | 1 + - purgatory/arch/loongarch/Makefile | 10 + - purgatory/arch/loongarch/console-loongarch.c | 7 + - .../arch/loongarch/purgatory-loongarch.c | 7 + - .../arch/loongarch/purgatory-loongarch.h | 6 + - 20 files changed, 974 insertions(+) - create mode 100644 kexec/arch/loongarch/Makefile - create mode 100644 kexec/arch/loongarch/crashdump-loongarch.c - create mode 100644 kexec/arch/loongarch/crashdump-loongarch.h - create mode 100644 kexec/arch/loongarch/include/arch/options.h - create mode 100644 kexec/arch/loongarch/kexec-elf-loongarch.c - create mode 100644 kexec/arch/loongarch/kexec-elf-rel-loongarch.c - create mode 100644 kexec/arch/loongarch/kexec-loongarch.c - create mode 100644 kexec/arch/loongarch/kexec-loongarch.h - create mode 100644 purgatory/arch/loongarch/Makefile - create mode 100644 purgatory/arch/loongarch/console-loongarch.c - create mode 100644 purgatory/arch/loongarch/purgatory-loongarch.c - create mode 100644 purgatory/arch/loongarch/purgatory-loongarch.h - -diff --git a/config/config.guess b/config/config.guess -index 8d70ec2..1cbf692 100755 ---- a/config/config.guess -+++ b/config/config.guess -@@ -1039,6 +1039,9 @@ EOF - mips64el:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; -+ loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; - openrisc*:Linux:*:*) - echo or1k-unknown-linux-"$LIBC" - exit ;; -diff --git a/config/config.sub b/config/config.sub -index 9bc49a7..d5bbcc3 100755 ---- a/config/config.sub -+++ b/config/config.sub -@@ -1107,6 +1107,9 @@ case $cpu-$vendor in - arm64-*) - cpu=aarch64 - ;; -+ loongarch-*) -+ cpu=loongarch64 -+ ;; - - # Recognize the canonical CPU Types that limit and/or modify the - # company names they are paired with. -@@ -1185,6 +1188,7 @@ case $cpu-$vendor in - | k1om \ - | le32 | le64 \ - | lm32 \ -+ | loongarch32 | loongarch64 | loongarchx32 \ - | m32c | m32r | m32rle \ - | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ - | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ -diff --git a/configure.ac b/configure.ac -index 1427ced..c28ccfd 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -58,6 +58,9 @@ case $target_cpu in - hppa*) - ARCH="hppa" - ;; -+ loongarch* ) -+ ARCH="loongarch" -+ ;; - * ) - AC_MSG_ERROR([unsupported architecture $target_cpu]) - ;; -diff --git a/include/elf.h b/include/elf.h -index b7677a2..ca42618 100644 ---- a/include/elf.h -+++ b/include/elf.h -@@ -260,6 +260,7 @@ typedef struct - #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ - #define EM_AARCH64 183 /* ARM AARCH64 */ - #define EM_NUM 184 -+#define EM_LOONGARCH 258 /* Loongson Loongarch*/ - - /* If it is necessary to assign new unofficial EM_* values, please - pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the -diff --git a/include/image.h b/include/image.h -index 8e9d81e..7a4bccf 100644 ---- a/include/image.h -+++ b/include/image.h -@@ -86,6 +86,7 @@ - #define IH_ARCH_ARC 23 /* Synopsys DesignWare ARC */ - #define IH_ARCH_X86_64 24 /* AMD x86_64, Intel and Via */ - #define IH_ARCH_XTENSA 25 /* Xtensa */ -+#define IH_ARCH_LOONGARCH 26 /* LoongArch Loongson */ - - /* - * Image Types -diff --git a/kexec/Makefile b/kexec/Makefile -index e69e309..8a52e8d 100644 ---- a/kexec/Makefile -+++ b/kexec/Makefile -@@ -92,6 +92,7 @@ include $(srcdir)/kexec/arch/s390/Makefile - include $(srcdir)/kexec/arch/sh/Makefile - include $(srcdir)/kexec/arch/x86_64/Makefile - include $(srcdir)/kexec/arch/hppa/Makefile -+include $(srcdir)/kexec/arch/loongarch/Makefile - - KEXEC_SRCS += $($(ARCH)_KEXEC_SRCS) - -diff --git a/kexec/arch/loongarch/Makefile b/kexec/arch/loongarch/Makefile -new file mode 100644 -index 0000000..b7553bc ---- /dev/null -+++ b/kexec/arch/loongarch/Makefile -@@ -0,0 +1,16 @@ -+# -+# kexec loongarch (linux booting linux) -+# -+loongarch_KEXEC_SRCS = kexec/arch/loongarch/kexec-loongarch.c -+loongarch_KEXEC_SRCS += kexec/arch/loongarch/kexec-elf-loongarch.c -+loongarch_KEXEC_SRCS += kexec/arch/loongarch/kexec-elf-rel-loongarch.c -+loongarch_KEXEC_SRCS += kexec/arch/loongarch/crashdump-loongarch.c -+ -+loongarch_ADD_BUFFER = -+loongarch_ADD_SEGMENT = -+loongarch_VIRT_TO_PHYS = -+ -+dist += kexec/arch/loongarch/Makefile $(loongarch_KEXEC_SRCS) \ -+ kexec/arch/loongarch/kexec-loongarch.h \ -+ kexec/arch/loongarch/crashdump-loongarch.h \ -+ kexec/arch/loongarch/include/arch/options.h -diff --git a/kexec/arch/loongarch/crashdump-loongarch.c b/kexec/arch/loongarch/crashdump-loongarch.c -new file mode 100644 -index 0000000..1c27aa7 ---- /dev/null -+++ b/kexec/arch/loongarch/crashdump-loongarch.c -@@ -0,0 +1,384 @@ -+/* -+ * kexec: Linux boots Linux -+ * -+ * Copyright (C) 2021 Loongson Technology Co., Ltd. -+ * -+ * This source code is licensed under the GNU General Public License, -+ * Version 2. See the file COPYING for more details. -+ */ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include "../../kexec.h" -+#include "../../kexec-elf.h" -+#include "../../kexec-syscall.h" -+#include "../../crashdump.h" -+#include "kexec-loongarch.h" -+#include "crashdump-loongarch.h" -+#include "unused.h" -+ -+/* -+ * Stores a sorted list of RAM memory ranges for which to create elf headers. -+ * A separate program header is created for backup region -+ */ -+static struct memory_range crash_memory_range[CRASH_MAX_MEMORY_RANGES]; -+ -+/* Memory region reserved for storing panic kernel and other data. */ -+static struct memory_range crash_reserved_mem; -+ -+/* -+ * Read kernel physical load addr from the file returned by proc_iomem() -+ * (Kernel Code) and store in kexec_info -+ */ -+static int get_kernel_paddr(struct crash_elf_info *elf_info) -+{ -+ uint64_t start; -+ -+ if (xen_present()) /* Kernel not entity mapped under Xen */ -+ return 0; -+ -+ if (parse_iomem_single("Kernel code\n", &start, NULL) == 0) { -+ elf_info->kern_paddr_start = start; -+ dbgprintf("kernel load physical addr start = 0x%" PRIu64 "\n", start); -+ return 0; -+ } -+ -+ fprintf(stderr, "Cannot determine kernel physical load addr\n"); -+ return -1; -+} -+ -+static int get_kernel_vaddr_and_size(struct crash_elf_info *elf_info, -+ unsigned long start_offset) -+{ -+ uint64_t end; -+ -+ if (!elf_info->kern_paddr_start) -+ return -1; -+ -+ elf_info->kern_vaddr_start = elf_info->kern_paddr_start | -+ start_offset; -+ /* -+ * If "Kernel bss" exists, the kernel ends there, else fall -+ * through and say that it ends at "Kernel data" -+ */ -+ if (parse_iomem_single("Kernel bss\n", NULL, &end) == 0 || -+ parse_iomem_single("Kernel data\n", NULL, &end) == 0) { -+ elf_info->kern_size = end - elf_info->kern_paddr_start; -+ dbgprintf("kernel_vaddr= 0x%llx paddr %llx\n", -+ elf_info->kern_vaddr_start, -+ elf_info->kern_paddr_start); -+ dbgprintf("kernel size = 0x%lx\n", elf_info->kern_size); -+ return 0; -+ } -+ -+ fprintf(stderr, "Cannot determine kernel virtual load addr and size\n"); -+ return -1; -+} -+ -+/* -+ * Removes crash reserve region from list of memory chunks for whom elf program -+ * headers have to be created. Assuming crash reserve region to be a single -+ * continuous area fully contained inside one of the memory chunks -+ */ -+static int exclude_crash_reserve_region(int *nr_ranges) -+{ -+ int i, j, tidx = -1; -+ unsigned long long cstart, cend; -+ struct memory_range temp_region = { -+ .start = 0, -+ .end = 0 -+ }; -+ -+ /* Crash reserved region. */ -+ cstart = crash_reserved_mem.start; -+ cend = crash_reserved_mem.end; -+ -+ for (i = 0; i < (*nr_ranges); i++) { -+ unsigned long long mstart, mend; -+ -+ mstart = crash_memory_range[i].start; -+ mend = crash_memory_range[i].end; -+ -+ if (cstart < mend && cend > mstart) { -+ if (cstart != mstart && cend != mend) { -+ /* Split memory region */ -+ crash_memory_range[i].end = cstart - 1; -+ temp_region.start = cend + 1; -+ temp_region.end = mend; -+ temp_region.type = RANGE_RAM; -+ tidx = i+1; -+ } else if (cstart != mstart) { -+ crash_memory_range[i].end = cstart - 1; -+ } else { -+ crash_memory_range[i].start = cend + 1; -+ } -+ } -+ } -+ -+ /* Insert split memory region, if any. */ -+ if (tidx >= 0) { -+ if (*nr_ranges == CRASH_MAX_MEMORY_RANGES) { -+ /* No space to insert another element. */ -+ fprintf(stderr, "Error: Number of crash memory ranges" -+ " excedeed the max limit\n"); -+ return -1; -+ } -+ -+ for (j = (*nr_ranges - 1); j >= tidx; j--) -+ crash_memory_range[j+1] = crash_memory_range[j]; -+ -+ crash_memory_range[tidx].start = temp_region.start; -+ crash_memory_range[tidx].end = temp_region.end; -+ crash_memory_range[tidx].type = temp_region.type; -+ (*nr_ranges)++; -+ } -+ -+ return 0; -+} -+ -+/* -+ * Reads the appropriate file and retrieves the SYSTEM RAM regions for whom to -+ * create Elf headers. Keeping it separate from get_memory_ranges() as -+ * requirements are different in the case of normal kexec and crashdumps. -+ * -+ * Normal kexec needs to look at all of available physical memory irrespective -+ * of the fact how much of it is being used by currently running kernel. -+ * Crashdumps need to have access to memory regions actually being used by -+ * running kernel. Expecting a different file/data structure than /proc/iomem -+ * to look into down the line. May be something like /proc/kernelmem or may -+ * be zone data structures exported from kernel. -+ */ -+static int get_crash_memory_ranges(struct memory_range **range, int *ranges) -+{ -+ const char *iomem = proc_iomem(); -+ int memory_ranges = 0; -+ char line[MAX_LINE]; -+ FILE *fp; -+ unsigned long long start, end; -+ -+ fp = fopen(iomem, "r"); -+ if (!fp) { -+ fprintf(stderr, "Cannot open %s: %s\n", iomem, strerror(errno)); -+ return -1; -+ } -+ -+ /* Separate segment for backup region */ -+ crash_memory_range[0].start = BACKUP_SRC_START; -+ crash_memory_range[0].end = BACKUP_SRC_END; -+ crash_memory_range[0].type = RANGE_RAM; -+ memory_ranges++; -+ -+ while (fgets(line, sizeof(line), fp) != 0) { -+ char *str; -+ int type, consumed, count; -+ if (memory_ranges >= CRASH_MAX_MEMORY_RANGES) -+ break; -+ count = sscanf(line, "%llx-%llx : %n", -+ &start, &end, &consumed); -+ if (count != 2) -+ continue; -+ str = line + consumed; -+ -+ /* Only Dumping memory of type System RAM. */ -+ if (memcmp(str, "System RAM\n", 11) == 0) { -+ type = RANGE_RAM; -+ } else if (memcmp(str, "Crash kernel\n", 13) == 0) { -+ /* -+ * Reserved memory region. New kernel can -+ * use this region to boot into. -+ */ -+ crash_reserved_mem.start = start; -+ crash_reserved_mem.end = end; -+ crash_reserved_mem.type = RANGE_RAM; -+ continue; -+ } else { -+ continue; -+ } -+ -+ if (start == BACKUP_SRC_START && end >= (BACKUP_SRC_END + 1)) -+ start = BACKUP_SRC_END + 1; -+ -+ crash_memory_range[memory_ranges].start = start; -+ crash_memory_range[memory_ranges].end = end; -+ crash_memory_range[memory_ranges].type = type; -+ memory_ranges++; -+ -+ /* Segregate linearly mapped region. */ -+ if (MAXMEM && (MAXMEM - 1) >= start && (MAXMEM - 1) <= end) { -+ crash_memory_range[memory_ranges - 1].end = MAXMEM - 1; -+ -+ /* Add segregated region. */ -+ crash_memory_range[memory_ranges].start = MAXMEM; -+ crash_memory_range[memory_ranges].end = end; -+ crash_memory_range[memory_ranges].type = type; -+ memory_ranges++; -+ } -+ } -+ fclose(fp); -+ -+ if (exclude_crash_reserve_region(&memory_ranges) < 0) -+ return -1; -+ -+ *range = crash_memory_range; -+ *ranges = memory_ranges; -+ -+ return 0; -+} -+ -+/* Converts unsigned long to ascii string. */ -+void ultoa(unsigned long i, char *str) -+{ -+ int j = 0, k; -+ char tmp; -+ -+ do { -+ str[j++] = i % 10 + '0'; -+ } while ((i /= 10) > 0); -+ str[j] = '\0'; -+ -+ /* Reverse the string. */ -+ for (j = 0, k = strlen(str) - 1; j < k; j++, k--) { -+ tmp = str[k]; -+ str[k] = str[j]; -+ str[j] = tmp; -+ } -+} -+ -+/* Append str to cmdline */ -+static void add_cmdline(char *cmdline, char *str) -+{ -+ int cmdline_size; -+ int cmdlen = strlen(cmdline) + strlen(str); -+ -+ cmdline_size = COMMAND_LINE_SIZE; -+ if (cmdlen > (cmdline_size - 1)) -+ die("Command line overflow\n"); -+ strcat(cmdline, str); -+} -+ -+/* -+ * Adds the appropriate mem= options to command line, indicating the -+ * memory region the new kernel can use to boot into. -+ */ -+static int cmdline_add_mem(char *cmdline, unsigned long addr, -+ unsigned long size) -+{ -+ char str[50], *ptr; -+ -+ addr = addr / 1024; -+ size = size / 1024; -+ ptr = str; -+ strcpy(str, " mem="); -+ ptr += strlen(str); -+ ultoa(size, ptr); -+ strcat(str, "K@"); -+ ptr = str + strlen(str); -+ ultoa(addr, ptr); -+ strcat(str, "K"); -+ -+ add_cmdline(cmdline, str); -+ -+ return 0; -+} -+ -+/* Adds the elfcorehdr= command line parameter to command line. */ -+static int cmdline_add_elfcorehdr(char *cmdline, unsigned long addr) -+{ -+ int align = 1024; -+ char str[30], *ptr; -+ -+ /* -+ * Passing in elfcorehdr=xxxK format. Saves space required in cmdline. -+ * Ensure 1K alignment -+ */ -+ if (addr % align) -+ return -1; -+ -+ addr = addr / align; -+ ptr = str; -+ strcpy(str, " elfcorehdr="); -+ ptr += strlen(str); -+ ultoa(addr, ptr); -+ strcat(str, "K"); -+ -+ add_cmdline(cmdline, str); -+ -+ return 0; -+} -+ -+ -+static struct crash_elf_info elf_info64 = { -+ class: ELFCLASS64, -+ data : ELFDATA2LSB, -+ machine : EM_LOONGARCH, -+ page_offset : PAGE_OFFSET, -+ lowmem_limit : 0, /* 0 == no limit */ -+}; -+ -+/* -+ * Loads additional segments in case of a panic kernel is being loaded. -+ * One segment for backup region, another segment for storing elf headers -+ * for crash memory image. -+ */ -+int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, -+ unsigned long max_addr, unsigned long min_base) -+{ -+ void *tmp; -+ unsigned long sz, elfcorehdr; -+ int nr_ranges, align = 1024; -+ struct memory_range *mem_range; -+ crash_create_elf_headers_func crash_create = crash_create_elf64_headers; -+ struct crash_elf_info *elf_info = &elf_info64; -+ unsigned long start_offset = PAGE_OFFSET; -+ -+ if (get_kernel_paddr(elf_info)) -+ return -1; -+ -+ if (get_kernel_vaddr_and_size(elf_info, start_offset)) -+ return -1; -+ -+ if (get_crash_memory_ranges(&mem_range, &nr_ranges) < 0) -+ return -1; -+ -+ if (min_base < crash_reserved_mem.start) -+ min_base = crash_reserved_mem.start; -+ if (max_addr > crash_reserved_mem.end) -+ max_addr = crash_reserved_mem.end; -+ -+ info->backup_src_start = BACKUP_SRC_START; -+ info->backup_src_size = BACKUP_SRC_SIZE; -+ /* Create a backup region segment to store backup data*/ -+ sz = _ALIGN(BACKUP_SRC_SIZE, align); -+ tmp = xmalloc(sz); -+ memset(tmp, 0, sz); -+ info->backup_start = add_buffer(info, tmp, sz, sz, align, -+ min_base, max_addr, -1); -+ -+ if (crash_create(info, elf_info, crash_memory_range, nr_ranges, -+ &tmp, &sz, ELF_CORE_HEADER_ALIGN) < 0) { -+ free(tmp); -+ return -1; -+ } -+ -+ elfcorehdr = add_buffer(info, tmp, sz, sz, align, min_base, max_addr, -1); -+ -+ /* -+ * backup segment is after elfcorehdr, so use elfcorehdr as top of -+ * kernel's available memory -+ */ -+ add_cmdline(mod_cmdline, " init 3 nr_cpus=1"); -+ cmdline_add_mem(mod_cmdline, min_base, max_addr - min_base + 1); -+ cmdline_add_elfcorehdr(mod_cmdline, elfcorehdr); -+ -+ dbgprintf("CRASH MEMORY RANGES:\n"); -+ dbgprintf("%016lx-%016lx\n", min_base, max_addr); -+ -+ return 0; -+} -diff --git a/kexec/arch/loongarch/crashdump-loongarch.h b/kexec/arch/loongarch/crashdump-loongarch.h -new file mode 100644 -index 0000000..3e6638a ---- /dev/null -+++ b/kexec/arch/loongarch/crashdump-loongarch.h -@@ -0,0 +1,24 @@ -+#ifndef CRASHDUMP_LOONGARCH_H -+#define CRASHDUMP_LOONGARCH_H -+ -+struct kexec_info; -+int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline, -+ unsigned long max_addr, unsigned long min_base); -+void ultoa(unsigned long i, char *str); -+ -+#define PAGE_OFFSET 0x9000000000000000ULL -+#define MAXMEM 0 -+#define __pa(x) ((unsigned long)(X) & 0x7fffffff) -+ -+#define CRASH_MAX_MEMMAP_NR (KEXEC_MAX_SEGMENTS + 1) -+#define CRASH_MAX_MEMORY_RANGES (MAX_MEMORY_RANGES + 2) -+ -+#define COMMAND_LINE_SIZE 512 -+ -+/* Backup Region, First 1M of System RAM. */ -+#define BACKUP_SRC_START 0x00000000 -+#define BACKUP_SRC_END 0x000fffff -+#define BACKUP_SRC_SIZE (BACKUP_SRC_END - BACKUP_SRC_START + 1) -+ -+extern struct arch_options_t arch_options; -+#endif /* CRASHDUMP_LOONGARCH_H */ -diff --git a/kexec/arch/loongarch/include/arch/options.h b/kexec/arch/loongarch/include/arch/options.h -new file mode 100644 -index 0000000..2bbd350 ---- /dev/null -+++ b/kexec/arch/loongarch/include/arch/options.h -@@ -0,0 +1,41 @@ -+#ifndef KEXEC_ARCH_LOONGARCH_OPTIONS_H -+#define KEXEC_ARCH_LOONGARCH_OPTIONS_H -+ -+#define OPT_ARCH_MAX (OPT_MAX + 0) -+#define OPT_APPEND (OPT_ARCH_MAX + 0) -+#define OPT_RAMDISK (OPT_ARCH_MAX+1) -+#define OPT_REUSE_CMDLINE (OPT_ARCH_MAX + 2) -+ -+/* Options relevant to the architecture (excluding loader-specific ones), -+ * in this case none: -+ */ -+#define KEXEC_ARCH_OPTIONS \ -+ KEXEC_OPTIONS \ -+ {"command-line", 1, 0, OPT_APPEND}, \ -+ {"append", 1, 0, OPT_APPEND}, \ -+ {"initrd", 1, 0, OPT_RAMDISK}, \ -+ {"reuse-cmdline", 0, NULL, OPT_REUSE_CMDLINE}, -+ -+ -+#define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR "" -+ -+/* The following two #defines list ALL of the options added by all of the -+ * architecture's loaders. -+ * o main() uses this complete list to scan for its options, ignoring -+ * arch-specific/loader-specific ones. -+ * o Then, arch_process_options() uses this complete list to scan for its -+ * options, ignoring general/loader-specific ones. -+ * o Then, the file_type[n].load re-scans for options, using -+ * KEXEC_ARCH_OPTIONS plus its loader-specific options subset. -+ * Any unrecognised options cause an error here. -+ * -+ * This is done so that main()'s/arch_process_options()'s getopt_long() calls -+ * don't choose a kernel filename from random arguments to options they don't -+ * recognise -- as they now recognise (if not act upon) all possible options. -+ */ -+#define KEXEC_ALL_OPTIONS \ -+ KEXEC_ARCH_OPTIONS -+ -+#define KEXEC_ALL_OPT_STR KEXEC_ARCH_OPT_STR -+ -+#endif /* KEXEC_ARCH_LOONGARCH_OPTIONS_H */ -diff --git a/kexec/arch/loongarch/kexec-elf-loongarch.c b/kexec/arch/loongarch/kexec-elf-loongarch.c -new file mode 100644 -index 0000000..6cfb539 ---- /dev/null -+++ b/kexec/arch/loongarch/kexec-elf-loongarch.c -@@ -0,0 +1,212 @@ -+/* -+ * kexec-elf-loongarch.c - kexec Elf loader for loongarch -+ * -+ * Copyright (C) 2021 Loongson Technology Co., Ltd. -+ * -+ * This source code is licensed under the GNU General Public License, -+ * Version 2. See the file COPYING for more details. -+*/ -+ -+#define _GNU_SOURCE -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include "../../kexec.h" -+#include "../../kexec-elf.h" -+#include "../../kexec-syscall.h" -+#include "crashdump-loongarch.h" -+#include "kexec-loongarch.h" -+#include -+ -+ -+off_t initrd_base = 0; -+off_t initrd_size = 0; -+ -+static const int probe_debug = 0; -+ -+#define BOOTLOADER "kexec" -+#define UPSZ(X) _ALIGN_UP(sizeof(X), 4) -+ -+#define CMDLINE_PREFIX "kexec " -+static char cmdline_buf[COMMAND_LINE_SIZE] = CMDLINE_PREFIX; -+ -+/* Adds the rd_start= command line parameter to command line. */ -+static int cmdline_add_rd_start(char *cmdline, unsigned long addr) -+{ -+ int cmdlen, len; -+ char str[40], *ptr; -+ -+ ptr = str; -+ strcpy(str, " rd_start="); -+ ptr += strlen(str); -+ ultoa(addr, ptr); -+ len = strlen(str); -+ cmdlen = strlen(cmdline) + len; -+ if (cmdlen > (COMMAND_LINE_SIZE - 1)) -+ die("Command line overflow\n"); -+ strcat(cmdline, str); -+ -+ return 0; -+} -+ -+/* Adds the rd_size= command line parameter to command line. */ -+static int cmdline_add_rd_size(char *cmdline, unsigned long addr) -+{ -+ int cmdlen, len; -+ char str[30], *ptr; -+ -+ ptr = str; -+ strcpy(str, " rd_size="); -+ ptr += strlen(str); -+ ultoa(addr, ptr); -+ len = strlen(str); -+ cmdlen = strlen(cmdline) + len; -+ if (cmdlen > (COMMAND_LINE_SIZE - 1)) -+ die("Command line overflow\n"); -+ strcat(cmdline, str); -+ -+ return 0; -+} -+ -+int elf_loongarch_probe(const char *buf, off_t len) -+{ -+ struct mem_ehdr ehdr; -+ int result; -+ result = build_elf_exec_info(buf, len, &ehdr, 0); -+ if (result < 0) { -+ if (probe_debug) -+ fprintf(stderr, "Not an ELF executable.\n"); -+ goto out; -+ } -+ -+ /* Verify the architecuture specific bits */ -+ if (ehdr.e_machine != EM_LOONGARCH) { -+ /* for a different architecture */ -+ if (probe_debug) { -+ fprintf(stderr, "Not LoongArch ELF executable.\n"); -+ } -+ result = -1; -+ goto out; -+ } -+ result = 0; -+ out: -+ free_elf_info(&ehdr); -+ return result; -+} -+ -+void elf_loongarch_usage(void) -+{ -+ printf( " --command-line=STRING Set the kernel command line to STRING\n" -+ " --append=STRING Set the kernel command line to STRING\n" -+ " --reuse-cmdline Use kernel command line from running system.\n" -+ " --initrd=FILE Use FILE as initial ramdisk.\n" -+ ); -+} -+ -+int elf_loongarch_load(int argc, char **argv, const char *buf, off_t len, -+ struct kexec_info *info) -+{ -+ struct mem_ehdr ehdr; -+ int command_line_len = 0; -+ int result; -+ size_t i; -+ unsigned long cmdline_addr = 0; -+ char *crash_cmdline; -+ char *initrd_buf = NULL; -+ unsigned long long kernel_addr = 0, kernel_size = 0; -+ unsigned long pagesize = getpagesize(); -+ -+ /* -+ * Need to append some command line parameters internally in case of -+ * taking crash dumps. -+ */ -+ if (info->kexec_flags & KEXEC_ON_CRASH) { -+ crash_cmdline = xmalloc(COMMAND_LINE_SIZE); -+ memset((void *)crash_cmdline, 0, COMMAND_LINE_SIZE); -+ } else { -+ crash_cmdline = NULL; -+ } -+ -+ result = build_elf_exec_info(buf, len, &ehdr, 0); -+ if (result < 0) -+ die("ELF exec parse failed\n"); -+ -+ /* Read in the PT_LOAD segments*/ -+ for (i = 0; i < ehdr.e_phnum; i++) { -+ struct mem_phdr *phdr; -+ phdr = &ehdr.e_phdr[i]; -+ if (phdr->p_type == PT_LOAD) { -+ phdr->p_paddr = virt_to_phys(phdr->p_paddr); -+ kernel_addr = phdr->p_paddr; -+ kernel_size = phdr->p_memsz; -+ } -+ } -+ -+ /* Load the Elf data */ -+ result = elf_exec_load(&ehdr, info); -+ if (result < 0) -+ die("ELF exec load failed\n"); -+ -+ info->entry = (void *)virt_to_phys(ehdr.e_entry); -+ -+ if (arch_options.command_line) -+ command_line_len = strlen(arch_options.command_line) + 1; -+ -+ if (info->kexec_flags & KEXEC_ON_CRASH) { -+ result = load_crashdump_segments(info, crash_cmdline, 0x0fffffff, 0); -+ if (result < 0) { -+ free(crash_cmdline); -+ return -1; -+ } -+ } -+ -+ if (arch_options.command_line) -+ strncat(cmdline_buf, arch_options.command_line, command_line_len); -+ -+ if (crash_cmdline) { -+ strncat(cmdline_buf, crash_cmdline, -+ sizeof(crash_cmdline) - -+ strlen(crash_cmdline) - 1); -+ free(crash_cmdline); -+ } -+ -+ if (info->kexec_flags & KEXEC_ON_CRASH) -+ /* -+ * In case of crashdump segment[0] is kernel. -+ * Put cmdline just after it. -+ */ -+ cmdline_addr = (unsigned long)info->segment[0].mem + -+ info->segment[0].memsz; -+ else -+ cmdline_addr = 0x10000; /* Skip exception handlers */ -+ -+ if (arch_options.initrd_file) { -+ initrd_buf = slurp_decompress_file(arch_options.initrd_file, &initrd_size); -+ -+ initrd_base = add_buffer(info, initrd_buf, initrd_size, -+ initrd_size, sizeof(void *), -+ _ALIGN_UP(kernel_addr + kernel_size, -+ pagesize), 0x0fffffff, 1); -+ cmdline_add_rd_start(cmdline_buf, PAGE_OFFSET + initrd_base); -+ cmdline_add_rd_size(cmdline_buf, initrd_size); -+ dbgprintf("initrd_base: %lx, initrd_size: %lx\n", initrd_base, initrd_size); -+ } -+ -+ /* This is a legacy method for command line passing used currently */ -+ add_buffer(info, cmdline_buf, sizeof(cmdline_buf), -+ sizeof(cmdline_buf), sizeof(void *), -+ cmdline_addr, 0x0fffffff, 1); -+ dbgprintf("command line: %s\n", cmdline_buf); -+ -+ return 0; -+} -+ -diff --git a/kexec/arch/loongarch/kexec-elf-rel-loongarch.c b/kexec/arch/loongarch/kexec-elf-rel-loongarch.c -new file mode 100644 -index 0000000..72307b3 ---- /dev/null -+++ b/kexec/arch/loongarch/kexec-elf-rel-loongarch.c -@@ -0,0 +1,43 @@ -+/* -+ * kexec-elf-rel-loongarch.c - kexec Elf relocation routines -+ * -+ * Copyright (C) 2021 Loongson Technology Co., Ltd. -+ * -+ * This source code is licensed under the GNU General Public License, -+ * Version 2. See the file COPYING for more details. -+*/ -+ -+#include -+#include -+#include "../../kexec.h" -+#include "../../kexec-elf.h" -+ -+int machine_verify_elf_rel(struct mem_ehdr *ehdr) -+{ -+ if (ehdr->ei_data != ELFDATA2MSB) { -+ return 0; -+ } -+ if (ehdr->ei_class != ELFCLASS32) { -+ return 0; -+ } -+ if (ehdr->e_machine != EM_LOONGARCH) { -+ return 0; -+ } -+ return 1; -+} -+ -+void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), -+ struct mem_sym *UNUSED(sym), -+ unsigned long r_type, -+ void *UNUSED(location), -+ unsigned long UNUSED(address), -+ unsigned long UNUSED(value)) -+{ -+ switch(r_type) { -+ -+ default: -+ die("Unknown rela relocation: %lu\n", r_type); -+ break; -+ } -+ return; -+} -diff --git a/kexec/arch/loongarch/kexec-loongarch.c b/kexec/arch/loongarch/kexec-loongarch.c -new file mode 100644 -index 0000000..75fce91 ---- /dev/null -+++ b/kexec/arch/loongarch/kexec-loongarch.c -@@ -0,0 +1,169 @@ -+/* -+ * kexec-loongarch.c - kexec for loongarch -+ * -+ * Copyright (C) 2021 Loongson Technology Co., Ltd. -+ * -+ * This source code is licensed under the GNU General Public License, -+ * Version 2. See the file COPYING for more details. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include "../../kexec.h" -+#include "../../kexec-syscall.h" -+#include "kexec-loongarch.h" -+#include -+ -+/* Return a sorted list of memory ranges. */ -+static struct memory_range memory_range[MAX_MEMORY_RANGES]; -+ -+int get_memory_ranges(struct memory_range **range, int *ranges, -+ unsigned long UNUSED(kexec_flags)) -+{ -+ int memory_ranges = 0; -+ -+ const char *iomem = proc_iomem(); -+ char line[MAX_LINE]; -+ FILE *fp; -+ unsigned long long start, end; -+ char *str; -+ int type, consumed, count; -+ -+ fp = fopen(iomem, "r"); -+ if (!fp) { -+ fprintf(stderr, "Cannot open %s: %s\n", iomem, strerror(errno)); -+ return -1; -+ } -+ while (fgets(line, sizeof(line), fp) != 0) { -+ if (memory_ranges >= MAX_MEMORY_RANGES) -+ break; -+ count = sscanf(line, "%llx-%llx : %n", &start, &end, &consumed); -+ if (count != 2) -+ continue; -+ str = line + consumed; -+ end = end + 1; -+ if (memcmp(str, "System RAM\n", 11) == 0) { -+ type = RANGE_RAM; -+ } else if (memcmp(str, "reserved\n", 9) == 0) { -+ type = RANGE_RESERVED; -+ } else { -+ continue; -+ } -+ if (memory_ranges > 0 && -+ memory_range[memory_ranges - 1].end == start && -+ memory_range[memory_ranges - 1].type == type) { -+ memory_range[memory_ranges - 1].end = end; -+ } else { -+ memory_range[memory_ranges].start = start; -+ memory_range[memory_ranges].end = end; -+ memory_range[memory_ranges].type = type; -+ memory_ranges++; -+ } -+ } -+ fclose(fp); -+ *range = memory_range; -+ *ranges = memory_ranges; -+ return 0; -+} -+ -+struct file_type file_type[] = { -+ {"elf-loongarch", elf_loongarch_probe, elf_loongarch_load, elf_loongarch_usage}, -+}; -+int file_types = sizeof(file_type) / sizeof(file_type[0]); -+ -+void arch_usage(void) -+{ -+} -+ -+struct arch_options_t arch_options = { -+ .core_header_type = CORE_TYPE_ELF64, -+}; -+ -+int arch_process_options(int argc, char **argv) -+{ -+ static const struct option options[] = { -+ KEXEC_ARCH_OPTIONS -+ { 0 }, -+ }; -+ static const char short_options[] = KEXEC_ARCH_OPT_STR; -+ int opt; -+ -+ while ((opt = getopt_long(argc, argv, short_options, -+ options, 0)) != -1) { -+ switch (opt) { -+ case OPT_APPEND: -+ arch_options.command_line = optarg; -+ break; -+ case OPT_REUSE_CMDLINE: -+ arch_options.command_line = get_command_line(); -+ break; -+ case OPT_RAMDISK: -+ arch_options.initrd_file = optarg; -+ break; -+ default: -+ break; -+ } -+ } -+ -+ return 0; -+} -+ -+const struct arch_map_entry arches[] = { -+ { "loongarch64", KEXEC_ARCH_LOONGARCH }, -+ { NULL, 0 }, -+}; -+ -+int arch_compat_trampoline(struct kexec_info *UNUSED(info)) -+{ -+ return 0; -+} -+ -+void arch_update_purgatory(struct kexec_info *UNUSED(info)) -+{ -+} -+ -+unsigned long virt_to_phys(unsigned long addr) -+{ -+ return addr & 0x7fffffff; -+} -+ -+/* -+ * add_segment() should convert base to a physical address on loongarch, -+ * while the default is just to work with base as is -+ */ -+void add_segment(struct kexec_info *info, const void *buf, size_t bufsz, -+ unsigned long base, size_t memsz) -+{ -+ add_segment_phys_virt(info, buf, bufsz, virt_to_phys(base), memsz, 1); -+} -+ -+/* -+ * add_buffer() should convert base to a physical address on loongarch, -+ * while the default is just to work with base as is -+ */ -+unsigned long add_buffer(struct kexec_info *info, const void *buf, -+ unsigned long bufsz, unsigned long memsz, -+ unsigned long buf_align, unsigned long buf_min, -+ unsigned long buf_max, int buf_end) -+{ -+ return add_buffer_phys_virt(info, buf, bufsz, memsz, buf_align, -+ buf_min, buf_max, buf_end, 1); -+} -+ -+int is_crashkernel_mem_reserved(void) -+{ -+ uint64_t start, end; -+ -+ return parse_iomem_single("Crash kernel\n", &start, &end) == 0 ? -+ (start != end) : 0; -+} -+ -+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) -+{ -+ return parse_iomem_single("Crash kernel\n", start, end); -+} -+ -diff --git a/kexec/arch/loongarch/kexec-loongarch.h b/kexec/arch/loongarch/kexec-loongarch.h -new file mode 100644 -index 0000000..750608e ---- /dev/null -+++ b/kexec/arch/loongarch/kexec-loongarch.h -@@ -0,0 +1,34 @@ -+#ifndef KEXEC_LOONGARCH_H -+#define KEXEC_LOONGARCH_H -+ -+#include -+ -+#define BOOT_BLOCK_VERSION 17 -+#define BOOT_BLOCK_LAST_COMP_VERSION 16 -+ -+#define MAX_MEMORY_RANGES 64 -+#define MAX_LINE 160 -+ -+#define CORE_TYPE_ELF32 1 -+#define CORE_TYPE_ELF64 2 -+ -+#define COMMAND_LINE_SIZE 512 -+ -+int elf_loongarch_probe(const char *buf, off_t len); -+int elf_loongarch_load(int argc, char **argv, const char *buf, off_t len, -+ struct kexec_info *info); -+void elf_loongarch_usage(void); -+int is_crashkernel_mem_reserved(void); -+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end); -+ -+struct arch_options_t { -+ char *command_line; -+ char *initrd_file; -+ int core_header_type; -+}; -+ -+extern struct memory_ranges usablemem_rgns; -+extern struct arch_options_t arch_options; -+extern off_t initrd_base, initrd_size; -+ -+#endif /* KEXEC_LOONGARCH_H */ -diff --git a/kexec/kexec-syscall.h b/kexec/kexec-syscall.h -index 993f7ec..8ef54d6 100644 ---- a/kexec/kexec-syscall.h -+++ b/kexec/kexec-syscall.h -@@ -51,6 +51,9 @@ - #ifdef __alpha__ - #define __NR_kexec_load 448 - #endif -+#ifdef __loongarch__ -+#define __NR_kexec_load 104 -+#endif - #ifndef __NR_kexec_load - #error Unknown processor architecture. Needs a kexec_load syscall number. - #endif -@@ -136,6 +139,7 @@ static inline long kexec_file_load(int kernel_fd, int initrd_fd, - #define KEXEC_ARCH_MIPS_LE (10 << 16) - #define KEXEC_ARCH_MIPS ( 8 << 16) - #define KEXEC_ARCH_CRIS (76 << 16) -+#define KEXEC_ARCH_LOONGARCH (258 << 16) - - #define KEXEC_MAX_SEGMENTS 16 - -@@ -179,5 +183,8 @@ static inline long kexec_file_load(int kernel_fd, int initrd_fd, - #if defined(__arm64__) - #define KEXEC_ARCH_NATIVE KEXEC_ARCH_ARM64 - #endif -+#if defined(__loongarch__) -+#define KEXEC_ARCH_NATIVE KEXEC_ARCH_LOONGARCH -+#endif - - #endif /* KEXEC_SYSCALL_H */ -diff --git a/purgatory/Makefile b/purgatory/Makefile -index 2dd6c47..f24cae0 100644 ---- a/purgatory/Makefile -+++ b/purgatory/Makefile -@@ -28,6 +28,7 @@ include $(srcdir)/purgatory/arch/ppc64/Makefile - include $(srcdir)/purgatory/arch/s390/Makefile - include $(srcdir)/purgatory/arch/sh/Makefile - include $(srcdir)/purgatory/arch/x86_64/Makefile -+include $(srcdir)/purgatory/arch/loongarch/Makefile - - PURGATORY_SRCS+=$($(ARCH)_PURGATORY_SRCS) - -diff --git a/purgatory/arch/loongarch/Makefile b/purgatory/arch/loongarch/Makefile -new file mode 100644 -index 0000000..b0c47b2 ---- /dev/null -+++ b/purgatory/arch/loongarch/Makefile -@@ -0,0 +1,10 @@ -+# -+# Purgatory loongarch -+# -+ -+loongarch_PURGATORY_SRCS+= purgatory/arch/loongarch/purgatory-loongarch.c -+loongarch_PURGATORY_SRCS+= purgatory/arch/loongarch/console-loongarch.c -+ -+dist += purgatory/arch/loongarch/Makefile $(loongarch_PURGATORY_SRCS) \ -+ purgatory/arch/loongarch/purgatory-loongarch.h -+ -diff --git a/purgatory/arch/loongarch/console-loongarch.c b/purgatory/arch/loongarch/console-loongarch.c -new file mode 100644 -index 0000000..af34ecf ---- /dev/null -+++ b/purgatory/arch/loongarch/console-loongarch.c -@@ -0,0 +1,7 @@ -+#include -+#include "unused.h" -+ -+void putchar(int UNUSED(ch)) -+{ -+ /* Nothing for now */ -+} -diff --git a/purgatory/arch/loongarch/purgatory-loongarch.c b/purgatory/arch/loongarch/purgatory-loongarch.c -new file mode 100644 -index 0000000..abe9297 ---- /dev/null -+++ b/purgatory/arch/loongarch/purgatory-loongarch.c -@@ -0,0 +1,7 @@ -+#include -+#include "purgatory-loongarch.h" -+ -+void setup_arch(void) -+{ -+ /* Nothing for now */ -+} -diff --git a/purgatory/arch/loongarch/purgatory-loongarch.h b/purgatory/arch/loongarch/purgatory-loongarch.h -new file mode 100644 -index 0000000..cd1ab97 ---- /dev/null -+++ b/purgatory/arch/loongarch/purgatory-loongarch.h -@@ -0,0 +1,6 @@ -+#ifndef PURGATORY_LOONGARCH_H -+#define PURGATORY_LOONGARCH_H -+ -+/* nothing yet */ -+ -+#endif /* PURGATORY_LOONGARCH_H */ --- -2.27.0 - diff --git a/fix-add-64-bit-loongArch-support-2.patch b/fix-add-64-bit-loongArch-support-2.patch deleted file mode 100644 index 43965fddb209f90521136ce1cca1102a6772aaba..0000000000000000000000000000000000000000 --- a/fix-add-64-bit-loongArch-support-2.patch +++ /dev/null @@ -1,222 +0,0 @@ -From dd302cc20cf48e312e608ebf2946e8b5432881c7 Mon Sep 17 00:00:00 2001 -From: wu-leilei -Date: Tue, 19 Apr 2022 11:51:24 +0800 -Subject: [PATCH] add 64 bit loongArch support - ---- - makedumpfile-1.7.0/Makefile | 2 +- - makedumpfile-1.7.0/arch/loongarch64.c | 108 ++++++++++++++++++++++++++ - makedumpfile-1.7.0/makedumpfile.h | 55 +++++++++++++ - 3 files changed, 164 insertions(+), 1 deletion(-) - create mode 100644 makedumpfile-1.7.0/arch/loongarch64.c - -diff --git a/makedumpfile-1.7.0/Makefile b/makedumpfile-1.7.0/Makefile -index 35bc04d..5940450 100644 ---- a/makedumpfile-1.7.0/Makefile -+++ b/makedumpfile-1.7.0/Makefile -@@ -48,7 +48,7 @@ endif - SRC_BASE = makedumpfile.c makedumpfile.h diskdump_mod.h sadump_mod.h sadump_info.h - SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c printk.c - OBJ_PART=$(patsubst %.c,%.o,$(SRC_PART)) --SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c arch/mips64.c -+SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c arch/mips64.c arch/loongarch64.c - OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH)) - - LIBS = -ldw -lbz2 -ldl -lelf -lz -diff --git a/makedumpfile-1.7.0/arch/loongarch64.c b/makedumpfile-1.7.0/arch/loongarch64.c -new file mode 100644 -index 0000000..338da6b ---- /dev/null -+++ b/makedumpfile-1.7.0/arch/loongarch64.c -@@ -0,0 +1,108 @@ -+/* -+ * loongarch64.c -+ * -+ * Copyright (C) 2021 Loongson Technology Co., Ltd. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ */ -+#ifdef __loongarch64 -+ -+#include "../print_info.h" -+#include "../elf_info.h" -+#include "../makedumpfile.h" -+ -+int -+get_phys_base_loongarch64(void) -+{ -+ info->phys_base = 0ULL; -+ -+ DEBUG_MSG("phys_base : %lx\n", info->phys_base); -+ -+ return TRUE; -+} -+ -+int -+get_machdep_info_loongarch64(void) -+{ -+ info->section_size_bits = _SECTION_SIZE_BITS; -+ -+ /* Check if we can get MAX_PHYSMEM_BITS from vmcoreinfo */ -+ if (NUMBER(MAX_PHYSMEM_BITS) != NOT_FOUND_NUMBER) -+ info->max_physmem_bits = NUMBER(MAX_PHYSMEM_BITS); -+ else -+ info->max_physmem_bits = _MAX_PHYSMEM_BITS; -+ -+ DEBUG_MSG("max_physmem_bits : %ld\n", info->max_physmem_bits); -+ DEBUG_MSG("section_size_bits: %ld\n", info->section_size_bits); -+ -+ return TRUE; -+} -+ -+int -+get_versiondep_info_loongarch64(void) -+{ -+ info->page_offset = 0x9000000000000000ULL; -+ -+ DEBUG_MSG("page_offset : %lx\n", info->page_offset); -+ -+ return TRUE; -+} -+ -+unsigned long long -+vaddr_to_paddr_loongarch64(unsigned long vaddr) -+{ -+ unsigned long long paddr = NOT_PADDR; -+ pgd_t *pgda, pgdv; -+ pmd_t *pmda, pmdv; -+ pte_t *ptea, ptev; -+ -+ if(vaddr >=0x8000000000000000ULL && vaddr < 0xc000000000000000ULL) -+ return vaddr & ((1ULL << MAX_PHYSMEM_BITS()) - 1); -+ -+ if (SYMBOL(swapper_pg_dir) == NOT_FOUND_SYMBOL) { -+ ERRMSG("Can't get the symbol of swapper_pg_dir.\n"); -+ return NOT_PADDR; -+ } -+ -+ pgda = pgd_offset(SYMBOL(swapper_pg_dir), vaddr); -+ if (!readmem(VADDR, (unsigned long long)pgda, &pgdv, sizeof(pgdv))) { -+ ERRMSG("Can't read pgd\n"); -+ return NOT_PADDR; -+ } -+ -+ pmda = pmd_offset(&pgdv, vaddr); -+ if (!readmem(VADDR, (unsigned long long)pmda, &pmdv, sizeof(pmdv))) { -+ ERRMSG("Can't read pmd\n"); -+ return NOT_PADDR; -+ } -+ -+ if (pmdv & _PAGE_HUGE) { -+ paddr = (pmdv & PMD_MASK) + (vaddr & (PMD_SIZE - 1)); -+ return paddr; -+ } -+ -+ ptea = pte_offset(&pmdv, vaddr); -+ if (!readmem(VADDR, (unsigned long long)ptea, &ptev, sizeof(ptev))) { -+ ERRMSG("Can't read pte\n"); -+ return NOT_PADDR; -+ } -+ -+ if (!(ptev & _PAGE_PRESENT)) { -+ ERRMSG("Can't get a valid pte.\n"); -+ return NOT_PADDR; -+ } else { -+ paddr = PAGEBASE(ptev) + (vaddr & (PAGESIZE() - 1)); -+ } -+ -+ return paddr; -+} -+ -+#endif /* loongarch64 */ -diff --git a/makedumpfile-1.7.0/makedumpfile.h b/makedumpfile-1.7.0/makedumpfile.h -index e59239d..fee3989 100644 ---- a/makedumpfile-1.7.0/makedumpfile.h -+++ b/makedumpfile-1.7.0/makedumpfile.h -@@ -996,6 +996,39 @@ typedef unsigned long pgd_t; - - #endif /* mips64 */ - -+#ifdef __loongarch64 -+#define KVBASE (0x8000000000000000UL) -+#define _SECTION_SIZE_BITS (28) -+#define _MAX_PHYSMEM_BITS (48) -+#define _PAGE_PRESENT (1 << 7) -+#define _PAGE_HUGE (1 << 6) -+ -+typedef unsigned long pte_t; -+typedef unsigned long pmd_t; -+typedef unsigned long pgd_t; -+ -+#define PAGE_MASK (~(PAGESIZE() - 1)) -+#define PMD_MASK (~(PMD_SIZE - 1)) -+#define PMD_SHIFT ((PAGESHIFT() - 3) * 2 + 3) -+#define PMD_SIZE (1UL << PMD_SHIFT) -+#define PGDIR_SHIFT ((PAGESHIFT() - 3) * 3 + 3) -+#define PTRS_PER_PTE (1 << (PAGESHIFT() - 3)) -+#define PTRS_PER_PMD PTRS_PER_PTE -+#define PTRS_PER_PGD PTRS_PER_PTE -+ -+#define pte_index(vaddr) (((vaddr) >> PAGESHIFT()) & (PTRS_PER_PTE - 1)) -+#define pmd_page_paddr(pmd) (pmd & (int32_t)PAGE_MASK) -+#define pte_offset(dir, vaddr) ((pte_t*)pmd_page_paddr((*dir)) + pte_index(vaddr)) -+ -+#define pmd_index(vaddr) (((vaddr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)) -+#define pgd_page_paddr(pgd) (pgd & (int32_t)PAGE_MASK) -+#define pmd_offset(pgd, vaddr) ((pmd_t *)pgd_page_paddr((*pgd)) + pmd_index(vaddr)) -+ -+#define pgd_index(vaddr) (((vaddr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)) -+#define pgd_offset(pgdir, vaddr) ((pgd_t *)(pgdir) + pgd_index(vaddr)) -+ -+#endif /* loongarch64 */ -+ - /* - * The function of dependence on machine - */ -@@ -1167,6 +1200,22 @@ unsigned long long vaddr_to_paddr_mips64(unsigned long vaddr); - #define arch_crashkernel_mem_size() stub_false() - #endif /* mips64 */ - -+#ifdef __loongarch64 /* loongarch64 */ -+int get_phys_base_loongarch64(void); -+int get_machdep_info_loongarch64(void); -+int get_versiondep_info_loongarch64(void); -+unsigned long long vaddr_to_paddr_loongarch64(unsigned long vaddr); -+#define find_vmemmap() stub_false() -+#define get_phys_base() get_phys_base_loongarch64() -+#define get_machdep_info() get_machdep_info_loongarch64() -+#define get_versiondep_info() get_versiondep_info_loongarch64() -+#define get_kaslr_offset(X) stub_false() -+#define vaddr_to_paddr(X) vaddr_to_paddr_loongarch64(X) -+#define paddr_to_vaddr(X) paddr_to_vaddr_general(X) -+#define is_phys_addr(X) stub_true_ul(X) -+#define arch_crashkernel_mem_size() stub_false() -+#endif /* loongarch64 */ -+ - typedef unsigned long long mdf_pfn_t; - - #ifndef ARCH_PFN_OFFSET -@@ -2301,6 +2350,12 @@ int get_xen_info_ia64(void); - #define get_xen_info_arch(X) FALSE - #endif /* mips64 */ - -+#ifdef __loongarch64 /* loongarch64 */ -+#define kvtop_xen(X) FALSE -+#define get_xen_basic_info_arch(X) FALSE -+#define get_xen_info_arch(X) FALSE -+#endif /* loongarch64 */ -+ - struct cycle { - mdf_pfn_t start_pfn; - mdf_pfn_t end_pfn; --- -2.27.0 - diff --git a/kexec-Quick-kexec-implementation-for-arm64.patch b/kexec-Quick-kexec-implementation-for-arm64.patch index efe0209347f7712eed50f60a7751d73293e8eadc..19c63386d799b496f65858dc88bab9b5cfc24d2b 100644 --- a/kexec-Quick-kexec-implementation-for-arm64.patch +++ b/kexec-Quick-kexec-implementation-for-arm64.patch @@ -17,10 +17,10 @@ index 45d7953..f283f50 100644 --- a/kexec/arch/arm64/iomem.h +++ b/kexec/arch/arm64/iomem.h @@ -7,5 +7,6 @@ - #define CRASH_KERNEL_LOW "Crash kernel (low)\n" + #define KERNEL_DATA "Kernel data\n" #define CRASH_KERNEL "Crash kernel\n" #define IOMEM_RESERVED "reserved\n" -+#define QUICK_KEXEC "Quick kexec\n" ++#define QUICK_KEXEC "Quick kexec\n" #endif diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c @@ -92,12 +92,12 @@ index 219ec49..8a3bb69 100644 else hole_max = ULONG_MAX; -@@ -944,7 +959,8 @@ static bool to_be_excluded(char *str) +@@ -1050,7 +1050,8 @@ static bool to_be_excluded(char *str, unsigned long long start, unsigned long lo + if (!strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) || !strncmp(str, KERNEL_CODE, strlen(KERNEL_CODE)) || - !strncmp(str, KERNEL_DATA, strlen(KERNEL_DATA)) || -- !strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL))) -+ !strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)) || +- !strncmp(str, KERNEL_DATA, strlen(KERNEL_DATA))) ++ !strncmp(str, KERNEL_DATA, strlen(KERNEL_DATA)) || + !strncmp(str, QUICK_KEXEC, strlen(QUICK_KEXEC))) return false; else diff --git a/kexec-tools-2.0.23.tar.xz b/kexec-tools-2.0.23.tar.xz deleted file mode 100644 index e2240ad1155a89cb3fa8d6e01597057d424aeb20..0000000000000000000000000000000000000000 Binary files a/kexec-tools-2.0.23.tar.xz and /dev/null differ diff --git a/kexec-tools-2.0.26.tar.xz b/kexec-tools-2.0.26.tar.xz new file mode 100644 index 0000000000000000000000000000000000000000..8c8c8b2ba51ea044e6940cc5dc3eec5bea963857 Binary files /dev/null and b/kexec-tools-2.0.26.tar.xz differ diff --git a/kexec-tools.spec b/kexec-tools.spec index cb4a0cc33a98e864316597ece296f2bbac3ec1c7..82019d7b8c8470d6bf19f7246f4623833073cc7c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,10 +1,10 @@ %global eppic_ver e8844d3793471163ae4a56d8f95897be9e5bd554 %global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7}) -%global mkdf_ver 1.7.0 +%global mkdf_ver 1.7.2 Name: kexec-tools -Version: 2.0.23 -Release: 11 +Version: 2.0.26 +Release: 1 License: GPLv2 Summary: The kexec/kdump userspace component URL: https://www.kernel.org/ @@ -69,21 +69,15 @@ Requires: systemd-udev%{?_isa} %undefine _hardened_build -Patch0001: arm64-support-more-than-one-crash-kernel-regions.patch -Patch0002: add-secure-compile-options-for-makedumpfile.patch -Patch0003: kexec-Add-quick-kexec-support.patch -Patch0004: kexec-Quick-kexec-implementation-for-arm64.patch -Patch0005: arm64-crashdump-deduce-paddr-of-_text-based-on-kerne.patch -Patch0006: arm64-make-phys_offset-signed.patch -Patch0007: arm64-crashdump-unify-routine-to-get-page_offset.patch -Patch0008: arm64-read-VA_BITS-from-kcore-for-52-bits-VA-kernel.patch -Patch0009: arm64-fix-PAGE_OFFSET-calc-for-flipped-mm.patch -%ifarch loongarch64 -Patch0010: fix-add-64-bit-loongArch-support-1.patch -Patch0011: fix-add-64-bit-loongArch-support-2.patch +Patch0001: add-secure-compile-options-for-makedumpfile.patch +Patch0002: kexec-Add-quick-kexec-support.patch +Patch0003: kexec-Quick-kexec-implementation-for-arm64.patch + +%ifarch sw_64 +Patch0004: sw_64.patch +Patch0005: makedumpfile-1.7.2-sw.patch %endif -Patch00012: sw_64.patch -Patch00013: makedumpfile-1.7.0-sw.patch + %description kexec-tools provides /sbin/kexec binary that facilitates a new kernel to boot using the kernel's kexec feature either on a @@ -105,30 +99,7 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} -%ifarch aarch64 -%patch0001 -p1 -%endif -%patch0002 -p1 -%patch0003 -p1 -%ifarch aarch64 -%patch0004 -p1 -%endif -%patch0005 -p1 -%patch0006 -p1 -%patch0007 -p1 -%patch0008 -p1 -%patch0009 -p1 - -%ifarch loongarch64 -%patch0010 -p1 -%patch0011 -p1 -%endif - -%ifarch sw_64 -%patch00012 -p1 -%patch00013 -p1 -%endif - +%autopatch -p1 %build autoreconf @@ -185,8 +156,8 @@ install -m 644 %{SOURCE13} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules %ifarch %{ix86} x86_64 aarch64 sw_64 loongarch64 install -m 755 makedumpfile-%{mkdf_ver}/makedumpfile $RPM_BUILD_ROOT/usr/sbin/makedumpfile -install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz -install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz +install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.8 $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8 +install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf.5 $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5 install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample install -m 755 makedumpfile-%{mkdf_ver}/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ @@ -313,6 +284,9 @@ done %endif %changelog +* Mon Jan 30 2023 chenhaixiang - 2.0.26-1 +- update to kexec-tools-2.0.26.1 + * Fri Dec 30 2022 chenhaixiang - 2.0.23-11 - fix shellcheck error in dracut module setup diff --git a/makedumpfile-1.7.0.tar.gz b/makedumpfile-1.7.0.tar.gz deleted file mode 100644 index a713847dfe9995d4e9b9025c307f381f19f89614..0000000000000000000000000000000000000000 Binary files a/makedumpfile-1.7.0.tar.gz and /dev/null differ diff --git a/makedumpfile-1.7.0-sw.patch b/makedumpfile-1.7.2-sw.patch similarity index 85% rename from makedumpfile-1.7.0-sw.patch rename to makedumpfile-1.7.2-sw.patch index 64ebd90c426877a488b97163648e60a503ca1dfc..1d14df279d692f8f6569a302b764d5033db8689b 100644 --- a/makedumpfile-1.7.0-sw.patch +++ b/makedumpfile-1.7.2-sw.patch @@ -1,6 +1,6 @@ -diff -Naru ./makedumpfile-1.7.0/arch/sw_64.c ./makedumpfile-1.7.0-sw/arch/sw_64.c ---- ./makedumpfile-1.7.0/arch/sw_64.c 1970-01-01 00:00:00.000000000 +0000 -+++ ./makedumpfile-1.7.0-sw/arch/sw_64.c 2022-08-19 06:54:24.938438551 +0000 +diff -Naru ./makedumpfile-1.7.2/arch/sw_64.c ./makedumpfile-1.7.2-sw/arch/sw_64.c +--- ./makedumpfile-1.7.2/arch/sw_64.c 1970-01-01 00:00:00.000000000 +0000 ++++ ./makedumpfile-1.7.2-sw/arch/sw_64.c 2022-08-19 06:54:24.938438551 +0000 @@ -0,0 +1,126 @@ +/* + * sw_64.c @@ -128,9 +128,9 @@ diff -Naru ./makedumpfile-1.7.0/arch/sw_64.c ./makedumpfile-1.7.0-sw/arch/sw_64. +} + +#endif /* sw_64 */ -diff -Naru ./makedumpfile-1.7.0/makedumpfile.h ./makedumpfile-1.7.0-sw/makedumpfile.h ---- ./makedumpfile-1.7.0/makedumpfile.h 2021-11-08 00:36:15.000000000 +0000 -+++ ./makedumpfile-1.7.0-sw/makedumpfile.h 2022-08-19 07:46:43.093698825 +0000 +diff -Naru ./makedumpfile-1.7.2/makedumpfile.h ./makedumpfile-1.7.2-sw/makedumpfile.h +--- ./makedumpfile-1.7.2/makedumpfile.h 2021-11-08 00:36:15.000000000 +0000 ++++ ./makedumpfile-1.7.2-sw/makedumpfile.h 2022-08-19 07:46:43.093698825 +0000 @@ -963,7 +963,7 @@ #endif /* sparc64 */ @@ -138,8 +138,8 @@ diff -Naru ./makedumpfile-1.7.0/makedumpfile.h ./makedumpfile-1.7.0-sw/makedumpf -#ifdef __mips64__ /* mips64 */ +#ifdef __mips64__ /* mips64 */ #define KVBASE PAGE_OFFSET - #define _SECTION_SIZE_BITS (28) - #define _MAX_PHYSMEM_BITS (48) + + #ifndef _XKPHYS_START_ADDR @@ -996,6 +996,40 @@ #endif /* mips64 */ @@ -178,9 +178,9 @@ diff -Naru ./makedumpfile-1.7.0/makedumpfile.h ./makedumpfile-1.7.0-sw/makedumpf +#endif /* sw_64 */ + + - /* - * The function of dependence on machine - */ + #ifdef __loongarch64__ + #define KVBASE (0x8000000000000000ULL) + #define _PAGE_OFFSET (0x9000000000000000ULL) @@ -1167,6 +1201,23 @@ #define arch_crashkernel_mem_size() stub_false() #endif /* mips64 */ @@ -202,9 +202,9 @@ diff -Naru ./makedumpfile-1.7.0/makedumpfile.h ./makedumpfile-1.7.0-sw/makedumpf +#endif /* sw_64 */ + + - typedef unsigned long long mdf_pfn_t; - - #ifndef ARCH_PFN_OFFSET + #ifdef __loongarch64__ /* loongarch64 */ + int get_phys_base_loongarch64(void); + int get_machdep_info_loongarch64(void); @@ -2301,6 +2352,13 @@ #define get_xen_info_arch(X) FALSE #endif /* mips64 */ @@ -216,18 +216,18 @@ diff -Naru ./makedumpfile-1.7.0/makedumpfile.h ./makedumpfile-1.7.0-sw/makedumpf +#endif /* sw_64 */ + + - struct cycle { - mdf_pfn_t start_pfn; - mdf_pfn_t end_pfn; -diff -Naru ./makedumpfile-1.7.0/Makefile ./makedumpfile-1.7.0-sw/Makefile ---- ./makedumpfile-1.7.0/Makefile 2021-11-08 00:36:15.000000000 +0000 -+++ ./makedumpfile-1.7.0-sw/Makefile 2022-08-19 06:55:54.538591123 +0000 + #ifdef __loongarch64__ /* loongarch64 */ + #define kvtop_xen(X) FALSE + #define get_xen_basic_info_arch(X) FALSE +diff -Naru ./makedumpfile-1.7.2/Makefile ./makedumpfile-1.7.2-sw/Makefile +--- ./makedumpfile-1.7.2/Makefile 2021-11-08 00:36:15.000000000 +0000 ++++ ./makedumpfile-1.7.2-sw/Makefile 2022-08-19 06:55:54.538591123 +0000 @@ -47,7 +47,7 @@ SRC_BASE = makedumpfile.c makedumpfile.h diskdump_mod.h sadump_mod.h sadump_info.h - SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c printk.c + SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c printk.c detect_cycle.c OBJ_PART=$(patsubst %.c,%.o,$(SRC_PART)) --SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c arch/mips64.c -+SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c arch/mips64.c arch/sw_64.c +-SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c arch/mips64.c arch/loongarch64.c ++SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c arch/mips64.c arch/loongarch64.c arch/sw_64.c OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH)) LIBS = -ldw -lbz2 -ldl -lelf -lz diff --git a/makedumpfile-1.7.2.tar.gz b/makedumpfile-1.7.2.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..80e07cd80dadf1dff3b2712e42cf0514ee20eefe Binary files /dev/null and b/makedumpfile-1.7.2.tar.gz differ diff --git a/sw_64.patch b/sw_64.patch index 183373d7e2e5ec1e36faaecf17ec65cf27bed0e7..548f6b842fb74a6c1021d7f1c099b3ad069a27e2 100644 --- a/sw_64.patch +++ b/sw_64.patch @@ -1,6 +1,6 @@ -diff -Naru kexec-tools-2.0.23/config/config.guess kexec-tools-2.0.23-sw/config/config.guess ---- kexec-tools-2.0.23/config/config.guess 2020-12-21 08:07:22.000000000 +0000 -+++ kexec-tools-2.0.23-sw/config/config.guess 2022-08-11 02:23:24.056917760 +0000 +diff -Naru kexec-tools-2.0.26/config/config.guess kexec-tools-2.0.26-sw/config/config.guess +--- kexec-tools-2.0.26/config/config.guess 2020-12-21 08:07:22.000000000 +0000 ++++ kexec-tools-2.0.26-sw/config/config.guess 2022-08-11 02:23:24.056917760 +0000 @@ -937,6 +937,15 @@ if test "$?" = 0 ; then LIBC=gnulibc1 ; fi echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" @@ -17,9 +17,9 @@ diff -Naru kexec-tools-2.0.23/config/config.guess kexec-tools-2.0.23-sw/config/c arc:Linux:*:* | arceb:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; -diff -Naru kexec-tools-2.0.23/config/config.sub kexec-tools-2.0.23-sw/config/config.sub ---- kexec-tools-2.0.23/config/config.sub 2020-12-21 08:07:22.000000000 +0000 -+++ kexec-tools-2.0.23-sw/config/config.sub 2022-08-11 02:23:50.316917760 +0000 +diff -Naru kexec-tools-2.0.26/config/config.sub kexec-tools-2.0.26-sw/config/config.sub +--- kexec-tools-2.0.26/config/config.sub 2020-12-21 08:07:22.000000000 +0000 ++++ kexec-tools-2.0.26-sw/config/config.sub 2022-08-11 02:23:50.316917760 +0000 @@ -1158,6 +1158,7 @@ case $cpu in 1750a | 580 \ @@ -28,12 +28,12 @@ diff -Naru kexec-tools-2.0.23/config/config.sub kexec-tools-2.0.23-sw/config/con | aarch64 | aarch64_be \ | abacus \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ -diff -Naru kexec-tools-2.0.23/configure kexec-tools-2.0.23-sw/configure ---- kexec-tools-2.0.23/configure 2021-11-04 14:59:17.000000000 +0000 -+++ kexec-tools-2.0.23-sw/configure 2022-08-18 08:54:34.059090794 +0000 +diff -Naru kexec-tools-2.0.26/configure kexec-tools-2.0.26-sw/configure +--- kexec-tools-2.0.26/configure 2021-11-04 14:59:17.000000000 +0000 ++++ kexec-tools-2.0.26-sw/configure 2022-08-18 08:54:34.059090794 +0000 @@ -3062,6 +3062,9 @@ - hppa*) - ARCH="hppa" + loongarch*) + ARCH="loongarch" ;; + sw_64*) + ARCH="sw_64" @@ -41,12 +41,12 @@ diff -Naru kexec-tools-2.0.23/configure kexec-tools-2.0.23-sw/configure * ) as_fn_error $? "unsupported architecture $target_cpu" "$LINENO" 5 ;; -diff -Naru kexec-tools-2.0.23/configure.ac kexec-tools-2.0.23-sw/configure.ac ---- kexec-tools-2.0.23/configure.ac 2021-11-04 14:57:43.000000000 +0000 -+++ kexec-tools-2.0.23-sw/configure.ac 2022-08-18 08:54:51.039112966 +0000 +diff -Naru kexec-tools-2.0.26/configure.ac kexec-tools-2.0.26-sw/configure.ac +--- kexec-tools-2.0.26/configure.ac 2021-11-04 14:57:43.000000000 +0000 ++++ kexec-tools-2.0.26-sw/configure.ac 2022-08-18 08:54:51.039112966 +0000 @@ -58,6 +58,9 @@ - hppa*) - ARCH="hppa" + loongarch*) + ARCH="loongarch" ;; + sw_64*) + ARCH="sw_64" @@ -54,9 +54,9 @@ diff -Naru kexec-tools-2.0.23/configure.ac kexec-tools-2.0.23-sw/configure.ac * ) AC_MSG_ERROR([unsupported architecture $target_cpu]) ;; -diff -Naru kexec-tools-2.0.23/include/boot/beoboot.h kexec-tools-2.0.23-sw/include/boot/beoboot.h ---- kexec-tools-2.0.23/include/boot/beoboot.h 2010-07-29 09:22:16.000000000 +0000 -+++ kexec-tools-2.0.23-sw/include/boot/beoboot.h 2022-08-11 02:36:05.796917760 +0000 +diff -Naru kexec-tools-2.0.26/include/boot/beoboot.h kexec-tools-2.0.26-sw/include/boot/beoboot.h +--- kexec-tools-2.0.26/include/boot/beoboot.h 2010-07-29 09:22:16.000000000 +0000 ++++ kexec-tools-2.0.26-sw/include/boot/beoboot.h 2022-08-11 02:36:05.796917760 +0000 @@ -23,6 +23,8 @@ #define BEOBOOT_ARCH_ALPHA 2 #define BEOBOOT_ARCH_PPC 3 @@ -75,9 +75,9 @@ diff -Naru kexec-tools-2.0.23/include/boot/beoboot.h kexec-tools-2.0.23-sw/inclu #else #error Unsupported architecture. #endif -diff -Naru kexec-tools-2.0.23/include/elf.h kexec-tools-2.0.23-sw/include/elf.h ---- kexec-tools-2.0.23/include/elf.h 2020-12-21 08:07:22.000000000 +0000 -+++ kexec-tools-2.0.23-sw/include/elf.h 2022-08-19 01:53:05.572119857 +0000 +diff -Naru kexec-tools-2.0.26/include/elf.h kexec-tools-2.0.26-sw/include/elf.h +--- kexec-tools-2.0.26/include/elf.h 2020-12-21 08:07:22.000000000 +0000 ++++ kexec-tools-2.0.26-sw/include/elf.h 2022-08-19 01:53:05.572119857 +0000 @@ -266,6 +266,8 @@ chances of collision with official or non-GNU unofficial values. */ @@ -87,9 +87,9 @@ diff -Naru kexec-tools-2.0.23/include/elf.h kexec-tools-2.0.23-sw/include/elf.h /* Legal values for e_version (version). */ -diff -Naru kexec-tools-2.0.23/kexec/arch/sw_64/crashdump-sw_64.c kexec-tools-2.0.23-sw/kexec/arch/sw_64/crashdump-sw_64.c ---- kexec-tools-2.0.23/kexec/arch/sw_64/crashdump-sw_64.c 1970-01-01 00:00:00.000000000 +0000 -+++ kexec-tools-2.0.23-sw/kexec/arch/sw_64/crashdump-sw_64.c 2022-08-19 01:50:42.851856092 +0000 +diff -Naru kexec-tools-2.0.26/kexec/arch/sw_64/crashdump-sw_64.c kexec-tools-2.0.26-sw/kexec/arch/sw_64/crashdump-sw_64.c +--- kexec-tools-2.0.26/kexec/arch/sw_64/crashdump-sw_64.c 1970-01-01 00:00:00.000000000 +0000 ++++ kexec-tools-2.0.26-sw/kexec/arch/sw_64/crashdump-sw_64.c 2022-08-19 01:50:42.851856092 +0000 @@ -0,0 +1,424 @@ +/* + * kexec: Linux boots Linux @@ -515,9 +515,9 @@ diff -Naru kexec-tools-2.0.23/kexec/arch/sw_64/crashdump-sw_64.c kexec-tools-2.0 +{ + return parse_iomem_single("Crash kernel\n", start, end); +} -diff -Naru kexec-tools-2.0.23/kexec/arch/sw_64/crashdump-sw_64.h kexec-tools-2.0.23-sw/kexec/arch/sw_64/crashdump-sw_64.h ---- kexec-tools-2.0.23/kexec/arch/sw_64/crashdump-sw_64.h 1970-01-01 00:00:00.000000000 +0000 -+++ kexec-tools-2.0.23-sw/kexec/arch/sw_64/crashdump-sw_64.h 2022-08-18 09:22:23.142660576 +0000 +diff -Naru kexec-tools-2.0.26/kexec/arch/sw_64/crashdump-sw_64.h kexec-tools-2.0.26-sw/kexec/arch/sw_64/crashdump-sw_64.h +--- kexec-tools-2.0.26/kexec/arch/sw_64/crashdump-sw_64.h 1970-01-01 00:00:00.000000000 +0000 ++++ kexec-tools-2.0.26-sw/kexec/arch/sw_64/crashdump-sw_64.h 2022-08-18 09:22:23.142660576 +0000 @@ -0,0 +1,23 @@ +#ifndef CRASHDUMP_SW_64_H +#define CRASHDUMP_SW_64_H @@ -542,9 +542,9 @@ diff -Naru kexec-tools-2.0.23/kexec/arch/sw_64/crashdump-sw_64.h kexec-tools-2.0 + +extern struct arch_options_t arch_options; +#endif /* CRASHDUMP_SW_64_H */ -diff -Naru kexec-tools-2.0.23/kexec/arch/sw_64/include/arch/options.h kexec-tools-2.0.23-sw/kexec/arch/sw_64/include/arch/options.h ---- kexec-tools-2.0.23/kexec/arch/sw_64/include/arch/options.h 1970-01-01 00:00:00.000000000 +0000 -+++ kexec-tools-2.0.23-sw/kexec/arch/sw_64/include/arch/options.h 2022-08-19 01:48:57.131660708 +0000 +diff -Naru kexec-tools-2.0.26/kexec/arch/sw_64/include/arch/options.h kexec-tools-2.0.26-sw/kexec/arch/sw_64/include/arch/options.h +--- kexec-tools-2.0.26/kexec/arch/sw_64/include/arch/options.h 1970-01-01 00:00:00.000000000 +0000 ++++ kexec-tools-2.0.26-sw/kexec/arch/sw_64/include/arch/options.h 2022-08-19 01:48:57.131660708 +0000 @@ -0,0 +1,30 @@ +#ifndef KEXEC_ARCH_SW_64_OPTIONS_H +#define KEXEC_ARCH_SW_64_OPTIONS_H @@ -576,9 +576,9 @@ diff -Naru kexec-tools-2.0.23/kexec/arch/sw_64/include/arch/options.h kexec-tool +#define KEXEC_ALL_OPT_STR KEXEC_ARCH_OPT_STR + +#endif /* KEXEC_ARCH_SW_64_OPTIONS_H */ -diff -Naru kexec-tools-2.0.23/kexec/arch/sw_64/kexec-elf-rel-sw_64.c kexec-tools-2.0.23-sw/kexec/arch/sw_64/kexec-elf-rel-sw_64.c ---- kexec-tools-2.0.23/kexec/arch/sw_64/kexec-elf-rel-sw_64.c 1970-01-01 00:00:00.000000000 +0000 -+++ kexec-tools-2.0.23-sw/kexec/arch/sw_64/kexec-elf-rel-sw_64.c 2022-08-19 01:51:21.131926839 +0000 +diff -Naru kexec-tools-2.0.26/kexec/arch/sw_64/kexec-elf-rel-sw_64.c kexec-tools-2.0.26-sw/kexec/arch/sw_64/kexec-elf-rel-sw_64.c +--- kexec-tools-2.0.26/kexec/arch/sw_64/kexec-elf-rel-sw_64.c 1970-01-01 00:00:00.000000000 +0000 ++++ kexec-tools-2.0.26-sw/kexec/arch/sw_64/kexec-elf-rel-sw_64.c 2022-08-19 01:51:21.131926839 +0000 @@ -0,0 +1,46 @@ +/* + * kexec-elf-rel-mips.c - kexec Elf relocation routines @@ -626,9 +626,9 @@ diff -Naru kexec-tools-2.0.23/kexec/arch/sw_64/kexec-elf-rel-sw_64.c kexec-tools + } + return; +} -diff -Naru kexec-tools-2.0.23/kexec/arch/sw_64/kexec-elf-sw_64.c kexec-tools-2.0.23-sw/kexec/arch/sw_64/kexec-elf-sw_64.c ---- kexec-tools-2.0.23/kexec/arch/sw_64/kexec-elf-sw_64.c 1970-01-01 00:00:00.000000000 +0000 -+++ kexec-tools-2.0.23-sw/kexec/arch/sw_64/kexec-elf-sw_64.c 2022-08-18 09:19:10.592068959 +0000 +diff -Naru kexec-tools-2.0.26/kexec/arch/sw_64/kexec-elf-sw_64.c kexec-tools-2.0.26-sw/kexec/arch/sw_64/kexec-elf-sw_64.c +--- kexec-tools-2.0.26/kexec/arch/sw_64/kexec-elf-sw_64.c 1970-01-01 00:00:00.000000000 +0000 ++++ kexec-tools-2.0.26-sw/kexec/arch/sw_64/kexec-elf-sw_64.c 2022-08-18 09:19:10.592068959 +0000 @@ -0,0 +1,189 @@ +/* + * kexec-elf-mips.c - kexec Elf loader for mips @@ -819,9 +819,9 @@ diff -Naru kexec-tools-2.0.23/kexec/arch/sw_64/kexec-elf-sw_64.c kexec-tools-2.0 + return 0; +} + -diff -Naru kexec-tools-2.0.23/kexec/arch/sw_64/kexec-sw_64.c kexec-tools-2.0.23-sw/kexec/arch/sw_64/kexec-sw_64.c ---- kexec-tools-2.0.23/kexec/arch/sw_64/kexec-sw_64.c 1970-01-01 00:00:00.000000000 +0000 -+++ kexec-tools-2.0.23-sw/kexec/arch/sw_64/kexec-sw_64.c 2022-08-18 09:15:28.891539590 +0000 +diff -Naru kexec-tools-2.0.26/kexec/arch/sw_64/kexec-sw_64.c kexec-tools-2.0.26-sw/kexec/arch/sw_64/kexec-sw_64.c +--- kexec-tools-2.0.26/kexec/arch/sw_64/kexec-sw_64.c 1970-01-01 00:00:00.000000000 +0000 ++++ kexec-tools-2.0.26-sw/kexec/arch/sw_64/kexec-sw_64.c 2022-08-18 09:15:28.891539590 +0000 @@ -0,0 +1,175 @@ +/* + * kexec-sw_64.c - kexec for sw_64 @@ -998,9 +998,9 @@ diff -Naru kexec-tools-2.0.23/kexec/arch/sw_64/kexec-sw_64.c kexec-tools-2.0.23- + buf_min, buf_max, buf_end, 1); +} + -diff -Naru kexec-tools-2.0.23/kexec/arch/sw_64/kexec-sw_64.h kexec-tools-2.0.23-sw/kexec/arch/sw_64/kexec-sw_64.h ---- kexec-tools-2.0.23/kexec/arch/sw_64/kexec-sw_64.h 1970-01-01 00:00:00.000000000 +0000 -+++ kexec-tools-2.0.23-sw/kexec/arch/sw_64/kexec-sw_64.h 2022-08-18 09:10:51.790877939 +0000 +diff -Naru kexec-tools-2.0.26/kexec/arch/sw_64/kexec-sw_64.h kexec-tools-2.0.26-sw/kexec/arch/sw_64/kexec-sw_64.h +--- kexec-tools-2.0.26/kexec/arch/sw_64/kexec-sw_64.h 1970-01-01 00:00:00.000000000 +0000 ++++ kexec-tools-2.0.26-sw/kexec/arch/sw_64/kexec-sw_64.h 2022-08-18 09:10:51.790877939 +0000 @@ -0,0 +1,30 @@ +#ifndef KEXEC_SW_64_H +#define KEXEC_SW_64_H @@ -1032,9 +1032,9 @@ diff -Naru kexec-tools-2.0.23/kexec/arch/sw_64/kexec-sw_64.h kexec-tools-2.0.23- +extern off_t initrd_base, initrd_size; + +#endif /* KEXEC_SW_64_H */ -diff -Naru kexec-tools-2.0.23/kexec/arch/sw_64/Makefile kexec-tools-2.0.23-sw/kexec/arch/sw_64/Makefile ---- kexec-tools-2.0.23/kexec/arch/sw_64/Makefile 1970-01-01 00:00:00.000000000 +0000 -+++ kexec-tools-2.0.23-sw/kexec/arch/sw_64/Makefile 2022-08-18 09:47:30.207054276 +0000 +diff -Naru kexec-tools-2.0.26/kexec/arch/sw_64/Makefile kexec-tools-2.0.26-sw/kexec/arch/sw_64/Makefile +--- kexec-tools-2.0.26/kexec/arch/sw_64/Makefile 1970-01-01 00:00:00.000000000 +0000 ++++ kexec-tools-2.0.26-sw/kexec/arch/sw_64/Makefile 2022-08-18 09:47:30.207054276 +0000 @@ -0,0 +1,29 @@ +# +# kexec sw_64 (linux booting linux) @@ -1065,9 +1065,9 @@ diff -Naru kexec-tools-2.0.23/kexec/arch/sw_64/Makefile kexec-tools-2.0.23-sw/ke + kexec/arch/sw_64/kexec-sw_64.h \ + kexec/arch/sw_64/crashdump-sw_64.h \ + kexec/arch/sw_64/include/arch/options.h -diff -Naru kexec-tools-2.0.23/kexec/kexec-syscall.h kexec-tools-2.0.23-sw/kexec/kexec-syscall.h ---- kexec-tools-2.0.23/kexec/kexec-syscall.h 2020-12-21 08:07:22.000000000 +0000 -+++ kexec-tools-2.0.23-sw/kexec/kexec-syscall.h 2022-08-18 08:44:14.408402498 +0000 +diff -Naru kexec-tools-2.0.26/kexec/kexec-syscall.h kexec-tools-2.0.26-sw/kexec/kexec-syscall.h +--- kexec-tools-2.0.26/kexec/kexec-syscall.h 2020-12-21 08:07:22.000000000 +0000 ++++ kexec-tools-2.0.26-sw/kexec/kexec-syscall.h 2022-08-18 08:44:14.408402498 +0000 @@ -51,6 +51,9 @@ #ifdef __alpha__ #define __NR_kexec_load 448 @@ -1078,20 +1078,20 @@ diff -Naru kexec-tools-2.0.23/kexec/kexec-syscall.h kexec-tools-2.0.23-sw/kexec/ #ifndef __NR_kexec_load #error Unknown processor architecture. Needs a kexec_load syscall number. #endif -diff -Naru kexec-tools-2.0.23/kexec/Makefile kexec-tools-2.0.23-sw/kexec/Makefile ---- kexec-tools-2.0.23/kexec/Makefile 2021-10-20 09:58:49.000000000 +0000 -+++ kexec-tools-2.0.23-sw/kexec/Makefile 2022-08-18 08:43:24.548411617 +0000 +diff -Naru kexec-tools-2.0.26/kexec/Makefile kexec-tools-2.0.26-sw/kexec/Makefile +--- kexec-tools-2.0.26/kexec/Makefile 2021-10-20 09:58:49.000000000 +0000 ++++ kexec-tools-2.0.26-sw/kexec/Makefile 2022-08-18 08:43:24.548411617 +0000 @@ -92,6 +92,7 @@ - include $(srcdir)/kexec/arch/sh/Makefile include $(srcdir)/kexec/arch/x86_64/Makefile include $(srcdir)/kexec/arch/hppa/Makefile + include $(srcdir)/kexec/arch/loongarch/Makefile +include $(srcdir)/kexec/arch/sw_64/Makefile KEXEC_SRCS += $($(ARCH)_KEXEC_SRCS) -diff -Naru kexec-tools-2.0.23/purgatory/arch/sw_64/Makefile kexec-tools-2.0.23-sw/purgatory/arch/sw_64/Makefile ---- kexec-tools-2.0.23/purgatory/arch/sw_64/Makefile 1970-01-01 00:00:00.000000000 +0000 -+++ kexec-tools-2.0.23-sw/purgatory/arch/sw_64/Makefile 2022-08-11 02:32:23.036917760 +0000 +diff -Naru kexec-tools-2.0.26/purgatory/arch/sw_64/Makefile kexec-tools-2.0.26-sw/purgatory/arch/sw_64/Makefile +--- kexec-tools-2.0.26/purgatory/arch/sw_64/Makefile 1970-01-01 00:00:00.000000000 +0000 ++++ kexec-tools-2.0.26-sw/purgatory/arch/sw_64/Makefile 2022-08-11 02:32:23.036917760 +0000 @@ -0,0 +1,8 @@ +# +# Purgatory sw_64 @@ -1101,13 +1101,13 @@ diff -Naru kexec-tools-2.0.23/purgatory/arch/sw_64/Makefile kexec-tools-2.0.23-s + +dist += purgatory/arch/sw_64/Makefile $(sw_64_PURGATORY_SRCS) + -diff -Naru kexec-tools-2.0.23/purgatory/Makefile kexec-tools-2.0.23-sw/purgatory/Makefile ---- kexec-tools-2.0.23/purgatory/Makefile 2020-12-21 08:07:22.000000000 +0000 -+++ kexec-tools-2.0.23-sw/purgatory/Makefile 2022-08-18 08:45:08.208392658 +0000 +diff -Naru kexec-tools-2.0.26/purgatory/Makefile kexec-tools-2.0.26-sw/purgatory/Makefile +--- kexec-tools-2.0.26/purgatory/Makefile 2020-12-21 08:07:22.000000000 +0000 ++++ kexec-tools-2.0.26-sw/purgatory/Makefile 2022-08-18 08:45:08.208392658 +0000 @@ -28,6 +28,7 @@ - include $(srcdir)/purgatory/arch/s390/Makefile include $(srcdir)/purgatory/arch/sh/Makefile include $(srcdir)/purgatory/arch/x86_64/Makefile + include $(srcdir)/purgatory/arch/loongarch/Makefile +include $(srcdir)/purgatory/arch/sw_64/Makefile PURGATORY_SRCS+=$($(ARCH)_PURGATORY_SRCS)