guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#75027] [PATCH v2 1/3] syscalls: Add ‘kexec-load-file’.


From: Ludovic Courtès
Subject: [bug#75027] [PATCH v2 1/3] syscalls: Add ‘kexec-load-file’.
Date: Sat, 28 Dec 2024 22:32:23 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Hi Maxim,

Maxim Cournoyer <maxim.cournoyer@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:

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)
Thanks,
Ludo’.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]