From nobody Tue Nov 04 19:22:41 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4d1JJ13Z6Tz65DMP; Tue, 04 Nov 2025 19:22:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4d1JJ12qNqz41cg; Tue, 04 Nov 2025 19:22:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762284161; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gq0R24e1GHbFXYskEz1H15ZXWG/Hgqt0IE98KgsO2rc=; b=Rf84LCKPuxWPHbGv5Yuw13rzNFAXdev+G2VMq+h1lOsxkLep9Z5bxmJnElClOCZxah05EB NvVWRNJI7KC144tui2puGG5aghnbjTLnc620+fd8df335TX8jRxBjKs8q+AI0sMohBHJhg Q1cQ12tQAv4nDu3H3515ZEoEQGn+MP7XYcwINU+X6xzSOEvZ6bI6gaEKryOOyN63SBDPQ3 o5sK0GzOGQgEMZ9Pgou3YvEZUNZOoPQ1iYF3cuDJWQZrqODYlVtI7kdU9GhDdlWIVzQMHI CizBaf0jhZLLLbDc6nX2ZXAXNx7MO2XDo+UobqoHREaZCauis2QZuZW6D9PtEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762284161; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gq0R24e1GHbFXYskEz1H15ZXWG/Hgqt0IE98KgsO2rc=; b=EGzfyIu1NIo4MvpFJa243xWpRV7dAND6yrrP8hvkiY5fgL6UtVHl5nS3s0n/C4CZj0oz8V gUnSpRa9q/v28SOu7/d9V0EVCkxnLYF77BbMrn/qKbAOx/2rHrnIHJJW5Bv2+p9LROv+DJ R45xPU4Ug3mEPqDjjB13w9fh8Vsv4bNN1Y1qM871d4wS3m8Jbc2MukQN1Gmu/+1RDr6VfK xPHjBi7BB8jDEEgpoeqBsHETEi4ccE3yLecOA51K4O8oQ/rDRW1gJseiF363lwNd7J5v73 5JuNygqM5d1FYzRGhLhpb7A5Q2fBqwt+YdAFiKaBOlhZ3KKrx3l6dLq+pO4Hiw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1762284161; a=rsa-sha256; cv=none; b=UzXk7oO4hdB9om/Lqej3DcgnkoGaY3xf/5gfWDiGmKOJKOnEIr5va6v9bduaCSmfncZfqU naXmVF9pUlWdZkXHUK+C1yYwKZ73l5ARcyNi3ogFmbtisLzV5BIQwpuvHIWkPNHTlXgdMh uY3q//gpBMxzW0EK7dk3soCbaVYEizOCygnHSxkJY4SoOF1aWRRNNB6PaMyBkKYnvzjCe6 sJbO9JsIoFTil9f3TOYErO9VEQo6gW0xnSZ4sK5kCyMgpql2Uzf/Y+YHNkl9noldyEkPR2 MHhXzOh/USgMK5GnRtqqco2uziOUXXHnBT9ENIX18kRIt3nL4A27gR2GzBjSpg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4d1JJ12GXvz19C3; Tue, 04 Nov 2025 19:22:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 5A4JMfef050794; Tue, 4 Nov 2025 19:22:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5A4JMfwo050791; Tue, 4 Nov 2025 19:22:41 GMT (envelope-from git) Date: Tue, 4 Nov 2025 19:22:41 GMT Message-Id: <202511041922.5A4JMfwo050791@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Justin Hibbits Subject: git: a935c2a63f92 - main - kexec: Add basic kexec_load man page List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhibbits X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a935c2a63f9270500cddab1d9868c6183c25d5a8 Auto-Submitted: auto-generated The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=a935c2a63f9270500cddab1d9868c6183c25d5a8 commit a935c2a63f9270500cddab1d9868c6183c25d5a8 Author: Justin Hibbits AuthorDate: 2025-10-06 21:11:02 +0000 Commit: Justin Hibbits CommitDate: 2025-11-04 19:23:20 +0000 kexec: Add basic kexec_load man page Also add kexec reboot flag to the reboot man page. --- lib/libsys/Makefile.sys | 1 + lib/libsys/kexec_load.2 | 119 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/libsys/reboot.2 | 7 ++- 3 files changed, 126 insertions(+), 1 deletion(-) diff --git a/lib/libsys/Makefile.sys b/lib/libsys/Makefile.sys index bd65b58083c2..1d1a4f1136ce 100644 --- a/lib/libsys/Makefile.sys +++ b/lib/libsys/Makefile.sys @@ -243,6 +243,7 @@ MAN+= abort2.2 \ jail.2 \ kcmp.2 \ kenv.2 \ + kexec_load.2 \ kill.2 \ kldfind.2 \ kldfirstmod.2 \ diff --git a/lib/libsys/kexec_load.2 b/lib/libsys/kexec_load.2 new file mode 100644 index 000000000000..c3d458f34100 --- /dev/null +++ b/lib/libsys/kexec_load.2 @@ -0,0 +1,119 @@ +.\" +.\" SPDX-License-Identifier: BSD-3-Clause +.\" +.\" Copyright (c) 2025 Juniper Networks, Inc. +.\" +.Dd October 29, 2025 +.Dt KEXEC_LOAD 2 +.Os +.Sh NAME +.Nm kexec_load +.Nd prepare new kernel to reboot into +.Sh SYNOPSIS +.Lb libc +.In sys/kexec.h +.Ft int +.Fn kexec_load "uint64_t entry" "unsigned long count" \ + "struct kexec_segment *segments" "unsigned long flags" +.Sh DESCRIPTION +The +.Fn kexec_load +system call loads a new kernel that can be executed later by +.Xr reboot 2 . +Subsequent calls will replace previously loaded images. +.Pp +The +.Fa flags +argument is a bitmask of flags that control the operation of the call. +This argument is present for compatibility with Linux, although it is currently +unused and must be 0. +.Pp +The +.Fa entry +argument is the physical address of the entry point of the new kernel image. +.Pp +The +.Fa count +argument is the number of segments in the image, currently limited to 16. +A value of 0 will unload the currently staged image, if one exists, without +staging a new image. +.Pp +The +.Fa segments +argument is an array of +.Fa count +members of the following structure: +.Bd -literal -offset indent +struct kexec_segment { + void *buf; + size_t bufsz; + vm_paddr_t mem; + vm_size_t memsz; +}; +.Ed +.Pp +The +.Va buf +and +.Va bufsz +members specify a memory region in the caller's address space containing the +source of the segment. +The +.Va mem +and +.Va memsz +members specify the target physical region of the segment. +.Va bufsz +must be less than or equal to +.Va memsz , +and +.Va mem +and +.Va memsz +must be page aligned. +The region covered by +.Va mem +must be in the list covered by the +.Va vm.phys_segs +sysctl. +.Pp +The +.Fn kexec_load +system call stages the kernel image in safe memory along with all +machine-dependent image data until +.Xr reboot 2 +is called with the +.Va RB_KEXEC +flag to load the image and execute the new kernel. +.Sh RETURN VALUES +The +.Fn kexec_load +system call returns 0 on success. +On failure, -1 is returned, and +.Va errno +is set to indicate the error. +On success any previously loaded image is unloaded and replaced with the new +image. +On failure, the previously loaded image is unchanged. +.Sh ERRORS +The following errors may be returned: +.Bl -tag -width Er +.It Bq Er EINVAL +Too many segments in image. +.It Bq Er EINVAL +The value of +.Va bufsz +is larger than +.Va memsz +in one or more segments. +.It Bq Er EINVAL +Machine-dependent load error. +.It Bq Er EBUSY +Another +.Fn kexec_load +call is in progress. +.Sh HISTORY +The +.Nm +system call appeared in +.Fx 16.0 . diff --git a/lib/libsys/reboot.2 b/lib/libsys/reboot.2 index f6c7bf6c83cc..54fa8b599cd5 100644 --- a/lib/libsys/reboot.2 +++ b/lib/libsys/reboot.2 @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd July 10, 2018 +.Dd October 29, 2025 .Dt REBOOT 2 .Os .Sh NAME @@ -126,6 +126,10 @@ on the console. is actually interpreted by the .Xr init 8 program in the newly booted system. +.It Dv RB_KEXEC +Execute a new kernel loaded via +.Fn kexec_load 2 . +If no kernel was loaded, reboot as normal. .El .Pp When no options are given (i.e., @@ -149,6 +153,7 @@ variable The caller is not the super-user. .El .Sh SEE ALSO +.Xr kexec_load 2 , .Xr crash 8 , .Xr halt 8 , .Xr init 8 ,