]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
syscall: add kexec_file_load to the generated override header
authorDaan De Meyer <daan@amutable.com>
Tue, 12 May 2026 19:54:06 +0000 (21:54 +0200)
committerDaan De Meyer <daan@amutable.com>
Wed, 13 May 2026 06:51:28 +0000 (08:51 +0200)
This makes __NR_kexec_file_load available on architectures where the kernel
UAPI headers don't define it, matching the runtime fallback path in
src/libc/kexec.c which is gated on #ifdef __NR_kexec_file_load.

src/include/override/sys/generate-syscall.py
src/include/override/sys/syscall.h

index 1c90ad0e384029075dc98a5848d631504fdd0be1..4391df6da349ba9dc814793e5760fbf2a5e227f9 100755 (executable)
@@ -7,6 +7,7 @@ import functools
 # We only generate numbers for a dozen or so syscalls
 SYSCALLS = [
     'fchmodat2',     # defined in glibc header since glibc-2.39
+    'kexec_file_load',
     'open_tree_attr',
     'quotactl_fd',   # defined in glibc header since glibc-2.35
     'removexattrat',
index 0233f254b421c71ad8564e9f3ad759b4dd8ab4d5..108885b725a311af20c3bb5e7ae298999732abf4 100644 (file)
@@ -124,6 +124,76 @@ static_assert(__NR_fchmodat2 == systemd_NR_fchmodat2, "");
 #  endif
 #endif
 
+#ifndef __IGNORE_kexec_file_load
+#  if defined(__aarch64__)
+#    define systemd_NR_kexec_file_load 294
+#  elif defined(__alpha__)
+#    define systemd_NR_kexec_file_load -1
+#  elif defined(__arc__) || defined(__tilegx__)
+#    define systemd_NR_kexec_file_load 294
+#  elif defined(__arm__)
+#    define systemd_NR_kexec_file_load 401
+#  elif defined(__i386__)
+#    define systemd_NR_kexec_file_load -1
+#  elif defined(__ia64__)
+#    define systemd_NR_kexec_file_load -1
+#  elif defined(__loongarch_lp64)
+#    define systemd_NR_kexec_file_load 294
+#  elif defined(__m68k__)
+#    define systemd_NR_kexec_file_load -1
+#  elif defined(_MIPS_SIM)
+#    if _MIPS_SIM == _MIPS_SIM_ABI32
+#      define systemd_NR_kexec_file_load -1
+#    elif _MIPS_SIM == _MIPS_SIM_NABI32
+#      define systemd_NR_kexec_file_load -1
+#    elif _MIPS_SIM == _MIPS_SIM_ABI64
+#      define systemd_NR_kexec_file_load -1
+#    else
+#      error "Unknown MIPS ABI"
+#    endif
+#  elif defined(__hppa__)
+#    define systemd_NR_kexec_file_load 355
+#  elif defined(__powerpc__)
+#    define systemd_NR_kexec_file_load 382
+#  elif defined(__riscv)
+#    if __riscv_xlen == 32
+#      define systemd_NR_kexec_file_load 294
+#    elif __riscv_xlen == 64
+#      define systemd_NR_kexec_file_load 294
+#    else
+#      error "Unknown RISC-V ABI"
+#    endif
+#  elif defined(__s390__)
+#    define systemd_NR_kexec_file_load 381
+#  elif defined(__sh__)
+#    define systemd_NR_kexec_file_load -1
+#  elif defined(__sparc__)
+#    define systemd_NR_kexec_file_load -1
+#  elif defined(__x86_64__)
+#    if defined(__ILP32__)
+#      define systemd_NR_kexec_file_load (320 | /* __X32_SYSCALL_BIT */ 0x40000000)
+#    else
+#      define systemd_NR_kexec_file_load 320
+#    endif
+#  elif !defined(missing_arch_template)
+#    warning "kexec_file_load() syscall number is unknown for your architecture"
+#  endif
+
+/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
+#  if defined __NR_kexec_file_load && __NR_kexec_file_load >= 0
+#    if defined systemd_NR_kexec_file_load
+static_assert(__NR_kexec_file_load == systemd_NR_kexec_file_load, "");
+#    endif
+#  else
+#    if defined __NR_kexec_file_load
+#      undef __NR_kexec_file_load
+#    endif
+#    if defined systemd_NR_kexec_file_load && systemd_NR_kexec_file_load >= 0
+#      define __NR_kexec_file_load systemd_NR_kexec_file_load
+#    endif
+#  endif
+#endif
+
 #ifndef __IGNORE_open_tree_attr
 #  if defined(__aarch64__)
 #    define systemd_NR_open_tree_attr 467