GNU bug report logs - #75402
[PATCH 0/3] Assorted kexec fixes

Previous Next

Package: guix-patches;

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

Date: Mon, 6 Jan 2025 12:58:01 UTC

Severity: normal

Tags: patch

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

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 75402 in the body.
You can then email your comments to 75402 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org:
bug#75402; Package guix-patches. (Mon, 06 Jan 2025 12:58:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Courtès <ludo <at> gnu.org>:
New bug report received and forwarded. Copy sent to guix <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org. (Mon, 06 Jan 2025 12:58:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: guix-patches <at> gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH 0/3] Assorted kexec fixes
Date: Mon,  6 Jan 2025 13:57:22 +0100
Hello,

Here’s a bunch of kexec-related fixes for bugs that have been reported
over the past week.

I checked the ‘kexec_file_load’ binding on i686 and aarch64 this time:
it’s definitely missing on i686, and alright on aarch64.

I’d like to commit it within a couple of days at most.  Feedback welcome!

Ludo’.

Ludovic Courtès (3):
  reconfigure: Do not pass KEXEC_FILE_DEBUG.
  syscalls: Remove wrong syscall ID for ‘kexec_load_file’ on i686.
  reconfigure: Make ‘load-system-for-kexec’ errors non-fatal.

 guix/build/syscalls.scm             |  6 ++---
 guix/scripts/system/reconfigure.scm | 38 +++++++++++++++++++++++------
 tests/syscalls.scm                  |  8 +++---
 3 files changed, 38 insertions(+), 14 deletions(-)


base-commit: 6cb47c374469f7c26775520540e1ed79a8bff674
-- 
2.47.1





Information forwarded to guix <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org:
bug#75402; Package guix-patches. (Mon, 06 Jan 2025 13:00:03 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: 75402 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>,
 nathan <nathan_mail <at> nborghese.com>,
 Simen Endsjø <contact <at> simendsjo.me>
Subject: [PATCH 1/3] reconfigure: Do not pass KEXEC_FILE_DEBUG.
Date: Mon,  6 Jan 2025 13:58:35 +0100
This flag is unsupported in Linux 6.6 and causes ‘kexec_file_load’ to
fail with EINVAL.

Fixes <https://issues.guix.gnu.org/75211>.

* guix/scripts/system/reconfigure.scm (kexec-loading-program): Remove
KEXEC_FILE_DEBUG.
* guix/build/syscalls.scm (KEXEC_FILE_DEBUG): Add comment.

Suggested-by: nathan <nathan_mail <at> nborghese.com>
Reported-by: Simen Endsjø <contact <at> simendsjo.me>
Change-Id: Ia48be7f4cfa9c6352908e4bea6472cd648f866ed
---
 guix/build/syscalls.scm             | 4 ++--
 guix/scripts/system/reconfigure.scm | 5 ++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index 960339e8bf..0f8927844b 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014-2024 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2014-2025 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2015 David Thompson <davet <at> gnu.org>
 ;;; Copyright © 2015 Mark H Weaver <mhw <at> netris.org>
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe <at> gmail.com>
@@ -783,7 +783,7 @@ (define (string->utf-8/nul-terminated str)
 (define KEXEC_FILE_UNLOAD	#x00000001)
 (define KEXEC_FILE_ON_CRASH	#x00000002)
 (define KEXEC_FILE_NO_INITRAMFS	#x00000004)
-(define KEXEC_FILE_DEBUG	#x00000008)
+(define KEXEC_FILE_DEBUG	#x00000008)       ;missing from Linux 6.6
 
 (define kexec-load-file
   (let* ((proc (syscall->procedure int "syscall"
diff --git a/guix/scripts/system/reconfigure.scm b/guix/scripts/system/reconfigure.scm
index e9e16e3422..96e5bff351 100644
--- a/guix/scripts/system/reconfigure.scm
+++ b/guix/scripts/system/reconfigure.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014-2022, 2024 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2014-2022, 2024-2025 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2016 Alex Kost <alezost <at> gmail.com>
 ;;; Copyright © 2016, 2017, 2018 Chris Marusich <cmmarusich <at> gmail.com>
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe <at> gmail.com>
@@ -198,8 +198,7 @@ (define (kexec-loading-program os)
              (kexec-load-file kernel initrd
                               (string-join
                                (list #$@(operating-system-kernel-arguments
-                                         os root-device)))
-                              KEXEC_FILE_DEBUG)))))))
+                                         os root-device))))))))))
 
 (define* (upgrade-shepherd-services eval os)
   "Using EVAL, a monadic procedure taking a single G-Expression as an argument,
-- 
2.47.1





Information forwarded to guix-patches <at> gnu.org:
bug#75402; Package guix-patches. (Mon, 06 Jan 2025 13:00:04 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: 75402 <at> debbugs.gnu.org
Cc: Dariqq <dariqq <at> posteo.net>,
 Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH 2/3] syscalls: Remove wrong syscall ID for ‘kexec_load_file’ on i686.
