kexec: introduce a protection mechanism for the crashkernel reserved memory
[sfrench/cifs-2.6.git] / kernel / kexec.c
index ee70aef5cd81dfb7ee5c4397b91810b0109a58b8..b44cb3f5a15ce0faef496b948d039bdf73b21f74 100644 (file)
@@ -167,8 +167,12 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
                return -EBUSY;
 
        dest_image = &kexec_image;
-       if (flags & KEXEC_ON_CRASH)
+       if (flags & KEXEC_ON_CRASH) {
                dest_image = &kexec_crash_image;
+               if (kexec_crash_image)
+                       arch_kexec_unprotect_crashkres();
+       }
+
        if (nr_segments > 0) {
                unsigned long i;
 
@@ -211,6 +215,9 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
        image = xchg(dest_image, image);
 
 out:
+       if ((flags & KEXEC_ON_CRASH) && kexec_crash_image)
+               arch_kexec_protect_crashkres();
+
        mutex_unlock(&kexec_mutex);
        kimage_free(image);