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