Re: [PATCH][2/4] kexec: Enable co-existence of normal kexec Imageand kexec on panic Image

From: Hariprasad Nellitheertha
Date: Thu Oct 21 2004 - 06:07:59 EST


This patch, to kexec, makes it possible to separate out the two uses of kexec - for normal kexec usage and kexec-on-panic. The image for the panic case is loaded using the "kexec -p" option instead of "kexec -l".

Regards, Hari
Signed-off-by: Hariprasad Nellitheertha <hari@xxxxxxxxxx>
---

linux-kexec-hari/include/linux/kexec.h | 1 +
linux-kexec-hari/kernel/kexec.c | 13 +++++--------
2 files changed, 6 insertions(+), 8 deletions(-)

diff -puN include/linux/kexec.h~kexec-panic include/linux/kexec.h
--- linux-kexec/include/linux/kexec.h~kexec-panic 2004-10-18 14:59:01.000000000 +0530
+++ linux-kexec-hari/include/linux/kexec.h 2004-10-18 15:00:33.000000000 +0530
@@ -52,5 +52,6 @@ extern asmlinkage long sys_kexec(unsigne
struct kexec_segment *segments);
extern struct page *kimage_alloc_control_pages(struct kimage *image, unsigned int order);
extern struct kimage *kexec_image;
+extern struct kimage *kexec_crash_image;
#endif
#endif /* LINUX_KEXEC_H */
diff -puN kernel/kexec.c~kexec-panic kernel/kexec.c
--- linux-kexec/kernel/kexec.c~kexec-panic 2004-10-18 14:59:01.000000000 +0530
+++ linux-kexec-hari/kernel/kexec.c 2004-10-19 14:12:33.000000000 +0530
@@ -585,6 +585,7 @@ static int kimage_load_segment(struct ki
* that to happen you need to do that yourself.
*/
struct kimage *kexec_image = NULL;
+struct kimage *kexec_crash_image = NULL;

asmlinkage long sys_kexec_load(unsigned long entry, unsigned long nr_segments,
struct kexec_segment *segments, unsigned long flags)
@@ -596,13 +597,6 @@ asmlinkage long sys_kexec_load(unsigned
if (!capable(CAP_SYS_BOOT))
return -EPERM;

- /*
- * In case we need just a little bit of special behavior for
- * reboot on panic.
- */
- if (flags != 0)
- return -EINVAL;
-
if (nr_segments > KEXEC_SEGMENT_MAX)
return -EINVAL;

@@ -632,7 +626,10 @@ asmlinkage long sys_kexec_load(unsigned
}
}

- image = xchg(&kexec_image, image);
+ if (!flags)
+ image = xchg(&kexec_image, image);
+ else
+ image = xchg(&kexec_crash_image, image);

out:
kimage_free(image);
_