diff options
author | Vivek Goyal <vgoyal@redhat.com> | 2014-08-29 18:18:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-29 19:28:16 -0400 |
commit | 74ca317c26a3f8543203b61d262c0ab2e30c384e (patch) | |
tree | e88c78846c33bd3f86034b2ba16616ea38bb2802 /kernel/kexec.c | |
parent | b38af4721f59d0b564468f623b3e52a638195015 (diff) |
kexec: create a new config option CONFIG_KEXEC_FILE for new syscall
Currently new system call kexec_file_load() and all the associated code
compiles if CONFIG_KEXEC=y. But new syscall also compiles purgatory
code which currently uses gcc option -mcmodel=large. This option seems
to be available only gcc 4.4 onwards.
Hiding new functionality behind a new config option will not break
existing users of old gcc. Those who wish to enable new functionality
will require new gcc. Having said that, I am trying to figure out how
can I move away from using -mcmodel=large but that can take a while.
I think there are other advantages of introducing this new config
option. As this option will be enabled only on x86_64, other arches
don't have to compile generic kexec code which will never be used. This
new code selects CRYPTO=y and CRYPTO_SHA256=y. And all other arches had
to do this for CONFIG_KEXEC. Now with introduction of new config
option, we can remove crypto dependency from other arches.
Now CONFIG_KEXEC_FILE is available only on x86_64. So whereever I had
CONFIG_X86_64 defined, I got rid of that.
For CONFIG_KEXEC_FILE, instead of doing select CRYPTO=y, I changed it to
"depends on CRYPTO=y". This should be safer as "select" is not
recursive.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Tested-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/kexec.c')
-rw-r--r-- | kernel/kexec.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/kernel/kexec.c b/kernel/kexec.c index 0b49a0a58102..2bee072268d9 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c | |||
@@ -64,7 +64,9 @@ bool kexec_in_progress = false; | |||
64 | char __weak kexec_purgatory[0]; | 64 | char __weak kexec_purgatory[0]; |
65 | size_t __weak kexec_purgatory_size = 0; | 65 | size_t __weak kexec_purgatory_size = 0; |
66 | 66 | ||
67 | #ifdef CONFIG_KEXEC_FILE | ||
67 | static int kexec_calculate_store_digests(struct kimage *image); | 68 | static int kexec_calculate_store_digests(struct kimage *image); |
69 | #endif | ||
68 | 70 | ||
69 | /* Location of the reserved area for the crash kernel */ | 71 | /* Location of the reserved area for the crash kernel */ |
70 | struct resource crashk_res = { | 72 | struct resource crashk_res = { |
@@ -341,6 +343,7 @@ out_free_image: | |||
341 | return ret; | 343 | return ret; |
342 | } | 344 | } |
343 | 345 | ||
346 | #ifdef CONFIG_KEXEC_FILE | ||
344 | static int copy_file_from_fd(int fd, void **buf, unsigned long *buf_len) | 347 | static int copy_file_from_fd(int fd, void **buf, unsigned long *buf_len) |
345 | { | 348 | { |
346 | struct fd f = fdget(fd); | 349 | struct fd f = fdget(fd); |
@@ -612,6 +615,9 @@ out_free_image: | |||
612 | kfree(image); | 615 | kfree(image); |
613 | return ret; | 616 | return ret; |
614 | } | 617 | } |
618 | #else /* CONFIG_KEXEC_FILE */ | ||
619 | static inline void kimage_file_post_load_cleanup(struct kimage *image) { } | ||
620 | #endif /* CONFIG_KEXEC_FILE */ | ||
615 | 621 | ||
616 | static int kimage_is_destination_range(struct kimage *image, | 622 | static int kimage_is_destination_range(struct kimage *image, |
617 | unsigned long start, | 623 | unsigned long start, |
@@ -1375,6 +1381,7 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry, | |||
1375 | } | 1381 | } |
1376 | #endif | 1382 | #endif |
1377 | 1383 | ||
1384 | #ifdef CONFIG_KEXEC_FILE | ||
1378 | SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd, | 1385 | SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd, |
1379 | unsigned long, cmdline_len, const char __user *, cmdline_ptr, | 1386 | unsigned long, cmdline_len, const char __user *, cmdline_ptr, |
1380 | unsigned long, flags) | 1387 | unsigned long, flags) |
@@ -1451,6 +1458,8 @@ out: | |||
1451 | return ret; | 1458 | return ret; |
1452 | } | 1459 | } |
1453 | 1460 | ||
1461 | #endif /* CONFIG_KEXEC_FILE */ | ||
1462 | |||
1454 | void crash_kexec(struct pt_regs *regs) | 1463 | void crash_kexec(struct pt_regs *regs) |
1455 | { | 1464 | { |
1456 | /* Take the kexec_mutex here to prevent sys_kexec_load | 1465 | /* Take the kexec_mutex here to prevent sys_kexec_load |
@@ -2006,6 +2015,7 @@ static int __init crash_save_vmcoreinfo_init(void) | |||
2006 | 2015 | ||
2007 | subsys_initcall(crash_save_vmcoreinfo_init); | 2016 | subsys_initcall(crash_save_vmcoreinfo_init); |
2008 | 2017 | ||
2018 | #ifdef CONFIG_KEXEC_FILE | ||
2009 | static int __kexec_add_segment(struct kimage *image, char *buf, | 2019 | static int __kexec_add_segment(struct kimage *image, char *buf, |
2010 | unsigned long bufsz, unsigned long mem, | 2020 | unsigned long bufsz, unsigned long mem, |
2011 | unsigned long memsz) | 2021 | unsigned long memsz) |
@@ -2682,6 +2692,7 @@ int kexec_purgatory_get_set_symbol(struct kimage *image, const char *name, | |||
2682 | 2692 | ||
2683 | return 0; | 2693 | return 0; |
2684 | } | 2694 | } |
2695 | #endif /* CONFIG_KEXEC_FILE */ | ||
2685 | 2696 | ||
2686 | /* | 2697 | /* |
2687 | * Move into place and start executing a preloaded standalone | 2698 | * Move into place and start executing a preloaded standalone |