aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Tesarik <ptesarik@suse.com>2016-08-02 17:06:16 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-08-02 19:35:30 -0400
commit21db79e8bb054d0351a6b1b464f1c9c47a2e6e8d (patch)
treea34bbff53fad1569f11eac002eeef688ed5dd170
parentb26e27ddfd2a986dc53e259aba572f3aac182eb8 (diff)
kexec: add a kexec_crash_loaded() function
Provide a wrapper function to be used by kernel code to check whether a crash kernel is loaded. It returns the same value that can be seen in /sys/kernel/kexec_crash_loaded by userspace programs. I'm exporting the function, because it will be used by Xen, and it is possible to compile Xen modules separately to enable the use of PV drivers with unmodified bare-metal kernels. Link: http://lkml.kernel.org/r/20160713121955.14969.69080.stgit@hananiah.suse.cz Signed-off-by: Petr Tesarik <ptesarik@suse.com> Cc: Juergen Gross <jgross@suse.com> Cc: Josh Triplett <josh@joshtriplett.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Eric Biederman <ebiederm@xmission.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> Cc: Dave Young <dyoung@redhat.com> Cc: David Vrabel <david.vrabel@citrix.com> Cc: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/kexec.h2
-rw-r--r--kernel/kexec_core.c6
-rw-r--r--kernel/ksysfs.c2
3 files changed, 9 insertions, 1 deletions
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 23e14a460cfb..d7437777baaa 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -230,6 +230,7 @@ extern void *kexec_purgatory_get_symbol_addr(struct kimage *image,
230extern void __crash_kexec(struct pt_regs *); 230extern void __crash_kexec(struct pt_regs *);
231extern void crash_kexec(struct pt_regs *); 231extern void crash_kexec(struct pt_regs *);
232int kexec_should_crash(struct task_struct *); 232int kexec_should_crash(struct task_struct *);
233int kexec_crash_loaded(void);
233void crash_save_cpu(struct pt_regs *regs, int cpu); 234void crash_save_cpu(struct pt_regs *regs, int cpu);
234void crash_save_vmcoreinfo(void); 235void crash_save_vmcoreinfo(void);
235void arch_crash_save_vmcoreinfo(void); 236void arch_crash_save_vmcoreinfo(void);
@@ -364,6 +365,7 @@ struct task_struct;
364static inline void __crash_kexec(struct pt_regs *regs) { } 365static inline void __crash_kexec(struct pt_regs *regs) { }
365static inline void crash_kexec(struct pt_regs *regs) { } 366static inline void crash_kexec(struct pt_regs *regs) { }
366static inline int kexec_should_crash(struct task_struct *p) { return 0; } 367static inline int kexec_should_crash(struct task_struct *p) { return 0; }
368static inline int kexec_crash_loaded(void) { return 0; }
367#define kexec_in_progress false 369#define kexec_in_progress false
368#endif /* CONFIG_KEXEC_CORE */ 370#endif /* CONFIG_KEXEC_CORE */
369 371
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index 73d4c5f57dd8..704534029a00 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -95,6 +95,12 @@ int kexec_should_crash(struct task_struct *p)
95 return 0; 95 return 0;
96} 96}
97 97
98int kexec_crash_loaded(void)
99{
100 return !!kexec_crash_image;
101}
102EXPORT_SYMBOL_GPL(kexec_crash_loaded);
103
98/* 104/*
99 * When kexec transitions to the new kernel there is a one-to-one 105 * When kexec transitions to the new kernel there is a one-to-one
100 * mapping between physical and virtual addresses. On processors 106 * mapping between physical and virtual addresses. On processors
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 9f1920d2d0c6..ee1bc1bb8feb 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -101,7 +101,7 @@ KERNEL_ATTR_RO(kexec_loaded);
101static ssize_t kexec_crash_loaded_show(struct kobject *kobj, 101static ssize_t kexec_crash_loaded_show(struct kobject *kobj,
102 struct kobj_attribute *attr, char *buf) 102 struct kobj_attribute *attr, char *buf)
103{ 103{
104 return sprintf(buf, "%d\n", !!kexec_crash_image); 104 return sprintf(buf, "%d\n", kexec_crash_loaded());
105} 105}
106KERNEL_ATTR_RO(kexec_crash_loaded); 106KERNEL_ATTR_RO(kexec_crash_loaded);
107 107