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
30 /* This file describes the Kexec / Kdump hypercall interface for Xen.
32 * Kexec under vanilla Linux allows a user to reboot the physical machine
33 * into a new user-specified kernel. The Xen port extends this idea
34 * to allow rebooting of the machine from dom0. When kexec for dom0
35 * is used to reboot, both the hypervisor and the domains get replaced
36 * with some other kernel. It is possible to kexec between vanilla
37 * Linux and Xen and back again. Xen to Xen works well too.
39 * The hypercall interface for kexec can be divided into three main
40 * types of hypercall operations:
42 * 1) Range information:
43 * This is used by the dom0 kernel to ask the hypervisor about various
44 * address information. This information is needed to allow kexec-tools
45 * to fill in the ELF headers for /proc/vmcore properly.
47 * 2) Load and unload of images:
48 * There are no big surprises here, the kexec binary from kexec-tools
49 * runs in userspace in dom0. The tool loads/unloads data into the
50 * dom0 kernel such as new kernel, initramfs and hypervisor. When
51 * loaded the dom0 kernel performs a load hypercall operation, and
52 * before releasing all page references the dom0 kernel calls unload.
55 * This is used to start a previously loaded kernel.
60 #if defined(__i386__) || defined(__x86_64__)
61 #define KEXEC_XEN_NO_PAGES 17
65 * Prototype for this hypercall is:
66 * int kexec_op(int cmd, void *args)
67 * @cmd == KEXEC_CMD_...
68 * KEXEC operation to perform
69 * @args == Operation-specific extra arguments (NULL if none).
73 * Kexec supports two types of operation:
74 * - kexec into a regular kernel, very similar to a standard reboot
75 * - KEXEC_TYPE_DEFAULT is used to specify this type
76 * - kexec into a special "crash kernel", aka kexec-on-panic
77 * - KEXEC_TYPE_CRASH is used to specify this type
78 * - parts of our system may be broken at kexec-on-panic time
79 * - the code should be kept as simple and self-contained as possible
82 #define KEXEC_TYPE_DEFAULT 0
83 #define KEXEC_TYPE_CRASH 1
85 /* The kexec implementation for Xen allows the user to load two
86 * types of kernels, KEXEC_TYPE_DEFAULT and KEXEC_TYPE_CRASH.
87 * All data needed for a kexec reboot is kept in one xen_kexec_image_t
88 * per "instance". The data mainly consists of machine address lists to pages
89 * together with destination addresses. The data in xen_kexec_image_t
90 * is passed to the "code page" which is one page of code that performs
91 * the final relocations before jumping to the new kernel.
94 typedef struct xen_kexec_image {
95 #if defined(__i386__) || defined(__x86_64__)
96 unsigned long page_list[KEXEC_XEN_NO_PAGES];
98 unsigned long indirection_page;
99 unsigned long start_address;
103 * Perform kexec having previously loaded a kexec or kdump kernel
105 * type == KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH [in]
107 * Control is transferred to the image entry point with the host in
108 * the following state.
110 * - The image may be executed on any PCPU and all other PCPUs are
113 * - Local interrupts are disabled.
115 * - Register values are undefined.
117 * - The image segments have writeable 1:1 virtual to machine
118 * mappings. The location of any page tables is undefined and these
119 * page table frames are not be mapped.
121 #define KEXEC_CMD_kexec 0
122 typedef struct xen_kexec_exec {
127 * Load/Unload kernel image for kexec or kdump.
128 * type == KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH [in]
129 * image == relocation information for kexec (ignored for unload) [in]
131 #define KEXEC_CMD_kexec_load_v1 1 /* obsolete since 0x00040400 */
132 #define KEXEC_CMD_kexec_unload_v1 2 /* obsolete since 0x00040400 */
133 typedef struct xen_kexec_load_v1 {
135 xen_kexec_image_t image;
136 } xen_kexec_load_v1_t;
138 #define KEXEC_RANGE_MA_CRASH 0 /* machine address and size of crash area */
139 #define KEXEC_RANGE_MA_XEN 1 /* machine address and size of Xen itself */
140 #define KEXEC_RANGE_MA_CPU 2 /* machine address and size of a CPU note */
141 #define KEXEC_RANGE_MA_XENHEAP 3 /* machine address and size of xenheap
142 * Note that although this is adjacent
143 * to Xen it exists in a separate EFI
144 * region on ia64, and thus needs to be
145 * inserted into iomem_machine separately */
146 #define KEXEC_RANGE_MA_BOOT_PARAM 4 /* Obsolete: machine address and size of
147 * the ia64_boot_param */
148 #define KEXEC_RANGE_MA_EFI_MEMMAP 5 /* machine address and size of
149 * of the EFI Memory Map */
150 #define KEXEC_RANGE_MA_VMCOREINFO 6 /* machine address and size of vmcoreinfo */
153 * Find the address and size of certain memory areas
154 * range == KEXEC_RANGE_... [in]
155 * nr == physical CPU number (starting from 0) if KEXEC_RANGE_MA_CPU [in]
156 * size == number of bytes reserved in window [out]
157 * start == address of the first byte in the window [out]
159 #define KEXEC_CMD_kexec_get_range 3
160 typedef struct xen_kexec_range {
167 #if __XEN_INTERFACE_VERSION__ >= 0x00040400
169 * A contiguous chunk of a kexec image and it's destination machine
172 typedef struct xen_kexec_segment {
174 XEN_GUEST_HANDLE(const_void) h;
180 } xen_kexec_segment_t;
181 DEFINE_XEN_GUEST_HANDLE(xen_kexec_segment_t);
184 * Load a kexec image into memory.
186 * For KEXEC_TYPE_DEFAULT images, the segments may be anywhere in RAM.
187 * The image is relocated prior to being executed.
189 * For KEXEC_TYPE_CRASH images, each segment of the image must reside
190 * in the memory region reserved for kexec (KEXEC_RANGE_MA_CRASH) and
191 * the entry point must be within the image. The caller is responsible
192 * for ensuring that multiple images do not overlap.
194 * All image segments will be loaded to their destination machine
195 * addresses prior to being executed. The trailing portion of any
196 * segments with a source buffer (from dest_maddr + buf_size to
197 * dest_maddr + dest_size) will be zeroed.
199 * Segments with no source buffer will be accessible to the image when
203 #define KEXEC_CMD_kexec_load 4
204 typedef struct xen_kexec_load {
205 uint8_t type; /* One of KEXEC_TYPE_* */
207 uint16_t arch; /* ELF machine type (EM_*). */
208 uint32_t nr_segments;
210 XEN_GUEST_HANDLE(xen_kexec_segment_t) h;
213 uint64_t entry_maddr; /* image entry point machine address. */
215 DEFINE_XEN_GUEST_HANDLE(xen_kexec_load_t);
218 * Unload a kexec image.
220 * Type must be one of KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH.
222 #define KEXEC_CMD_kexec_unload 5
223 typedef struct xen_kexec_unload {
225 } xen_kexec_unload_t;
226 DEFINE_XEN_GUEST_HANDLE(xen_kexec_unload_t);
228 #else /* __XEN_INTERFACE_VERSION__ < 0x00040400 */
230 #define KEXEC_CMD_kexec_load KEXEC_CMD_kexec_load_v1
231 #define KEXEC_CMD_kexec_unload KEXEC_CMD_kexec_unload_v1
232 #define xen_kexec_load xen_kexec_load_v1
233 #define xen_kexec_load_t xen_kexec_load_v1_t
237 #endif /* _XEN_PUBLIC_KEXEC_H */
242 * c-file-style: "BSD"
245 * indent-tabs-mode: nil