1 /* $NetBSD: kexec.h,v 1.3 2008/05/04 19:56:28 cegger Exp $ */
2 /******************************************************************************
3 * kexec.h - Public portion
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
23 * Xen port written by:
24 * - Simon 'Horms' Horman <horms@verge.net.au>
25 * - Magnus Damm <magnus@valinux.co.jp>
28 #ifndef _XEN_PUBLIC_KEXEC_H
29 #define _XEN_PUBLIC_KEXEC_H
32 /* This file describes the Kexec / Kdump hypercall interface for Xen.
34 * Kexec under vanilla Linux allows a user to reboot the physical machine
35 * into a new user-specified kernel. The Xen port extends this idea
36 * to allow rebooting of the machine from dom0. When kexec for dom0
37 * is used to reboot, both the hypervisor and the domains get replaced
38 * with some other kernel. It is possible to kexec between vanilla
39 * Linux and Xen and back again. Xen to Xen works well too.
41 * The hypercall interface for kexec can be divided into three main
42 * types of hypercall operations:
44 * 1) Range information:
45 * This is used by the dom0 kernel to ask the hypervisor about various
46 * address information. This information is needed to allow kexec-tools
47 * to fill in the ELF headers for /proc/vmcore properly.
49 * 2) Load and unload of images:
50 * There are no big surprises here, the kexec binary from kexec-tools
51 * runs in userspace in dom0. The tool loads/unloads data into the
52 * dom0 kernel such as new kernel, initramfs and hypervisor. When
53 * loaded the dom0 kernel performs a load hypercall operation, and
54 * before releasing all page references the dom0 kernel calls unload.
57 * This is used to start a previously loaded kernel.
62 #if defined(__i386__) || defined(__x86_64__)
63 #define KEXEC_XEN_NO_PAGES 17
67 * Prototype for this hypercall is:
68 * int kexec_op(int cmd, void *args)
69 * @cmd == KEXEC_CMD_...
70 * KEXEC operation to perform
71 * @args == Operation-specific extra arguments (NULL if none).
75 * Kexec supports two types of operation:
76 * - kexec into a regular kernel, very similar to a standard reboot
77 * - KEXEC_TYPE_DEFAULT is used to specify this type
78 * - kexec into a special "crash kernel", aka kexec-on-panic
79 * - KEXEC_TYPE_CRASH is used to specify this type
80 * - parts of our system may be broken at kexec-on-panic time
81 * - the code should be kept as simple and self-contained as possible
84 #define KEXEC_TYPE_DEFAULT 0
85 #define KEXEC_TYPE_CRASH 1
88 /* The kexec implementation for Xen allows the user to load two
89 * types of kernels, KEXEC_TYPE_DEFAULT and KEXEC_TYPE_CRASH.
90 * All data needed for a kexec reboot is kept in one xen_kexec_image_t
91 * per "instance". The data mainly consists of machine address lists to pages
92 * together with destination addresses. The data in xen_kexec_image_t
93 * is passed to the "code page" which is one page of code that performs
94 * the final relocations before jumping to the new kernel.
97 typedef struct xen_kexec_image
{
98 #if defined(__i386__) || defined(__x86_64__)
99 unsigned long page_list
[KEXEC_XEN_NO_PAGES
];
101 #if defined(__ia64__)
102 unsigned long reboot_code_buffer
;
104 unsigned long indirection_page
;
105 unsigned long start_address
;
109 * Perform kexec having previously loaded a kexec or kdump kernel
111 * type == KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH [in]
113 #define KEXEC_CMD_kexec 0
114 typedef struct xen_kexec_exec
{
119 * Load/Unload kernel image for kexec or kdump.
120 * type == KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH [in]
121 * image == relocation information for kexec (ignored for unload) [in]
123 #define KEXEC_CMD_kexec_load 1
124 #define KEXEC_CMD_kexec_unload 2
125 typedef struct xen_kexec_load
{
127 xen_kexec_image_t image
;
130 #define KEXEC_RANGE_MA_CRASH 0 /* machine address and size of crash area */
131 #define KEXEC_RANGE_MA_XEN 1 /* machine address and size of Xen itself */
132 #define KEXEC_RANGE_MA_CPU 2 /* machine address and size of a CPU note */
133 #define KEXEC_RANGE_MA_XENHEAP 3 /* machine address and size of xenheap
134 * Note that although this is adjacent
135 * to Xen it exists in a separate EFI
136 * region on ia64, and thus needs to be
137 * inserted into iomem_machine separately */
138 #define KEXEC_RANGE_MA_BOOT_PARAM 4 /* machine address and size of
139 * the ia64_boot_param */
140 #define KEXEC_RANGE_MA_EFI_MEMMAP 5 /* machine address and size of
141 * of the EFI Memory Map */
142 #define KEXEC_RANGE_MA_VMCOREINFO 6 /* machine address and size of vmcoreinfo */
145 * Find the address and size of certain memory areas
146 * range == KEXEC_RANGE_... [in]
147 * nr == physical CPU number (starting from 0) if KEXEC_RANGE_MA_CPU [in]
148 * size == number of bytes reserved in window [out]
149 * start == address of the first byte in the window [out]
151 #define KEXEC_CMD_kexec_get_range 3
152 typedef struct xen_kexec_range
{
159 /* vmcoreinfo stuff */
160 #define VMCOREINFO_BYTES (4096)
161 #define VMCOREINFO_NOTE_NAME "VMCOREINFO_XEN"
162 void arch_crash_save_vmcoreinfo(void);
163 void vmcoreinfo_append_str(const char *fmt
, ...)
164 __attribute__ ((format (printf
, 1, 2)));
165 #define VMCOREINFO_PAGESIZE(value) \
166 vmcoreinfo_append_str("PAGESIZE=%ld\n", value)
167 #define VMCOREINFO_SYMBOL(name) \
168 vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)&name)
169 #define VMCOREINFO_SYMBOL_ALIAS(alias, name) \
170 vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #alias, (unsigned long)&name)
171 #define VMCOREINFO_STRUCT_SIZE(name) \
172 vmcoreinfo_append_str("SIZE(%s)=%zu\n", #name, sizeof(struct name))
173 #define VMCOREINFO_OFFSET(name, field) \
174 vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \
175 (unsigned long)offsetof(struct name, field))
176 #define VMCOREINFO_OFFSET_ALIAS(name, field, alias) \
177 vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #alias, \
178 (unsigned long)offsetof(struct name, field))
180 #endif /* _XEN_PUBLIC_KEXEC_H */
188 * indent-tabs-mode: nil