]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/kexec_load.2
kexec_load.2: Move some text from NOTES to DESCRIPTION
[thirdparty/man-pages.git] / man2 / kexec_load.2
1 .\" Copyright (C) 2010 Intel Corporation, Author: Andi Kleen
2 .\" and Copyright 2014, Vivek Goyal <vgoyal@redhat.com>
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 .BI "long kexec_file_load(int " kernel_fd ", int " initrd_fd ","
38 .br
39 .BI " unsigned long " cmdline_len \
40 ", const char *" cmdline ","
41 .BI " unsigned long " flags ");"
42
43 .fi
44 .IR Note :
45 There are no glibc wrappers for these system calls; see NOTES.
46 .SH DESCRIPTION
47 The
48 .BR kexec_load ()
49 system call loads a new kernel that can be executed later by
50 .BR reboot (2).
51 .PP
52 The
53 .I flags
54 argument is a bit mask that controls the operation of the call.
55 The following values can be specified in
56 .IR flags :
57 .TP
58 .BR KEXEC_ON_CRASH " (since Linux 2.6.13)"
59 Execute the new kernel automatically on a system crash.
60 .\" FIXME Explain in more detail how KEXEC_ON_CRASH is actually used
61 .TP
62 .BR KEXEC_PRESERVE_CONTEXT " (since Linux 2.6.27)"
63 Preserve the system hardware and
64 software states before executing the new kernel.
65 This could be used for system suspend.
66 This flag is available only if the kernel was configured with
67 .BR CONFIG_KEXEC_JUMP ,
68 and is effective only if
69 .I nr_segments
70 is greater than 0.
71 .PP
72 The high-order bits (corresponding to the mask 0xffff0000) of
73 .I flags
74 contain the architecture of the to-be-executed kernel.
75 Specify (OR) the constant
76 .B KEXEC_ARCH_DEFAULT
77 to use the current architecture,
78 or one of the following architecture constants
79 .BR KEXEC_ARCH_386 ,
80 .BR KEXEC_ARCH_68K ,
81 .BR KEXEC_ARCH_X86_64 ,
82 .BR KEXEC_ARCH_PPC ,
83 .BR KEXEC_ARCH_PPC64 ,
84 .BR KEXEC_ARCH_IA_64 ,
85 .BR KEXEC_ARCH_ARM ,
86 .BR KEXEC_ARCH_S390 ,
87 .BR KEXEC_ARCH_SH ,
88 .BR KEXEC_ARCH_MIPS ,
89 and
90 .BR KEXEC_ARCH_MIPS_LE .
91 The architecture must be executable on the CPU of the system.
92
93 The
94 .I entry
95 argument is the physical entry address in the kernel image.
96 The
97 .I nr_segments
98 argument is the number of segments pointed to by the
99 .I segments
100 pointer;
101 the kernel imposes an (arbitrary) limit of 16 on the number of segments.
102 The
103 .I segments
104 argument is an array of
105 .I kexec_segment
106 structures which define the kernel layout:
107 .in +4n
108 .nf
109
110 struct kexec_segment {
111 void *buf; /* Buffer in user space */
112 size_t bufsz; /* Buffer length in user space */
113 void *mem; /* Physical address of kernel */
114 size_t memsz; /* Physical address length */
115 };
116 .fi
117 .in
118 .PP
119 .\" FIXME Explain the details of how the kernel image defined by segments
120 .\" is copied from the calling process into previously reserved memory.
121 The kernel image defined by
122 .I segments
123 is copied from the calling process into previously reserved memory.
124
125 The
126 .BR kexec_load ()
127 system call is available only if the kernel was configured with
128 .BR CONFIG_KEXEC .
129 .SS kexec_file_load()
130 The
131 .BR kexec_file_load ()
132 system call is similar to
133 .BR kexec_load (),
134 but it takes a different set of arguments.
135 It reads the kernel to be loaded from the file referred to by the descriptor
136 .IR kernel_fd ,
137 and the initrd (initial RAM disk)
138 to be loaded from file referred to by the descriptor
139 .IR initrd_fd .
140 The
141 .IR cmdline
142 argument is a pointer to a string containing the command line
143 for the new kernel; the
144 .IR cmdline_len
145 argument specifies the length of the string in
146 .IR cmdline .
147
148 The
149 .IR flags
150 argument is a bit mask which modifies the behavior of the call.
151 The following values can be specified in
152 .IR flags :
153 .TP
154 .BR KEXEC_FILE_UNLOAD
155 Unload the currently loaded kernel.
156 .TP
157 .BR KEXEC_FILE_ON_CRASH
158 Load the new kernel in the memory region reserved for the crash kernel.
159 This kernel is booted if the currently running kernel crashes.
160 .TP
161 .BR KEXEC_FILE_NO_INITRAMFS
162 Loading initrd/initramfs is optional.
163 Specify this flag if no initramfs is being loaded.
164 If this flag is set, the value passed in
165 .IR initrd_fd
166 is ignored.
167 .PP
168 The
169 .BR kexec_file_load ()
170 .\" See also http://lwn.net/Articles/603116/
171 system call was added to provide support for systems
172 where "kexec" loading should be restricted to
173 only kernels that are signed.
174 This system call is available only if the kernel was configured with
175 .BR CONFIG_KEXEC_FILE .
176 .SH RETURN VALUE
177 On success, these system calls returns 0.
178 On error, \-1 is returned and
179 .I errno
180 is set to indicate the error.
181 .SH ERRORS
182 .TP
183 .B EBUSY
184 Another crash kernel is already being loaded
185 or a crash kernel is already in use.
186 .TP
187 .B EINVAL
188 .I flags
189 is invalid; or
190 .IR nr_segments
191 is too large
192 .\" KEXEC_SEGMENT_MAX == 16
193 .TP
194 .B ENOEXEC
195 .I kernel_fd
196 does not refer to an open file, or the kernel can't load this file.
197 .TP
198 .B EPERM
199 The caller does not have the
200 .BR CAP_SYS_BOOT
201 capability.
202 .SH VERSIONS
203 The
204 .BR kexec_load ()
205 system call first appeared in Linux 2.6.13.
206 The
207 .BR kexec_file_load ()
208 system call first appeared in Linux 3.17.
209 .SH CONFORMING TO
210 These system calls are Linux-specific.
211 .SH NOTES
212 Currently, there is no glibc support for these system calls.
213 Call them using
214 .BR syscall (2).
215 .PP
216 The required constants are in the Linux kernel source file
217 .IR linux/kexec.h ,
218 which is not currently exported to glibc.
219 Therefore, these constants must be defined manually.
220 .SH SEE ALSO
221 .BR reboot (2),
222 .BR syscall (2),
223 .BR kexec (8)
224
225 The kernel source files
226 .IR Documentation/kdump/kdump.txt
227 and
228 .IR Documentation/kernel-parameters.txt .