]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/kexec_load.2
kexec_load.2: Note rationale for kexec_file_load()
[thirdparty/man-pages.git] / man2 / kexec_load.2
1 .\" Copyright (C) 2010 Intel Corporation
2 .\" Author: Andi Kleen
3 .\"
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.
8 .\"
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.
13 .\"
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
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .TH KEXEC_LOAD 2 2014-08-19 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 kexec_load, kexec_file_load \- load a new kernel for later execution
29 .SH SYNOPSIS
30 .nf
31 .B #include <linux/kexec.h>
32
33 .BI "long kexec_load(unsigned long " entry ", unsigned long " nr_segments ","
34 .BI " struct kexec_segment *" segments \
35 ", unsigned long " flags ");"
36
37 .\" FIXME(kexec_file_load):
38 .\" Why are the return types of kexec_laod() and kexec_file_load()
39 .\" different?
40 .BI "int kexec_file_load(int " kernel_fd ", int " initrd_fd ","
41 .br
42 .BI " unsigned long " cmdline_len \
43 ", const char *" cmdline ","
44 .BI " unsigned long " flags ");"
45
46 .fi
47 .IR Note :
48 There are no glibc wrappers for these system calls; see NOTES.
49 .SH DESCRIPTION
50 The
51 .BR kexec_load ()
52 system call loads a new kernel that can be executed later by
53 .BR reboot (2).
54 .PP
55 The
56 .I flags
57 argument is a bit mask that controls the operation of the call.
58 The following values can be specified in
59 .IR flags :
60 .TP
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
64 .TP
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
72 .I nr_segments
73 is greater than 0.
74 .PP
75 The high-order bits (corresponding to the mask 0xffff0000) of
76 .I flags
77 contain the architecture of the to-be-executed kernel.
78 Specify (OR) the constant
79 .B KEXEC_ARCH_DEFAULT
80 to use the current architecture,
81 or one of the following architecture constants
82 .BR KEXEC_ARCH_386 ,
83 .BR KEXEC_ARCH_68K ,
84 .BR KEXEC_ARCH_X86_64 ,
85 .BR KEXEC_ARCH_PPC ,
86 .BR KEXEC_ARCH_PPC64 ,
87 .BR KEXEC_ARCH_IA_64 ,
88 .BR KEXEC_ARCH_ARM ,
89 .BR KEXEC_ARCH_S390 ,
90 .BR KEXEC_ARCH_SH ,
91 .BR KEXEC_ARCH_MIPS ,
92 and
93 .BR KEXEC_ARCH_MIPS_LE .
94 The architecture must be executable on the CPU of the system.
95
96 The
97 .I entry
98 argument is the physical entry address in the kernel image.
99 The
100 .I nr_segments
101 argument is the number of segments pointed to by the
102 .I segments
103 pointer;
104 the kernel imposes an (arbitrary) limit of 16 on the number of segments.
105 The
106 .I segments
107 argument is an array of
108 .I kexec_segment
109 structures which define the kernel layout:
110 .in +4n
111 .nf
112
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 */
118 };
119 .fi
120 .in
121 .PP
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
125 .I segments
126 is copied from the calling process into previously reserved memory.
127 .SS kexec_file_load()
128 The
129 .BR kexec_file_load ()
130 system call is similar to
131 .BR kexec_load (),
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
134 .IR kernel_fd ,
135 and the initrd (initial RAM disk)
136 to be loaded from file referred to by the descriptor
137 .IR initrd_fd .
138 The
139 .IR cmdline
140 argument is a pointer to a string containing the command line
141 for the new kernel; the
142 .IR cmdline_len
143 argument specifies the length of the string in
144 .IR cmdline .
145
146 The
147 .IR flags
148 argument is a bit mask which modifies the behavior of the call.
149 The following values can be specified in
150 .IR flags :
151 .TP
152 .BR KEXEC_FILE_UNLOAD
153 Unload the currently loaded kernel.
154 .TP
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.
158 .TP
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
163 .IR initrd_fd
164 is ignored.
165 .SH RETURN VALUE
166 On success, these system calls returns 0.
167 On error, \-1 is returned and
168 .I errno
169 is set to indicate the error.
170 .SH ERRORS
171 .TP
172 .B EBUSY
173 Another crash kernel is already being loaded
174 or a crash kernel is already in use.
175 .TP
176 .B EINVAL
177 .I flags
178 is invalid; or
179 .IR nr_segments
180 is too large
181 .\" KEXEC_SEGMENT_MAX == 16
182 .TP
183 .B ENOEXEC
184 .I kernel_fd
185 does not refer to an open file, or the kernel can't load this file.
186 .TP
187 .B EPERM
188 The caller does not have the
189 .BR CAP_SYS_BOOT
190 capability.
191 .SH VERSIONS
192 The
193 .BR kexec_load ()
194 system call first appeared in Linux 2.6.13.
195 The
196 .BR kexec_file_load ()
197 system call first appeared in Linux 3.17.
198 .SH CONFORMING TO
199 These system calls are Linux-specific.
200 .SH NOTES
201 Currently, there is no glibc support for these system calls.
202 Call them using
203 .BR syscall (2).
204 .PP
205 The required constants are in the Linux kernel source file
206 .IR linux/kexec.h ,
207 which is not currently exported to glibc.
208 Therefore, these constants must be defined manually.
209
210 .\" FIXME(kexec_file_load):
211 .\" Is the following rationale accurate? Does it need expanding?
212 The
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.
218
219 The
220 .BR kexec_load ()
221 system call is available only if the kernel was configured with
222 .BR CONFIG_KEXEC .
223 The
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?
229 .SH SEE ALSO
230 .BR reboot (2),
231 .BR syscall (2),
232 .BR kexec (8)