diff --git a/Fix-building-on-x86_64-with-binutils-2.41.patch b/Fix-building-on-x86_64-with-binutils-2.41.patch new file mode 100644 index 0000000000000000000000000000000000000000..cbf30a53997f534a653a517be31e13209ef664b5 --- /dev/null +++ b/Fix-building-on-x86_64-with-binutils-2.41.patch @@ -0,0 +1,92 @@ +From 328de8e00e298f00d7ba6b25dc3950147e9642e6 Mon Sep 17 00:00:00 2001 +From: Michel Lind +Date: Tue, 30 Jan 2024 04:14:31 -0600 +Subject: [PATCH] Fix building on x86_64 with binutils 2.41 + +Newer versions of the GNU assembler (observed with binutils 2.41) will +complain about the ".arch i386" in files assembled with "as --64", +with the message "Error: 64bit mode not supported on 'i386'". + +Fix by moving ".arch i386" below the relevant ".code32" directive, so +that the assembler is no longer expecting 64-bit instructions to be used +by the time that the ".arch i386" directive is encountered. + +Based on similar iPXE fix: +https://github.com/ipxe/ipxe/commit/6ca597eee + +Signed-off-by: Michel Lind +Signed-off-by: Simon Horman +--- + purgatory/arch/i386/entry32-16-debug.S | 2 +- + purgatory/arch/i386/entry32-16.S | 2 +- + purgatory/arch/i386/entry32.S | 2 +- + purgatory/arch/i386/setup-x86.S | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/purgatory/arch/i386/entry32-16-debug.S b/purgatory/arch/i386/entry32-16-debug.S +index 5167944..12e1164 100644 +--- a/purgatory/arch/i386/entry32-16-debug.S ++++ b/purgatory/arch/i386/entry32-16-debug.S +@@ -25,10 +25,10 @@ + .globl entry16_debug_pre32 + .globl entry16_debug_first32 + .globl entry16_debug_old_first32 +- .arch i386 + .balign 16 + entry16_debug: + .code32 ++ .arch i386 + /* Compute where I am running at (assumes esp valid) */ + call 1f + 1: popl %ebx +diff --git a/purgatory/arch/i386/entry32-16.S b/purgatory/arch/i386/entry32-16.S +index c051aab..eace095 100644 +--- a/purgatory/arch/i386/entry32-16.S ++++ b/purgatory/arch/i386/entry32-16.S +@@ -20,10 +20,10 @@ + #undef i386 + .text + .globl entry16, entry16_regs +- .arch i386 + .balign 16 + entry16: + .code32 ++ .arch i386 + /* Compute where I am running at (assumes esp valid) */ + call 1f + 1: popl %ebx +diff --git a/purgatory/arch/i386/entry32.S b/purgatory/arch/i386/entry32.S +index f7a494f..8ce9e31 100644 +--- a/purgatory/arch/i386/entry32.S ++++ b/purgatory/arch/i386/entry32.S +@@ -20,10 +20,10 @@ + #undef i386 + + .text +- .arch i386 + .globl entry32, entry32_regs + entry32: + .code32 ++ .arch i386 + + /* Setup a gdt that should that is generally usefully */ + lgdt %cs:gdt +diff --git a/purgatory/arch/i386/setup-x86.S b/purgatory/arch/i386/setup-x86.S +index 201bb2c..a212eed 100644 +--- a/purgatory/arch/i386/setup-x86.S ++++ b/purgatory/arch/i386/setup-x86.S +@@ -21,10 +21,10 @@ + #undef i386 + + .text +- .arch i386 + .globl purgatory_start + purgatory_start: + .code32 ++ .arch i386 + + /* Load a gdt so I know what the segment registers are */ + lgdt %cs:gdt +-- +2.20.1 + diff --git a/kdump.sysconfig.loongarch64 b/kdump.sysconfig.loongarch64 index e2a2d7b6f6f4d1c85ccf5e06a24daa0d8b2f4c86..2fa5bce7b79eaef24b383a858e0a259f9c167695 100755 --- a/kdump.sysconfig.loongarch64 +++ b/kdump.sysconfig.loongarch64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len rd_s # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="init 3 irqpoll reset_devices cgroup_disable=memory udev.children-max=2 panic=10 novmcoredd" +KDUMP_COMMANDLINE_APPEND="init 3 irqpoll reset_devices cgroup_disable=memory udev.children-max=2 panic=10 novmcoredd nokaslr" # Any additional kexec arguments required. In most situations, this should # be left empty diff --git a/kexec-tools.spec b/kexec-tools.spec index bf667e85185fda5600558292eca427befb65d41d..0c7c76f4f0a1cb0578caa0bcdc4c24c3f4b61fc3 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -3,7 +3,7 @@ %global mkdf_ver 1.7.4 %global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) -%define anolis_release 5 +%define anolis_release 6 Name: kexec-tools Version: 2.0.26 @@ -91,6 +91,8 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic Patch0001: loongarch64-fix-some-functional-issues-and-compilati.patch Patch0002: kexec-tools-rv64-support.patch +Patch0003: loongarch64-fix-kernel-image-size-error.patch +Patch0004: Fix-building-on-x86_64-with-binutils-2.41.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -116,6 +118,8 @@ tar -z -x -v -f %{SOURCE19} %patch0001 -p1 %patch0002 -p1 +%patch0003 -p1 +%patch0004 -p1 %build autoreconf @@ -344,6 +348,9 @@ done %doc TODO AUTHORS %changelog +* Tue Jun 4 2024 Ming Wang - 2.0.26-6 +- Backport upstream patch for loongarch and x86_64 + * Wed Feb 21 2024 Chang Gao - 2.0.26-5 - Update makedumpfile to 1.7.4 (bug#8121) diff --git a/loongarch64-fix-kernel-image-size-error.patch b/loongarch64-fix-kernel-image-size-error.patch new file mode 100644 index 0000000000000000000000000000000000000000..ff06441564922e3cd3e603a1dc032269e4bf6dc0 --- /dev/null +++ b/loongarch64-fix-kernel-image-size-error.patch @@ -0,0 +1,114 @@ +From 9df89b0198a61f3c5e29cfb41787c4ca99f502e6 Mon Sep 17 00:00:00 2001 +From: Ming Wang +Date: Fri, 17 May 2024 10:39:31 +0800 +Subject: [PATCH] kexec: loongarch: fix some issue. + +Signed-off-by: Hongchen Zhang +Signed-off-by: Ming Wang +Signed-off-by: Your Name +--- + kexec/arch/loongarch/kexec-elf-loongarch.c | 28 ++++++++++++++++++---- + kexec/arch/loongarch/kexec-loongarch.c | 11 +++++---- + 2 files changed, 31 insertions(+), 8 deletions(-) + +diff --git a/kexec/arch/loongarch/kexec-elf-loongarch.c b/kexec/arch/loongarch/kexec-elf-loongarch.c +index 0ac451e..7e84d03 100644 +--- a/kexec/arch/loongarch/kexec-elf-loongarch.c ++++ b/kexec/arch/loongarch/kexec-elf-loongarch.c +@@ -54,6 +54,7 @@ int elf_loongarch_load(int argc, char **argv, const char *kernel_buf, + unsigned long kernel_segment; + struct mem_ehdr ehdr; + int result; ++ int i; + + result = build_elf_exec_info(kernel_buf, kernel_size, &ehdr, 0); + +@@ -62,6 +63,26 @@ int elf_loongarch_load(int argc, char **argv, const char *kernel_buf, + goto exit; + } + ++ /* Find and process the loongarch image header. */ ++ for (i = 0; i < ehdr.e_phnum; i++) { ++ struct mem_phdr *phdr = &ehdr.e_phdr[i]; ++ ++ if (phdr->p_type != PT_LOAD) ++ continue; ++ ++ header = (const struct loongarch_image_header *)( ++ kernel_buf + phdr->p_offset); ++ ++ if (!loongarch_process_image_header(header)) ++ break; ++ } ++ ++ if (i == ehdr.e_phnum) { ++ dbgprintf("%s: Valid loongarch image header not found\n", __func__); ++ result = EFAILED; ++ goto exit; ++ } ++ + kernel_segment = loongarch_locate_kernel_segment(info); + + if (kernel_segment == ULONG_MAX) { +@@ -72,13 +93,12 @@ int elf_loongarch_load(int argc, char **argv, const char *kernel_buf, + + dbgprintf("%s: kernel_segment: %016lx\n", __func__, kernel_segment); + dbgprintf("%s: image_size: %016lx\n", __func__, +- kernel_size); ++ loongarch_mem.image_size); + dbgprintf("%s: text_offset: %016lx\n", __func__, + loongarch_mem.text_offset); + dbgprintf("%s: phys_offset: %016lx\n", __func__, + loongarch_mem.phys_offset); +- dbgprintf("%s: PE format: %s\n", __func__, +- (loongarch_header_check_pe_sig(header) ? "yes" : "no")); ++ dbgprintf("%s: PE format: no\n", __func__); + + /* create and initialize elf core header segment */ + if (info->kexec_flags & KEXEC_ON_CRASH) { +@@ -112,7 +132,7 @@ int elf_loongarch_load(int argc, char **argv, const char *kernel_buf, + kernel_size = MiB(64); + + /* load additional data */ +- result = loongarch_load_other_segments(info, kernel_segment + kernel_size); ++ result = loongarch_load_other_segments(info, kernel_segment + loongarch_mem.image_size); + + exit: + free_elf_info(&ehdr); +diff --git a/kexec/arch/loongarch/kexec-loongarch.c b/kexec/arch/loongarch/kexec-loongarch.c +index 51f334a..6485080 100644 +--- a/kexec/arch/loongarch/kexec-loongarch.c ++++ b/kexec/arch/loongarch/kexec-loongarch.c +@@ -288,6 +288,7 @@ int loongarch_load_other_segments(struct kexec_info *info, unsigned long hole_mi + unsigned long initrd_min, hole_max; + char *initrd_buf = NULL; + unsigned long pagesize = getpagesize(); ++ int i; + + if (arch_options.command_line) { + if (strlen(arch_options.command_line) > +@@ -325,15 +326,17 @@ int loongarch_load_other_segments(struct kexec_info *info, unsigned long hole_mi + cmdline_add_elfcorehdr(cmdline, elfcorehdr_mem.start, + elfcorehdr_mem.end - elfcorehdr_mem.start + 1); + +- cmdline_add_mem(cmdline, crash_reserved_mem[usablemem_rgns.size - 1].start, +- crash_reserved_mem[usablemem_rgns.size - 1].end - +- crash_reserved_mem[usablemem_rgns.size - 1].start + 1); ++ for(i = 0;i < usablemem_rgns.size; i++) { ++ cmdline_add_mem(cmdline, crash_reserved_mem[i].start, ++ crash_reserved_mem[i].end - ++ crash_reserved_mem[i].start + 1); ++ } + } + + cmdline[sizeof(cmdline) - 1] = 0; + add_buffer(info, cmdline, sizeof(cmdline), sizeof(cmdline), + sizeof(void *), _ALIGN_UP(hole_min, getpagesize()), +- 0xffffffff, 1); ++ hole_max, 1); + + dbgprintf("%s:%d: command_line: %s\n", __func__, __LINE__, cmdline); + +-- +2.41.0 +