1*a935c2a6SJustin Hibbits.\" 2*a935c2a6SJustin Hibbits.\" SPDX-License-Identifier: BSD-3-Clause 3*a935c2a6SJustin Hibbits.\" 4*a935c2a6SJustin Hibbits.\" Copyright (c) 2025 Juniper Networks, Inc. 5*a935c2a6SJustin Hibbits.\" 6*a935c2a6SJustin Hibbits.Dd October 29, 2025 7*a935c2a6SJustin Hibbits.Dt KEXEC_LOAD 2 8*a935c2a6SJustin Hibbits.Os 9*a935c2a6SJustin Hibbits.Sh NAME 10*a935c2a6SJustin Hibbits.Nm kexec_load 11*a935c2a6SJustin Hibbits.Nd prepare new kernel to reboot into 12*a935c2a6SJustin Hibbits.Sh SYNOPSIS 13*a935c2a6SJustin Hibbits.Lb libc 14*a935c2a6SJustin Hibbits.In sys/kexec.h 15*a935c2a6SJustin Hibbits.Ft int 16*a935c2a6SJustin Hibbits.Fn kexec_load "uint64_t entry" "unsigned long count" \ 17*a935c2a6SJustin Hibbits "struct kexec_segment *segments" "unsigned long flags" 18*a935c2a6SJustin Hibbits.Sh DESCRIPTION 19*a935c2a6SJustin HibbitsThe 20*a935c2a6SJustin Hibbits.Fn kexec_load 21*a935c2a6SJustin Hibbitssystem call loads a new kernel that can be executed later by 22*a935c2a6SJustin Hibbits.Xr reboot 2 . 23*a935c2a6SJustin HibbitsSubsequent calls will replace previously loaded images. 24*a935c2a6SJustin Hibbits.Pp 25*a935c2a6SJustin HibbitsThe 26*a935c2a6SJustin Hibbits.Fa flags 27*a935c2a6SJustin Hibbitsargument is a bitmask of flags that control the operation of the call. 28*a935c2a6SJustin HibbitsThis argument is present for compatibility with Linux, although it is currently 29*a935c2a6SJustin Hibbitsunused and must be 0. 30*a935c2a6SJustin Hibbits.Pp 31*a935c2a6SJustin HibbitsThe 32*a935c2a6SJustin Hibbits.Fa entry 33*a935c2a6SJustin Hibbitsargument is the physical address of the entry point of the new kernel image. 34*a935c2a6SJustin Hibbits.Pp 35*a935c2a6SJustin HibbitsThe 36*a935c2a6SJustin Hibbits.Fa count 37*a935c2a6SJustin Hibbitsargument is the number of segments in the image, currently limited to 16. 38*a935c2a6SJustin HibbitsA value of 0 will unload the currently staged image, if one exists, without 39*a935c2a6SJustin Hibbitsstaging a new image. 40*a935c2a6SJustin Hibbits.Pp 41*a935c2a6SJustin HibbitsThe 42*a935c2a6SJustin Hibbits.Fa segments 43*a935c2a6SJustin Hibbitsargument is an array of 44*a935c2a6SJustin Hibbits.Fa count 45*a935c2a6SJustin Hibbitsmembers of the following structure: 46*a935c2a6SJustin Hibbits.Bd -literal -offset indent 47*a935c2a6SJustin Hibbitsstruct kexec_segment { 48*a935c2a6SJustin Hibbits void *buf; 49*a935c2a6SJustin Hibbits size_t bufsz; 50*a935c2a6SJustin Hibbits vm_paddr_t mem; 51*a935c2a6SJustin Hibbits vm_size_t memsz; 52*a935c2a6SJustin Hibbits}; 53*a935c2a6SJustin Hibbits.Ed 54*a935c2a6SJustin Hibbits.Pp 55*a935c2a6SJustin HibbitsThe 56*a935c2a6SJustin Hibbits.Va buf 57*a935c2a6SJustin Hibbitsand 58*a935c2a6SJustin Hibbits.Va bufsz 59*a935c2a6SJustin Hibbitsmembers specify a memory region in the caller's address space containing the 60*a935c2a6SJustin Hibbitssource of the segment. 61*a935c2a6SJustin HibbitsThe 62*a935c2a6SJustin Hibbits.Va mem 63*a935c2a6SJustin Hibbitsand 64*a935c2a6SJustin Hibbits.Va memsz 65*a935c2a6SJustin Hibbitsmembers specify the target physical region of the segment. 66*a935c2a6SJustin Hibbits.Va bufsz 67*a935c2a6SJustin Hibbitsmust be less than or equal to 68*a935c2a6SJustin Hibbits.Va memsz , 69*a935c2a6SJustin Hibbitsand 70*a935c2a6SJustin Hibbits.Va mem 71*a935c2a6SJustin Hibbitsand 72*a935c2a6SJustin Hibbits.Va memsz 73*a935c2a6SJustin Hibbitsmust be page aligned. 74*a935c2a6SJustin HibbitsThe region covered by 75*a935c2a6SJustin Hibbits.Va mem 76*a935c2a6SJustin Hibbitsmust be in the list covered by the 77*a935c2a6SJustin Hibbits.Va vm.phys_segs 78*a935c2a6SJustin Hibbitssysctl. 79*a935c2a6SJustin Hibbits.Pp 80*a935c2a6SJustin HibbitsThe 81*a935c2a6SJustin Hibbits.Fn kexec_load 82*a935c2a6SJustin Hibbitssystem call stages the kernel image in safe memory along with all 83*a935c2a6SJustin Hibbitsmachine-dependent image data until 84*a935c2a6SJustin Hibbits.Xr reboot 2 85*a935c2a6SJustin Hibbitsis called with the 86*a935c2a6SJustin Hibbits.Va RB_KEXEC 87*a935c2a6SJustin Hibbitsflag to load the image and execute the new kernel. 88*a935c2a6SJustin Hibbits.Sh RETURN VALUES 89*a935c2a6SJustin HibbitsThe 90*a935c2a6SJustin Hibbits.Fn kexec_load 91*a935c2a6SJustin Hibbitssystem call returns 0 on success. 92*a935c2a6SJustin HibbitsOn failure, -1 is returned, and 93*a935c2a6SJustin Hibbits.Va errno 94*a935c2a6SJustin Hibbitsis set to indicate the error. 95*a935c2a6SJustin HibbitsOn success any previously loaded image is unloaded and replaced with the new 96*a935c2a6SJustin Hibbitsimage. 97*a935c2a6SJustin HibbitsOn failure, the previously loaded image is unchanged. 98*a935c2a6SJustin Hibbits.Sh ERRORS 99*a935c2a6SJustin HibbitsThe following errors may be returned: 100*a935c2a6SJustin Hibbits.Bl -tag -width Er 101*a935c2a6SJustin Hibbits.It Bq Er EINVAL 102*a935c2a6SJustin HibbitsToo many segments in image. 103*a935c2a6SJustin Hibbits.It Bq Er EINVAL 104*a935c2a6SJustin HibbitsThe value of 105*a935c2a6SJustin Hibbits.Va bufsz 106*a935c2a6SJustin Hibbitsis larger than 107*a935c2a6SJustin Hibbits.Va memsz 108*a935c2a6SJustin Hibbitsin one or more segments. 109*a935c2a6SJustin Hibbits.It Bq Er EINVAL 110*a935c2a6SJustin HibbitsMachine-dependent load error. 111*a935c2a6SJustin Hibbits.It Bq Er EBUSY 112*a935c2a6SJustin HibbitsAnother 113*a935c2a6SJustin Hibbits.Fn kexec_load 114*a935c2a6SJustin Hibbitscall is in progress. 115*a935c2a6SJustin Hibbits.Sh HISTORY 116*a935c2a6SJustin HibbitsThe 117*a935c2a6SJustin Hibbits.Nm 118*a935c2a6SJustin Hibbitssystem call appeared in 119*a935c2a6SJustin Hibbits.Fx 16.0 . 120