175584Sru/****************************************************************************** 275584Sru * kexec.h - Public portion 375584Sru * 475584Sru * Permission is hereby granted, free of charge, to any person obtaining a copy 575584Sru * of this software and associated documentation files (the "Software"), to 675584Sru * deal in the Software without restriction, including without limitation the 775584Sru * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 875584Sru * sell copies of the Software, and to permit persons to whom the Software is 975584Sru * furnished to do so, subject to the following conditions: 1075584Sru * 1175584Sru * The above copyright notice and this permission notice shall be included in 1275584Sru * all copies or substantial portions of the Software. 1375584Sru * 1475584Sru * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1575584Sru * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1675584Sru * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1775584Sru * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1875584Sru * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 1975584Sru * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 2075584Sru * DEALINGS IN THE SOFTWARE. 2175584Sru * 2275584Sru * Xen port written by: 2375584Sru * - Simon 'Horms' Horman <horms@verge.net.au> 2475584Sru * - Magnus Damm <magnus@valinux.co.jp> 2575584Sru */ 2675584Sru 2775584Sru#ifndef _XEN_PUBLIC_KEXEC_H 2875584Sru#define _XEN_PUBLIC_KEXEC_H 2975584Sru 3075584Sru 3175584Sru/* This file describes the Kexec / Kdump hypercall interface for Xen. 3275584Sru * 3375584Sru * Kexec under vanilla Linux allows a user to reboot the physical machine 3475584Sru * into a new user-specified kernel. The Xen port extends this idea 3575584Sru * to allow rebooting of the machine from dom0. When kexec for dom0 3675584Sru * is used to reboot, both the hypervisor and the domains get replaced 3775584Sru * with some other kernel. It is possible to kexec between vanilla 3875584Sru * Linux and Xen and back again. Xen to Xen works well too. 3975584Sru * 4075584Sru * The hypercall interface for kexec can be divided into three main 4175584Sru * types of hypercall operations: 4275584Sru * 4375584Sru * 1) Range information: 4475584Sru * This is used by the dom0 kernel to ask the hypervisor about various 4575584Sru * address information. This information is needed to allow kexec-tools 4675584Sru * to fill in the ELF headers for /proc/vmcore properly. 4775584Sru * 4875584Sru * 2) Load and unload of images: 4975584Sru * There are no big surprises here, the kexec binary from kexec-tools 5075584Sru * runs in userspace in dom0. The tool loads/unloads data into the 5175584Sru * dom0 kernel such as new kernel, initramfs and hypervisor. When 5275584Sru * loaded the dom0 kernel performs a load hypercall operation, and 5375584Sru * before releasing all page references the dom0 kernel calls unload. 5475584Sru * 5575584Sru * 3) Kexec operation: 5675584Sru * This is used to start a previously loaded kernel. 5775584Sru */ 5875584Sru 5975584Sru#include "xen.h" 6075584Sru 6175584Sru#if defined(__i386__) || defined(__x86_64__) 6275584Sru#define KEXEC_XEN_NO_PAGES 17 6375584Sru#endif 6475584Sru 6575584Sru/* 6675584Sru * Prototype for this hypercall is: 6775584Sru * int kexec_op(int cmd, void *args) 6875584Sru * @cmd == KEXEC_CMD_... 6975584Sru * KEXEC operation to perform 7075584Sru * @args == Operation-specific extra arguments (NULL if none). 7175584Sru */ 7275584Sru 7375584Sru/* 7475584Sru * Kexec supports two types of operation: 7575584Sru * - kexec into a regular kernel, very similar to a standard reboot 7675584Sru * - KEXEC_TYPE_DEFAULT is used to specify this type 7775584Sru * - kexec into a special "crash kernel", aka kexec-on-panic 7875584Sru * - KEXEC_TYPE_CRASH is used to specify this type 7975584Sru * - parts of our system may be broken at kexec-on-panic time 8075584Sru * - the code should be kept as simple and self-contained as possible 8175584Sru */ 8275584Sru 8375584Sru#define KEXEC_TYPE_DEFAULT 0 8475584Sru#define KEXEC_TYPE_CRASH 1 8575584Sru 8675584Sru 8775584Sru/* The kexec implementation for Xen allows the user to load two 8875584Sru * types of kernels, KEXEC_TYPE_DEFAULT and KEXEC_TYPE_CRASH. 8975584Sru * All data needed for a kexec reboot is kept in one xen_kexec_image_t 9075584Sru * per "instance". The data mainly consists of machine address lists to pages 9175584Sru * together with destination addresses. The data in xen_kexec_image_t 9275584Sru * is passed to the "code page" which is one page of code that performs 9375584Sru * the final relocations before jumping to the new kernel. 9475584Sru */ 9575584Sru 9675584Srutypedef struct xen_kexec_image { 9775584Sru#if defined(__i386__) || defined(__x86_64__) 9875584Sru unsigned long page_list[KEXEC_XEN_NO_PAGES]; 9975584Sru#endif 10075584Sru#if defined(__ia64__) 10175584Sru unsigned long reboot_code_buffer; 10275584Sru#endif 10375584Sru unsigned long indirection_page; 10475584Sru unsigned long start_address; 10575584Sru} xen_kexec_image_t; 10675584Sru 10775584Sru/* 10875584Sru * Perform kexec having previously loaded a kexec or kdump kernel 10975584Sru * as appropriate. 11075584Sru * type == KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH [in] 11175584Sru */ 11275584Sru#define KEXEC_CMD_kexec 0 11375584Srutypedef struct xen_kexec_exec { 11475584Sru int type; 11575584Sru} xen_kexec_exec_t; 11675584Sru 11775584Sru/* 11875584Sru * Load/Unload kernel image for kexec or kdump. 11975584Sru * type == KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH [in] 12075584Sru * image == relocation information for kexec (ignored for unload) [in] 12175584Sru */ 122#define KEXEC_CMD_kexec_load 1 123#define KEXEC_CMD_kexec_unload 2 124typedef 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 151typedef 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#endif /* _XEN_PUBLIC_KEXEC_H */ 159 160/* 161 * Local variables: 162 * mode: C 163 * c-set-style: "BSD" 164 * c-basic-offset: 4 165 * tab-width: 4 166 * indent-tabs-mode: nil 167 * End: 168 */ 169