aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kexec.h
diff options
context:
space:
mode:
authorVivek Goyal <vgoyal@redhat.com>2014-08-08 17:25:57 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-08 18:57:32 -0400
commitcb1052581e2bddd6096544f3f944f4e7fdad4c7f (patch)
treec802781e0c67685bfe062d9a04d09cdb4ff82aea /include/linux/kexec.h
parentf0895685c7fd8c938c91a9d8a6f7c11f22df58d2 (diff)
kexec: implementation of new syscall kexec_file_load
Previous patch provided the interface definition and this patch prvides implementation of new syscall. Previously segment list was prepared in user space. Now user space just passes kernel fd, initrd fd and command line and kernel will create a segment list internally. This patch contains generic part of the code. Actual segment preparation and loading is done by arch and image specific loader. Which comes in next patch. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Cc: Borislav Petkov <bp@suse.de> Cc: Michael Kerrisk <mtk.manpages@gmail.com> Cc: Yinghai Lu <yinghai@kernel.org> Cc: Eric Biederman <ebiederm@xmission.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Matthew Garrett <mjg59@srcf.ucam.org> Cc: Greg Kroah-Hartman <greg@kroah.com> Cc: Dave Young <dyoung@redhat.com> Cc: WANG Chao <chaowang@redhat.com> Cc: Baoquan He <bhe@redhat.com> Cc: Andy Lutomirski <luto@amacapital.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/kexec.h')
-rw-r--r--include/linux/kexec.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 66d56ac0f64c..8e80901e466f 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -121,13 +121,57 @@ struct kimage {
121#define KEXEC_TYPE_DEFAULT 0 121#define KEXEC_TYPE_DEFAULT 0
122#define KEXEC_TYPE_CRASH 1 122#define KEXEC_TYPE_CRASH 1
123 unsigned int preserve_context : 1; 123 unsigned int preserve_context : 1;
124 /* If set, we are using file mode kexec syscall */
125 unsigned int file_mode:1;
124 126
125#ifdef ARCH_HAS_KIMAGE_ARCH 127#ifdef ARCH_HAS_KIMAGE_ARCH
126 struct kimage_arch arch; 128 struct kimage_arch arch;
127#endif 129#endif
130
131 /* Additional fields for file based kexec syscall */
132 void *kernel_buf;
133 unsigned long kernel_buf_len;
134
135 void *initrd_buf;
136 unsigned long initrd_buf_len;
137
138 char *cmdline_buf;
139 unsigned long cmdline_buf_len;
140
141 /* File operations provided by image loader */
142 struct kexec_file_ops *fops;
143
144 /* Image loader handling the kernel can store a pointer here */
145 void *image_loader_data;
128}; 146};
129 147
148/*
149 * Keeps track of buffer parameters as provided by caller for requesting
150 * memory placement of buffer.
151 */
152struct kexec_buf {
153 struct kimage *image;
154 char *buffer;
155 unsigned long bufsz;
156 unsigned long memsz;
157 unsigned long buf_align;
158 unsigned long buf_min;
159 unsigned long buf_max;
160 bool top_down; /* allocate from top of memory hole */
161};
130 162
163typedef int (kexec_probe_t)(const char *kernel_buf, unsigned long kernel_size);
164typedef void *(kexec_load_t)(struct kimage *image, char *kernel_buf,
165 unsigned long kernel_len, char *initrd,
166 unsigned long initrd_len, char *cmdline,
167 unsigned long cmdline_len);
168typedef int (kexec_cleanup_t)(struct kimage *image);
169
170struct kexec_file_ops {
171 kexec_probe_t *probe;
172 kexec_load_t *load;
173 kexec_cleanup_t *cleanup;
174};
131 175
132/* kexec interface functions */ 176/* kexec interface functions */
133extern void machine_kexec(struct kimage *image); 177extern void machine_kexec(struct kimage *image);
@@ -138,6 +182,11 @@ extern asmlinkage long sys_kexec_load(unsigned long entry,
138 struct kexec_segment __user *segments, 182 struct kexec_segment __user *segments,
139 unsigned long flags); 183 unsigned long flags);
140extern int kernel_kexec(void); 184extern int kernel_kexec(void);
185extern int kexec_add_buffer(struct kimage *image, char *buffer,
186 unsigned long bufsz, unsigned long memsz,
187 unsigned long buf_align, unsigned long buf_min,
188 unsigned long buf_max, bool top_down,
189 unsigned long *load_addr);
141extern struct page *kimage_alloc_control_pages(struct kimage *image, 190extern struct page *kimage_alloc_control_pages(struct kimage *image,
142 unsigned int order); 191 unsigned int order);
143extern void crash_kexec(struct pt_regs *); 192extern void crash_kexec(struct pt_regs *);
@@ -188,6 +237,10 @@ extern int kexec_load_disabled;
188#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT) 237#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT)
189#endif 238#endif
190 239
240/* List of defined/legal kexec file flags */
241#define KEXEC_FILE_FLAGS (KEXEC_FILE_UNLOAD | KEXEC_FILE_ON_CRASH | \
242 KEXEC_FILE_NO_INITRAMFS)
243
191#define VMCOREINFO_BYTES (4096) 244#define VMCOREINFO_BYTES (4096)
192#define VMCOREINFO_NOTE_NAME "VMCOREINFO" 245#define VMCOREINFO_NOTE_NAME "VMCOREINFO"
193#define VMCOREINFO_NOTE_NAME_BYTES ALIGN(sizeof(VMCOREINFO_NOTE_NAME), 4) 246#define VMCOREINFO_NOTE_NAME_BYTES ALIGN(sizeof(VMCOREINFO_NOTE_NAME), 4)