aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authormaximilian attems <max@stro.at>2012-05-31 19:26:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-31 20:49:30 -0400
commit29a5c67e7a78815fda0567a867adce467f6e6e5a (patch)
tree79033c85c4d2a4875e4b17e292f015495b97457b /include/linux
parente4cc2f873ad0833aa5c4aca56bebe15b9603a1e7 (diff)
kexec: export kexec.h to user space
Add userspace definitions, guard all relevant kernel structures. While at it document stuff and remove now useless userspace hint. It is easy to add the relevant system call to respective libc's, but it seems pointless to have to duplicate the data structures. This is based on the kexec-tools headers, with the exception of just using int on return (succes or failure) and using size_t instead of 'unsigned long int' for the number of segments argument of kexec_load(). Signed-off-by: maximilian attems <max@stro.at> Cc: Simon Horman <horms@verge.net.au> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: Haren Myneni <hbabu@us.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/Kbuild1
-rw-r--r--include/linux/kexec.h75
2 files changed, 54 insertions, 22 deletions
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 7185b8f15ced..8760be30b375 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -226,6 +226,7 @@ header-y += kdev_t.h
226header-y += kernel.h 226header-y += kernel.h
227header-y += kernelcapi.h 227header-y += kernelcapi.h
228header-y += kernel-page-flags.h 228header-y += kernel-page-flags.h
229header-y += kexec.h
229header-y += keyboard.h 230header-y += keyboard.h
230header-y += keyctl.h 231header-y += keyctl.h
231header-y += l2tp.h 232header-y += l2tp.h
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 0d7d6a1b172f..37c5f7261142 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -1,8 +1,58 @@
1#ifndef LINUX_KEXEC_H 1#ifndef LINUX_KEXEC_H
2#define LINUX_KEXEC_H 2#define LINUX_KEXEC_H
3 3
4#ifdef CONFIG_KEXEC 4/* kexec system call - It loads the new kernel to boot into.
5 * kexec does not sync, or unmount filesystems so if you need
6 * that to happen you need to do that yourself.
7 */
8
5#include <linux/types.h> 9#include <linux/types.h>
10
11/* kexec flags for different usage scenarios */
12#define KEXEC_ON_CRASH 0x00000001
13#define KEXEC_PRESERVE_CONTEXT 0x00000002
14#define KEXEC_ARCH_MASK 0xffff0000
15
16/* These values match the ELF architecture values.
17 * Unless there is a good reason that should continue to be the case.
18 */
19#define KEXEC_ARCH_DEFAULT ( 0 << 16)
20#define KEXEC_ARCH_386 ( 3 << 16)
21#define KEXEC_ARCH_X86_64 (62 << 16)
22#define KEXEC_ARCH_PPC (20 << 16)
23#define KEXEC_ARCH_PPC64 (21 << 16)
24#define KEXEC_ARCH_IA_64 (50 << 16)
25#define KEXEC_ARCH_ARM (40 << 16)
26#define KEXEC_ARCH_S390 (22 << 16)
27#define KEXEC_ARCH_SH (42 << 16)
28#define KEXEC_ARCH_MIPS_LE (10 << 16)
29#define KEXEC_ARCH_MIPS ( 8 << 16)
30
31/* The artificial cap on the number of segments passed to kexec_load. */
32#define KEXEC_SEGMENT_MAX 16
33
34#ifndef __KERNEL__
35/*
36 * This structure is used to hold the arguments that are used when
37 * loading kernel binaries.
38 */
39struct kexec_segment {
40 const void *buf;
41 size_t bufsz;
42 const void *mem;
43 size_t memsz;
44};
45
46/* Load a new kernel image as described by the kexec_segment array
47 * consisting of passed number of segments at the entry-point address.
48 * The flags allow different useage types.
49 */
50extern int kexec_load(void *, size_t, struct kexec_segment *,
51 unsigned long int);
52#endif /* __KERNEL__ */
53
54#ifdef __KERNEL__
55#ifdef CONFIG_KEXEC
6#include <linux/list.h> 56#include <linux/list.h>
7#include <linux/linkage.h> 57#include <linux/linkage.h>
8#include <linux/compat.h> 58#include <linux/compat.h>
@@ -67,11 +117,10 @@ typedef unsigned long kimage_entry_t;
67#define IND_DONE 0x4 117#define IND_DONE 0x4
68#define IND_SOURCE 0x8 118#define IND_SOURCE 0x8
69 119
70#define KEXEC_SEGMENT_MAX 16
71struct kexec_segment { 120struct kexec_segment {
72 void __user *buf; 121 void __user *buf;
73 size_t bufsz; 122 size_t bufsz;
74 unsigned long mem; /* User space sees this as a (void *) ... */ 123 unsigned long mem;
75 size_t memsz; 124 size_t memsz;
76}; 125};
77 126
@@ -175,25 +224,6 @@ extern struct kimage *kexec_crash_image;
175#define kexec_flush_icache_page(page) 224#define kexec_flush_icache_page(page)
176#endif 225#endif
177 226
178#define KEXEC_ON_CRASH 0x00000001
179#define KEXEC_PRESERVE_CONTEXT 0x00000002
180#define KEXEC_ARCH_MASK 0xffff0000
181
182/* These values match the ELF architecture values.
183 * Unless there is a good reason that should continue to be the case.
184 */
185#define KEXEC_ARCH_DEFAULT ( 0 << 16)
186#define KEXEC_ARCH_386 ( 3 << 16)
187#define KEXEC_ARCH_X86_64 (62 << 16)
188#define KEXEC_ARCH_PPC (20 << 16)
189#define KEXEC_ARCH_PPC64 (21 << 16)
190#define KEXEC_ARCH_IA_64 (50 << 16)
191#define KEXEC_ARCH_ARM (40 << 16)
192#define KEXEC_ARCH_S390 (22 << 16)
193#define KEXEC_ARCH_SH (42 << 16)
194#define KEXEC_ARCH_MIPS_LE (10 << 16)
195#define KEXEC_ARCH_MIPS ( 8 << 16)
196
197/* List of defined/legal kexec flags */ 227/* List of defined/legal kexec flags */
198#ifndef CONFIG_KEXEC_JUMP 228#ifndef CONFIG_KEXEC_JUMP
199#define KEXEC_FLAGS KEXEC_ON_CRASH 229#define KEXEC_FLAGS KEXEC_ON_CRASH
@@ -228,4 +258,5 @@ struct task_struct;
228static inline void crash_kexec(struct pt_regs *regs) { } 258static inline void crash_kexec(struct pt_regs *regs) { }
229static inline int kexec_should_crash(struct task_struct *p) { return 0; } 259static inline int kexec_should_crash(struct task_struct *p) { return 0; }
230#endif /* CONFIG_KEXEC */ 260#endif /* CONFIG_KEXEC */
261#endif /* __KERNEL__ */
231#endif /* LINUX_KEXEC_H */ 262#endif /* LINUX_KEXEC_H */