From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 75027@debbugs.gnu.org
Subject: [bug#75027] [PATCH v2 1/3] syscalls: Add ‘kexec-load-file’.
Date: Sat, 28 Dec 2024 15:12:02 +0900 [thread overview]
Message-ID: <87ikr4s5e5.fsf@gmail.com> (raw)
In-Reply-To: <c38e2be82743c57be5da2ed45d85fd7835e51a17.1735233263.git.ludo@gnu.org> ("Ludovic Courtès"'s message of "Thu, 26 Dec 2024 18:21:25 +0100")
Hi Ludovic,
Ludovic Courtès <ludo@gnu.org> writes:
> * guix/build/syscalls.scm (string->utf-8/nul-terminated)
> (kexec-load-file): New procedures.
[...]
> +;; Constants from <linux/kexec.h>.
> +(define KEXEC_FILE_UNLOAD #x00000001)
> +(define KEXEC_FILE_ON_CRASH #x00000002)
> +(define KEXEC_FILE_NO_INITRAMFS #x00000004)
> +(define KEXEC_FILE_DEBUG #x00000008)
> +
> +(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? 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.
> + (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.
> + (_ #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."
> + (let*-values (((command-line)
> + (string->utf-8/nul-terminated command-line))
> + ((ret err)
> + (proc syscall-id kernel-fd initrd-fd
> + (bytevector-length command-line)
> + (bytevector->pointer command-line)
> + flags)))
> + (when (= ret -1)
I checked 'man 2 kexec_file_load*' to make sure:
On success, these system calls returns 0. On error, -1 is returned and
errno is set to indicate the error.
So, looks good.
--
Thanks,
Maxim
next prev parent reply other threads:[~2024-12-28 6:14 UTC|newest]
Thread overview: 15+ 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 [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 7:24 ` [bug#75027] [PATCH v2 0/3] 'guix system reconfigure' loads " 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=87ikr4s5e5.fsf@gmail.com \
--to=maxim.cournoyer@gmail.com \
--cc=75027@debbugs.gnu.org \
--cc=ludo@gnu.org \
/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).