unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#75402] [PATCH 0/3] Assorted kexec fixes
@ 2025-01-06 12:57 Ludovic Courtès
  2025-01-06 12:58 ` [bug#75402] [PATCH 1/3] reconfigure: Do not pass KEXEC_FILE_DEBUG Ludovic Courtès
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Ludovic Courtès @ 2025-01-06 12:57 UTC (permalink / raw)
  To: 75402
  Cc: Ludovic Courtès, Christopher Baines, Josselin Poiret,
	Ludovic Courtès, Mathieu Othacehe, Simon Tournier,
	Tobias Geerinckx-Rice

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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* [bug#75402] [PATCH 1/3] reconfigure: Do not pass KEXEC_FILE_DEBUG.
  2025-01-06 12:57 [bug#75402] [PATCH 0/3] Assorted kexec fixes Ludovic Courtès
@ 2025-01-06 12:58 ` Ludovic Courtès
  2025-01-06 12:58 ` [bug#75402] [PATCH 2/3] syscalls: Remove wrong syscall ID for ‘kexec_load_file’ on i686 Ludovic Courtès
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2025-01-06 12:58 UTC (permalink / raw)
  To: 75402
  Cc: Ludovic Courtès, nathan, Simen Endsjø,
	Christopher Baines, Josselin Poiret, Ludovic Courtès,
	Mathieu Othacehe, Simon Tournier, Tobias Geerinckx-Rice

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@nborghese.com>
Reported-by: Simen Endsjø <contact@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@gnu.org>
+;;; Copyright © 2014-2025 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@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@gnu.org>
+;;; Copyright © 2014-2022, 2024-2025 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016 Alex Kost <alezost@gmail.com>
 ;;; Copyright © 2016, 2017, 2018 Chris Marusich <cmmarusich@gmail.com>
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@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





^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [bug#75402] [PATCH 2/3] syscalls: Remove wrong syscall ID for ‘kexec_load_file’ on i686.
  2025-01-06 12:57 [bug#75402] [PATCH 0/3] Assorted kexec fixes Ludovic Courtès
  2025-01-06 12:58 ` [bug#75402] [PATCH 1/3] reconfigure: Do not pass KEXEC_FILE_DEBUG Ludovic Courtès
@ 2025-01-06 12:58 ` Ludovic Courtès
  2025-01-06 12:58 ` [bug#75402] [PATCH 3/3] reconfigure: Make ‘load-system-for-kexec’ errors non-fatal Ludovic Courtès
  2025-01-07 10:41 ` [bug#75402] [PATCH 0/3] Assorted kexec fixes Tomas Volf
  3 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2025-01-06 12:58 UTC (permalink / raw)
  To: 75402; +Cc: Dariqq, Ludovic Courtès

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@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@gnu.org>
+;;; Copyright © 2014-2021, 2024-2025 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
 ;;; Copyright © 2020 Simon South <simon@simonsouth.net>
 ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@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





^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [bug#75402] [PATCH 3/3] reconfigure: Make ‘load-system-for-kexec’ errors non-fatal.
  2025-01-06 12:57 [bug#75402] [PATCH 0/3] Assorted kexec fixes Ludovic Courtès
  2025-01-06 12:58 ` [bug#75402] [PATCH 1/3] reconfigure: Do not pass KEXEC_FILE_DEBUG Ludovic Courtès
  2025-01-06 12:58 ` [bug#75402] [PATCH 2/3] syscalls: Remove wrong syscall ID for ‘kexec_load_file’ on i686 Ludovic Courtès
@ 2025-01-06 12:58 ` Ludovic Courtès
  2025-01-07 10:41 ` [bug#75402] [PATCH 0/3] Assorted kexec fixes Tomas Volf
  3 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2025-01-06 12:58 UTC (permalink / raw)
  To: 75402
  Cc: Luis Guilherme Coelho, Ludovic Courtès, Christopher Baines,
	Josselin Poiret, Ludovic Courtès, Mathieu Othacehe,
	Simon Tournier, Tobias Geerinckx-Rice

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@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)))))
 
 \f
 ;;;
-- 
2.47.1





^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [bug#75402] [PATCH 0/3] Assorted kexec fixes
  2025-01-06 12:57 [bug#75402] [PATCH 0/3] Assorted kexec fixes Ludovic Courtès
                   ` (2 preceding siblings ...)
  2025-01-06 12:58 ` [bug#75402] [PATCH 3/3] reconfigure: Make ‘load-system-for-kexec’ errors non-fatal Ludovic Courtès
@ 2025-01-07 10:41 ` Tomas Volf
  2025-01-07 10:48   ` Ludovic Courtès
  3 siblings, 1 reply; 9+ messages in thread
From: Tomas Volf @ 2025-01-07 10:41 UTC (permalink / raw)
  To: Ludovic Courtès
  Cc: Josselin Poiret, Simon Tournier, 75402, Tobias Geerinckx-Rice,
	Mathieu Othacehe, Christopher Baines

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

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 853 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [bug#75402] [PATCH 0/3] Assorted kexec fixes
  2025-01-07 10:41 ` [bug#75402] [PATCH 0/3] Assorted kexec fixes Tomas Volf
@ 2025-01-07 10:48   ` Ludovic Courtès
  2025-01-07 10:58     ` Tomas Volf
  2025-01-07 18:08     ` bug#75402: " Ludovic Courtès
  0 siblings, 2 replies; 9+ messages in thread
From: Ludovic Courtès @ 2025-01-07 10:48 UTC (permalink / raw)
  To: Tomas Volf
  Cc: Josselin Poiret, Simon Tournier, 75402, Tobias Geerinckx-Rice,
	Mathieu Othacehe, Christopher Baines

Tomas Volf <~@wolfsden.cz> skribis:

> Ludovic Courtès <ludo@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’.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [bug#75402] [PATCH 0/3] Assorted kexec fixes
  2025-01-07 10:48   ` Ludovic Courtès
@ 2025-01-07 10:58     ` Tomas Volf
  2025-01-07 18:12       ` Ludovic Courtès
  2025-01-07 18:08     ` bug#75402: " Ludovic Courtès
  1 sibling, 1 reply; 9+ messages in thread
From: Tomas Volf @ 2025-01-07 10:58 UTC (permalink / raw)
  To: Ludovic Courtès
  Cc: Josselin Poiret, Simon Tournier, 75402, Tobias Geerinckx-Rice,
	Mathieu Othacehe, Christopher Baines

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

Ludovic Courtès <ludo@gnu.org> writes:

> Tomas Volf <~@wolfsden.cz> skribis:
>
>> Ludovic Courtès <ludo@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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 853 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#75402: [PATCH 0/3] Assorted kexec fixes
  2025-01-07 10:48   ` Ludovic Courtès
  2025-01-07 10:58     ` Tomas Volf
@ 2025-01-07 18:08     ` Ludovic Courtès
  1 sibling, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2025-01-07 18:08 UTC (permalink / raw)
  To: Tomas Volf
  Cc: Josselin Poiret, Simon Tournier, Mathieu Othacehe,
	Tobias Geerinckx-Rice, Christopher Baines, 75402-done

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’.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [bug#75402] [PATCH 0/3] Assorted kexec fixes
  2025-01-07 10:58     ` Tomas Volf
@ 2025-01-07 18:12       ` Ludovic Courtès
  0 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2025-01-07 18:12 UTC (permalink / raw)
  To: Tomas Volf
  Cc: Josselin Poiret, Simon Tournier, 75402, Tobias Geerinckx-Rice,
	Mathieu Othacehe, Christopher Baines

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’.




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-01-07 18:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-06 12:57 [bug#75402] [PATCH 0/3] Assorted kexec fixes Ludovic Courtès
2025-01-06 12:58 ` [bug#75402] [PATCH 1/3] reconfigure: Do not pass KEXEC_FILE_DEBUG Ludovic Courtès
2025-01-06 12:58 ` [bug#75402] [PATCH 2/3] syscalls: Remove wrong syscall ID for ‘kexec_load_file’ on i686 Ludovic Courtès
2025-01-06 12:58 ` [bug#75402] [PATCH 3/3] reconfigure: Make ‘load-system-for-kexec’ errors non-fatal Ludovic Courtès
2025-01-07 10:41 ` [bug#75402] [PATCH 0/3] Assorted kexec fixes Tomas Volf
2025-01-07 10:48   ` Ludovic Courtès
2025-01-07 10:58     ` Tomas Volf
2025-01-07 18:12       ` Ludovic Courtès
2025-01-07 18:08     ` bug#75402: " Ludovic Courtès

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).