Date: Mon,  6 Jan 2025 13:58:36 +0100
Fixes <https://issues.guix.gnu.org/75205>.

* guix/build/syscalls.scm (kexec-load-file): Remove syscall ID for i686.
* tests/syscalls.scm ("kexec-load-file"): Accept ENOSYS in addition to
EPERM.

Reported-by: Dariqq <dariqq <at> posteo.net>
Change-Id: I83fe25636addb57533ed88cbfb40107d265b13a7
---
 guix/build/syscalls.scm | 2 +-
 tests/syscalls.scm      | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index 0f8927844b..7e16452462 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -794,8 +794,8 @@ (define kexec-load-file
                                          '*               ;cmdline
                                          unsigned-long))) ;flags
          (syscall-id (match (utsname:machine (uname))
-                       ("i686"    320)
                        ("x86_64"  320)
+                       ;; unsupported on i686
                        ("armv7l"  401)
                        ("aarch64" 294)
                        ("ppc64le" 382)
diff --git a/tests/syscalls.scm b/tests/syscalls.scm
index eef864d097..d2848879d7 100644
--- a/tests/syscalls.scm
+++ b/tests/syscalls.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014-2021, 2024 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2014-2021, 2024-2025 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2015 David Thompson <davet <at> gnu.org>
 ;;; Copyright © 2020 Simon South <simon <at> simonsouth.net>
 ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe <at> gmail.com>
@@ -682,15 +682,15 @@ (define perform-container-tests?
 (when (or (zero? (getuid))
           (not (string-contains %host-type "linux")))
   (test-skip 1))
-(test-equal "kexec-load-file"
-  EPERM
+(test-assert "kexec-load-file"
   (catch 'system-error
     (lambda ()
       (let ((fd1 (open-fdes "/dev/null" O_RDONLY))
             (fd2 (open-fdes "/dev/null" O_RDONLY)))
         (kexec-load-file fd1 fd2 "gnu.repl=yes")))
     (lambda args
-      (system-error-errno args))))
+      (member (system-error-errno args)
+              (list EPERM ENOSYS)))))
 
 (test-end)
 
-- 
2.47.1





Information forwarded to guix <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org:
bug#75402; Package guix-patches. (Mon, 06 Jan 2025 13:00:04 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: 75402 <at> debbugs.gnu.org
Cc: Luis Guilherme Coelho <lgcoelho <at> disroot.org>,
 Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH 3/3] reconfigure: Make ‘load-system-for-kexec’ errors non-fatal.
Date: Mon,  6 Jan 2025 13:58:37 +0100
Partially fixes <https://issues.guix.gnu.org/75215>.

* guix/scripts/system/reconfigure.scm (load-system-for-kexec): Catch
exceptions in the gexp.  Report them outside.

Reported-by: Luis Guilherme Coelho <lgcoelho <at> disroot.org>
Change-Id: Iebcdc92e29b8623a55967d58a4f353abab01631a
---
 guix/scripts/system/reconfigure.scm | 33 +++++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/guix/scripts/system/reconfigure.scm b/guix/scripts/system/reconfigure.scm
