GNU bug report logs - #75027
[PATCH 0/3] 'guix system reconfigure' loads system for kexec reboot

Previous Next

Package: guix-patches;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Sun, 22 Dec 2024 15:57:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ludovic Courtès <ludo <at> gnu.org>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 75027 <at> debbugs.gnu.org
Subject: [bug#75027] [PATCH v2 1/3] syscalls: Add ‘kexec-load-file’.
Date: Sat, 28 Dec 2024 22:32:23 +0100
[Message part 1 (text/plain, inline)]
Hi Maxim,

Maxim Cournoyer <maxim.cournoyer <at> gmail.com> skribis:

>> +(define kexec-load-file
>> +  (let* ((proc (syscall->procedure int "syscall"
>> +                                   (list long             ;sysno
>> +                                         int              ;kernel fd
>> +                                         int              ;initrd fd
>> +                                         unsigned-long    ;cmdline length
>> +                                         '*               ;cmdline
>> +                                         unsigned-long))) ;flags
>> +         ;; TODO: Don't do this.
>
> Why this TODO?  "Don't do this" is not explicit enough; what would be
> preferable to do here, but can't be done now for some reason?

The TODO is actually copy/pasted for a few lines above, but I agree it’s
not very clear nor helpful.  Presumably it’s here to mean that using the
‘syscall’ function and having to record syscall numbers of each
architecture is not great.  There’s no alternative though, at this time.

> Could we instead detect the error as returned by the syscall when it's
> not implemented, and throw/report the error accordingly?  I see that's
> kind of done below (a misc-error is raised) -- I think we can remove
> this special handling already and let the error be throw if it's not
> implemented -- this removes the need to remember to come back here to
> edit the list of supported systems the day they gain support.

Yes.  Plus I got the magic numbers wrong it seems (protip: it’s easier
to grep glibc than Linux to get them), so this gives us this change:

[Message part 2 (text/x-patch, inline)]
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index f8c9937f54..960339e8bf 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -793,20 +793,24 @@ (define kexec-load-file
                                          unsigned-long    ;cmdline length
                                          '*               ;cmdline
                                          unsigned-long))) ;flags
-         ;; TODO: Don't do this.
          (syscall-id (match (utsname:machine (uname))
                        ("i686"    320)
                        ("x86_64"  320)
                        ("armv7l"  401)
-                       ("aarch64" 401)
-                       ;; XXX: There's apparently no support for ppc64le and
-                       ;; riscv64.
+                       ("aarch64" 294)
+                       ("ppc64le" 382)
+                       ("riscv64" 294)
                        (_ #f))))
     (lambda* (kernel-fd initrd-fd command-line #:optional (flags 0))
       "Load for eventual use of kexec(8) the Linux kernel from
 @var{kernel-fd}, its initial RAM disk from @var{initrd-fd}, with the given
 @var{command-line} (a string).  Optionally, @var{flags} can be a bitwise or of
 the KEXEC_FILE_* constants."
+      (unless syscall-id
+        (throw 'system-error "kexec-load-file" "~A"
+               (list (strerror ENOSYS))
+               (list ENOSYS)))
+
       (let*-values (((command-line)
                      (string->utf-8/nul-terminated command-line))
                     ((ret err)
[Message part 3 (text/plain, inline)]
Thanks,
Ludo’.

This bug report was last modified 215 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.