mm: remove remaining references to NUMA hinting bits and helpers
[deliverable/linux.git] / include / linux / kexec.h
CommitLineData
dc009d92
EB
1#ifndef LINUX_KEXEC_H
2#define LINUX_KEXEC_H
3
607ca46e 4#include <uapi/linux/kexec.h>
29a5c67e 5
29a5c67e 6#ifdef CONFIG_KEXEC
dc009d92
EB
7#include <linux/list.h>
8#include <linux/linkage.h>
9#include <linux/compat.h>
9c15e852 10#include <linux/ioport.h>
6672f76a
SH
11#include <linux/elfcore.h>
12#include <linux/elf.h>
12db5562 13#include <linux/module.h>
dc009d92
EB
14#include <asm/kexec.h>
15
16/* Verify architecture specific macros are defined */
17
18#ifndef KEXEC_SOURCE_MEMORY_LIMIT
19#error KEXEC_SOURCE_MEMORY_LIMIT not defined
20#endif
21
22#ifndef KEXEC_DESTINATION_MEMORY_LIMIT
23#error KEXEC_DESTINATION_MEMORY_LIMIT not defined
24#endif
25
26#ifndef KEXEC_CONTROL_MEMORY_LIMIT
27#error KEXEC_CONTROL_MEMORY_LIMIT not defined
28#endif
29
163f6876
HY
30#ifndef KEXEC_CONTROL_PAGE_SIZE
31#error KEXEC_CONTROL_PAGE_SIZE not defined
dc009d92
EB
32#endif
33
34#ifndef KEXEC_ARCH
35#error KEXEC_ARCH not defined
36#endif
37
3d214fae
MH
38#ifndef KEXEC_CRASH_CONTROL_MEMORY_LIMIT
39#define KEXEC_CRASH_CONTROL_MEMORY_LIMIT KEXEC_CONTROL_MEMORY_LIMIT
40#endif
41
558df720
MH
42#ifndef KEXEC_CRASH_MEM_ALIGN
43#define KEXEC_CRASH_MEM_ALIGN PAGE_SIZE
44#endif
45
6672f76a
SH
46#define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
47#define KEXEC_CORE_NOTE_NAME "CORE"
48#define KEXEC_CORE_NOTE_NAME_BYTES ALIGN(sizeof(KEXEC_CORE_NOTE_NAME), 4)
49#define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
50/*
51 * The per-cpu notes area is a list of notes terminated by a "NULL"
52 * note header. For kdump, the code in vmcore.c runs in the context
53 * of the second kernel to combine them into one note.
54 */
cb78edfd 55#ifndef KEXEC_NOTE_BYTES
6672f76a
SH
56#define KEXEC_NOTE_BYTES ( (KEXEC_NOTE_HEAD_BYTES * 2) + \
57 KEXEC_CORE_NOTE_NAME_BYTES + \
58 KEXEC_CORE_NOTE_DESC_BYTES )
cb78edfd 59#endif
6672f76a 60
dc009d92
EB
61/*
62 * This structure is used to hold the arguments that are used when loading
63 * kernel binaries.
64 */
65
66typedef unsigned long kimage_entry_t;
67#define IND_DESTINATION 0x1
68#define IND_INDIRECTION 0x2
69#define IND_DONE 0x4
70#define IND_SOURCE 0x8
71
dc009d92 72struct kexec_segment {
815d5704
VG
73 /*
74 * This pointer can point to user memory if kexec_load() system
75 * call is used or will point to kernel memory if
76 * kexec_file_load() system call is used.
77 *
78 * Use ->buf when expecting to deal with user memory and use ->kbuf
79 * when expecting to deal with kernel memory.
80 */
81 union {
82 void __user *buf;
83 void *kbuf;
84 };
dc009d92 85 size_t bufsz;
29a5c67e 86 unsigned long mem;
dc009d92
EB
87 size_t memsz;
88};
89
90#ifdef CONFIG_COMPAT
91struct compat_kexec_segment {
92 compat_uptr_t buf;
93 compat_size_t bufsz;
94 compat_ulong_t mem; /* User space sees this as a (void *) ... */
95 compat_size_t memsz;
96};
97#endif
98
12db5562
VG
99struct kexec_sha_region {
100 unsigned long start;
101 unsigned long len;
102};
103
104struct purgatory_info {
105 /* Pointer to elf header of read only purgatory */
106 Elf_Ehdr *ehdr;
107
108 /* Pointer to purgatory sechdrs which are modifiable */
109 Elf_Shdr *sechdrs;
110 /*
111 * Temporary buffer location where purgatory is loaded and relocated
112 * This memory can be freed post image load
113 */
114 void *purgatory_buf;
115
116 /* Address where purgatory is finally loaded and is executed from */
117 unsigned long purgatory_load_addr;
118};
119
dc009d92
EB
120struct kimage {
121 kimage_entry_t head;
122 kimage_entry_t *entry;
123 kimage_entry_t *last_entry;
124
125 unsigned long destination;
126
127 unsigned long start;
128 struct page *control_code_page;
3ab83521 129 struct page *swap_page;
dc009d92
EB
130
131 unsigned long nr_segments;
132 struct kexec_segment segment[KEXEC_SEGMENT_MAX];
133
134 struct list_head control_pages;
135 struct list_head dest_pages;
7d3e2bca 136 struct list_head unusable_pages;
dc009d92
EB
137
138 /* Address of next control page to allocate for crash kernels. */
139 unsigned long control_page;
140
141 /* Flags to indicate special processing */
142 unsigned int type : 1;
143#define KEXEC_TYPE_DEFAULT 0
144#define KEXEC_TYPE_CRASH 1
3ab83521 145 unsigned int preserve_context : 1;
cb105258
VG
146 /* If set, we are using file mode kexec syscall */
147 unsigned int file_mode:1;
92be3d6b
HY
148
149#ifdef ARCH_HAS_KIMAGE_ARCH
150 struct kimage_arch arch;
151#endif
cb105258
VG
152
153 /* Additional fields for file based kexec syscall */
154 void *kernel_buf;
155 unsigned long kernel_buf_len;
156
157 void *initrd_buf;
158 unsigned long initrd_buf_len;
159
160 char *cmdline_buf;
161 unsigned long cmdline_buf_len;
162
163 /* File operations provided by image loader */
164 struct kexec_file_ops *fops;
165
166 /* Image loader handling the kernel can store a pointer here */
167 void *image_loader_data;
12db5562
VG
168
169 /* Information for loading purgatory */
170 struct purgatory_info purgatory_info;
dc009d92
EB
171};
172
cb105258
VG
173/*
174 * Keeps track of buffer parameters as provided by caller for requesting
175 * memory placement of buffer.
176 */
177struct kexec_buf {
178 struct kimage *image;
179 char *buffer;
180 unsigned long bufsz;
669280a1 181 unsigned long mem;
cb105258
VG
182 unsigned long memsz;
183 unsigned long buf_align;
184 unsigned long buf_min;
185 unsigned long buf_max;
186 bool top_down; /* allocate from top of memory hole */
187};
dc009d92 188
cb105258
VG
189typedef int (kexec_probe_t)(const char *kernel_buf, unsigned long kernel_size);
190typedef void *(kexec_load_t)(struct kimage *image, char *kernel_buf,
191 unsigned long kernel_len, char *initrd,
192 unsigned long initrd_len, char *cmdline,
193 unsigned long cmdline_len);
27f48d3e 194typedef int (kexec_cleanup_t)(void *loader_data);
8e7d8381
VG
195typedef int (kexec_verify_sig_t)(const char *kernel_buf,
196 unsigned long kernel_len);
cb105258
VG
197
198struct kexec_file_ops {
199 kexec_probe_t *probe;
200 kexec_load_t *load;
201 kexec_cleanup_t *cleanup;
8e7d8381 202 kexec_verify_sig_t *verify_sig;
cb105258 203};
dc009d92
EB
204
205/* kexec interface functions */
3ab83521 206extern void machine_kexec(struct kimage *image);
dc009d92
EB
207extern int machine_kexec_prepare(struct kimage *image);
208extern void machine_kexec_cleanup(struct kimage *image);
209extern asmlinkage long sys_kexec_load(unsigned long entry,
72414d3f
MS
210 unsigned long nr_segments,
211 struct kexec_segment __user *segments,
212 unsigned long flags);
3ab83521 213extern int kernel_kexec(void);
cb105258
VG
214extern int kexec_add_buffer(struct kimage *image, char *buffer,
215 unsigned long bufsz, unsigned long memsz,
216 unsigned long buf_align, unsigned long buf_min,
217 unsigned long buf_max, bool top_down,
218 unsigned long *load_addr);
72414d3f
MS
219extern struct page *kimage_alloc_control_pages(struct kimage *image,
220 unsigned int order);
12db5562
VG
221extern int kexec_load_purgatory(struct kimage *image, unsigned long min,
222 unsigned long max, int top_down,
223 unsigned long *load_addr);
224extern int kexec_purgatory_get_set_symbol(struct kimage *image,
225 const char *name, void *buf,
226 unsigned int size, bool get_value);
227extern void *kexec_purgatory_get_symbol_addr(struct kimage *image,
228 const char *name);
6e274d14
AN
229extern void crash_kexec(struct pt_regs *);
230int kexec_should_crash(struct task_struct *);
85916f81 231void crash_save_cpu(struct pt_regs *regs, int cpu);
fd59d231 232void crash_save_vmcoreinfo(void);
558df720
MH
233void crash_map_reserved_pages(void);
234void crash_unmap_reserved_pages(void);
fd59d231 235void arch_crash_save_vmcoreinfo(void);
b9075fa9
JP
236__printf(1, 2)
237void vmcoreinfo_append_str(const char *fmt, ...);
fd59d231
KO
238unsigned long paddr_vmcoreinfo_note(void);
239
c6e2bee2
BW
240#define VMCOREINFO_OSRELEASE(value) \
241 vmcoreinfo_append_str("OSRELEASE=%s\n", value)
bba1f603
KO
242#define VMCOREINFO_PAGESIZE(value) \
243 vmcoreinfo_append_str("PAGESIZE=%ld\n", value)
bcbba6c1 244#define VMCOREINFO_SYMBOL(name) \
fd59d231 245 vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)&name)
bcbba6c1 246#define VMCOREINFO_SIZE(name) \
6cfa062f
KO
247 vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \
248 (unsigned long)sizeof(name))
c76f860c
KO
249#define VMCOREINFO_STRUCT_SIZE(name) \
250 vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \
251 (unsigned long)sizeof(struct name))
bcbba6c1 252#define VMCOREINFO_OFFSET(name, field) \
d768281e 253 vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \
1e4f2955 254 (unsigned long)offsetof(struct name, field))
bcbba6c1 255#define VMCOREINFO_LENGTH(name, value) \
d768281e 256 vmcoreinfo_append_str("LENGTH(%s)=%lu\n", #name, (unsigned long)value)
bcbba6c1 257#define VMCOREINFO_NUMBER(name) \
6cfa062f 258 vmcoreinfo_append_str("NUMBER(%s)=%ld\n", #name, (long)name)
bcbba6c1 259#define VMCOREINFO_CONFIG(name) \
fd59d231
KO
260 vmcoreinfo_append_str("CONFIG_%s=y\n", #name)
261
dc009d92 262extern struct kimage *kexec_image;
c330dda9 263extern struct kimage *kexec_crash_image;
7984754b 264extern int kexec_load_disabled;
dc009d92 265
a7956113
ZN
266#ifndef kexec_flush_icache_page
267#define kexec_flush_icache_page(page)
268#endif
269
3ab83521
HY
270/* List of defined/legal kexec flags */
271#ifndef CONFIG_KEXEC_JUMP
272#define KEXEC_FLAGS KEXEC_ON_CRASH
273#else
274#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT)
275#endif
dc009d92 276
cb105258
VG
277/* List of defined/legal kexec file flags */
278#define KEXEC_FILE_FLAGS (KEXEC_FILE_UNLOAD | KEXEC_FILE_ON_CRASH | \
279 KEXEC_FILE_NO_INITRAMFS)
280
fd59d231
KO
281#define VMCOREINFO_BYTES (4096)
282#define VMCOREINFO_NOTE_NAME "VMCOREINFO"
283#define VMCOREINFO_NOTE_NAME_BYTES ALIGN(sizeof(VMCOREINFO_NOTE_NAME), 4)
284#define VMCOREINFO_NOTE_SIZE (KEXEC_NOTE_HEAD_BYTES*2 + VMCOREINFO_BYTES \
285 + VMCOREINFO_NOTE_NAME_BYTES)
286
dc009d92
EB
287/* Location of a reserved region to hold the crash kernel.
288 */
289extern struct resource crashk_res;
0212f915 290extern struct resource crashk_low_res;
6672f76a 291typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4];
43cf38eb 292extern note_buf_t __percpu *crash_notes;
fd59d231 293extern u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];
d768281e
KO
294extern size_t vmcoreinfo_size;
295extern size_t vmcoreinfo_max_size;
dc009d92 296
4fc9bbf9
KA
297/* flag to track if kexec reboot is in progress */
298extern bool kexec_in_progress;
299
cba63c30
BW
300int __init parse_crashkernel(char *cmdline, unsigned long long system_ram,
301 unsigned long long *crash_size, unsigned long long *crash_base);
55a20ee7
YL
302int parse_crashkernel_high(char *cmdline, unsigned long long system_ram,
303 unsigned long long *crash_size, unsigned long long *crash_base);
0212f915
YL
304int parse_crashkernel_low(char *cmdline, unsigned long long system_ram,
305 unsigned long long *crash_size, unsigned long long *crash_base);
06a7f711
AW
306int crash_shrink_memory(unsigned long new_size);
307size_t crash_get_memory_size(void);
c0bb9e45 308void crash_free_reserved_phys_range(unsigned long begin, unsigned long end);
a7956113 309
dc009d92 310#else /* !CONFIG_KEXEC */
6e274d14
AN
311struct pt_regs;
312struct task_struct;
313static inline void crash_kexec(struct pt_regs *regs) { }
314static inline int kexec_should_crash(struct task_struct *p) { return 0; }
dc009d92
EB
315#endif /* CONFIG_KEXEC */
316#endif /* LINUX_KEXEC_H */
This page took 1.823799 seconds and 5 git commands to generate.