]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/kexec_load.2
kexec_load.2: SEE ALSO: add kexec(8)
[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 It also takes the length of the kernel command line in
139 .IR cmdline_len
140 and a pointer to the command line in
141 .IR cmdline .
142
143 The
144 .IR flags
145 argument is a bit mask which modifies the behavior of the call.
146 The following values can be specified in
147 .IR flags :
148 .TP
149 .BR KEXEC_FILE_UNLOAD
150 Unload the currently loaded kernel.
151 .TP
152 .BR KEXEC_FILE_ON_CRASH
153 Load the new kernel in the memory region reserved for the crash kernel.
154 This kernel is booted if the currently running kernel crashes.
155 .TP
156 .BR KEXEC_FILE_NO_INITRAMFS
157 Loading initrd/initramfs is optional.
158 Specify this flag if no initramfs is being loaded.
159 If this flag is set, the value passed in
160 .IR initrd_fd
161 is ignored.
162 .SH RETURN VALUE
163 On success, these system calls returns 0.
164 On error, \-1 is returned and
165 .I errno
166 is set to indicate the error.
167 .SH ERRORS
168 .TP
169 .B EBUSY
170 Another crash kernel is already being loaded
171 or a crash kernel is already in use.
172 .TP
173 .B EINVAL
174 .I flags
175 is invalid; or
176 .IR nr_segments
177 is too large
178 .\" KEXEC_SEGMENT_MAX == 16
179 .TP
180 .B ENOEXEC
181 .I kernel_fd
182 does not refer to an open file, or the kernel can't load this file.
183 .TP
184 .B EPERM
185 The caller does not have the
186 .BR CAP_SYS_BOOT
187 capability.
188 .SH VERSIONS
189 The
190 .BR kexec_load ()
191 system call first appeared in Linux 2.6.13.
192 The
193 .BR kexec_file_load ()
194 system call first appeared in Linux 3.17.
195 .SH CONFORMING TO
196 These system calls are Linux-specific.
197 .SH NOTES
198 Currently, there is no glibc support for these system calls.
199 Call them using
200 .BR syscall (2).
201 .PP
202 The required constants are in the Linux kernel source file
203 .IR linux/kexec.h ,
204 which is not currently exported to glibc.
205 Therefore, these constants must be defined manually.
206
207 The
208 .BR kexec_load ()
209 system call is available only if the kernel was configured with
210 .BR CONFIG_KEXEC .
211 The
212 .BR kexec_file_load ()
213 system call is available only if the kernel was configured with
214 .BR CONFIG_KEXEC_FILE .
215 .\" FIXME(kexec_file_load):
216 .\" Does kexec_file_load() need any other CONFIG_* options to be defined?
217 .SH SEE ALSO
218 .BR reboot (2),
219 .BR syscall (2),
220 .BR kexec (8)