diff options
| author | Khem Raj <raj.khem@gmail.com> | 2025-12-13 12:30:17 -0800 |
|---|---|---|
| committer | Khem Raj <raj.khem@gmail.com> | 2025-12-14 10:11:17 -0800 |
| commit | d3529a351dd4b6481493e5e40d2d57a6d92d59bc (patch) | |
| tree | 8687a252bbd61aa07b35707641fc3644a16dcf93 | |
| parent | d50131ca7c1f10965056ce98e48110d6bf13fab0 (diff) | |
| download | meta-openembedded-d3529a351dd4b6481493e5e40d2d57a6d92d59bc.tar.gz | |
kexec-tools-klibc: Update to latest 2.0.32 release
Add riscv64 support
Rework klibc support patches
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Andrea Adami <andrea.adami@gmail.com>
35 files changed, 461 insertions, 461 deletions
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0001-force-static-build.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0001-force-static-build.patch index 34826baed9..843ce3c881 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0001-force-static-build.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0001-force-static-build.patch | |||
| @@ -10,8 +10,6 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 10 | Makefile.in | 2 +- | 10 | Makefile.in | 2 +- |
| 11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 12 | 12 | ||
| 13 | diff --git a/Makefile.in b/Makefile.in | ||
| 14 | index fb01134..dbf1fb6 100644 | ||
| 15 | --- a/Makefile.in | 13 | --- a/Makefile.in |
| 16 | +++ b/Makefile.in | 14 | +++ b/Makefile.in |
| 17 | @@ -47,7 +47,7 @@ TARGET_CFLAGS = @TARGET_CFLAGS@ | 15 | @@ -47,7 +47,7 @@ TARGET_CFLAGS = @TARGET_CFLAGS@ |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0001-kexec-Provide-local-implementation-of-mkstemp-for-kl.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0001-kexec-Provide-local-implementation-of-mkstemp-for-kl.patch new file mode 100644 index 0000000000..93c7124e52 --- /dev/null +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0001-kexec-Provide-local-implementation-of-mkstemp-for-kl.patch | |||
| @@ -0,0 +1,118 @@ | |||
| 1 | From 24c140dee30304668ecc829ed8a672f3439f4f1c Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Sat, 13 Dec 2025 11:24:10 -0800 | ||
| 4 | Subject: [PATCH 1/5] kexec: Provide local implementation of mkstemp for klibc | ||
| 5 | |||
| 6 | Upstream-Status: Pending | ||
| 7 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 8 | --- | ||
| 9 | kexec/kexec-pe-zboot.c | 42 ++++++++++++++++++++++++++++++++++++++++++ | ||
| 10 | kexec/kexec-uki.c | 42 ++++++++++++++++++++++++++++++++++++++++++ | ||
| 11 | 2 files changed, 84 insertions(+) | ||
| 12 | |||
| 13 | diff --git a/kexec/kexec-pe-zboot.c b/kexec/kexec-pe-zboot.c | ||
| 14 | index c09f2ae..fd86820 100644 | ||
| 15 | --- a/kexec/kexec-pe-zboot.c | ||
| 16 | +++ b/kexec/kexec-pe-zboot.c | ||
| 17 | @@ -29,6 +29,48 @@ | ||
| 18 | #include <fcntl.h> | ||
| 19 | #include "kexec.h" | ||
| 20 | #include <pe.h> | ||
| 21 | +#ifdef __KLIBC__ | ||
| 22 | +/* klibc doesn't provide mkstemp(), implement a simple version */ | ||
| 23 | +#include <string.h> | ||
| 24 | +#include <errno.h> | ||
| 25 | +#include <time.h> | ||
| 26 | + | ||
| 27 | +static int mkstemp(char *template) | ||
| 28 | +{ | ||
| 29 | + char *p; | ||
| 30 | + int len, fd; | ||
| 31 | + unsigned long val; | ||
| 32 | + unsigned int n; | ||
| 33 | + | ||
| 34 | + if (!template) { | ||
| 35 | + errno = EINVAL; | ||
| 36 | + return -1; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + len = strlen(template); | ||
| 40 | + if (len < 6) { | ||
| 41 | + errno = EINVAL; | ||
| 42 | + return -1; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + p = template + len - 6; | ||
| 46 | + if (strcmp(p, "XXXXXX") != 0) { | ||
| 47 | + errno = EINVAL; | ||
| 48 | + return -1; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + val = ((unsigned long)getpid() << 16) ^ (unsigned long)time(NULL); | ||
| 52 | + | ||
| 53 | + for (n = 0; n < 100; n++) { | ||
| 54 | + snprintf(p, 7, "%06lu", (val + n) % 1000000); | ||
| 55 | + fd = open(template, O_RDWR | O_CREAT | O_EXCL, 0600); | ||
| 56 | + if (fd >= 0 || errno != EEXIST) | ||
| 57 | + return fd; | ||
| 58 | + } | ||
| 59 | + return -1; | ||
| 60 | +} | ||
| 61 | +#endif /* __KLIBC__ */ | ||
| 62 | + | ||
| 63 | #include <kexec-pe-zboot.h> | ||
| 64 | |||
| 65 | #define FILENAME_IMAGE "/tmp/ImageXXXXXX" | ||
| 66 | diff --git a/kexec/kexec-uki.c b/kexec/kexec-uki.c | ||
| 67 | index 9888d7e..ecd3f17 100644 | ||
| 68 | --- a/kexec/kexec-uki.c | ||
| 69 | +++ b/kexec/kexec-uki.c | ||
| 70 | @@ -20,6 +20,48 @@ | ||
| 71 | static int embeded_linux_format_index = -1; | ||
| 72 | static int kernel_fd = -1; | ||
| 73 | |||
| 74 | +#ifdef __KLIBC__ | ||
| 75 | +/* klibc doesn't provide mkstemp(), implement a simple version */ | ||
| 76 | +#include <string.h> | ||
| 77 | +#include <errno.h> | ||
| 78 | +#include <time.h> | ||
| 79 | + | ||
| 80 | +static int mkstemp(char *template) | ||
| 81 | +{ | ||
| 82 | + char *p; | ||
| 83 | + int len, fd; | ||
| 84 | + unsigned long val; | ||
| 85 | + unsigned int n; | ||
| 86 | + | ||
| 87 | + if (!template) { | ||
| 88 | + errno = EINVAL; | ||
| 89 | + return -1; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + len = strlen(template); | ||
| 93 | + if (len < 6) { | ||
| 94 | + errno = EINVAL; | ||
| 95 | + return -1; | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + p = template + len - 6; | ||
| 99 | + if (strcmp(p, "XXXXXX") != 0) { | ||
| 100 | + errno = EINVAL; | ||
| 101 | + return -1; | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + val = ((unsigned long)getpid() << 16) ^ (unsigned long)time(NULL); | ||
| 105 | + | ||
| 106 | + for (n = 0; n < 100; n++) { | ||
| 107 | + snprintf(p, 7, "%06lu", (val + n) % 1000000); | ||
| 108 | + fd = open(template, O_RDWR | O_CREAT | O_EXCL, 0600); | ||
| 109 | + if (fd >= 0 || errno != EEXIST) | ||
| 110 | + return fd; | ||
| 111 | + } | ||
| 112 | + return -1; | ||
| 113 | +} | ||
| 114 | +#endif /* __KLIBC__ */ | ||
| 115 | + | ||
| 116 | static int create_tmpfd(const char *template, char *buf, int buf_sz, int *tmpfd) | ||
| 117 | { | ||
| 118 | char *fname; | ||
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0002-Adjust-the-order-of-headers-to-fix-build-for-musl.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0002-Adjust-the-order-of-headers-to-fix-build-for-musl.patch index ec456f382b..a02e9306bb 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0002-Adjust-the-order-of-headers-to-fix-build-for-musl.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0002-Adjust-the-order-of-headers-to-fix-build-for-musl.patch | |||
| @@ -13,11 +13,9 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> | |||
| 13 | kexec/ifdown.c | 2 +- | 13 | kexec/ifdown.c | 2 +- |
| 14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 15 | 15 | ||
| 16 | diff --git a/kexec/ifdown.c b/kexec/ifdown.c | ||
| 17 | index 9679ad7..82c6141 100644 | ||
| 18 | --- a/kexec/ifdown.c | 16 | --- a/kexec/ifdown.c |
| 19 | +++ b/kexec/ifdown.c | 17 | +++ b/kexec/ifdown.c |
| 20 | @@ -16,8 +16,8 @@ char *v_ifdown = "@(#)ifdown.c 1.11 02-Jun-1998 miquels@cistron.nl"; | 18 | @@ -16,8 +16,8 @@ char *v_ifdown = "@(#)ifdown.c 1.11 02 |
| 21 | #include <sys/socket.h> | 19 | #include <sys/socket.h> |
| 22 | #include <sys/time.h> | 20 | #include <sys/time.h> |
| 23 | 21 | ||
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0002-kexec-Add-imaxdiv-implementation-for-klibc-builds.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0002-kexec-Add-imaxdiv-implementation-for-klibc-builds.patch new file mode 100644 index 0000000000..b19281eed9 --- /dev/null +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0002-kexec-Add-imaxdiv-implementation-for-klibc-builds.patch | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | From 47bad82779f7fcd46b8a269cfe9a99f8ef34d317 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Sat, 13 Dec 2025 12:13:08 -0800 | ||
| 4 | Subject: [PATCH 2/5] kexec: Add imaxdiv implementation for klibc builds | ||
| 5 | |||
| 6 | klibc doesn't provide the imaxdiv_t structure or imaxdiv() function | ||
| 7 | from inttypes.h. Add a simple inline implementation when building | ||
| 8 | with klibc. | ||
| 9 | |||
| 10 | The imaxdiv() function computes the quotient and remainder of the | ||
| 11 | division of numer by denom, which is required for standard C99 | ||
| 12 | compliance but missing in minimal libc implementations. | ||
| 13 | |||
| 14 | Upstream-Status: Pending | ||
| 15 | |||
| 16 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 17 | --- | ||
| 18 | util_lib/include/elf_info.h | 16 ++++++++++++++++ | ||
| 19 | 1 file changed, 16 insertions(+) | ||
| 20 | |||
| 21 | diff --git a/util_lib/include/elf_info.h b/util_lib/include/elf_info.h | ||
| 22 | index fdf4c3d..9338205 100644 | ||
| 23 | --- a/util_lib/include/elf_info.h | ||
| 24 | +++ b/util_lib/include/elf_info.h | ||
| 25 | @@ -22,7 +22,23 @@ | ||
| 26 | #include <stdbool.h> | ||
| 27 | #include <inttypes.h> | ||
| 28 | #include <ctype.h> | ||
| 29 | +#ifdef __KLIBC__ | ||
| 30 | +/* klibc doesn't provide imaxdiv_t or imaxdiv() */ | ||
| 31 | +#include <inttypes.h> | ||
| 32 | + | ||
| 33 | +typedef struct { | ||
| 34 | + intmax_t quot; /* Quotient */ | ||
| 35 | + intmax_t rem; /* Remainder */ | ||
| 36 | +} imaxdiv_t; | ||
| 37 | |||
| 38 | +static inline imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom) | ||
| 39 | +{ | ||
| 40 | + imaxdiv_t result; | ||
| 41 | + result.quot = numer / denom; | ||
| 42 | + result.rem = numer % denom; | ||
| 43 | + return result; | ||
| 44 | +} | ||
| 45 | +#endif /* __KLIBC__ */ | ||
| 46 | int get_pt_load(int idx, | ||
| 47 | unsigned long long *phys_start, | ||
| 48 | unsigned long long *phys_end, | ||
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0003-kexec-elf-rel-use-our-elf.h.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0003-kexec-elf-rel-use-our-elf.h.patch index 32035ca128..b7a71aaac3 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0003-kexec-elf-rel-use-our-elf.h.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0003-kexec-elf-rel-use-our-elf.h.patch | |||
| @@ -22,8 +22,6 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 22 | kexec/kexec-elf-rel.c | 2 +- | 22 | kexec/kexec-elf-rel.c | 2 +- |
| 23 | 6 files changed, 6 insertions(+), 6 deletions(-) | 23 | 6 files changed, 6 insertions(+), 6 deletions(-) |
| 24 | 24 | ||
| 25 | diff --git a/kexec/arch/arm/kexec-elf-rel-arm.c b/kexec/arch/arm/kexec-elf-rel-arm.c | ||
| 26 | index a939cf4..2551dc0 100644 | ||
| 27 | --- a/kexec/arch/arm/kexec-elf-rel-arm.c | 25 | --- a/kexec/arch/arm/kexec-elf-rel-arm.c |
| 28 | +++ b/kexec/arch/arm/kexec-elf-rel-arm.c | 26 | +++ b/kexec/arch/arm/kexec-elf-rel-arm.c |
| 29 | @@ -1,5 +1,5 @@ | 27 | @@ -1,5 +1,5 @@ |
| @@ -33,8 +31,6 @@ index a939cf4..2551dc0 100644 | |||
| 33 | #include "../../kexec.h" | 31 | #include "../../kexec.h" |
| 34 | #include "../../kexec-elf.h" | 32 | #include "../../kexec-elf.h" |
| 35 | 33 | ||
| 36 | diff --git a/kexec/arch/i386/kexec-elf-rel-x86.c b/kexec/arch/i386/kexec-elf-rel-x86.c | ||
| 37 | index 55a214e..e7583d1 100644 | ||
| 38 | --- a/kexec/arch/i386/kexec-elf-rel-x86.c | 34 | --- a/kexec/arch/i386/kexec-elf-rel-x86.c |
| 39 | +++ b/kexec/arch/i386/kexec-elf-rel-x86.c | 35 | +++ b/kexec/arch/i386/kexec-elf-rel-x86.c |
| 40 | @@ -1,5 +1,5 @@ | 36 | @@ -1,5 +1,5 @@ |
| @@ -44,8 +40,6 @@ index 55a214e..e7583d1 100644 | |||
| 44 | #include "../../kexec.h" | 40 | #include "../../kexec.h" |
| 45 | #include "../../kexec-elf.h" | 41 | #include "../../kexec-elf.h" |
| 46 | 42 | ||
| 47 | diff --git a/kexec/arch/ppc/kexec-elf-rel-ppc.c b/kexec/arch/ppc/kexec-elf-rel-ppc.c | ||
| 48 | index 1acbd86..a60c66c 100644 | ||
| 49 | --- a/kexec/arch/ppc/kexec-elf-rel-ppc.c | 43 | --- a/kexec/arch/ppc/kexec-elf-rel-ppc.c |
| 50 | +++ b/kexec/arch/ppc/kexec-elf-rel-ppc.c | 44 | +++ b/kexec/arch/ppc/kexec-elf-rel-ppc.c |
| 51 | @@ -1,5 +1,5 @@ | 45 | @@ -1,5 +1,5 @@ |
| @@ -55,8 +49,6 @@ index 1acbd86..a60c66c 100644 | |||
| 55 | #include "../../kexec.h" | 49 | #include "../../kexec.h" |
| 56 | #include "../../kexec-elf.h" | 50 | #include "../../kexec-elf.h" |
| 57 | 51 | ||
| 58 | diff --git a/kexec/arch/ppc64/kexec-elf-rel-ppc64.c b/kexec/arch/ppc64/kexec-elf-rel-ppc64.c | ||
| 59 | index 51b1354..c85f421 100644 | ||
| 60 | --- a/kexec/arch/ppc64/kexec-elf-rel-ppc64.c | 52 | --- a/kexec/arch/ppc64/kexec-elf-rel-ppc64.c |
| 61 | +++ b/kexec/arch/ppc64/kexec-elf-rel-ppc64.c | 53 | +++ b/kexec/arch/ppc64/kexec-elf-rel-ppc64.c |
| 62 | @@ -1,5 +1,5 @@ | 54 | @@ -1,5 +1,5 @@ |
| @@ -66,8 +58,6 @@ index 51b1354..c85f421 100644 | |||
| 66 | #include <string.h> | 58 | #include <string.h> |
| 67 | #include "../../kexec.h" | 59 | #include "../../kexec.h" |
| 68 | #include "../../kexec-elf.h" | 60 | #include "../../kexec-elf.h" |
| 69 | diff --git a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c | ||
| 70 | index db85b44..761a4ed 100644 | ||
| 71 | --- a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c | 61 | --- a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c |
| 72 | +++ b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c | 62 | +++ b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c |
| 73 | @@ -1,5 +1,5 @@ | 63 | @@ -1,5 +1,5 @@ |
| @@ -77,8 +67,6 @@ index db85b44..761a4ed 100644 | |||
| 77 | #include "../../kexec.h" | 67 | #include "../../kexec.h" |
| 78 | #include "../../kexec-elf.h" | 68 | #include "../../kexec-elf.h" |
| 79 | 69 | ||
| 80 | diff --git a/kexec/kexec-elf-rel.c b/kexec/kexec-elf-rel.c | ||
| 81 | index 9a6e63d..a856636 100644 | ||
| 82 | --- a/kexec/kexec-elf-rel.c | 70 | --- a/kexec/kexec-elf-rel.c |
| 83 | +++ b/kexec/kexec-elf-rel.c | 71 | +++ b/kexec/kexec-elf-rel.c |
| 84 | @@ -4,7 +4,7 @@ | 72 | @@ -4,7 +4,7 @@ |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0003-kexec-riscv-Add-endian-conversion-macros-for-klibc-b.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0003-kexec-riscv-Add-endian-conversion-macros-for-klibc-b.patch new file mode 100644 index 0000000000..9719dc1ce1 --- /dev/null +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0003-kexec-riscv-Add-endian-conversion-macros-for-klibc-b.patch | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | From 5054d110fbc05141e0c2287ba19676e7c1e0286e Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Sat, 13 Dec 2025 12:14:54 -0800 | ||
| 4 | Subject: [PATCH 3/5] kexec/riscv: Add endian conversion macros for klibc | ||
| 5 | builds | ||
| 6 | |||
| 7 | klibc doesn't provide the standard endian conversion functions | ||
| 8 | (le16toh, le32toh, le64toh, htole*, be*toh, htobe*) that are | ||
| 9 | normally available in glibc's endian.h. | ||
| 10 | |||
| 11 | Add macro implementations for these functions when building with | ||
| 12 | klibc, using the existing bswap_* functions from byteswap.h for | ||
| 13 | byte swapping when needed based on the host byte order. | ||
| 14 | |||
| 15 | This fixes build errors when using RISC-V image headers with klibc. | ||
| 16 | |||
| 17 | Upstream-Status: Pending | ||
| 18 | |||
| 19 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 20 | --- | ||
| 21 | kexec/arch/riscv/image-header.h | 36 +++++++++++++++++++++++++++++++++ | ||
| 22 | 1 file changed, 36 insertions(+) | ||
| 23 | |||
| 24 | diff --git a/kexec/arch/riscv/image-header.h b/kexec/arch/riscv/image-header.h | ||
| 25 | index a677546..892f77f 100644 | ||
| 26 | --- a/kexec/arch/riscv/image-header.h | ||
| 27 | +++ b/kexec/arch/riscv/image-header.h | ||
| 28 | @@ -9,6 +9,42 @@ | ||
| 29 | #include <endian.h> | ||
| 30 | #include <stdint.h> | ||
| 31 | |||
| 32 | +#ifdef __KLIBC__ | ||
| 33 | +#include <byteswap.h> | ||
| 34 | + | ||
| 35 | +/* klibc doesn't provide endian conversion functions, define them */ | ||
| 36 | +#ifndef le64toh | ||
| 37 | +# if __BYTE_ORDER == __LITTLE_ENDIAN | ||
| 38 | +# define le16toh(x) ((uint16_t)(x)) | ||
| 39 | +# define le32toh(x) ((uint32_t)(x)) | ||
| 40 | +# define le64toh(x) ((uint64_t)(x)) | ||
| 41 | +# define htole16(x) ((uint16_t)(x)) | ||
| 42 | +# define htole32(x) ((uint32_t)(x)) | ||
| 43 | +# define htole64(x) ((uint64_t)(x)) | ||
| 44 | +# define be16toh(x) bswap_16(x) | ||
| 45 | +# define be32toh(x) bswap_32(x) | ||
| 46 | +# define be64toh(x) bswap_64(x) | ||
| 47 | +# define htobe16(x) bswap_16(x) | ||
| 48 | +# define htobe32(x) bswap_32(x) | ||
| 49 | +# define htobe64(x) bswap_64(x) | ||
| 50 | +# elif __BYTE_ORDER == __BIG_ENDIAN | ||
| 51 | +# define le16toh(x) bswap_16(x) | ||
| 52 | +# define le32toh(x) bswap_32(x) | ||
| 53 | +# define le64toh(x) bswap_64(x) | ||
| 54 | +# define htole16(x) bswap_16(x) | ||
| 55 | +# define htole32(x) bswap_32(x) | ||
| 56 | +# define htole64(x) bswap_64(x) | ||
| 57 | +# define be16toh(x) ((uint16_t)(x)) | ||
| 58 | +# define be32toh(x) ((uint32_t)(x)) | ||
| 59 | +# define be64toh(x) ((uint64_t)(x)) | ||
| 60 | +# define htobe16(x) ((uint16_t)(x)) | ||
| 61 | +# define htobe32(x) ((uint32_t)(x)) | ||
| 62 | +# define htobe64(x) ((uint64_t)(x)) | ||
| 63 | +# else | ||
| 64 | +# error "Unknown byte order" | ||
| 65 | +# endif | ||
| 66 | +#endif /* le64toh */ | ||
| 67 | +#endif /* __KLIBC__ */ | ||
| 68 | /** | ||
| 69 | * struct riscv_image_header - riscv kernel image header. | ||
| 70 | * | ||
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0004-exec-Define-EM_RISCV-for-klibc-builds.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0004-exec-Define-EM_RISCV-for-klibc-builds.patch new file mode 100644 index 0000000000..9bba417ac9 --- /dev/null +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0004-exec-Define-EM_RISCV-for-klibc-builds.patch | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | From c71b58dd324a29f2d157eb9d07f5a05bee0518f6 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Sat, 13 Dec 2025 12:16:00 -0800 | ||
| 4 | Subject: [PATCH 4/5] exec: Define EM_RISCV for klibc builds | ||
| 5 | |||
| 6 | klibc's elf.h header doesn't define the EM_RISCV machine type | ||
| 7 | constant. Add a fallback definition when building with klibc to | ||
| 8 | support RISC-V architecture. | ||
| 9 | |||
| 10 | EM_RISCV (243) is the official ELF machine type for RISC-V as | ||
| 11 | defined in the ELF specification. | ||
| 12 | |||
| 13 | Upstream-Status: Pending | ||
| 14 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 15 | --- | ||
| 16 | kexec/kexec-elf.h | 7 +++++++ | ||
| 17 | 1 file changed, 7 insertions(+) | ||
| 18 | |||
| 19 | diff --git a/kexec/kexec-elf.h b/kexec/kexec-elf.h | ||
| 20 | index 1e512c8..af3fc55 100644 | ||
| 21 | --- a/kexec/kexec-elf.h | ||
| 22 | +++ b/kexec/kexec-elf.h | ||
| 23 | @@ -4,6 +4,13 @@ | ||
| 24 | #include <stdint.h> | ||
| 25 | #include <sys/types.h> | ||
| 26 | |||
| 27 | +/* klibc provided elf.h does not yet have this definition and its preferred in includes | ||
| 28 | + * when building for klibc | ||
| 29 | + */ | ||
| 30 | +#ifndef EM_RISCV | ||
| 31 | +#define EM_RISCV 243 /* RISC-V */ | ||
| 32 | +#endif | ||
| 33 | + | ||
| 34 | struct kexec_info; | ||
| 35 | |||
| 36 | struct mem_ehdr { | ||
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0004-kexec-elf-exec.c-replace-with-our-err.h.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0004-kexec-elf-exec.c-replace-with-our-err.h.patch index 27a1cc7a56..c4ffe1403e 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0004-kexec-elf-exec.c-replace-with-our-err.h.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0004-kexec-elf-exec.c-replace-with-our-err.h.patch | |||
| @@ -15,8 +15,6 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 15 | kexec/kexec-elf-exec.c | 2 +- | 15 | kexec/kexec-elf-exec.c | 2 +- |
| 16 | 1 file changed, 1 insertion(+), 1 deletion(-) | 16 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 17 | 17 | ||
| 18 | diff --git a/kexec/kexec-elf-exec.c b/kexec/kexec-elf-exec.c | ||
| 19 | index a9329ac..0dd0700 100644 | ||
| 20 | --- a/kexec/kexec-elf-exec.c | 18 | --- a/kexec/kexec-elf-exec.c |
| 21 | +++ b/kexec/kexec-elf-exec.c | 19 | +++ b/kexec/kexec-elf-exec.c |
| 22 | @@ -4,7 +4,7 @@ | 20 | @@ -4,7 +4,7 @@ |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0005-crashdump-elf.c-work-around-for-sysconf-_SC_NPROCESS.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0005-crashdump-elf.c-work-around-for-sysconf-_SC_NPROCESS.patch index 4604c2a5b7..b01b07b417 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0005-crashdump-elf.c-work-around-for-sysconf-_SC_NPROCESS.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0005-crashdump-elf.c-work-around-for-sysconf-_SC_NPROCESS.patch | |||
| @@ -21,8 +21,6 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 21 | kexec/crashdump-elf.c | 92 +++++++++++++++++++++++++++++++++++++++++++ | 21 | kexec/crashdump-elf.c | 92 +++++++++++++++++++++++++++++++++++++++++++ |
| 22 | 1 file changed, 92 insertions(+) | 22 | 1 file changed, 92 insertions(+) |
| 23 | 23 | ||
| 24 | diff --git a/kexec/crashdump-elf.c b/kexec/crashdump-elf.c | ||
| 25 | index b8bb686..7e6767c 100644 | ||
| 26 | --- a/kexec/crashdump-elf.c | 24 | --- a/kexec/crashdump-elf.c |
| 27 | +++ b/kexec/crashdump-elf.c | 25 | +++ b/kexec/crashdump-elf.c |
| 28 | @@ -25,6 +25,94 @@ do { \ | 26 | @@ -25,6 +25,94 @@ do { \ |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0005-kexec-Disable-memfd_create-for-klibc-builds.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0005-kexec-Disable-memfd_create-for-klibc-builds.patch new file mode 100644 index 0000000000..523a12aaca --- /dev/null +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0005-kexec-Disable-memfd_create-for-klibc-builds.patch | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | From b0792ce24c28abb88835c3e0d77cfd8d24da1131 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Sat, 13 Dec 2025 12:19:14 -0800 | ||
| 4 | Subject: [PATCH 5/5] kexec: Disable memfd_create for klibc builds | ||
| 5 | |||
| 6 | klibc doesn't provide the syscall() wrapper function needed to | ||
| 7 | invoke the memfd_create system call. Since klibc is typically used | ||
| 8 | for minimal early-boot environments where memfd_create is not | ||
| 9 | essential for kexec functionality, return ENOSYS to allow kexec | ||
| 10 | to fall back to alternative methods. | ||
| 11 | |||
| 12 | This fixes the build error: | ||
| 13 | error: call to undeclared function 'syscall' | ||
| 14 | |||
| 15 | Upstream-Status: Pending | ||
| 16 | |||
| 17 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 18 | --- | ||
| 19 | kexec/kexec.c | 9 +++++++-- | ||
| 20 | 1 file changed, 7 insertions(+), 2 deletions(-) | ||
| 21 | |||
| 22 | diff --git a/kexec/kexec.c b/kexec/kexec.c | ||
| 23 | index c9e4bcb..1fd2062 100644 | ||
| 24 | --- a/kexec/kexec.c | ||
| 25 | +++ b/kexec/kexec.c | ||
| 26 | @@ -649,11 +649,16 @@ char *slurp_decompress_file(const char *filename, off_t *r_size) | ||
| 27 | } | ||
| 28 | return kernel_buf; | ||
| 29 | } | ||
| 30 | - | ||
| 31 | #ifndef HAVE_MEMFD_CREATE | ||
| 32 | static int memfd_create(const char *name, unsigned int flags) | ||
| 33 | { | ||
| 34 | - return syscall(SYS_memfd_create, name, flags); | ||
| 35 | +#ifdef __KLIBC__ | ||
| 36 | +/* klibc doesn't provide syscall() or memfd_create */ | ||
| 37 | + errno = ENOSYS; | ||
| 38 | + return -1; | ||
| 39 | +#else | ||
| 40 | + return syscall(SYS_memfd_create, name, flags); | ||
| 41 | +#endif | ||
| 42 | } | ||
| 43 | #endif | ||
| 44 | |||
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0006-kexec-syscall.h-work-around-missing-syscall-wrapper.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0006-kexec-syscall.h-work-around-missing-syscall-wrapper.patch index a607ce777e..28b0de1377 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0006-kexec-syscall.h-work-around-missing-syscall-wrapper.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0006-kexec-syscall.h-work-around-missing-syscall-wrapper.patch | |||
| @@ -15,11 +15,9 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 15 | kexec/kexec-syscall.h | 21 +++++++++++++++++++++ | 15 | kexec/kexec-syscall.h | 21 +++++++++++++++++++++ |
| 16 | 1 file changed, 21 insertions(+) | 16 | 1 file changed, 21 insertions(+) |
| 17 | 17 | ||
| 18 | diff --git a/kexec/kexec-syscall.h b/kexec/kexec-syscall.h | ||
| 19 | index b96e02a..2a3794d 100644 | ||
| 20 | --- a/kexec/kexec-syscall.h | 18 | --- a/kexec/kexec-syscall.h |
| 21 | +++ b/kexec/kexec-syscall.h | 19 | +++ b/kexec/kexec-syscall.h |
| 22 | @@ -77,11 +77,16 @@ | 20 | @@ -96,11 +96,16 @@ |
| 23 | 21 | ||
| 24 | struct kexec_segment; | 22 | struct kexec_segment; |
| 25 | 23 | ||
| @@ -36,7 +34,7 @@ index b96e02a..2a3794d 100644 | |||
| 36 | 34 | ||
| 37 | static inline int is_kexec_file_load_implemented(void) { | 35 | static inline int is_kexec_file_load_implemented(void) { |
| 38 | if (__NR_kexec_file_load != 0xffffffff) | 36 | if (__NR_kexec_file_load != 0xffffffff) |
| 39 | @@ -89,6 +94,21 @@ static inline int is_kexec_file_load_implemented(void) { | 37 | @@ -108,6 +113,21 @@ static inline int is_kexec_file_load_imp |
| 40 | return 0; | 38 | return 0; |
| 41 | } | 39 | } |
| 42 | 40 | ||
| @@ -58,7 +56,7 @@ index b96e02a..2a3794d 100644 | |||
| 58 | static inline long kexec_file_load(int kernel_fd, int initrd_fd, | 56 | static inline long kexec_file_load(int kernel_fd, int initrd_fd, |
| 59 | unsigned long cmdline_len, const char *cmdline_ptr, | 57 | unsigned long cmdline_len, const char *cmdline_ptr, |
| 60 | unsigned long flags) | 58 | unsigned long flags) |
| 61 | @@ -96,6 +116,7 @@ static inline long kexec_file_load(int kernel_fd, int initrd_fd, | 59 | @@ -115,6 +135,7 @@ static inline long kexec_file_load(int k |
| 62 | return (long) syscall(__NR_kexec_file_load, kernel_fd, initrd_fd, | 60 | return (long) syscall(__NR_kexec_file_load, kernel_fd, initrd_fd, |
| 63 | cmdline_len, cmdline_ptr, flags); | 61 | cmdline_len, cmdline_ptr, flags); |
| 64 | } | 62 | } |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0007-kexec.c-add-guard-around-ENOTSUP.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0007-kexec.c-add-guard-around-ENOTSUP.patch index 0ae90016d0..76bb1c5e69 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0007-kexec.c-add-guard-around-ENOTSUP.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0007-kexec.c-add-guard-around-ENOTSUP.patch | |||
| @@ -15,23 +15,20 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 15 | kexec/kexec.c | 2 ++ | 15 | kexec/kexec.c | 2 ++ |
| 16 | 1 file changed, 2 insertions(+) | 16 | 1 file changed, 2 insertions(+) |
| 17 | 17 | ||
| 18 | diff --git a/kexec/kexec.c b/kexec/kexec.c | ||
| 19 | index 32ae56c..0764e85 100644 | ||
| 20 | --- a/kexec/kexec.c | 18 | --- a/kexec/kexec.c |
| 21 | +++ b/kexec/kexec.c | 19 | +++ b/kexec/kexec.c |
| 22 | @@ -1517,6 +1517,7 @@ int main(int argc, char *argv[]) | 20 | @@ -1421,12 +1421,14 @@ static int do_kexec_file_load(int filein |
| 23 | */ | 21 | */ |
| 24 | case -EINVAL: | 22 | case EINVAL: |
| 25 | case -ENOEXEC: | 23 | case ENOEXEC: |
| 26 | +#ifndef __KLIBC__ | 24 | +#ifndef __KLIBC__ |
| 27 | /* | 25 | /* |
| 28 | * ENOTSUP can be unsupported image | 26 | * ENOTSUP can be unsupported image |
| 29 | * type or unsupported PE signature | 27 | * type or unsupported PE signature |
| 30 | @@ -1529,6 +1530,7 @@ int main(int argc, char *argv[]) | 28 | * wrapper type, duh. |
| 31 | * kernel bug | 29 | */ |
| 32 | */ | 30 | case ENOTSUP: |
| 33 | case -ENOTSUP: | ||
| 34 | +#endif | 31 | +#endif |
| 35 | do_kexec_file_syscall = 0; | 32 | ret = EFALLBACK; |
| 36 | break; | 33 | break; |
| 37 | } | 34 | } |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0008-kexec.c-replace-mising-BLKGETSIZE64.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0008-kexec.c-replace-mising-BLKGETSIZE64.patch index 0ab7a1d71e..bb34157559 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0008-kexec.c-replace-mising-BLKGETSIZE64.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0008-kexec.c-replace-mising-BLKGETSIZE64.patch | |||
| @@ -15,11 +15,9 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 15 | kexec/kexec.c | 4 ++++ | 15 | kexec/kexec.c | 4 ++++ |
| 16 | 1 file changed, 4 insertions(+) | 16 | 1 file changed, 4 insertions(+) |
| 17 | 17 | ||
| 18 | diff --git a/kexec/kexec.c b/kexec/kexec.c | ||
| 19 | index 0764e85..157c577 100644 | ||
| 20 | --- a/kexec/kexec.c | 18 | --- a/kexec/kexec.c |
| 21 | +++ b/kexec/kexec.c | 19 | +++ b/kexec/kexec.c |
| 22 | @@ -55,6 +55,10 @@ | 20 | @@ -61,6 +61,10 @@ |
| 23 | #define KEXEC_LOADED_PATH "/sys/kernel/kexec_loaded" | 21 | #define KEXEC_LOADED_PATH "/sys/kernel/kexec_loaded" |
| 24 | #define KEXEC_CRASH_LOADED_PATH "/sys/kernel/kexec_crash_loaded" | 22 | #define KEXEC_CRASH_LOADED_PATH "/sys/kernel/kexec_crash_loaded" |
| 25 | 23 | ||
| @@ -29,4 +27,4 @@ index 0764e85..157c577 100644 | |||
| 29 | + | 27 | + |
| 30 | unsigned long long mem_min = 0; | 28 | unsigned long long mem_min = 0; |
| 31 | unsigned long long mem_max = ULONG_MAX; | 29 | unsigned long long mem_max = ULONG_MAX; |
| 32 | static unsigned long kexec_flags = 0; | 30 | unsigned long elfcorehdrsz = 0; |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0009-vmcore-dmesg.c-work-around-missing-imaxdiv.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0009-vmcore-dmesg.c-work-around-missing-imaxdiv.patch deleted file mode 100644 index 8bc473cb00..0000000000 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0009-vmcore-dmesg.c-work-around-missing-imaxdiv.patch +++ /dev/null | |||
| @@ -1,57 +0,0 @@ | |||
| 1 | From 20e2c61fc04a291250acee649c2523d2546cedea Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Andrea Adami <andrea.adami@gmail.com> | ||
| 3 | Date: Tue, 17 Apr 2018 13:14:12 +0200 | ||
| 4 | Subject: [PATCH] vmcore-dmesg.c: work around missing imaxdiv() | ||
| 5 | |||
| 6 | Convert to integer arithmetic for klibc. | ||
| 7 | |||
| 8 | Fix | ||
| 9 | |||
| 10 | vmcore-dmesg.c: In function 'dump_dmesg_structured': | ||
| 11 | vmcore-dmesg.c:578:2: error: unknown type name 'imaxdiv_t' | ||
| 12 | |||
| 13 | Upstream-Status: Inappropriate [klibc specific] | ||
| 14 | Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | ||
| 15 | |||
| 16 | --- | ||
| 17 | vmcore-dmesg/vmcore-dmesg.c | 13 ++++++++++++- | ||
| 18 | 1 file changed, 12 insertions(+), 1 deletion(-) | ||
| 19 | |||
| 20 | diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c | ||
| 21 | index 7972788..c63ac4f 100644 | ||
| 22 | --- a/vmcore-dmesg/vmcore-dmesg.c | ||
| 23 | +++ b/vmcore-dmesg/vmcore-dmesg.c | ||
| 24 | @@ -575,8 +575,11 @@ static void dump_dmesg_structured(int fd) | ||
| 25 | ssize_t ret; | ||
| 26 | char *msg; | ||
| 27 | uint16_t text_len; | ||
| 28 | +#ifndef __KLIBC__ | ||
| 29 | imaxdiv_t imaxdiv_sec, imaxdiv_usec; | ||
| 30 | - | ||
| 31 | +#else | ||
| 32 | + int64_t imaxdiv_sec, imaxdiv_usec; | ||
| 33 | +#endif | ||
| 34 | if (!log_buf_vaddr) { | ||
| 35 | fprintf(stderr, "Missing the log_buf symbol\n"); | ||
| 36 | exit(60); | ||
| 37 | @@ -645,12 +648,20 @@ static void dump_dmesg_structured(int fd) | ||
| 38 | exit(65); | ||
| 39 | } | ||
| 40 | ts_nsec = struct_val_u64(buf, log_offset_ts_nsec); | ||
| 41 | +#ifndef __KLIBC__ | ||
| 42 | imaxdiv_sec = imaxdiv(ts_nsec, 1000000000); | ||
| 43 | imaxdiv_usec = imaxdiv(imaxdiv_sec.rem, 1000); | ||
| 44 | |||
| 45 | len += sprintf(out_buf + len, "[%5llu.%06llu] ", | ||
| 46 | (long long unsigned int)imaxdiv_sec.quot, | ||
| 47 | (long long unsigned int)imaxdiv_usec.quot); | ||
| 48 | +#else | ||
| 49 | + imaxdiv_sec = ts_nsec / 1000000000; | ||
| 50 | + imaxdiv_usec = (ts_nsec % 1000000000) / 1000; | ||
| 51 | + len += sprintf(out_buf + len, "[%5llu.%06llu] ", | ||
| 52 | + (long long unsigned int)imaxdiv_sec, | ||
| 53 | + (long long unsigned int)imaxdiv_usec); | ||
| 54 | +#endif | ||
| 55 | |||
| 56 | /* escape non-printable characters */ | ||
| 57 | text_len = struct_val_u16(buf, log_offset_text_len); | ||
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0010-fs2dt.c-work-around-missing-getline.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0010-fs2dt.c-work-around-missing-getline.patch index 4652f10a6e..6c960e671a 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0010-fs2dt.c-work-around-missing-getline.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0010-fs2dt.c-work-around-missing-getline.patch | |||
| @@ -17,11 +17,9 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 17 | kexec/fs2dt.c | 8 ++++++++ | 17 | kexec/fs2dt.c | 8 ++++++++ |
| 18 | 1 file changed, 8 insertions(+) | 18 | 1 file changed, 8 insertions(+) |
| 19 | 19 | ||
| 20 | diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c | ||
| 21 | index 07a5e2f..d635636 100644 | ||
| 22 | --- a/kexec/fs2dt.c | 20 | --- a/kexec/fs2dt.c |
| 23 | +++ b/kexec/fs2dt.c | 21 | +++ b/kexec/fs2dt.c |
| 24 | @@ -531,6 +531,9 @@ static void dt_copy_old_root_param(void) | 22 | @@ -532,6 +532,9 @@ static void dt_copy_old_root_param(void) |
| 25 | char *last_cmdline = NULL; | 23 | char *last_cmdline = NULL; |
| 26 | char *p, *old_param; | 24 | char *p, *old_param; |
| 27 | size_t len = 0; | 25 | size_t len = 0; |
| @@ -31,7 +29,7 @@ index 07a5e2f..d635636 100644 | |||
| 31 | 29 | ||
| 32 | strcpy(filename, pathname); | 30 | strcpy(filename, pathname); |
| 33 | strcat(filename, "bootargs"); | 31 | strcat(filename, "bootargs"); |
| 34 | @@ -538,8 +541,13 @@ static void dt_copy_old_root_param(void) | 32 | @@ -539,8 +542,13 @@ static void dt_copy_old_root_param(void) |
| 35 | if (!fp) | 33 | if (!fp) |
| 36 | return; | 34 | return; |
| 37 | 35 | ||
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0011-purgatory-Makefile-adapt-to-klcc.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0011-purgatory-Makefile-adapt-to-klcc.patch index 07fa841ccc..c591923c2d 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0011-purgatory-Makefile-adapt-to-klcc.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0011-purgatory-Makefile-adapt-to-klcc.patch | |||
| @@ -12,16 +12,16 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 12 | 12 | ||
| 13 | --- a/purgatory/Makefile | 13 | --- a/purgatory/Makefile |
| 14 | +++ b/purgatory/Makefile | 14 | +++ b/purgatory/Makefile |
| 15 | @@ -47,7 +47,7 @@ purgatory/sha256.o: $(srcdir)/util_lib/s | 15 | @@ -49,7 +49,7 @@ purgatory/sha256.o: $(srcdir)/util_lib/s |
| 16 | $(PURGATORY): CC=$(TARGET_CC) | 16 | $(PURGATORY): CC=$(TARGET_CC) |
| 17 | $(PURGATORY): CFLAGS+=$(PURGATORY_EXTRA_CFLAGS) \ | 17 | $(PURGATORY): CFLAGS=$(PURGATORY_EXTRA_CFLAGS) \ |
| 18 | $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \ | 18 | $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \ |
| 19 | - -Os -fno-builtin -ffreestanding \ | 19 | - -Os -fno-builtin -ffreestanding \ |
| 20 | + -Os -fno-builtin -ffreestanding -nostdinc \ | 20 | + -Os -fno-builtin -ffreestanding -nostdinc \ |
| 21 | -fno-zero-initialized-in-bss \ | 21 | -fno-zero-initialized-in-bss \ |
| 22 | -fno-PIC -fno-PIE -fno-stack-protector | 22 | -fno-PIC -fno-PIE -fno-stack-protector -fno-tree-vectorize |
| 23 | 23 | ||
| 24 | @@ -59,8 +59,8 @@ $(PURGATORY): CPPFLAGS=$($(ARCH)_PURGATO | 24 | @@ -61,8 +61,8 @@ $(PURGATORY): CPPFLAGS=$($(ARCH)_PURGATO |
| 25 | -Iinclude \ | 25 | -Iinclude \ |
| 26 | -I$(shell $(CC) -print-file-name=include) | 26 | -I$(shell $(CC) -print-file-name=include) |
| 27 | $(PURGATORY): LDFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS)\ | 27 | $(PURGATORY): LDFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS)\ |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0012-purgatory-string.c-avoid-inclusion-of-string.h.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0012-purgatory-string.c-avoid-inclusion-of-string.h.patch index db0d763178..93ac0908c3 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0012-purgatory-string.c-avoid-inclusion-of-string.h.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0012-purgatory-string.c-avoid-inclusion-of-string.h.patch | |||
| @@ -14,8 +14,6 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 14 | purgatory/string.c | 2 ++ | 14 | purgatory/string.c | 2 ++ |
| 15 | 1 file changed, 2 insertions(+) | 15 | 1 file changed, 2 insertions(+) |
| 16 | 16 | ||
| 17 | diff --git a/purgatory/string.c b/purgatory/string.c | ||
| 18 | index f06c460..c5e978a 100644 | ||
| 19 | --- a/purgatory/string.c | 17 | --- a/purgatory/string.c |
| 20 | +++ b/purgatory/string.c | 18 | +++ b/purgatory/string.c |
| 21 | @@ -1,5 +1,7 @@ | 19 | @@ -1,5 +1,7 @@ |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0013-sha256.h-avoid-inclusion-of-sys-types.h.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0013-sha256.h-avoid-inclusion-of-sys-types.h.patch index 777cbcf94f..b7c4d7d8e2 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0013-sha256.h-avoid-inclusion-of-sys-types.h.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0013-sha256.h-avoid-inclusion-of-sys-types.h.patch | |||
| @@ -15,8 +15,6 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 15 | util_lib/include/sha256.h | 4 ++++ | 15 | util_lib/include/sha256.h | 4 ++++ |
| 16 | 1 file changed, 4 insertions(+) | 16 | 1 file changed, 4 insertions(+) |
| 17 | 17 | ||
| 18 | diff --git a/util_lib/include/sha256.h b/util_lib/include/sha256.h | ||
| 19 | index 467fb22..40fd3ed 100644 | ||
| 20 | --- a/util_lib/include/sha256.h | 18 | --- a/util_lib/include/sha256.h |
| 21 | +++ b/util_lib/include/sha256.h | 19 | +++ b/util_lib/include/sha256.h |
| 22 | @@ -1,7 +1,11 @@ | 20 | @@ -1,7 +1,11 @@ |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0014-add-if_nameindex-from-musl.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0014-add-if_nameindex-from-musl.patch index eca01b956c..738623f0dd 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0014-add-if_nameindex-from-musl.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0014-add-if_nameindex-from-musl.patch | |||
| @@ -32,8 +32,6 @@ Upstream-Status: Pending | |||
| 32 | create mode 100644 kexec/if_nameindex.c | 32 | create mode 100644 kexec/if_nameindex.c |
| 33 | create mode 100644 kexec/if_nameindex.h | 33 | create mode 100644 kexec/if_nameindex.h |
| 34 | 34 | ||
| 35 | diff --git a/kexec/Makefile b/kexec/Makefile | ||
| 36 | index 4db84d8..fb7520b 100644 | ||
| 37 | --- a/kexec/Makefile | 35 | --- a/kexec/Makefile |
| 38 | +++ b/kexec/Makefile | 36 | +++ b/kexec/Makefile |
| 39 | @@ -11,7 +11,7 @@ KEXEC_SRCS = $(KEXEC_SRCS_base) | 37 | @@ -11,7 +11,7 @@ KEXEC_SRCS = $(KEXEC_SRCS_base) |
| @@ -45,9 +43,6 @@ index 4db84d8..fb7520b 100644 | |||
| 45 | KEXEC_SRCS_base += kexec/kexec-elf.c | 43 | KEXEC_SRCS_base += kexec/kexec-elf.c |
| 46 | KEXEC_SRCS_base += kexec/kexec-elf-exec.c | 44 | KEXEC_SRCS_base += kexec/kexec-elf-exec.c |
| 47 | KEXEC_SRCS_base += kexec/kexec-elf-core.c | 45 | KEXEC_SRCS_base += kexec/kexec-elf-core.c |
| 48 | diff --git a/kexec/if_nameindex.c b/kexec/if_nameindex.c | ||
| 49 | new file mode 100644 | ||
| 50 | index 0000000..e586e41 | ||
| 51 | --- /dev/null | 46 | --- /dev/null |
| 52 | +++ b/kexec/if_nameindex.c | 47 | +++ b/kexec/if_nameindex.c |
| 53 | @@ -0,0 +1,64 @@ | 48 | @@ -0,0 +1,64 @@ |
| @@ -115,9 +110,6 @@ index 0000000..e586e41 | |||
| 115 | + errno = ENOBUFS; | 110 | + errno = ENOBUFS; |
| 116 | + return p; | 111 | + return p; |
| 117 | +} | 112 | +} |
| 118 | diff --git a/kexec/if_nameindex.h b/kexec/if_nameindex.h | ||
| 119 | new file mode 100644 | ||
| 120 | index 0000000..cf1c061 | ||
| 121 | --- /dev/null | 113 | --- /dev/null |
| 122 | +++ b/kexec/if_nameindex.h | 114 | +++ b/kexec/if_nameindex.h |
| 123 | @@ -0,0 +1,15 @@ | 115 | @@ -0,0 +1,15 @@ |
| @@ -136,11 +128,9 @@ index 0000000..cf1c061 | |||
| 136 | +void if_freenameindex (struct if_nameindex *); | 128 | +void if_freenameindex (struct if_nameindex *); |
| 137 | + | 129 | + |
| 138 | +#endif | 130 | +#endif |
| 139 | diff --git a/kexec/ifdown.c b/kexec/ifdown.c | ||
| 140 | index 82c6141..cc3ca9f 100644 | ||
| 141 | --- a/kexec/ifdown.c | 131 | --- a/kexec/ifdown.c |
| 142 | +++ b/kexec/ifdown.c | 132 | +++ b/kexec/ifdown.c |
| 143 | @@ -18,6 +18,9 @@ char *v_ifdown = "@(#)ifdown.c 1.11 02-Jun-1998 miquels@cistron.nl"; | 133 | @@ -18,6 +18,9 @@ char *v_ifdown = "@(#)ifdown.c 1.11 02 |
| 144 | 134 | ||
| 145 | #include <netinet/in.h> | 135 | #include <netinet/in.h> |
| 146 | #include <net/if.h> | 136 | #include <net/if.h> |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0015-vmcore-dmesg-fix-warning.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0015-vmcore-dmesg-fix-warning.patch deleted file mode 100644 index 044a70d93b..0000000000 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0015-vmcore-dmesg-fix-warning.patch +++ /dev/null | |||
| @@ -1,29 +0,0 @@ | |||
| 1 | From a2679731a56748de58a4cf0a46b7a15d75543a88 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Andrea Adami <andrea.adami@gmail.com> | ||
| 3 | Date: Sun, 29 Apr 2018 00:52:31 +0200 | ||
| 4 | Subject: [PATCH] vmcore-dmesg: fix warning | ||
| 5 | |||
| 6 | # define __bitwise | ||
| 7 | |||
| 8 | Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | ||
| 9 | |||
| 10 | --- | ||
| 11 | Upstream-Status: Pending | ||
| 12 | |||
| 13 | vmcore-dmesg/vmcore-dmesg.c | 3 +++ | ||
| 14 | 1 file changed, 3 insertions(+) | ||
| 15 | |||
| 16 | diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c | ||
| 17 | index c63ac4f..a4e3014 100644 | ||
| 18 | --- a/vmcore-dmesg/vmcore-dmesg.c | ||
| 19 | +++ b/vmcore-dmesg/vmcore-dmesg.c | ||
| 20 | @@ -2,6 +2,9 @@ | ||
| 21 | #define _GNU_SOURCE | ||
| 22 | #define _LARGEFILE_SOURCE 1 | ||
| 23 | #define _FILE_OFFSET_BITS 64 | ||
| 24 | +#ifdef __KLIBC__ | ||
| 25 | +#include <sys/types.h> | ||
| 26 | +#endif | ||
| 27 | #include <endian.h> | ||
| 28 | #include <byteswap.h> | ||
| 29 | #include <stdio.h> | ||
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/140-mips_disable_devicetree_support.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/140-mips_disable_devicetree_support.patch index 031efb6275..d9363bf50c 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/140-mips_disable_devicetree_support.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/140-mips_disable_devicetree_support.patch | |||
| @@ -26,27 +26,28 @@ Upstream-Status: Pending | |||
| 26 | 26 | ||
| 27 | --- a/kexec/arch/mips/include/arch/options.h | 27 | --- a/kexec/arch/mips/include/arch/options.h |
| 28 | +++ b/kexec/arch/mips/include/arch/options.h | 28 | +++ b/kexec/arch/mips/include/arch/options.h |
| 29 | @@ -5,6 +5,7 @@ | 29 | @@ -6,6 +6,7 @@ |
| 30 | #define OPT_APPEND (OPT_ARCH_MAX+0) | 30 | #define OPT_DTB (OPT_ARCH_MAX+1) |
| 31 | #define OPT_DTB (OPT_ARCH_MAX+1) | 31 | #define OPT_RAMDISK (OPT_ARCH_MAX+2) |
| 32 | #define OPT_RAMDISK (OPT_ARCH_MAX+2) | 32 | #define OPT_REUSE_CMDLINE (OPT_ARCH_MAX+3) |
| 33 | +#define OPT_NO_DTB (OPT_ARCH_MAX+3) | 33 | +#define OPT_NO_DTB (OPT_ARCH_MAX+4) |
| 34 | 34 | ||
| 35 | /* Options relevant to the architecture (excluding loader-specific ones), | 35 | /* Options relevant to the architecture (excluding loader-specific ones), |
| 36 | * in this case none: | 36 | * in this case none: |
| 37 | @@ -14,7 +15,8 @@ | 37 | @@ -16,8 +17,8 @@ |
| 38 | {"command-line", 1, 0, OPT_APPEND}, \ | ||
| 39 | {"append", 1, 0, OPT_APPEND}, \ | 38 | {"append", 1, 0, OPT_APPEND}, \ |
| 40 | {"dtb", 1, 0, OPT_DTB }, \ | 39 | {"dtb", 1, 0, OPT_DTB }, \ |
| 41 | - {"initrd", 1, 0, OPT_RAMDISK }, | 40 | {"initrd", 1, 0, OPT_RAMDISK }, \ |
| 42 | + {"initrd", 1, 0, OPT_RAMDISK }, \ | 41 | - { "reuse-cmdline", 0, NULL, OPT_REUSE_CMDLINE }, |
| 42 | - | ||
| 43 | + { "reuse-cmdline", 0, NULL, OPT_REUSE_CMDLINE }, \ | ||
| 43 | + {"no-dtb", 0, 0, OPT_NO_DTB }, | 44 | + {"no-dtb", 0, 0, OPT_NO_DTB }, |
| 44 | 45 | ||
| 45 | |||
| 46 | #define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR "" | 46 | #define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR "" |
| 47 | |||
| 47 | --- a/kexec/arch/mips/kexec-elf-mips.c | 48 | --- a/kexec/arch/mips/kexec-elf-mips.c |
| 48 | +++ b/kexec/arch/mips/kexec-elf-mips.c | 49 | +++ b/kexec/arch/mips/kexec-elf-mips.c |
| 49 | @@ -141,45 +141,49 @@ int elf_mips_load(int argc, char **argv, | 50 | @@ -196,36 +196,38 @@ int elf_mips_load(int argc, char **argv, |
| 50 | else | 51 | else |
| 51 | cmdline_addr = 0; | 52 | cmdline_addr = 0; |
| 52 | 53 | ||
| @@ -64,10 +65,10 @@ Upstream-Status: Pending | |||
| 64 | - | 65 | - |
| 65 | - if (arch_options.initrd_file) { | 66 | - if (arch_options.initrd_file) { |
| 66 | - initrd_buf = slurp_file(arch_options.initrd_file, &initrd_size); | 67 | - initrd_buf = slurp_file(arch_options.initrd_file, &initrd_size); |
| 67 | 68 | - | |
| 68 | - /* Create initrd entries in dtb - although at this time | 69 | - /* Create initrd entries in dtb - although at this time |
| 69 | - * they would not point to the correct location */ | 70 | - * they would not point to the correct location */ |
| 70 | - dtb_set_initrd(&dtb_buf, &dtb_length, initrd_buf, initrd_buf + initrd_size); | 71 | - dtb_set_initrd(&dtb_buf, &dtb_length, (off_t)initrd_buf, (off_t)initrd_buf + initrd_size); |
| 71 | - | 72 | - |
| 72 | - initrd_base = add_buffer(info, initrd_buf, initrd_size, | 73 | - initrd_base = add_buffer(info, initrd_buf, initrd_size, |
| 73 | - initrd_size, sizeof(void *), | 74 | - initrd_size, sizeof(void *), |
| @@ -77,6 +78,9 @@ Upstream-Status: Pending | |||
| 77 | - /* Now that the buffer for initrd is prepared, update the dtb | 78 | - /* Now that the buffer for initrd is prepared, update the dtb |
| 78 | - * with an appropriate location */ | 79 | - * with an appropriate location */ |
| 79 | - dtb_set_initrd(&dtb_buf, &dtb_length, initrd_base, initrd_base + initrd_size); | 80 | - dtb_set_initrd(&dtb_buf, &dtb_length, initrd_base, initrd_base + initrd_size); |
| 81 | - | ||
| 82 | - /* Add the initrd parameters to cmdline */ | ||
| 83 | - patch_initrd_info(cmdline_buf, initrd_base, initrd_size); | ||
| 80 | + if (!arch_options.no_dtb) { | 84 | + if (!arch_options.no_dtb) { |
| 81 | + /* MIPS systems that have been converted to use device tree | 85 | + /* MIPS systems that have been converted to use device tree |
| 82 | + * passed through UHI will use commandline in the DTB and | 86 | + * passed through UHI will use commandline in the DTB and |
| @@ -94,7 +98,7 @@ Upstream-Status: Pending | |||
| 94 | + initrd_buf = slurp_file(arch_options.initrd_file, &initrd_size); | 98 | + initrd_buf = slurp_file(arch_options.initrd_file, &initrd_size); |
| 95 | + | 99 | + |
| 96 | + /* Create initrd entries in dtb - although at this time | 100 | + /* Create initrd entries in dtb - although at this time |
| 97 | + * they would not point to the correct location */ | 101 | + * they would not point to the correct location */ |
| 98 | + dtb_set_initrd(&dtb_buf, &dtb_length, (off_t)initrd_buf, (off_t)initrd_buf + initrd_size); | 102 | + dtb_set_initrd(&dtb_buf, &dtb_length, (off_t)initrd_buf, (off_t)initrd_buf + initrd_size); |
| 99 | + | 103 | + |
| 100 | + initrd_base = add_buffer(info, initrd_buf, initrd_size, | 104 | + initrd_base = add_buffer(info, initrd_buf, initrd_size, |
| @@ -103,40 +107,42 @@ Upstream-Status: Pending | |||
| 103 | + pagesize), 0x0fffffff, 1); | 107 | + pagesize), 0x0fffffff, 1); |
| 104 | + | 108 | + |
| 105 | + /* Now that the buffer for initrd is prepared, update the dtb | 109 | + /* Now that the buffer for initrd is prepared, update the dtb |
| 106 | + * with an appropriate location */ | 110 | + * with an appropriate location */ |
| 107 | + dtb_set_initrd(&dtb_buf, &dtb_length, initrd_base, initrd_base + initrd_size); | 111 | + dtb_set_initrd(&dtb_buf, &dtb_length, initrd_base, initrd_base + initrd_size); |
| 112 | + | ||
| 113 | + /* Add the initrd parameters to cmdline */ | ||
| 114 | + patch_initrd_info(cmdline_buf, initrd_base, initrd_size); | ||
| 108 | + } | 115 | + } |
| 109 | } | 116 | } |
| 110 | |||
| 111 | - | ||
| 112 | /* This is a legacy method for commandline passing used | 117 | /* This is a legacy method for commandline passing used |
| 113 | * currently by Octeon CPUs only */ | 118 | * currently by Octeon CPUs only */ |
| 114 | add_buffer(info, cmdline_buf, sizeof(cmdline_buf), | 119 | @@ -233,10 +235,11 @@ int elf_mips_load(int argc, char **argv, |
| 115 | sizeof(cmdline_buf), sizeof(void *), | 120 | sizeof(cmdline_buf), sizeof(void *), |
| 116 | cmdline_addr, 0x0fffffff, 1); | 121 | cmdline_addr, 0x0fffffff, 1); |
| 117 | 122 | ||
| 118 | - add_buffer(info, dtb_buf, dtb_length, dtb_length, 0, | 123 | - add_buffer(info, dtb_buf, dtb_length, dtb_length, 0, |
| 119 | - _ALIGN_UP(kernel_addr + kernel_size, pagesize), | 124 | - _ALIGN_UP(kernel_addr + kernel_size, pagesize), |
| 120 | - 0x0fffffff, 1); | 125 | - 0x0fffffff, 1); |
| 126 | - | ||
| 121 | + if (!arch_options.no_dtb) { | 127 | + if (!arch_options.no_dtb) { |
| 122 | + add_buffer(info, dtb_buf, dtb_length, dtb_length, 0, | 128 | + add_buffer(info, dtb_buf, dtb_length, dtb_length, 0, |
| 123 | + _ALIGN_UP(kernel_addr + kernel_size, pagesize), | 129 | + _ALIGN_UP(kernel_addr + kernel_size, pagesize), |
| 124 | + 0x0fffffff, 1); | 130 | + 0x0fffffff, 1); |
| 125 | + } | 131 | + } |
| 126 | |||
| 127 | return 0; | 132 | return 0; |
| 128 | } | 133 | } |
| 134 | |||
| 129 | --- a/kexec/arch/mips/kexec-mips.c | 135 | --- a/kexec/arch/mips/kexec-mips.c |
| 130 | +++ b/kexec/arch/mips/kexec-mips.c | 136 | +++ b/kexec/arch/mips/kexec-mips.c |
| 131 | @@ -89,6 +89,7 @@ void arch_usage(void) | 137 | @@ -90,6 +90,7 @@ void arch_usage(void) |
| 132 | " --append=STRING Set the kernel command line to STRING.\n" | ||
| 133 | " --dtb=FILE Use FILE as the device tree blob.\n" | 138 | " --dtb=FILE Use FILE as the device tree blob.\n" |
| 134 | " --initrd=FILE Use FILE as initial ramdisk.\n" | 139 | " --initrd=FILE Use FILE as initial ramdisk.\n" |
| 135 | + " --no-dtb Don't try to find device tree\n" | 140 | " --reuse-cmdline Use kernel command line from running system.\n" |
| 141 | + " --no-dtb Don't try to find device tree.\n" | ||
| 136 | ); | 142 | ); |
| 137 | } | 143 | } |
| 138 | 144 | ||
| 139 | @@ -121,6 +122,9 @@ int arch_process_options(int argc, char | 145 | @@ -127,6 +128,9 @@ int arch_process_options(int argc, char |
| 140 | case OPT_RAMDISK: | 146 | case OPT_RAMDISK: |
| 141 | arch_options.initrd_file = optarg; | 147 | arch_options.initrd_file = optarg; |
| 142 | break; | 148 | break; |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/Fix-building-on-x86_64-with-binutils-2.41.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/Fix-building-on-x86_64-with-binutils-2.41.patch deleted file mode 100644 index 4894f044fc..0000000000 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/Fix-building-on-x86_64-with-binutils-2.41.patch +++ /dev/null | |||
| @@ -1,95 +0,0 @@ | |||
| 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Michel Lind <salimma@fedoraproject.org> | ||
| 3 | Date: Tue, 30 Jan 2024 04:14:31 -0600 | ||
| 4 | Subject: [PATCH] Fix building on x86_64 with binutils 2.41 | ||
| 5 | |||
| 6 | Newer versions of the GNU assembler (observed with binutils 2.41) will | ||
| 7 | complain about the ".arch i386" in files assembled with "as --64", | ||
| 8 | with the message "Error: 64bit mode not supported on 'i386'". | ||
| 9 | |||
| 10 | Fix by moving ".arch i386" below the relevant ".code32" directive, so | ||
| 11 | that the assembler is no longer expecting 64-bit instructions to be used | ||
| 12 | by the time that the ".arch i386" directive is encountered. | ||
| 13 | |||
| 14 | Based on similar iPXE fix: | ||
| 15 | https://github.com/ipxe/ipxe/commit/6ca597eee | ||
| 16 | |||
| 17 | Signed-off-by: Michel Lind <michel@michel-slm.name> | ||
| 18 | Signed-off-by: Simon Horman <horms@kernel.org> | ||
| 19 | |||
| 20 | Upstream-Status: Backport [https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/?h=main&id=328de8e00e298f00d7ba6b25dc3950147e9642e6] | ||
| 21 | Signed-off-by: Yoann Congal <yoann.congal@smile.fr> | ||
| 22 | --- | ||
| 23 | purgatory/arch/i386/entry32-16-debug.S | 2 +- | ||
| 24 | purgatory/arch/i386/entry32-16.S | 2 +- | ||
| 25 | purgatory/arch/i386/entry32.S | 2 +- | ||
| 26 | purgatory/arch/i386/setup-x86.S | 2 +- | ||
| 27 | 4 files changed, 4 insertions(+), 4 deletions(-) | ||
| 28 | |||
| 29 | diff --git a/purgatory/arch/i386/entry32-16-debug.S b/purgatory/arch/i386/entry32-16-debug.S | ||
| 30 | index 5167944..12e1164 100644 | ||
| 31 | --- a/purgatory/arch/i386/entry32-16-debug.S | ||
| 32 | +++ b/purgatory/arch/i386/entry32-16-debug.S | ||
| 33 | @@ -25,10 +25,10 @@ | ||
| 34 | .globl entry16_debug_pre32 | ||
| 35 | .globl entry16_debug_first32 | ||
| 36 | .globl entry16_debug_old_first32 | ||
| 37 | - .arch i386 | ||
| 38 | .balign 16 | ||
| 39 | entry16_debug: | ||
| 40 | .code32 | ||
| 41 | + .arch i386 | ||
| 42 | /* Compute where I am running at (assumes esp valid) */ | ||
| 43 | call 1f | ||
| 44 | 1: popl %ebx | ||
| 45 | diff --git a/purgatory/arch/i386/entry32-16.S b/purgatory/arch/i386/entry32-16.S | ||
| 46 | index c051aab..eace095 100644 | ||
| 47 | --- a/purgatory/arch/i386/entry32-16.S | ||
| 48 | +++ b/purgatory/arch/i386/entry32-16.S | ||
| 49 | @@ -20,10 +20,10 @@ | ||
| 50 | #undef i386 | ||
| 51 | .text | ||
| 52 | .globl entry16, entry16_regs | ||
| 53 | - .arch i386 | ||
| 54 | .balign 16 | ||
| 55 | entry16: | ||
| 56 | .code32 | ||
| 57 | + .arch i386 | ||
| 58 | /* Compute where I am running at (assumes esp valid) */ | ||
| 59 | call 1f | ||
| 60 | 1: popl %ebx | ||
| 61 | diff --git a/purgatory/arch/i386/entry32.S b/purgatory/arch/i386/entry32.S | ||
| 62 | index f7a494f..8ce9e31 100644 | ||
| 63 | --- a/purgatory/arch/i386/entry32.S | ||
| 64 | +++ b/purgatory/arch/i386/entry32.S | ||
| 65 | @@ -20,10 +20,10 @@ | ||
| 66 | #undef i386 | ||
| 67 | |||
| 68 | .text | ||
| 69 | - .arch i386 | ||
| 70 | .globl entry32, entry32_regs | ||
| 71 | entry32: | ||
| 72 | .code32 | ||
| 73 | + .arch i386 | ||
| 74 | |||
| 75 | /* Setup a gdt that should that is generally usefully */ | ||
| 76 | lgdt %cs:gdt | ||
| 77 | diff --git a/purgatory/arch/i386/setup-x86.S b/purgatory/arch/i386/setup-x86.S | ||
| 78 | index 201bb2c..a212eed 100644 | ||
| 79 | --- a/purgatory/arch/i386/setup-x86.S | ||
| 80 | +++ b/purgatory/arch/i386/setup-x86.S | ||
| 81 | @@ -21,10 +21,10 @@ | ||
| 82 | #undef i386 | ||
| 83 | |||
| 84 | .text | ||
| 85 | - .arch i386 | ||
| 86 | .globl purgatory_start | ||
| 87 | purgatory_start: | ||
| 88 | .code32 | ||
| 89 | + .arch i386 | ||
| 90 | |||
| 91 | /* Load a gdt so I know what the segment registers are */ | ||
| 92 | lgdt %cs:gdt | ||
| 93 | -- | ||
| 94 | 2.39.2 | ||
| 95 | |||
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64-crashdump-arm64.c-fix-warning.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64-crashdump-arm64.c-fix-warning.patch index a3b7789eba..dd27faf2ab 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64-crashdump-arm64.c-fix-warning.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64-crashdump-arm64.c-fix-warning.patch | |||
| @@ -18,8 +18,6 @@ Upstream-Status: Pending | |||
| 18 | kexec/arch/arm64/crashdump-arm64.c | 3 +++ | 18 | kexec/arch/arm64/crashdump-arm64.c | 3 +++ |
| 19 | 1 file changed, 3 insertions(+) | 19 | 1 file changed, 3 insertions(+) |
| 20 | 20 | ||
| 21 | diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c | ||
| 22 | index 4fd7aa8..890d88f 100644 | ||
| 23 | --- a/kexec/arch/arm64/crashdump-arm64.c | 21 | --- a/kexec/arch/arm64/crashdump-arm64.c |
| 24 | +++ b/kexec/arch/arm64/crashdump-arm64.c | 22 | +++ b/kexec/arch/arm64/crashdump-arm64.c |
| 25 | @@ -13,6 +13,9 @@ | 23 | @@ -13,6 +13,9 @@ |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-arm64.c-workaround-for-getrandom-syscall.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-arm64.c-workaround-for-getrandom-syscall.patch index df7b0a7782..d0ec574b39 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-arm64.c-workaround-for-getrandom-syscall.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-arm64.c-workaround-for-getrandom-syscall.patch | |||
| @@ -22,12 +22,10 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 22 | kexec/arch/arm64/kexec-arm64.c | 12 +++++++++++- | 22 | kexec/arch/arm64/kexec-arm64.c | 12 +++++++++++- |
| 23 | 1 file changed, 11 insertions(+), 1 deletion(-) | 23 | 1 file changed, 11 insertions(+), 1 deletion(-) |
| 24 | 24 | ||
| 25 | diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c | ||
| 26 | index b143e86..88d4168 100644 | ||
| 27 | --- a/kexec/arch/arm64/kexec-arm64.c | 25 | --- a/kexec/arch/arm64/kexec-arm64.c |
| 28 | +++ b/kexec/arch/arm64/kexec-arm64.c | 26 | +++ b/kexec/arch/arm64/kexec-arm64.c |
| 29 | @@ -16,7 +16,11 @@ | 27 | @@ -19,7 +19,11 @@ |
| 30 | #include <elf.h> | 28 | #include <elf_info.h> |
| 31 | 29 | ||
| 32 | #include <unistd.h> | 30 | #include <unistd.h> |
| 33 | + | 31 | + |
| @@ -38,7 +36,7 @@ index b143e86..88d4168 100644 | |||
| 38 | #include <errno.h> | 36 | #include <errno.h> |
| 39 | #include <linux/random.h> | 37 | #include <linux/random.h> |
| 40 | 38 | ||
| 41 | @@ -487,10 +491,16 @@ static int setup_2nd_dtb(struct dtb *dtb, char *command_line, int on_crash) | 39 | @@ -595,10 +599,16 @@ static int setup_2nd_dtb(struct dtb *dtb |
| 42 | * have a valid random seed to pass to the | 40 | * have a valid random seed to pass to the |
| 43 | * secondary kernel. | 41 | * secondary kernel. |
| 44 | */ | 42 | */ |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-image-header.h-add-missing-le64toh.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-image-header.h-add-missing-le64toh.patch index cdcecdf41e..27bcabaa18 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-image-header.h-add-missing-le64toh.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-image-header.h-add-missing-le64toh.patch | |||
| @@ -15,8 +15,6 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 15 | kexec/arch/arm64/image-header.h | 9 +++++++++ | 15 | kexec/arch/arm64/image-header.h | 9 +++++++++ |
| 16 | 1 file changed, 9 insertions(+) | 16 | 1 file changed, 9 insertions(+) |
| 17 | 17 | ||
| 18 | diff --git a/kexec/arch/arm64/image-header.h b/kexec/arch/arm64/image-header.h | ||
| 19 | index 158d411..10ed2d6 100644 | ||
| 20 | --- a/kexec/arch/arm64/image-header.h | 18 | --- a/kexec/arch/arm64/image-header.h |
| 21 | +++ b/kexec/arch/arm64/image-header.h | 19 | +++ b/kexec/arch/arm64/image-header.h |
| 22 | @@ -8,6 +8,15 @@ | 20 | @@ -8,6 +8,15 @@ |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm_crashdump-fix-buffer-align.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm_crashdump-fix-buffer-align.patch deleted file mode 100644 index 89a5d34c83..0000000000 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm_crashdump-fix-buffer-align.patch +++ /dev/null | |||
| @@ -1,44 +0,0 @@ | |||
| 1 | From edf186f45d543e318400195cc25175387ff3f5c4 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Andrea Adami <andrea.adami@gmail.com> | ||
| 3 | Date: Sun, 26 Aug 2018 21:40:06 +0200 | ||
| 4 | Subject: [PATCH] arm- backport from oe-core | ||
| 5 | |||
| 6 | Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | ||
| 7 | |||
| 8 | --- | ||
| 9 | Upstream-Status: Pending | ||
| 10 | |||
| 11 | kexec/arch/arm/crashdump-arm.c | 5 ++++- | ||
| 12 | 1 file changed, 4 insertions(+), 1 deletion(-) | ||
| 13 | |||
| 14 | diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c | ||
| 15 | index daa4788..3f72b38 100644 | ||
| 16 | --- a/kexec/arch/arm/crashdump-arm.c | ||
| 17 | +++ b/kexec/arch/arm/crashdump-arm.c | ||
| 18 | @@ -240,6 +240,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline) | ||
| 19 | void *buf; | ||
| 20 | int err; | ||
| 21 | int last_ranges; | ||
| 22 | + unsigned short align_bit_shift = 20; | ||
| 23 | |||
| 24 | /* | ||
| 25 | * First fetch all the memory (RAM) ranges that we are going to pass to | ||
| 26 | @@ -281,6 +282,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline) | ||
| 27 | |||
| 28 | /* for support LPAE enabled kernel*/ | ||
| 29 | elf_info.class = ELFCLASS64; | ||
| 30 | + align_bit_shift = 21; | ||
| 31 | |||
| 32 | err = crash_create_elf64_headers(info, &elf_info, | ||
| 33 | usablemem_rgns.ranges, | ||
| 34 | @@ -302,8 +304,9 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline) | ||
| 35 | * 1MB) so that available memory passed in kernel command line will be | ||
| 36 | * aligned to 1MB. This is because kernel create_mapping() wants memory | ||
| 37 | * regions to be aligned to SECTION_SIZE. | ||
| 38 | + * The SECTION_SIZE of LPAE kernel is '1UL << 21' defined in pgtable-3level.h | ||
| 39 | */ | ||
| 40 | - elfcorehdr = add_buffer_phys_virt(info, buf, bufsz, bufsz, 1 << 20, | ||
| 41 | + elfcorehdr = add_buffer_phys_virt(info, buf, bufsz, bufsz, 1 << align_bit_shift, | ||
| 42 | crash_kernel_mem.start, | ||
| 43 | crash_kernel_mem.end, -1, 0); | ||
| 44 | |||
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/include_next.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/include_next.patch index 29ea1d9f18..62279f9cb6 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/include_next.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/include_next.patch | |||
| @@ -2,7 +2,7 @@ Upstream-Status: Pending | |||
| 2 | 2 | ||
| 3 | --- a/kexec/Makefile | 3 | --- a/kexec/Makefile |
| 4 | +++ b/kexec/Makefile | 4 | +++ b/kexec/Makefile |
| 5 | @@ -110,7 +110,7 @@ $(KEXEC): $(KEXEC_OBJS) $(UTIL_LIB) | 5 | @@ -116,7 +116,7 @@ $(KEXEC): $(KEXEC_OBJS) $(UTIL_LIB) |
| 6 | @$(MKDIR) -p $(@D) | 6 | @$(MKDIR) -p $(@D) |
| 7 | $(LINK.o) -o $@ $^ $(CFLAGS) $(LIBS) | 7 | $(LINK.o) -o $@ $^ $(CFLAGS) $(LIBS) |
| 8 | 8 | ||
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/kexec-x32.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/kexec-x32.patch deleted file mode 100644 index 3c2594a5d0..0000000000 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/kexec-x32.patch +++ /dev/null | |||
| @@ -1,94 +0,0 @@ | |||
| 1 | From fd40eee42273220fb0050fe10744b10067adc0a7 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: =?UTF-8?q?An=C3=ADbal=20Lim=C3=B3n?= <anibal.limon@linux.intel.com> | ||
| 3 | Date: Fri, 31 Aug 2018 17:31:50 +0200 | ||
| 4 | Subject: [PATCH] x86_64: Add support to build kexec-tools with x32 ABI | ||
| 5 | MIME-Version: 1.0 | ||
| 6 | Content-Type: text/plain; charset=UTF-8 | ||
| 7 | Content-Transfer-Encoding: 8bit | ||
| 8 | |||
| 9 | Summary of changes, | ||
| 10 | |||
| 11 | configure.ac: Add test for detect x32 ABI. | ||
| 12 | purgatory/arch/x86_64/Makefile: Not use mcmodel large when | ||
| 13 | x32 ABI is set. | ||
| 14 | kexec/arch/x86_64/kexec-elf-rel-x86_64.c: When x32 ABI is set | ||
| 15 | use ELFCLASS32 instead of ELFCLASS64. | ||
| 16 | kexec/kexec-syscall.h: Add correct syscall number for x32 ABI. | ||
| 17 | |||
| 18 | Upstream-Status: Submitted | ||
| 19 | |||
| 20 | Signed-off-by: AnÃbal Limón <anibal.limon@linux.intel.com> | ||
| 21 | Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> | ||
| 22 | |||
| 23 | --- | ||
| 24 | configure.ac | 9 +++++++++ | ||
| 25 | kexec/arch/x86_64/kexec-elf-rel-x86_64.c | 4 ++++ | ||
| 26 | kexec/kexec-syscall.h | 4 ++++ | ||
| 27 | purgatory/arch/x86_64/Makefile | 4 +++- | ||
| 28 | 4 files changed, 20 insertions(+), 1 deletion(-) | ||
| 29 | |||
| 30 | diff --git a/configure.ac b/configure.ac | ||
| 31 | index e05d601..c428146 100644 | ||
| 32 | --- a/configure.ac | ||
| 33 | +++ b/configure.ac | ||
| 34 | @@ -54,6 +54,15 @@ case $target_cpu in | ||
| 35 | ;; | ||
| 36 | ia64|x86_64|alpha|m68k ) | ||
| 37 | ARCH="$target_cpu" | ||
| 38 | + | ||
| 39 | + dnl ---Test for x32 ABI in x86_64 | ||
| 40 | + if test "x$ARCH" = "xx86_64" ; then | ||
| 41 | + AC_EGREP_CPP(x32_test, | ||
| 42 | + [#if defined(__x86_64__) && defined (__ILP32__) | ||
| 43 | + x32_test | ||
| 44 | + #endif | ||
| 45 | + ], SUBARCH='x32', SUBARCH='64') | ||
| 46 | + fi | ||
| 47 | ;; | ||
| 48 | * ) | ||
| 49 | AC_MSG_ERROR([unsupported architecture $target_cpu]) | ||
| 50 | diff --git a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c | ||
| 51 | index 761a4ed..1c0e3f8 100644 | ||
| 52 | --- a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c | ||
| 53 | +++ b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c | ||
| 54 | @@ -8,7 +8,11 @@ int machine_verify_elf_rel(struct mem_ehdr *ehdr) | ||
| 55 | if (ehdr->ei_data != ELFDATA2LSB) { | ||
| 56 | return 0; | ||
| 57 | } | ||
| 58 | +#ifdef __ILP32__ | ||
| 59 | + if (ehdr->ei_class != ELFCLASS32) { | ||
| 60 | +#else | ||
| 61 | if (ehdr->ei_class != ELFCLASS64) { | ||
| 62 | +#endif | ||
| 63 | return 0; | ||
| 64 | } | ||
| 65 | if (ehdr->e_machine != EM_X86_64) { | ||
| 66 | diff --git a/kexec/kexec-syscall.h b/kexec/kexec-syscall.h | ||
| 67 | index 2a3794d..3e67078 100644 | ||
| 68 | --- a/kexec/kexec-syscall.h | ||
| 69 | +++ b/kexec/kexec-syscall.h | ||
| 70 | @@ -31,8 +31,12 @@ | ||
| 71 | #define __NR_kexec_load 268 | ||
| 72 | #endif | ||
| 73 | #ifdef __x86_64__ | ||
| 74 | +#ifdef __ILP32__ | ||
| 75 | +#define __NR_kexec_load 528 | ||
| 76 | +#else | ||
| 77 | #define __NR_kexec_load 246 | ||
| 78 | #endif | ||
| 79 | +#endif | ||
| 80 | #ifdef __s390x__ | ||
| 81 | #define __NR_kexec_load 277 | ||
| 82 | #endif | ||
| 83 | diff --git a/purgatory/arch/x86_64/Makefile b/purgatory/arch/x86_64/Makefile | ||
| 84 | index 7300937..4af11e4 100644 | ||
| 85 | --- a/purgatory/arch/x86_64/Makefile | ||
| 86 | +++ b/purgatory/arch/x86_64/Makefile | ||
| 87 | @@ -23,4 +23,6 @@ x86_64_PURGATORY_SRCS += purgatory/arch/i386/console-x86.c | ||
| 88 | x86_64_PURGATORY_SRCS += purgatory/arch/i386/vga.c | ||
| 89 | x86_64_PURGATORY_SRCS += purgatory/arch/i386/pic.c | ||
| 90 | |||
| 91 | -x86_64_PURGATORY_EXTRA_CFLAGS = -mcmodel=large | ||
| 92 | +ifeq ($(SUBARCH),64) | ||
| 93 | + x86_64_PURGATORY_EXTRA_CFLAGS = -mcmodel=large | ||
| 94 | +endif | ||
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/klibc-reboot.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/klibc-reboot.patch index 1c58e92b35..70e9f556b6 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/klibc-reboot.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/klibc-reboot.patch | |||
| @@ -8,16 +8,73 @@ Upstream-Status: Pending | |||
| 8 | kexec/kexec.c | 2 +- | 8 | kexec/kexec.c | 2 +- |
| 9 | 1 file changed, 1 insertion(+), 1 deletion(-) | 9 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 10 | 10 | ||
| 11 | diff --git a/kexec/kexec.c b/kexec/kexec.c | ||
| 12 | index 157c577..5da0d67 100644 | ||
| 13 | --- a/kexec/kexec.c | 11 | --- a/kexec/kexec.c |
| 14 | +++ b/kexec/kexec.c | 12 | +++ b/kexec/kexec.c |
| 15 | @@ -901,7 +901,7 @@ static int my_exec(void) | 13 | @@ -222,8 +222,8 @@ int sort_segments(struct kexec_info *inf |
| 16 | if (xen_present()) | 14 | } |
| 17 | xen_kexec_exec(); | 15 | |
| 18 | else | 16 | unsigned long locate_hole(struct kexec_info *info, |
| 17 | - unsigned long hole_size, unsigned long hole_align, | ||
| 18 | - unsigned long hole_min, unsigned long hole_max, | ||
| 19 | + unsigned long hole_size, unsigned long hole_align, | ||
| 20 | + unsigned long hole_min, unsigned long hole_max, | ||
| 21 | int hole_end) | ||
| 22 | { | ||
| 23 | int i, j; | ||
| 24 | @@ -247,7 +247,7 @@ unsigned long locate_hole(struct kexec_i | ||
| 25 | max_mem_ranges = info->memory_ranges + info->nr_segments; | ||
| 26 | mem_range = xmalloc(max_mem_ranges *sizeof(struct memory_range)); | ||
| 27 | mem_ranges = 0; | ||
| 28 | - | ||
| 29 | + | ||
| 30 | /* Perform a merge on the 2 sorted lists of memory ranges */ | ||
| 31 | for (j = 0, i = 0; i < info->memory_ranges; i++) { | ||
| 32 | unsigned long long sstart, send; | ||
| 33 | @@ -401,7 +401,7 @@ unsigned long add_buffer_phys_virt(struc | ||
| 34 | if (base == ULONG_MAX) { | ||
| 35 | die("locate_hole failed\n"); | ||
| 36 | } | ||
| 37 | - | ||
| 38 | + | ||
| 39 | add_segment_phys_virt(info, buf, bufsz, base, memsz, phys); | ||
| 40 | return base; | ||
| 41 | } | ||
| 42 | @@ -847,7 +847,7 @@ static int my_load(const char *type, int | ||
| 43 | if (!valid_memory_segment(&info, info.segment +i)) { | ||
| 44 | fprintf(stderr, "Invalid memory segment %p - %p\n", | ||
| 45 | info.segment[i].mem, | ||
| 46 | - ((char *)info.segment[i].mem) + | ||
| 47 | + ((char *)info.segment[i].mem) + | ||
| 48 | info.segment[i].memsz); | ||
| 49 | return -1; | ||
| 50 | } | ||
| 51 | @@ -874,9 +874,9 @@ static int my_load(const char *type, int | ||
| 52 | info.kexec_flags); | ||
| 53 | if (result != 0) { | ||
| 54 | /* The load failed, print some debugging information */ | ||
| 55 | - fprintf(stderr, "kexec_load failed: %s\n", | ||
| 56 | + fprintf(stderr, "kexec_load failed: %s\n", | ||
| 57 | strerror(errno)); | ||
| 58 | - fprintf(stderr, "entry = %p flags = 0x%lx\n", | ||
| 59 | + fprintf(stderr, "entry = %p flags = 0x%lx\n", | ||
| 60 | info.entry, info.kexec_flags); | ||
| 61 | print_segments(stderr, &info); | ||
| 62 | } | ||
| 63 | @@ -973,9 +973,9 @@ static int my_exec(void) | ||
| 64 | if ((kexec_flags & KEXEC_LIVE_UPDATE) && !ret) | ||
| 65 | return 0; | ||
| 66 | } else | ||
| 19 | - reboot(LINUX_REBOOT_CMD_KEXEC); | 67 | - reboot(LINUX_REBOOT_CMD_KEXEC); |
| 20 | + reboot(LINUX_REBOOT_CMD_KEXEC, NULL); | 68 | + reboot(LINUX_REBOOT_CMD_KEXEC, NULL); |
| 21 | /* I have failed if I make it here */ | 69 | /* I have failed if I make it here */ |
| 22 | fprintf(stderr, "kexec failed: %s\n", | 70 | - fprintf(stderr, "kexec failed: %s\n", |
| 71 | + fprintf(stderr, "kexec failed: %s\n", | ||
| 23 | strerror(errno)); | 72 | strerror(errno)); |
| 73 | return -1; | ||
| 74 | } | ||
| 75 | @@ -1805,4 +1805,4 @@ int main(int argc, char *argv[]) | ||
| 76 | fflush(stdout); | ||
| 77 | fflush(stderr); | ||
| 78 | return result; | ||
| 79 | -} | ||
| 80 | +} | ||
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/powerpc_change-the-memory-size-limit.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/powerpc_change-the-memory-size-limit.patch index 67a3cac1fa..35d2d6ad16 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/powerpc_change-the-memory-size-limit.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/powerpc_change-the-memory-size-limit.patch | |||
| @@ -21,8 +21,6 @@ Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com> | |||
| 21 | kexec/arch/ppc/kexec-ppc.h | 2 +- | 21 | kexec/arch/ppc/kexec-ppc.h | 2 +- |
| 22 | 1 file changed, 1 insertion(+), 1 deletion(-) | 22 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 23 | 23 | ||
| 24 | diff --git a/kexec/arch/ppc/kexec-ppc.h b/kexec/arch/ppc/kexec-ppc.h | ||
| 25 | index 04e728e..6bae9ec 100644 | ||
| 26 | --- a/kexec/arch/ppc/kexec-ppc.h | 24 | --- a/kexec/arch/ppc/kexec-ppc.h |
| 27 | +++ b/kexec/arch/ppc/kexec-ppc.h | 25 | +++ b/kexec/arch/ppc/kexec-ppc.h |
| 28 | @@ -44,7 +44,7 @@ void dol_ppc_usage(void); | 26 | @@ -44,7 +44,7 @@ void dol_ppc_usage(void); |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_basename.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_basename.patch index 568f19758a..4c65815fdb 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_basename.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_basename.patch | |||
| @@ -12,19 +12,17 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 12 | kexec/arch/i386/x86-linux-setup.c | 4 ++-- | 12 | kexec/arch/i386/x86-linux-setup.c | 4 ++-- |
| 13 | 1 file changed, 2 insertions(+), 2 deletions(-) | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
| 14 | 14 | ||
| 15 | diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c | ||
| 16 | index 6cda12c..5514c1c 100644 | ||
| 17 | --- a/kexec/arch/i386/x86-linux-setup.c | 15 | --- a/kexec/arch/i386/x86-linux-setup.c |
| 18 | +++ b/kexec/arch/i386/x86-linux-setup.c | 16 | +++ b/kexec/arch/i386/x86-linux-setup.c |
| 19 | @@ -304,9 +304,9 @@ static int add_edd_entry(struct x86_linux_param_header *real_mode, | 17 | @@ -332,9 +332,9 @@ static int add_edd_entry(struct x86_linu |
| 20 | memset(edd_info, 0, sizeof(struct edd_info)); | ||
| 21 | 18 | ||
| 22 | /* extract the device number */ | 19 | /* extract the device number */ |
| 23 | - if (sscanf(basename(sysfs_name), "int13_dev%hhx", &devnum) != 1) { | 20 | char* sysfs_name_copy = strdup(sysfs_name); |
| 24 | + if (sscanf(strrchr(sysfs_name,'/') + 1, "int13_dev%hhx", &devnum) != 1) { | 21 | - if (sscanf(basename(sysfs_name_copy), "int13_dev%hhx", &devnum) != 1) { |
| 22 | + if (sscanf(strrchr(sysfs_name_copy,'/') + 1, "int13_dev%hhx", &devnum) != 1) { | ||
| 25 | fprintf(stderr, "Invalid format of int13_dev dir " | 23 | fprintf(stderr, "Invalid format of int13_dev dir " |
| 26 | - "entry: %s\n", basename(sysfs_name)); | 24 | - "entry: %s\n", basename(sysfs_name_copy)); |
| 27 | + "entry: %s\n", strrchr(sysfs_name,'/') + 1); | 25 | + "entry: %s\n", strrchr(sysfs_name_copy,'/') + 1); |
| 26 | free(sysfs_name_copy); | ||
| 28 | return -1; | 27 | return -1; |
| 29 | } | 28 | } |
| 30 | |||
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_kexec_test.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_kexec_test.patch index ecb0d85e26..31ae76ab31 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_kexec_test.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_kexec_test.patch | |||
| @@ -13,12 +13,10 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 13 | Makefile.in | 4 ++-- | 13 | Makefile.in | 4 ++-- |
| 14 | 1 file changed, 2 insertions(+), 2 deletions(-) | 14 | 1 file changed, 2 insertions(+), 2 deletions(-) |
| 15 | 15 | ||
| 16 | diff --git a/Makefile.in b/Makefile.in | ||
| 17 | index dbf1fb6..440730d 100644 | ||
| 18 | --- a/Makefile.in | 16 | --- a/Makefile.in |
| 19 | +++ b/Makefile.in | 17 | +++ b/Makefile.in |
| 20 | @@ -173,8 +173,8 @@ PSRCS:=$(foreach s, $(SRCS), $(PACKAGE_NAME)-$(PACKAGE_VERSION)/$(s)) | 18 | @@ -181,8 +181,8 @@ TARBALL.gz=$(TARBALL).gz |
| 21 | PGSRCS:=$(foreach s, $(GENERATED_SRCS), $(PACKAGE_NAME)-$(PACKAGE_VERSION)/$(s)) | 19 | SRCS:= $(dist) |
| 22 | 20 | ||
| 23 | MAN_PAGES:=$(KEXEC_MANPAGE) $(VMCORE_DMESG_MANPAGE) | 21 | MAN_PAGES:=$(KEXEC_MANPAGE) $(VMCORE_DMESG_MANPAGE) |
| 24 | -BINARIES_i386:=$(KEXEC_TEST) | 22 | -BINARIES_i386:=$(KEXEC_TEST) |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_sys_io.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_sys_io.patch index ef9a411b5c..591654b49d 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_sys_io.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_sys_io.patch | |||
| @@ -11,8 +11,6 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 11 | purgatory/arch/i386/vga.c | 2 +- | 11 | purgatory/arch/i386/vga.c | 2 +- |
| 12 | 2 files changed, 2 insertions(+), 2 deletions(-) | 12 | 2 files changed, 2 insertions(+), 2 deletions(-) |
| 13 | 13 | ||
| 14 | diff --git a/purgatory/arch/i386/pic.c b/purgatory/arch/i386/pic.c | ||
| 15 | index c23c459..c5f7046 100644 | ||
| 16 | --- a/purgatory/arch/i386/pic.c | 14 | --- a/purgatory/arch/i386/pic.c |
| 17 | +++ b/purgatory/arch/i386/pic.c | 15 | +++ b/purgatory/arch/i386/pic.c |
| 18 | @@ -16,7 +16,7 @@ | 16 | @@ -16,7 +16,7 @@ |
| @@ -24,8 +22,6 @@ index c23c459..c5f7046 100644 | |||
| 24 | #include <purgatory.h> | 22 | #include <purgatory.h> |
| 25 | #include "purgatory-x86.h" | 23 | #include "purgatory-x86.h" |
| 26 | 24 | ||
| 27 | diff --git a/purgatory/arch/i386/vga.c b/purgatory/arch/i386/vga.c | ||
| 28 | index e65976c..d079d96 100644 | ||
| 29 | --- a/purgatory/arch/i386/vga.c | 25 | --- a/purgatory/arch/i386/vga.c |
| 30 | +++ b/purgatory/arch/i386/vga.c | 26 | +++ b/purgatory/arch/i386/vga.c |
| 31 | @@ -1,4 +1,4 @@ | 27 | @@ -1,4 +1,4 @@ |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_vfscanf.patch b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_vfscanf.patch index af8467a239..0f61f90d24 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_vfscanf.patch +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_vfscanf.patch | |||
| @@ -12,11 +12,9 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | |||
| 12 | kexec/arch/i386/x86-linux-setup.c | 11 ++++++++++- | 12 | kexec/arch/i386/x86-linux-setup.c | 11 ++++++++++- |
| 13 | 1 file changed, 10 insertions(+), 1 deletion(-) | 13 | 1 file changed, 10 insertions(+), 1 deletion(-) |
| 14 | 14 | ||
| 15 | diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c | ||
| 16 | index 5514c1c..bdb28c6 100644 | ||
| 17 | --- a/kexec/arch/i386/x86-linux-setup.c | 15 | --- a/kexec/arch/i386/x86-linux-setup.c |
| 18 | +++ b/kexec/arch/i386/x86-linux-setup.c | 16 | +++ b/kexec/arch/i386/x86-linux-setup.c |
| 19 | @@ -200,6 +200,8 @@ static int file_scanf(const char *dir, const char *file, const char *scanf_line, | 17 | @@ -215,6 +215,8 @@ static int file_scanf(const char *dir, c |
| 20 | FILE *fp; | 18 | FILE *fp; |
| 21 | int retno; | 19 | int retno; |
| 22 | char filename[PATH_MAX]; | 20 | char filename[PATH_MAX]; |
| @@ -25,7 +23,7 @@ index 5514c1c..bdb28c6 100644 | |||
| 25 | 23 | ||
| 26 | snprintf(filename, PATH_MAX, "%s/%s", dir, file); | 24 | snprintf(filename, PATH_MAX, "%s/%s", dir, file); |
| 27 | filename[PATH_MAX-1] = 0; | 25 | filename[PATH_MAX-1] = 0; |
| 28 | @@ -210,7 +212,14 @@ static int file_scanf(const char *dir, const char *file, const char *scanf_line, | 26 | @@ -225,7 +227,14 @@ static int file_scanf(const char *dir, c |
| 29 | } | 27 | } |
| 30 | 28 | ||
| 31 | va_start(argptr, scanf_line); | 29 | va_start(argptr, scanf_line); |
diff --git a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc_git.bb b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc_git.bb index 2df53ff38e..a6ef7a4d66 100644 --- a/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc_git.bb +++ b/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc_git.bb | |||
| @@ -3,20 +3,19 @@ SUMMARY = "Kexec tools, statically compiled against klibc" | |||
| 3 | HOMEPAGE = "http://kernel.org/pub/linux/utils/kernel/kexec/" | 3 | HOMEPAGE = "http://kernel.org/pub/linux/utils/kernel/kexec/" |
| 4 | SECTION = "kernel/userland" | 4 | SECTION = "kernel/userland" |
| 5 | LICENSE = "GPL-2.0-only" | 5 | LICENSE = "GPL-2.0-only" |
| 6 | LIC_FILES_CHKSUM = "file://COPYING;md5=ea5bed2f60d357618ca161ad539f7c0a \ | 6 | LIC_FILES_CHKSUM = "file://COPYING;md5=570a9b3749dd0463a1778803b12a6dce \ |
| 7 | file://kexec/kexec.c;beginline=1;endline=20;md5=af10f6ae4a8715965e648aa687ad3e09" | 7 | file://kexec/kexec.c;beginline=1;endline=20;md5=af10f6ae4a8715965e648aa687ad3e09" |
| 8 | PV = "2.0.18+git" | 8 | PV = "2.0.32" |
| 9 | 9 | ||
| 10 | DEPENDS = "zlib xz" | 10 | DEPENDS = "zlib xz" |
| 11 | 11 | ||
| 12 | inherit klibc autotools siteinfo | 12 | inherit klibc autotools siteinfo |
| 13 | 13 | ||
| 14 | SRC_URI = "git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git;branch=master" | 14 | SRC_URI = "git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git;branch=master" |
| 15 | SRCREV = "5750980cdbbc33ef75bfba6660295b932376ce15" | 15 | SRCREV = "15d78e5799eea7ec5ea9c5897ae95aaa0ce8970c" |
| 16 | 16 | ||
| 17 | BUILD_PATCHES = "file://0001-force-static-build.patch \ | 17 | BUILD_PATCHES = "file://0001-force-static-build.patch \ |
| 18 | file://0002-Adjust-the-order-of-headers-to-fix-build-for-musl.patch \ | 18 | file://0002-Adjust-the-order-of-headers-to-fix-build-for-musl.patch \ |
| 19 | file://Fix-building-on-x86_64-with-binutils-2.41.patch \ | ||
| 20 | " | 19 | " |
| 21 | 20 | ||
| 22 | KLIBC_PATCHES += " \ | 21 | KLIBC_PATCHES += " \ |
| @@ -26,21 +25,23 @@ KLIBC_PATCHES += " \ | |||
| 26 | file://0006-kexec-syscall.h-work-around-missing-syscall-wrapper.patch \ | 25 | file://0006-kexec-syscall.h-work-around-missing-syscall-wrapper.patch \ |
| 27 | file://0007-kexec.c-add-guard-around-ENOTSUP.patch \ | 26 | file://0007-kexec.c-add-guard-around-ENOTSUP.patch \ |
| 28 | file://0008-kexec.c-replace-mising-BLKGETSIZE64.patch \ | 27 | file://0008-kexec.c-replace-mising-BLKGETSIZE64.patch \ |
| 29 | file://0009-vmcore-dmesg.c-work-around-missing-imaxdiv.patch \ | ||
| 30 | file://0010-fs2dt.c-work-around-missing-getline.patch \ | 28 | file://0010-fs2dt.c-work-around-missing-getline.patch \ |
| 31 | file://0011-purgatory-Makefile-adapt-to-klcc.patch \ | 29 | file://0011-purgatory-Makefile-adapt-to-klcc.patch \ |
| 32 | file://0012-purgatory-string.c-avoid-inclusion-of-string.h.patch \ | 30 | file://0012-purgatory-string.c-avoid-inclusion-of-string.h.patch \ |
| 33 | file://0013-sha256.h-avoid-inclusion-of-sys-types.h.patch \ | 31 | file://0013-sha256.h-avoid-inclusion-of-sys-types.h.patch \ |
| 34 | file://0014-add-if_nameindex-from-musl.patch \ | 32 | file://0014-add-if_nameindex-from-musl.patch \ |
| 35 | file://0015-vmcore-dmesg-fix-warning.patch \ | ||
| 36 | file://klibc-reboot.patch \ | 33 | file://klibc-reboot.patch \ |
| 37 | file://include_next.patch \ | 34 | file://include_next.patch \ |
| 35 | file://0001-kexec-Provide-local-implementation-of-mkstemp-for-kl.patch \ | ||
| 36 | file://0002-kexec-Add-imaxdiv-implementation-for-klibc-builds.patch \ | ||
| 37 | file://0003-kexec-riscv-Add-endian-conversion-macros-for-klibc-b.patch \ | ||
| 38 | file://0004-exec-Define-EM_RISCV-for-klibc-builds.patch \ | ||
| 39 | file://0005-kexec-Disable-memfd_create-for-klibc-builds.patch \ | ||
| 38 | " | 40 | " |
| 39 | 41 | ||
| 40 | WARNING_FIXES = "" | 42 | WARNING_FIXES = "" |
| 41 | FROM_OE_CORE = "file://arm_crashdump-fix-buffer-align.patch \ | 43 | FROM_OE_CORE = "file://powerpc_change-the-memory-size-limit.patch \ |
| 42 | file://powerpc_change-the-memory-size-limit.patch \ | 44 | " |
| 43 | file://kexec-x32.patch" | ||
| 44 | 45 | ||
| 45 | SRC_URI += "${BUILD_PATCHES} ${KLIBC_PATCHES} ${WARNING_FIXES} ${FROM_OE_CORE}" | 46 | SRC_URI += "${BUILD_PATCHES} ${KLIBC_PATCHES} ${WARNING_FIXES} ${FROM_OE_CORE}" |
| 46 | 47 | ||
| @@ -91,4 +92,4 @@ FILES:vmcore-dmesg-klibc = "${sbindir}/vmcore-dmesg" | |||
| 91 | 92 | ||
| 92 | INSANE_SKIP:${PN} = "arch" | 93 | INSANE_SKIP:${PN} = "arch" |
| 93 | 94 | ||
| 94 | COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*|powerpc.*|mips.*)-(linux|freebsd.*)' | 95 | COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*|powerpc.*|mips.*|riscv64.*)-(linux|freebsd.*)' |
