.. | .. |
---|
15 | 15 | |
---|
16 | 16 | int machine_kexec_post_load(struct kimage *image); |
---|
17 | 17 | |
---|
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 | +} |
---|
19 | 32 | |
---|
20 | 33 | #ifdef CONFIG_KEXEC_FILE |
---|
21 | 34 | #include <linux/purgatory.h> |
---|