1 /******************************************************************************
2 * kexec.h - Public portion
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to
6 * deal in the Software without restriction, including without limitation the
7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 * sell copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
22 * Xen port written by:
23 * - Simon 'Horms' Horman <horms@verge.net.au>
24 * - Magnus Damm <magnus@valinux.co.jp>
27 #ifndef _XEN_PUBLIC_KEXEC_H
28 #define _XEN_PUBLIC_KEXEC_H
31 /* This file describes the Kexec / Kdump hypercall interface for Xen.
33 * Kexec under vanilla Linux allows a user to reboot the physical machine
34 * into a new user-specified kernel. The Xen port extends this idea
35 * to allow rebooting of the machine from dom0. When kexec for dom0
36 * is used to reboot, both the hypervisor and the domains get replaced
37 * with some other kernel. It is possible to kexec between vanilla
38 * Linux and Xen and back again. Xen to Xen works well too.
40 * The hypercall interface for kexec can be divided into three main
41 * types of hypercall operations:
43 * 1) Range information:
44 * This is used by the dom0 kernel to ask the hypervisor about various
45 * address information. This information is needed to allow kexec-tools
46 * to fill in the ELF headers for /proc/vmcore properly.
48 * 2) Load and unload of images:
49 * There are no big surprises here, the kexec binary from kexec-tools
50 * runs in userspace in dom0. The tool loads/unloads data into the
51 * dom0 kernel such as new kernel, initramfs and hypervisor. When
52 * loaded the dom0 kernel performs a load hypercall operation, and
53 * before releasing all page references the dom0 kernel calls unload.
56 * This is used to start a previously loaded kernel.
61 #if defined(__i386__) || defined(__x86_64__)
62 #define KEXEC_XEN_NO_PAGES 17
66 * Prototype for this hypercall is:
67 * int kexec_op(int cmd, void *args)
68 * @cmd == KEXEC_CMD_...
69 * KEXEC operation to perform
70 * @args == Operation-specific extra arguments (NULL if none).
74 * Kexec supports two types of operation:
75 * - kexec into a regular kernel, very similar to a standard reboot
76 * - KEXEC_TYPE_DEFAULT is used to specify this type
77 * - kexec into a special "crash kernel", aka kexec-on-panic
78 * - KEXEC_TYPE_CRASH is used to specify this type
79 * - parts of our system may be broken at kexec-on-panic time
80 * - the code should be kept as simple and self-contained as possible
83 #define KEXEC_TYPE_DEFAULT 0
84 #define KEXEC_TYPE_CRASH 1
87 /* The kexec implementation for Xen allows the user to load two
88 * types of kernels, KEXEC_TYPE_DEFAULT and KEXEC_TYPE_CRASH.
89 * All data needed for a kexec reboot is kept in one xen_kexec_image_t
90 * per "instance". The data mainly consists of machine address lists to pages
91 * together with destination addresses. The data in xen_kexec_image_t
92 * is passed to the "code page" which is one page of code that performs
93 * the final relocations before jumping to the new kernel.
96 typedef struct xen_kexec_image {
97 #if defined(__i386__) || defined(__x86_64__)
98 unsigned long page_list[KEXEC_XEN_NO_PAGES];
100 unsigned long indirection_page;
101 unsigned long start_address;
105 * Perform kexec having previously loaded a kexec or kdump kernel
107 * type == KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH [in]
109 * Control is transferred to the image entry point with the host in
110 * the following state.
112 * - The image may be executed on any PCPU and all other PCPUs are
115 * - Local interrupts are disabled.
117 * - Register values are undefined.
119 * - The image segments have writeable 1:1 virtual to machine
120 * mappings. The location of any page tables is undefined and these
121 * page table frames are not be mapped.
123 #define KEXEC_CMD_kexec 0
124 typedef struct xen_kexec_exec {
129 * Load/Unload kernel image for kexec or kdump.
130 * type == KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH [in]
131 * image == relocation information for kexec (ignored for unload) [in]
133 #define KEXEC_CMD_kexec_load_v1 1 /* obsolete since 0x00040400 */
134 #define KEXEC_CMD_kexec_unload_v1 2 /* obsolete since 0x00040400 */
135 typedef struct xen_kexec_load_v1 {
137 xen_kexec_image_t image;
138 } xen_kexec_load_v1_t;
140 #define KEXEC_RANGE_MA_CRASH 0 /* machine address and size of crash area */
141 #define KEXEC_RANGE_MA_XEN 1 /* machine address and size of Xen itself */
142 #define KEXEC_RANGE_MA_CPU 2 /* machine address and size of a CPU note */
143 #define KEXEC_RANGE_MA_XENHEAP 3 /* machine address and size of xenheap
144 * Note that although this is adjacent
145 * to Xen it exists in a separate EFI
146 * region on ia64, and thus needs to be
147 * inserted into iomem_machine separately */
148 #define KEXEC_RANGE_MA_BOOT_PARAM 4 /* Obsolete: machine address and size of
149 * the ia64_boot_param */
150 #define KEXEC_RANGE_MA_EFI_MEMMAP 5 /* machine address and size of
151 * of the EFI Memory Map */
152 #define KEXEC_RANGE_MA_VMCOREINFO 6 /* machine address and size of vmcoreinfo */
155 * Find the address and size of certain memory areas
156 * range == KEXEC_RANGE_... [in]
157 * nr == physical CPU number (starting from 0) if KEXEC_RANGE_MA_CPU [in]
158 * size == number of bytes reserved in window [out]
159 * start == address of the first byte in the window [out]
161 #define KEXEC_CMD_kexec_get_range 3
162 typedef struct xen_kexec_range {
169 #if __XEN_INTERFACE_VERSION__ >= 0x00040400
171 * A contiguous chunk of a kexec image and it's destination machine
174 typedef struct xen_kexec_segment {
176 XEN_GUEST_HANDLE(const_void) h;
182 } xen_kexec_segment_t;
183 DEFINE_XEN_GUEST_HANDLE(xen_kexec_segment_t);
186 * Load a kexec image into memory.
188 * For KEXEC_TYPE_DEFAULT images, the segments may be anywhere in RAM.
189 * The image is relocated prior to being executed.
191 * For KEXEC_TYPE_CRASH images, each segment of the image must reside
192 * in the memory region reserved for kexec (KEXEC_RANGE_MA_CRASH) and
193 * the entry point must be within the image. The caller is responsible
194 * for ensuring that multiple images do not overlap.
196 * All image segments will be loaded to their destination machine
197 * addresses prior to being executed. The trailing portion of any
198 * segments with a source buffer (from dest_maddr + buf_size to
199 * dest_maddr + dest_size) will be zeroed.
201 * Segments with no source buffer will be accessible to the image when
205 #define KEXEC_CMD_kexec_load 4
206 typedef struct xen_kexec_load {
207 uint8_t type; /* One of KEXEC_TYPE_* */
209 uint16_t arch; /* ELF machine type (EM_*). */
210 uint32_t nr_segments;
212 XEN_GUEST_HANDLE(xen_kexec_segment_t) h;
215 uint64_t entry_maddr; /* image entry point machine address. */
217 DEFINE_XEN_GUEST_HANDLE(xen_kexec_load_t);
220 * Unload a kexec image.
222 * Type must be one of KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH.
224 #define KEXEC_CMD_kexec_unload 5
225 typedef struct xen_kexec_unload {
227 } xen_kexec_unload_t;
228 DEFINE_XEN_GUEST_HANDLE(xen_kexec_unload_t);
230 #else /* __XEN_INTERFACE_VERSION__ < 0x00040400 */
232 #define KEXEC_CMD_kexec_load KEXEC_CMD_kexec_load_v1
233 #define KEXEC_CMD_kexec_unload KEXEC_CMD_kexec_unload_v1
234 #define xen_kexec_load xen_kexec_load_v1
235 #define xen_kexec_load_t xen_kexec_load_v1_t
239 #endif /* _XEN_PUBLIC_KEXEC_H */
244 * c-file-style: "BSD"
247 * indent-tabs-mode: nil