1181624Skmacy/****************************************************************************** 2181624Skmacy * kexec.h - Public portion 3181624Skmacy * 4183375Skmacy * Permission is hereby granted, free of charge, to any person obtaining a copy 5183375Skmacy * of this software and associated documentation files (the "Software"), to 6183375Skmacy * deal in the Software without restriction, including without limitation the 7183375Skmacy * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8183375Skmacy * sell copies of the Software, and to permit persons to whom the Software is 9183375Skmacy * furnished to do so, subject to the following conditions: 10183375Skmacy * 11183375Skmacy * The above copyright notice and this permission notice shall be included in 12183375Skmacy * all copies or substantial portions of the Software. 13183375Skmacy * 14183375Skmacy * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15183375Skmacy * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16183375Skmacy * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17183375Skmacy * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18183375Skmacy * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19183375Skmacy * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20183375Skmacy * DEALINGS IN THE SOFTWARE. 21183375Skmacy * 22181624Skmacy * Xen port written by: 23181624Skmacy * - Simon 'Horms' Horman <horms@verge.net.au> 24181624Skmacy * - Magnus Damm <magnus@valinux.co.jp> 25181624Skmacy */ 26181624Skmacy 27181624Skmacy#ifndef _XEN_PUBLIC_KEXEC_H 28181624Skmacy#define _XEN_PUBLIC_KEXEC_H 29181624Skmacy 30181624Skmacy 31181624Skmacy/* This file describes the Kexec / Kdump hypercall interface for Xen. 32181624Skmacy * 33181624Skmacy * Kexec under vanilla Linux allows a user to reboot the physical machine 34181624Skmacy * into a new user-specified kernel. The Xen port extends this idea 35181624Skmacy * to allow rebooting of the machine from dom0. When kexec for dom0 36181624Skmacy * is used to reboot, both the hypervisor and the domains get replaced 37181624Skmacy * with some other kernel. It is possible to kexec between vanilla 38181624Skmacy * Linux and Xen and back again. Xen to Xen works well too. 39181624Skmacy * 40181624Skmacy * The hypercall interface for kexec can be divided into three main 41181624Skmacy * types of hypercall operations: 42181624Skmacy * 43181624Skmacy * 1) Range information: 44181624Skmacy * This is used by the dom0 kernel to ask the hypervisor about various 45181624Skmacy * address information. This information is needed to allow kexec-tools 46181624Skmacy * to fill in the ELF headers for /proc/vmcore properly. 47181624Skmacy * 48181624Skmacy * 2) Load and unload of images: 49181624Skmacy * There are no big surprises here, the kexec binary from kexec-tools 50181624Skmacy * runs in userspace in dom0. The tool loads/unloads data into the 51181624Skmacy * dom0 kernel such as new kernel, initramfs and hypervisor. When 52181624Skmacy * loaded the dom0 kernel performs a load hypercall operation, and 53181624Skmacy * before releasing all page references the dom0 kernel calls unload. 54181624Skmacy * 55181624Skmacy * 3) Kexec operation: 56181624Skmacy * This is used to start a previously loaded kernel. 57181624Skmacy */ 58181624Skmacy 59181624Skmacy#include "xen.h" 60181624Skmacy 61181624Skmacy#if defined(__i386__) || defined(__x86_64__) 62181624Skmacy#define KEXEC_XEN_NO_PAGES 17 63181624Skmacy#endif 64181624Skmacy 65181624Skmacy/* 66181624Skmacy * Prototype for this hypercall is: 67181624Skmacy * int kexec_op(int cmd, void *args) 68181624Skmacy * @cmd == KEXEC_CMD_... 69181624Skmacy * KEXEC operation to perform 70181624Skmacy * @args == Operation-specific extra arguments (NULL if none). 71181624Skmacy */ 72181624Skmacy 73181624Skmacy/* 74181624Skmacy * Kexec supports two types of operation: 75181624Skmacy * - kexec into a regular kernel, very similar to a standard reboot 76181624Skmacy * - KEXEC_TYPE_DEFAULT is used to specify this type 77181624Skmacy * - kexec into a special "crash kernel", aka kexec-on-panic 78181624Skmacy * - KEXEC_TYPE_CRASH is used to specify this type 79181624Skmacy * - parts of our system may be broken at kexec-on-panic time 80181624Skmacy * - the code should be kept as simple and self-contained as possible 81181624Skmacy */ 82181624Skmacy 83181624Skmacy#define KEXEC_TYPE_DEFAULT 0 84181624Skmacy#define KEXEC_TYPE_CRASH 1 85181624Skmacy 86181624Skmacy 87181624Skmacy/* The kexec implementation for Xen allows the user to load two 88181624Skmacy * types of kernels, KEXEC_TYPE_DEFAULT and KEXEC_TYPE_CRASH. 89181624Skmacy * All data needed for a kexec reboot is kept in one xen_kexec_image_t 90181624Skmacy * per "instance". The data mainly consists of machine address lists to pages 91181624Skmacy * together with destination addresses. The data in xen_kexec_image_t 92181624Skmacy * is passed to the "code page" which is one page of code that performs 93181624Skmacy * the final relocations before jumping to the new kernel. 94181624Skmacy */ 95181624Skmacy 96181624Skmacytypedef struct xen_kexec_image { 97181624Skmacy#if defined(__i386__) || defined(__x86_64__) 98181624Skmacy unsigned long page_list[KEXEC_XEN_NO_PAGES]; 99181624Skmacy#endif 100183375Skmacy#if defined(__ia64__) 101183375Skmacy unsigned long reboot_code_buffer; 102183375Skmacy#endif 103181624Skmacy unsigned long indirection_page; 104181624Skmacy unsigned long start_address; 105181624Skmacy} xen_kexec_image_t; 106181624Skmacy 107181624Skmacy/* 108181624Skmacy * Perform kexec having previously loaded a kexec or kdump kernel 109181624Skmacy * as appropriate. 110181624Skmacy * type == KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH [in] 111181624Skmacy */ 112181624Skmacy#define KEXEC_CMD_kexec 0 113181624Skmacytypedef struct xen_kexec_exec { 114181624Skmacy int type; 115181624Skmacy} xen_kexec_exec_t; 116181624Skmacy 117181624Skmacy/* 118181624Skmacy * Load/Unload kernel image for kexec or kdump. 119181624Skmacy * type == KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH [in] 120181624Skmacy * image == relocation information for kexec (ignored for unload) [in] 121181624Skmacy */ 122181624Skmacy#define KEXEC_CMD_kexec_load 1 123181624Skmacy#define KEXEC_CMD_kexec_unload 2 124181624Skmacytypedef struct xen_kexec_load { 125181624Skmacy int type; 126181624Skmacy xen_kexec_image_t image; 127181624Skmacy} xen_kexec_load_t; 128181624Skmacy 129183375Skmacy#define KEXEC_RANGE_MA_CRASH 0 /* machine address and size of crash area */ 130183375Skmacy#define KEXEC_RANGE_MA_XEN 1 /* machine address and size of Xen itself */ 131183375Skmacy#define KEXEC_RANGE_MA_CPU 2 /* machine address and size of a CPU note */ 132183375Skmacy#define KEXEC_RANGE_MA_XENHEAP 3 /* machine address and size of xenheap 133183375Skmacy * Note that although this is adjacent 134183375Skmacy * to Xen it exists in a separate EFI 135183375Skmacy * region on ia64, and thus needs to be 136183375Skmacy * inserted into iomem_machine separately */ 137183375Skmacy#define KEXEC_RANGE_MA_BOOT_PARAM 4 /* machine address and size of 138183375Skmacy * the ia64_boot_param */ 139183375Skmacy#define KEXEC_RANGE_MA_EFI_MEMMAP 5 /* machine address and size of 140183375Skmacy * of the EFI Memory Map */ 141183375Skmacy#define KEXEC_RANGE_MA_VMCOREINFO 6 /* machine address and size of vmcoreinfo */ 142181624Skmacy 143181624Skmacy/* 144181624Skmacy * Find the address and size of certain memory areas 145181624Skmacy * range == KEXEC_RANGE_... [in] 146181624Skmacy * nr == physical CPU number (starting from 0) if KEXEC_RANGE_MA_CPU [in] 147181624Skmacy * size == number of bytes reserved in window [out] 148181624Skmacy * start == address of the first byte in the window [out] 149181624Skmacy */ 150181624Skmacy#define KEXEC_CMD_kexec_get_range 3 151181624Skmacytypedef struct xen_kexec_range { 152181624Skmacy int range; 153181624Skmacy int nr; 154181624Skmacy unsigned long size; 155181624Skmacy unsigned long start; 156181624Skmacy} xen_kexec_range_t; 157181624Skmacy 158183375Skmacy/* vmcoreinfo stuff */ 159183375Skmacy#define VMCOREINFO_BYTES (4096) 160183375Skmacy#define VMCOREINFO_NOTE_NAME "VMCOREINFO_XEN" 161183375Skmacyvoid arch_crash_save_vmcoreinfo(void); 162183375Skmacyvoid vmcoreinfo_append_str(const char *fmt, ...) 163183375Skmacy __attribute__ ((format (printf, 1, 2))); 164183375Skmacy#define VMCOREINFO_PAGESIZE(value) \ 165183375Skmacy vmcoreinfo_append_str("PAGESIZE=%ld\n", value) 166183375Skmacy#define VMCOREINFO_SYMBOL(name) \ 167183375Skmacy vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)&name) 168183375Skmacy#define VMCOREINFO_SYMBOL_ALIAS(alias, name) \ 169183375Skmacy vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #alias, (unsigned long)&name) 170183375Skmacy#define VMCOREINFO_STRUCT_SIZE(name) \ 171183375Skmacy vmcoreinfo_append_str("SIZE(%s)=%zu\n", #name, sizeof(struct name)) 172183375Skmacy#define VMCOREINFO_OFFSET(name, field) \ 173183375Skmacy vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \ 174183375Skmacy (unsigned long)offsetof(struct name, field)) 175183375Skmacy#define VMCOREINFO_OFFSET_ALIAS(name, field, alias) \ 176183375Skmacy vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #alias, \ 177183375Skmacy (unsigned long)offsetof(struct name, field)) 178183375Skmacy 179181624Skmacy#endif /* _XEN_PUBLIC_KEXEC_H */ 180181624Skmacy 181181624Skmacy/* 182181624Skmacy * Local variables: 183181624Skmacy * mode: C 184181624Skmacy * c-set-style: "BSD" 185181624Skmacy * c-basic-offset: 4 186181624Skmacy * tab-width: 4 187181624Skmacy * indent-tabs-mode: nil 188181624Skmacy * End: 189181624Skmacy */ 190