crash: split crash dumping code out from kexec_core.c
[linux-2.6-microblaze.git] / kernel / kexec.c
index 8f35a5a..bab542f 100644 (file)
@@ -28,12 +28,14 @@ static int kimage_alloc_init(struct kimage **rimage, unsigned long entry,
        struct kimage *image;
        bool kexec_on_panic = flags & KEXEC_ON_CRASH;
 
+#ifdef CONFIG_CRASH_DUMP
        if (kexec_on_panic) {
                /* Verify we have a valid entry point */
                if ((entry < phys_to_boot_phys(crashk_res.start)) ||
                    (entry > phys_to_boot_phys(crashk_res.end)))
                        return -EADDRNOTAVAIL;
        }
+#endif
 
        /* Allocate and initialize a controlling structure */
        image = do_kimage_alloc_init();
@@ -44,11 +46,13 @@ static int kimage_alloc_init(struct kimage **rimage, unsigned long entry,
        image->nr_segments = nr_segments;
        memcpy(image->segment, segments, nr_segments * sizeof(*segments));
 
+#ifdef CONFIG_CRASH_DUMP
        if (kexec_on_panic) {
                /* Enable special crash kernel control page alloc policy. */
                image->control_page = crashk_res.start;
                image->type = KEXEC_TYPE_CRASH;
        }
+#endif
 
        ret = sanity_check_segment_list(image);
        if (ret)
@@ -99,13 +103,14 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments,
        if (!kexec_trylock())
                return -EBUSY;
 
+#ifdef CONFIG_CRASH_DUMP
        if (flags & KEXEC_ON_CRASH) {
                dest_image = &kexec_crash_image;
                if (kexec_crash_image)
                        arch_kexec_unprotect_crashkres();
-       } else {
+       } else
+#endif
                dest_image = &kexec_image;
-       }
 
        if (nr_segments == 0) {
                /* Uninstall image */
@@ -162,8 +167,10 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments,
        image = xchg(dest_image, image);
 
 out:
+#ifdef CONFIG_CRASH_DUMP
        if ((flags & KEXEC_ON_CRASH) && kexec_crash_image)
                arch_kexec_protect_crashkres();
+#endif
 
        kimage_free(image);
 out_unlock: