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


Message #41 received at 75027 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 75027 <at> debbugs.gnu.org
Subject: Re: [bug#75027] [PATCH v2 1/3] syscalls: Add ‘kexec-load-file’.
Date: Sat, 28 Dec 2024 15:12:02 +0900
Hi Ludovic,

Ludovic Courtès <ludo <at> 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




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.