hc
2024-05-10 61598093bbdd283a7edc367d900f223070ead8d2
kernel/kernel/kexec_internal.h
....@@ -15,7 +15,20 @@
1515
1616 int machine_kexec_post_load(struct kimage *image);
1717
18
-extern struct mutex kexec_mutex;
18
+/*
19
+ * Whatever is used to serialize accesses to the kexec_crash_image needs to be
20
+ * NMI safe, as __crash_kexec() can happen during nmi_panic(), so here we use a
21
+ * "simple" atomic variable that is acquired with a cmpxchg().
22
+ */
23
+extern atomic_t __kexec_lock;
24
+static inline bool kexec_trylock(void)
25
+{
26
+ return atomic_cmpxchg_acquire(&__kexec_lock, 0, 1) == 0;
27
+}
28
+static inline void kexec_unlock(void)
29
+{
30
+ atomic_set_release(&__kexec_lock, 0);
31
+}
1932
2033 #ifdef CONFIG_KEXEC_FILE
2134 #include <linux/purgatory.h>