unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Cc: 75027@debbugs.gnu.org
Subject: [bug#75027] [PATCH v2 1/3] syscalls: Add ‘kexec-load-file’.
Date: Sat, 28 Dec 2024 22:32:23 +0100	[thread overview]
Message-ID: <8734i7trx4.fsf@gnu.org> (raw)
In-Reply-To: <87ikr4s5e5.fsf@gmail.com> (Maxim Cournoyer's message of "Sat, 28 Dec 2024 15:12:02 +0900")

[-- Attachment #1: Type: text/plain, Size: 1649 bytes --]

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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1541 bytes --]

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)

[-- Attachment #3: Type: text/plain, Size: 21 bytes --]


Thanks,
Ludo’.

  reply	other threads:[~2024-12-28 21:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-22 15:56 [bug#75027] [PATCH 0/3] 'guix system reconfigure' loads system for kexec reboot Ludovic Courtès
2024-12-22 15:57 ` [bug#75027] [PATCH 1/3] syscalls: Add ‘kexec-load-file’ Ludovic Courtès
2024-12-22 15:57 ` [bug#75027] [PATCH 2/3] system: Export ‘…-initrd-file’ and ‘…-root-file-system’ Ludovic Courtès
2024-12-22 15:57 ` [bug#75027] [PATCH 3/3] reconfigure: Call ‘kexec-load-file’ Ludovic Courtès
2024-12-22 21:47 ` [bug#75027] [PATCH 0/3] 'guix system reconfigure' loads system for kexec reboot Jakob Kirsch via Guix-patches via
     [not found]   ` <87y106ej9v.fsf@gnu.org>
2024-12-23 18:24     ` Jakob Kirsch via Guix-patches via
2024-12-26 17:25       ` Ludovic Courtès
2024-12-26 17:21 ` [bug#75027] [PATCH v2 " Ludovic Courtès
2024-12-26 17:21   ` [bug#75027] [PATCH v2 1/3] syscalls: Add ‘kexec-load-file’ Ludovic Courtès
2024-12-28  6:12     ` Maxim Cournoyer
2024-12-28 21:32       ` Ludovic Courtès [this message]
2024-12-26 17:21   ` [bug#75027] [PATCH v2 2/3] system: Export ‘…-initrd-file’ and ‘…-root-file-system’ Ludovic Courtès
2024-12-28  6:12     ` Maxim Cournoyer
2024-12-26 17:21   ` [bug#75027] [PATCH v2 3/3] reconfigure: Support loading the system for kexec reboot Ludovic Courtès
2024-12-28  7:22     ` Maxim Cournoyer
2024-12-28 21:46       ` Ludovic Courtès
2024-12-28  7:24   ` [bug#75027] [PATCH v2 0/3] 'guix system reconfigure' loads " Maxim Cournoyer
2024-12-28 22:18     ` Ludovic Courtès
2024-12-29  2:23       ` Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8734i7trx4.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=75027@debbugs.gnu.org \
    --cc=maxim.cournoyer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).