1 .\" Copyright (C) 2010 Intel Corporation, Author: Andi Kleen
2 .\" and Copyright 2014, Vivek Goyal <vgoyal@redhat.com>
3 .\" and Copyright (c) 2015, Michael Kerrisk <mtk.manpages@gmail.com>
5 .\" %%%LICENSE_START(VERBATIM)
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein. The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
27 .TH KEXEC_LOAD 2 2017-05-03 "Linux" "Linux Programmer's Manual"
29 kexec_load, kexec_file_load \- load a new kernel for later execution
32 .B #include <linux/kexec.h>
34 .BI "long kexec_load(unsigned long " entry ", unsigned long " nr_segments ","
35 .BI " struct kexec_segment *" segments \
36 ", unsigned long " flags ");"
38 .BI "long kexec_file_load(int " kernel_fd ", int " initrd_fd ","
40 .BI " unsigned long " cmdline_len \
41 ", const char *" cmdline ","
42 .BI " unsigned long " flags ");"
46 There are no glibc wrappers for these system calls; see NOTES.
50 system call loads a new kernel that can be executed later by
55 argument is a bit mask that controls the operation of the call.
56 The following values can be specified in
59 .BR KEXEC_ON_CRASH " (since Linux 2.6.13)"
60 Execute the new kernel automatically on a system crash.
61 This "crash kernel" is loaded into an area of reserved memory that
62 is determined at boot time using the
64 kernel command-line parameter.
65 The location of this reserved memory is exported to user space via the
67 file, in an entry labeled "Crash kernel".
68 A user-space application can parse this file and prepare a list of
69 segments (see below) that specify this reserved memory as destination.
70 If this flag is specified, the kernel checks that the
71 target segments specified in
73 fall within the reserved region.
75 .BR KEXEC_PRESERVE_CONTEXT " (since Linux 2.6.27)"
76 Preserve the system hardware and
77 software states before executing the new kernel.
78 This could be used for system suspend.
79 This flag is available only if the kernel was configured with
80 .BR CONFIG_KEXEC_JUMP ,
81 and is effective only if
85 The high-order bits (corresponding to the mask 0xffff0000) of
87 contain the architecture of the to-be-executed kernel.
88 Specify (OR) the constant
90 to use the current architecture,
91 or one of the following architecture constants
94 .BR KEXEC_ARCH_X86_64 ,
96 .BR KEXEC_ARCH_PPC64 ,
97 .BR KEXEC_ARCH_IA_64 ,
101 .BR KEXEC_ARCH_MIPS ,
103 .BR KEXEC_ARCH_MIPS_LE .
104 The architecture must be executable on the CPU of the system.
108 argument is the physical entry address in the kernel image.
111 argument is the number of segments pointed to by the
114 the kernel imposes an (arbitrary) limit of 16 on the number of segments.
117 argument is an array of
119 structures which define the kernel layout:
123 struct kexec_segment {
124 void *buf; /* Buffer in user space */
125 size_t bufsz; /* Buffer length in user space */
126 void *mem; /* Physical address of kernel */
127 size_t memsz; /* Physical address length */
132 The kernel image defined by
134 is copied from the calling process into
135 the kernel either in regular
136 memory or in reserved memory (if
139 The kernel first performs various sanity checks on the
140 information passed in
142 If these checks pass, the kernel copies the segment data to kernel memory.
143 Each segment specified in
145 is copied as follows:
150 identify a memory region in the caller's virtual address space
151 that is the source of the copy.
154 may not exceed the value in the
161 specify a physical address range that is the target of the copy.
162 The values specified in both fields must be multiples of
163 the system page size.
166 bytes are copied from the source buffer to the target kernel buffer.
171 then the excess bytes in the kernel buffer are zeroed out.
173 In case of a normal kexec (i.e., the
175 flag is not set), the segment data is loaded in any available memory
176 and is moved to the final destination at kexec reboot time (e.g., when the
178 command is executed with the
182 In case of kexec on panic (i.e., the
184 flag is set), the segment data is
185 loaded to reserved memory at the time of the call, and, after a crash,
186 the kexec mechanism simply passes control to that kernel.
190 system call is available only if the kernel was configured with
192 .SS kexec_file_load()
194 .BR kexec_file_load ()
195 system call is similar to
197 but it takes a different set of arguments.
198 It reads the kernel to be loaded from the file referred to by
201 and the initrd (initial RAM disk)
202 to be loaded from file referred to by the file descriptor
206 argument is a pointer to a buffer containing the command line
210 argument specifies size of the buffer.
211 The last byte in the buffer must be a null byte (\(aq\\0\(aq).
215 argument is a bit mask which modifies the behavior of the call.
216 The following values can be specified in
219 .BR KEXEC_FILE_UNLOAD
220 Unload the currently loaded kernel.
222 .BR KEXEC_FILE_ON_CRASH
223 Load the new kernel in the memory region reserved for the crash kernel
226 This kernel is booted if the currently running kernel crashes.
228 .BR KEXEC_FILE_NO_INITRAMFS
229 Loading initrd/initramfs is optional.
230 Specify this flag if no initramfs is being loaded.
231 If this flag is set, the value passed in
236 .BR kexec_file_load ()
237 .\" See also http://lwn.net/Articles/603116/
238 system call was added to provide support for systems
239 where "kexec" loading should be restricted to
240 only kernels that are signed.
241 This system call is available only if the kernel was configured with
242 .BR CONFIG_KEXEC_FILE .
244 On success, these system calls returns 0.
245 On error, \-1 is returned and
247 is set to indicate the error.
251 .\" See kernel/kexec.::sanity_check_segment_list in the 3.19 kernel source
254 flags was specified, but the region specified by the
260 entries lies outside the range of memory reserved for the crash kernel.
269 entries is not a multiple of the system page size.
275 is not a valid file descriptor.
278 Another crash kernel is already being loaded
279 or a crash kernel is already in use.
290 entries exceeds the value in the corresponding
297 .BR KEXEC_SEGMENT_MAX
301 Two or more of the kernel target buffers overlap.
305 .I cmdline[cmdline_len-1]
309 The file referred to by
313 is empty (length zero).
317 does not refer to an open file, or the kernel can't load this file.
318 Currently, the file must be a bzImage and contain an x86 kernel that
319 is loadable above 4GiB in memory (see the kernel source file
320 .IR Documentation/x86/boot.txt ).
323 Could not allocate memory.
326 The caller does not have the
332 system call first appeared in Linux 2.6.13.
334 .BR kexec_file_load ()
335 system call first appeared in Linux 3.17.
337 These system calls are Linux-specific.
339 Currently, there is no glibc support for these system calls.
347 The kernel source files
348 .IR Documentation/kdump/kdump.txt
350 .IR Documentation/admin-guide/kernel-parameters.txt