|
|
1.1 root 1: /******************************************************************************
2: * kexec.h - Public portion
3: *
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:
10: *
11: * The above copyright notice and this permission notice shall be included in
12: * all copies or substantial portions of the Software.
13: *
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.
21: *
22: * Xen port written by:
23: * - Simon 'Horms' Horman <[email protected]>
24: * - Magnus Damm <[email protected]>
25: */
26:
27: #ifndef _XEN_PUBLIC_KEXEC_H
28: #define _XEN_PUBLIC_KEXEC_H
29:
30:
31: /* This file describes the Kexec / Kdump hypercall interface for Xen.
32: *
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.
39: *
40: * The hypercall interface for kexec can be divided into three main
41: * types of hypercall operations:
42: *
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.
47: *
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.
54: *
55: * 3) Kexec operation:
56: * This is used to start a previously loaded kernel.
57: */
58:
59: #include "xen.h"
60:
61: #if defined(__i386__) || defined(__x86_64__)
62: #define KEXEC_XEN_NO_PAGES 17
63: #endif
64:
65: /*
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).
71: */
72:
73: /*
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
81: */
82:
83: #define KEXEC_TYPE_DEFAULT 0
84: #define KEXEC_TYPE_CRASH 1
85:
86:
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.
94: */
95:
96: typedef struct xen_kexec_image {
97: #if defined(__i386__) || defined(__x86_64__)
98: unsigned long page_list[KEXEC_XEN_NO_PAGES];
99: #endif
100: #if defined(__ia64__)
101: unsigned long reboot_code_buffer;
102: #endif
103: unsigned long indirection_page;
104: unsigned long start_address;
105: } xen_kexec_image_t;
106:
107: /*
108: * Perform kexec having previously loaded a kexec or kdump kernel
109: * as appropriate.
110: * type == KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH [in]
111: */
112: #define KEXEC_CMD_kexec 0
113: typedef struct xen_kexec_exec {
114: int type;
115: } xen_kexec_exec_t;
116:
117: /*
118: * Load/Unload kernel image for kexec or kdump.
119: * type == KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH [in]
120: * image == relocation information for kexec (ignored for unload) [in]
121: */
122: #define KEXEC_CMD_kexec_load 1
123: #define KEXEC_CMD_kexec_unload 2
124: typedef struct xen_kexec_load {
125: int type;
126: xen_kexec_image_t image;
127: } xen_kexec_load_t;
128:
129: #define KEXEC_RANGE_MA_CRASH 0 /* machine address and size of crash area */
130: #define KEXEC_RANGE_MA_XEN 1 /* machine address and size of Xen itself */
131: #define KEXEC_RANGE_MA_CPU 2 /* machine address and size of a CPU note */
132: #define KEXEC_RANGE_MA_XENHEAP 3 /* machine address and size of xenheap
133: * Note that although this is adjacent
134: * to Xen it exists in a separate EFI
135: * region on ia64, and thus needs to be
136: * inserted into iomem_machine separately */
137: #define KEXEC_RANGE_MA_BOOT_PARAM 4 /* machine address and size of
138: * the ia64_boot_param */
139: #define KEXEC_RANGE_MA_EFI_MEMMAP 5 /* machine address and size of
140: * of the EFI Memory Map */
141: #define KEXEC_RANGE_MA_VMCOREINFO 6 /* machine address and size of vmcoreinfo */
142:
143: /*
144: * Find the address and size of certain memory areas
145: * range == KEXEC_RANGE_... [in]
146: * nr == physical CPU number (starting from 0) if KEXEC_RANGE_MA_CPU [in]
147: * size == number of bytes reserved in window [out]
148: * start == address of the first byte in the window [out]
149: */
150: #define KEXEC_CMD_kexec_get_range 3
151: typedef struct xen_kexec_range {
152: int range;
153: int nr;
154: unsigned long size;
155: unsigned long start;
156: } xen_kexec_range_t;
157:
158: /* vmcoreinfo stuff */
159: #define VMCOREINFO_BYTES (4096)
160: #define VMCOREINFO_NOTE_NAME "VMCOREINFO_XEN"
161: void arch_crash_save_vmcoreinfo(void);
162: void vmcoreinfo_append_str(const char *fmt, ...)
163: __attribute__ ((format (printf, 1, 2)));
164: #define VMCOREINFO_PAGESIZE(value) \
165: vmcoreinfo_append_str("PAGESIZE=%ld\n", value)
166: #define VMCOREINFO_SYMBOL(name) \
167: vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)&name)
168: #define VMCOREINFO_SYMBOL_ALIAS(alias, name) \
169: vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #alias, (unsigned long)&name)
170: #define VMCOREINFO_STRUCT_SIZE(name) \
171: vmcoreinfo_append_str("SIZE(%s)=%zu\n", #name, sizeof(struct name))
172: #define VMCOREINFO_OFFSET(name, field) \
173: vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \
174: (unsigned long)offsetof(struct name, field))
175: #define VMCOREINFO_OFFSET_ALIAS(name, field, alias) \
176: vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #alias, \
177: (unsigned long)offsetof(struct name, field))
178:
179: #endif /* _XEN_PUBLIC_KEXEC_H */
180:
181: /*
182: * Local variables:
183: * mode: C
184: * c-set-style: "BSD"
185: * c-basic-offset: 4
186: * tab-width: 4
187: * indent-tabs-mode: nil
188: * End:
189: */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.