OSDN Git Service

325ecec7a13ae495f3a4a16f2e0d2373f9d3acee
[linuxjm/LDP_man-pages.git] / original / man2 / kexec_load.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (C) 2010 Intel Corporation
4 .\" Author: Andi Kleen
5 .\"
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .TH KEXEC_LOAD 2 2010-11-04 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 kexec_load \- load a new kernel for later execution
28 .SH SYNOPSIS
29 .B #include <linux/kexec.h>
30 .br
31 .BI "long kexec_load(unsigned long " entry ", unsigned long " nr_segments ","
32 .br
33 .BI "                struct kexec_segment *" segments \
34 ", unsigned long " flags ");"
35 .SH DESCRIPTION
36 The
37 .BR kexec_load ()
38 system call loads a new kernel that can be executed later by
39 .BR reboot (2).
40 .PP
41 The
42 .I flags
43 argument is a mask whose high-order bits control the operation of the call.
44 The following values can be specified in
45 .IR flags :
46 .TP
47 .BR KEXEC_ON_CRASH " (since Linux 2.6.13)"
48 Execute the new kernel automatically on a system crash.
49 .\" FIXME figure out how this is really used
50 .TP
51 .BR KEXEC_PRESERVE_CONTEXT " (since Linux 2.7.27)"
52 Preserve the system hardware and
53 software states before executing the new kernel.
54 This could be used for system suspend.
55 This flag is only available if the kernel was configured with
56 .BR CONFIG_KEXEC_JUMP ,
57 and is only effective if
58 .I nr_segments
59 is greater than 0.
60 .PP
61 The low-order bits of
62 .I flags
63 contain the architecture of the to-be-executed kernel.
64 Specify (OR) the constant
65 .B KEXEC_ARCH_DEFAULT
66 to use the current architecture,
67 or one of the following architecture constants
68 .BR KEXEC_ARCH_386 ,
69 .BR KEXEC_ARCH_X86_64 ,
70 .BR KEXEC_ARCH_PPC ,
71 .BR KEXEC_ARCH_PPC64 ,
72 .BR KEXEC_ARCH_IA_64 ,
73 .BR KEXEC_ARCH_ARM ,
74 .BR KEXEC_ARCH_S390 ,
75 .BR KEXEC_ARCH_SH ,
76 .BR KEXEC_ARCH_MIPS ,
77 and
78 .BR KEXEC_ARCH_MIPS_LE .
79 The architecture must be executable on the CPU of the system.
80
81 The
82 .I entry
83 argument is the physical entry address in the kernel image.
84 The
85 .I nr_segments
86 argument is the number of segments pointed to by the
87 .I segments
88 pointer.
89 The
90 .I segments
91 argument is an array of
92 .I kexec_segment
93 structures which define the kernel layout:
94 .in +4n
95 .nf
96
97 struct kexec_segment {
98     void   *buf;        /* Buffer in user space */
99     size_t  bufsz;      /* Buffer length in user space */
100     void   *mem;        /* Physical address of kernel */
101     size_t  memsz;      /* Physical address length */
102 };
103 .fi
104 .in
105 .PP
106 .\" FIXME elaborate on the following:
107 The kernel image defined by
108 .I segments
109 is copied from the calling process into previously reserved memory.
110 .SH RETURN VALUE
111 On success,
112 .BR kexec_load ()
113 returns 0.
114 On error, -1 is returned and
115 .I errno
116 is set to indicate the error.
117 .SH ERRORS
118 .TP
119 .B EBUSY
120 Another crash kernel is already being loaded
121 or a crash kernel is already in use.
122 .TP
123 .B EINVAL
124 .I flags
125 is invalid; or
126 .IR nr_segments
127 is too large
128 .\" KEXEC_SEGMENT_MAX == 16
129 .TP
130 .B EPERM
131 The caller does not have the
132 .BR CAP_SYS_BOOT
133 capability.
134 .SH VERSIONS
135 The
136 .BR kexec_load ()
137 system call first appeared in Linux 2.6.13.
138 .SH CONFORMING TO
139 This system call is Linux-specific.
140 .SH NOTES
141 Currently, there is no glibc support for
142 .BR kexec_load ().
143 Call it using
144 .BR syscall (2).
145 .PP
146 The required constants are in the kernel source file
147 .IR linux/kexec.h ,
148 which is not currently exported to glibc.
149 .\" FIXME Andi submitted a patch for this.
150 .\" Check if it got accepted later.
151 Therefore, these constants must be defined manually.
152
153 This system call is only available if the kernel was configured with
154 .BR CONFIG_KEXEC .
155 .SH SEE ALSO
156 .BR reboot (2),
157 .BR syscall (2)