index 96e5bff351..d35980590d 100644
--- a/guix/scripts/system/reconfigure.scm
+++ b/guix/scripts/system/reconfigure.scm
@@ -230,10 +230,35 @@ (define* (upgrade-shepherd-services eval os)
                                                             to-restart)))))))
 
 (define (load-system-for-kexec eval os)
-  "Load OS so that it can be rebooted into via kexec, if supported.  Return
-true on success."
-  (eval #~(and (string-contains %host-type "-linux")
-               (primitive-load #$(kexec-loading-program os)))))
+  "Load OS so that it can be rebooted into via kexec, if supported.  Print a
+warning in case of failure."
+  (mlet %store-monad
+      ((result (eval
+                #~(and (string-contains %host-type "-linux")
+                       (with-exception-handler
+                           (lambda (c)
+                             (define kind-and-args?
+                               (exception-predicate &exception-with-kind-and-args))
+
+                             (list 'exception
+                                   (if (kind-and-args? c)
+                                       (call-with-output-string
+                                         (lambda (port)
+                                           (print-exception port #f
+                                                            (exception-kind c)
+                                                            (exception-args c))))
+                                       (object->string c))))
+                         (lambda ()
+                           (primitive-load #$(kexec-loading-program os))
+                           'success)
+                         #:unwind? #t)))))
+    (match result
+      ('success
+       (return #t))
+      (('exception message)
+       (warning (G_ "failed to load operating system for kexec: ~a~%")
+                message)
+       (return #f)))))
 
 
 ;;;
-- 
2.47.1





Information forwarded to guix-patches <at> gnu.org:
bug#75402; Package guix-patches. (Tue, 07 Jan 2025 10:42:01 GMT) Full text and rfc822 format available.

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

From: Tomas Volf <~@wolfsden.cz>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, 75402 <at> debbugs.gnu.org,
 Tobias Geerinckx-Rice <me <at> tobias.gr>, Mathieu Othacehe <othacehe <at> gnu.org>,
 Christopher Baines <guix <at> cbaines.net>
Subject: Re: [bug#75402] [PATCH 0/3] Assorted kexec fixes
Date: Tue, 07 Jan 2025 11:41:43 +0100
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:

> Hello,
>
> Here’s a bunch of kexec-related fixes for bugs that have been reported
> over the past week.
>
> I checked the ‘kexec_file_load’ binding on i686 and aarch64 this time:
> it’s definitely missing on i686, and alright on aarch64.
>
> I’d like to commit it within a couple of days at most.  Feedback
> welcome!

While I am hardly an expert here, the changes look reasonable.  One
feature request though.  I think it would be nice to get --no-kexec for
guix-deploy as well :)

>
> Ludo’.
>
> Ludovic Courtès (3):
>   reconfigure: Do not pass KEXEC_FILE_DEBUG.
>   syscalls: Remove wrong syscall ID for ‘kexec_load_file’ on i686.
>   reconfigure: Make ‘load-system-for-kexec’ errors non-fatal.
>
>  guix/build/syscalls.scm             |  6 ++---
>  guix/scripts/system/reconfigure.scm | 38 +++++++++++++++++++++++------
>  tests/syscalls.scm                  |  8 +++---
>  3 files changed, 38 insertions(+), 14 deletions(-)
>
>
> base-commit: 6cb47c374469f7c26775520540e1ed79a8bff674

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#75402; Package guix-patches. (Tue, 07 Jan 2025 10:49:01 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Tomas Volf <~@wolfsden.cz>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, 75402 <at> debbugs.gnu.org,
 Tobias Geerinckx-Rice <me <at> tobias.gr>, Mathieu Othacehe <othacehe <at> gnu.org>,
 Christopher Baines <guix <at> cbaines.net>
Subject: Re: [bug#75402] [PATCH 0/3] Assorted kexec fixes
Date: Tue, 07 Jan 2025 11:48:18 +0100
Tomas Volf <~@wolfsden.cz> skribis:

> Ludovic Courtès <ludo <at> gnu.org> writes:
>
>> Hello,
>>
>> Here’s a bunch of kexec-related fixes for bugs that have been reported
>> over the past week.
>>
>> I checked the ‘kexec_file_load’ binding on i686 and aarch64 this time:
>> it’s definitely missing on i686, and alright on aarch64.
>>
>> I’d like to commit it within a couple of days at most.  Feedback
>> welcome!
>
> While I am hardly an expert here, the changes look reasonable.

Cool.

> One feature request though.  I think it would be nice to get
> --no-kexec for guix-deploy as well :)

Good point.  I’m not sure where to put it though.  In
<machine-ssh-configuration>?

Thanks!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#75402; Package guix-patches. (Tue, 07 Jan 2025 10:59:02 GMT) Full text and rfc822 format available.

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

From: Tomas Volf <~@wolfsden.cz>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, 75402 <at> debbugs.gnu.org,
 Tobias Geerinckx-Rice <me <at> tobias.gr>, Mathieu Othacehe <othacehe <at> gnu.org>,
 Christopher Baines <guix <at> cbaines.net>
Subject: Re: [bug#75402] [PATCH 0/3] Assorted kexec fixes
Date: Tue, 07 Jan 2025 11:58:02 +0100
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:

> Tomas Volf <~@wolfsden.cz> skribis:
>
>> Ludovic Courtès <ludo <at> gnu.org> writes:
>>
>>> Hello,
>>>
>>> Here’s a bunch of kexec-related fixes for bugs that have been reported
>>> over the past week.
>>>
>>> I checked the ‘kexec_file_load’ binding on i686 and aarch64 this time:
>>> it’s definitely missing on i686, and alright on aarch64.
>>>
>>> I’d like to commit it within a couple of days at most.  Feedback
>>> welcome!
>>
>> While I am hardly an expert here, the changes look reasonable.
>
> Cool.
>
>> One feature request though.  I think it would be nice to get
>> --no-kexec for guix-deploy as well :)
>
> Good point.  I’m not sure where to put it though.  In
> <machine-ssh-configuration>?

I am asking for a command line argument.  Not sure if that does answer
the question.  I am not familiar enough with this part to suggest how to
wire the option through the program flow.

On a separate note, if we would want to disable the kexec in the
definition, I feel like operating-system would be the most fitting
place.  Reason being that either I want to kexec the specific system or
I do not want to kexec it.  But I would expect that to rarely correlate
with the deployment method.  Sometimes I reconfigure the system via
guix-deploy, sometimes (when I break the networking) via
guix-system-reconfigure from USB drive, and it would seem to make sense
to have kexec behave the same way for both of the approaches.

>
> Thanks!
>
> Ludo’.

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
[signature.asc (application/pgp-signature, inline)]

Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Tue, 07 Jan 2025 18:09:02 GMT) Full text and rfc822 format available.

Notification sent to Ludovic Courtès <ludo <at> gnu.org>:
bug acknowledged by developer. (Tue, 07 Jan 2025 18:09:02 GMT) Full text and rfc822 format available.

Message #28 received at 75402-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Tomas Volf <~@wolfsden.cz>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, Mathieu Othacehe <othacehe <at> gnu.org>,
 Tobias Geerinckx-Rice <me <at> tobias.gr>, Christopher Baines <guix <at> cbaines.net>,
 75402-done <at> debbugs.gnu.org
Subject: Re: [bug#75402] [PATCH 0/3] Assorted kexec fixes
Date: Tue, 07 Jan 2025 19:08:29 +0100
Pushed:

  a6642650a7 * reconfigure: Make ‘load-system-for-kexec’ errors non-fatal.
  410a359d4a * syscalls: Remove wrong syscall ID for ‘kexec_load_file’ on i686.
  d8b7259197 * reconfigure: Do not pass KEXEC_FILE_DEBUG.

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#75402; Package guix-patches. (Tue, 07 Jan 2025 18:13:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Tomas Volf <~@wolfsden.cz>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, 75402 <at> debbugs.gnu.org,
 Tobias Geerinckx-Rice <me <at> tobias.gr>, Mathieu Othacehe <othacehe <at> gnu.org>,
 Christopher Baines <guix <at> cbaines.net>
Subject: Re: [bug#75402] [PATCH 0/3] Assorted kexec fixes
Date: Tue, 07 Jan 2025 19:12:43 +0100
Hi,

Tomas Volf <~@wolfsden.cz> skribis:

>>> One feature request though.  I think it would be nice to get
>>> --no-kexec for guix-deploy as well :)
>>
>> Good point.  I’m not sure where to put it though.  In
>> <machine-ssh-configuration>?
>
> I am asking for a command line argument.  Not sure if that does answer
> the question.  I am not familiar enough with this part to suggest how to
> wire the option through the program flow.

The reason I was suggesting this is that authorize?, allow-downgrades?,
safety-checks? are already part of <machine-ssh-configuration>.  These
cannot really be a command-line option… for reasons that escape me right
now.  :-)  But anyway, I thought we’d be in the same situation here.

> On a separate note, if we would want to disable the kexec in the
> definition, I feel like operating-system would be the most fitting
> place.  Reason being that either I want to kexec the specific system or
> I do not want to kexec it.  But I would expect that to rarely correlate
> with the deployment method.  Sometimes I reconfigure the system via
> guix-deploy, sometimes (when I break the networking) via
> guix-system-reconfigure from USB drive, and it would seem to make sense
> to have kexec behave the same way for both of the approaches.

Hmm I see.  The way I saw it, kexec loading is a bonus that doesn’t cost
much, which is why it’s opt-out.  It didn’t occur to me that one would
really want to control that to the level you describe.

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 05 Feb 2025 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 36 days ago.

Previous Next


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