1 .\" Copyright (C) 2010 Intel Corporation
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .TH KEXEC_LOAD 2 2014-08-19 "Linux" "Linux Programmer's Manual"
28 kexec_load, kexec_file_load \- load a new kernel for later execution
31 .B #include <linux/kexec.h>
33 .BI "long kexec_load(unsigned long " entry ", unsigned long " nr_segments ","
34 .BI " struct kexec_segment *" segments \
35 ", unsigned long " flags ");"
37 .\" FIXME(kexec_file_load):
38 .\" Why are the return types of kexec_laod() and kexec_file_load()
40 .BI "int kexec_file_load(int " kernel_fd ", int " initrd_fd ","
42 .BI " unsigned long " cmdline_len \
43 ", const char *" cmdline ","
44 .BI " unsigned long " flags ");"
48 There are no glibc wrappers for these system calls; see NOTES.
52 system call loads a new kernel that can be executed later by
57 argument is a bit mask that controls the operation of the call.
58 The following values can be specified in
61 .BR KEXEC_ON_CRASH " (since Linux 2.6.13)"
62 Execute the new kernel automatically on a system crash.
63 .\" FIXME Explain in more detail how KEXEC_ON_CRASH is actually used
65 .BR KEXEC_PRESERVE_CONTEXT " (since Linux 2.6.27)"
66 Preserve the system hardware and
67 software states before executing the new kernel.
68 This could be used for system suspend.
69 This flag is available only if the kernel was configured with
70 .BR CONFIG_KEXEC_JUMP ,
71 and is effective only if
75 The high-order bits (corresponding to the mask 0xffff0000) of
77 contain the architecture of the to-be-executed kernel.
78 Specify (OR) the constant
80 to use the current architecture,
81 or one of the following architecture constants
84 .BR KEXEC_ARCH_X86_64 ,
86 .BR KEXEC_ARCH_PPC64 ,
87 .BR KEXEC_ARCH_IA_64 ,
93 .BR KEXEC_ARCH_MIPS_LE .
94 The architecture must be executable on the CPU of the system.
98 argument is the physical entry address in the kernel image.
101 argument is the number of segments pointed to by the
104 the kernel imposes an (arbitrary) limit of 16 on the number of segments.
107 argument is an array of
109 structures which define the kernel layout:
113 struct kexec_segment {
114 void *buf; /* Buffer in user space */
115 size_t bufsz; /* Buffer length in user space */
116 void *mem; /* Physical address of kernel */
117 size_t memsz; /* Physical address length */
122 .\" FIXME Explain the details of how the kernel image defined by segments
123 .\" is copied from the calling process into previously reserved memory.
124 The kernel image defined by
126 is copied from the calling process into previously reserved memory.
127 .SS kexec_file_load()
129 .BR kexec_file_load ()
130 system call is similar to
132 but it takes a different set of arguments.
133 It reads the kernel to be loaded from the file referred to by the descriptor
135 and the initrd (initial RAM disk)
136 to be loaded from file referred to by the descriptor
140 argument is a pointer to a string containing the command line
141 for the new kernel; the
143 argument specifies the length of the string in
148 argument is a bit mask which modifies the behavior of the call.
149 The following values can be specified in
152 .BR KEXEC_FILE_UNLOAD
153 Unload the currently loaded kernel.
155 .BR KEXEC_FILE_ON_CRASH
156 Load the new kernel in the memory region reserved for the crash kernel.
157 This kernel is booted if the currently running kernel crashes.
159 .BR KEXEC_FILE_NO_INITRAMFS
160 Loading initrd/initramfs is optional.
161 Specify this flag if no initramfs is being loaded.
162 If this flag is set, the value passed in
166 On success, these system calls returns 0.
167 On error, \-1 is returned and
169 is set to indicate the error.
173 Another crash kernel is already being loaded
174 or a crash kernel is already in use.
181 .\" KEXEC_SEGMENT_MAX == 16
185 does not refer to an open file, or the kernel can't load this file.
188 The caller does not have the
194 system call first appeared in Linux 2.6.13.
196 .BR kexec_file_load ()
197 system call first appeared in Linux 3.17.
199 These system calls are Linux-specific.
201 Currently, there is no glibc support for these system calls.
205 The required constants are in the Linux kernel source file
207 which is not currently exported to glibc.
208 Therefore, these constants must be defined manually.
210 .\" FIXME(kexec_file_load):
211 .\" Is the following rationale accurate? Does it need expanding?
213 .BR kexec_file_load ()
214 .\" See also http://lwn.net/Articles/603116/
215 system call was added to provide support for systems
216 where "kexec" loading should be restricted to
217 only kernels that are signed.
221 system call is available only if the kernel was configured with
224 .BR kexec_file_load ()
225 system call is available only if the kernel was configured with
226 .BR CONFIG_KEXEC_FILE .
227 .\" FIXME(kexec_file_load):
228 .\" Does kexec_file_load() need any other CONFIG_* options to be defined?