aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
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 /arch/x86/kernel
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 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/machine_kexec_64.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index 679cef0791cd..c8875b5545e1 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -22,6 +22,10 @@
22#include <asm/mmu_context.h> 22#include <asm/mmu_context.h>
23#include <asm/debugreg.h> 23#include <asm/debugreg.h>
24 24
25static struct kexec_file_ops *kexec_file_loaders[] = {
26 NULL,
27};
28
25static void free_transition_pgtable(struct kimage *image) 29static void free_transition_pgtable(struct kimage *image)
26{ 30{
27 free_page((unsigned long)image->arch.pud); 31 free_page((unsigned long)image->arch.pud);
@@ -283,3 +287,44 @@ void arch_crash_save_vmcoreinfo(void)
283 (unsigned long)&_text - __START_KERNEL); 287 (unsigned long)&_text - __START_KERNEL);
284} 288}
285 289
290/* arch-dependent functionality related to kexec file-based syscall */
291
292int arch_kexec_kernel_image_probe(struct kimage *image, void *buf,
293 unsigned long buf_len)
294{
295 int i, ret = -ENOEXEC;
296 struct kexec_file_ops *fops;
297
298 for (i = 0; i < ARRAY_SIZE(kexec_file_loaders); i++) {
299 fops = kexec_file_loaders[i];
300 if (!fops || !fops->probe)
301 continue;
302
303 ret = fops->probe(buf, buf_len);
304 if (!ret) {
305 image->fops = fops;
306 return ret;
307 }
308 }
309
310 return ret;
311}
312
313void *arch_kexec_kernel_image_load(struct kimage *image)
314{
315 if (!image->fops || !image->fops->load)
316 return ERR_PTR(-ENOEXEC);
317
318 return image->fops->load(image, image->kernel_buf,
319 image->kernel_buf_len, image->initrd_buf,
320 image->initrd_buf_len, image->cmdline_buf,
321 image->cmdline_buf_len);
322}
323
324int arch_kimage_file_post_load_cleanup(struct kimage *image)
325{
326 if (!image->fops || !image->fops->cleanup)
327 return 0;
328
329 return image->fops->cleanup(image);
330}