Kexec jump - v2 - kexec jump
Subsystems (4)
PATCH 1/1 Kexec jump - v2 - kexec jump
This patch implement the functionality of jumping from kexeced kernel to original kernel.
A new reboot command named LINUX_REBOOT_CMD_KJUMP is defined to trigger the jumping to (executing) the new kernel or jumping back to the original kernel.
To support jumping back from kexeced kernel, before executing the new kernel, the devices are put into quiescent state (to be fully implemented), and the state of devices and CPU is saved. After jumping back from kexeced kernel, the state of devices and CPU are restored accordingly. The devices/CPU state save/restore code of software suspend is called to implement corresponding function.
---
arch/i386/Kconfig | 7 +++ arch/i386/kernel/Makefile | 1 arch/i386/kernel/kexec_jump.S | 74 +++++++++++++++++++++++++++++++++++++ arch/i386/kernel/machine_kexec.c | 59 +++++++++++++++++++++++++++++ include/asm-i386/kexec.h | 4 ++ include/linux/kexec.h | 17 ++++++++ include/linux/reboot.h | 1 kernel/kexec.c | 78 +++++++++++++++++++++++++++++++++++++++ kernel/ksysfs.c | 12 ++++++ kernel/sys.c | 8 ++++ 10 files changed, 261 insertions(+)
arch/i386/kernel/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_X86_REBOOTFIXUPS) += reboot_fixups.o obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o obj-$(CONFIG_CRASH_DUMP) += crash_dump.o +obj-$(CONFIG_KEXEC_JUMP) += kexec_jump.o obj-$(CONFIG_X86_NUMAQ) += numaq.o obj-$(CONFIG_X86_SUMMIT_NUMA) += summit.o obj-$(CONFIG_KPROBES) += kprobes.o
arch/i386/kernel/machine_kexec.c +59 -0
68 lines not on this page · raw message
include/asm-i386/kexec.h +4 -0
@@ -94,6 +94,10 @@unsigned long start_address, unsigned int has_pae) ATTRIB_NORET; +#ifdef CONFIG_KEXEC_JUMP +extern asmlinkage int machine_kexec_real_jump(void *buf); +#endif +#endif /* __ASSEMBLY__ */ #endif /* _I386_KEXEC_H */
include/linux/kexec.h +17 -0
@@ -1,6 +1,11 @@#ifndef LINUX_KEXEC_H #define LINUX_KEXEC_H +#ifdef CONFIG_KEXEC_JUMP +#define KEXEC_FLAGS_IS_KEXECED_KERNEL 0x1 +#endif /* CONFIG_KEXEC_JUMP */ + +#ifndef __ASSEMBLY__#ifdef CONFIG_KEXEC #include <linux/types.h> #include <linux/list.h>
@@ -161,4 +166,16 @@static inline void crash_kexec (struct pt_regs *regs) { }static inline int kexec_should_crash (struct task_struct *p) {return 0 ; }#endif /* CONFIG_KEXEC */ + +#ifdef CONFIG_KEXEC_JUMP +extern int kexec_flags; +extern int machine_kexec_jump (void ); +extern int kexec_jump (void ); +extern unsigned long kexec_get_jump_buf_pfn (int alloc); +extern void kexec_restore_backup (void ); +#else +static inline int kexec_jump (void ) {return 0 ; } +#endif /* CONFIG_KEXEC_JUMP */ +#endif /* !__ASSEMBLY__ */ +#endif /* LINUX_KEXEC_H */
kernel/kexec.c +78 -0
87 lines not on this page · raw message
kernel/ksysfs.c +12 -0
@@ -60,6 +60,15 @@ return sprintf(page, "%d\n", !!kexec_crash_image); }KERNEL_ATTR_RO (kexec_crash_loaded); + +#ifdef CONFIG_KEXEC_JUMP +static ssize_t kexec_jump_buf_pfn_show (struct kset *kset,char *page) +{ +return sprintf (page,"0x%lx\n" ,kexec_get_jump_buf_pfn (1 )); +} + +KERNEL_ATTR_RO (kexec_jump_buf_pfn); +#endif #endif /* CONFIG_KEXEC */ decl_subsys (kernel,NULL ,NULL );
@@ -73,6 +82,9 @@#ifdef CONFIG_KEXEC &kexec_loaded_attr.attr, &kexec_crash_loaded_attr.attr, +#ifdef CONFIG_KEXEC_JUMP + &kexec_jump_buf_pfn_attr.attr, +#endif #endifNULL };
arch/i386/kernel/kexec_jump.S new file +74 -0
74 lines not on this page · raw message
kernel/sys.c +8 -0
@@ -940,6 +940,14 @@unlock_kernel ();return -EINVAL ; +case LINUX_REBOOT_CMD_KJUMP : + { +int ret; + ret =kexec_jump (); +unlock_kernel (); +return ret; + } +#ifdef CONFIG_SOFTWARE_SUSPEND case LINUX_REBOOT_CMD_SW_SUSPEND : {
include/linux/reboot.h +1 -0
@@ -33,6 +33,7 @@#define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4#define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2#define LINUX_REBOOT_CMD_KEXEC 0x45584543 +#define LINUX_REBOOT_CMD_KJUMP 0x3928A5FD#ifdef __KERNEL__
arch/i386/Kconfig +7 -0
@@ -813,6 +813,13 @@ PHYSICAL_START. For more details see Documentation/kdump/kdump.txt +config KEXEC_JUMP + bool "kexec jump (EXPERIMENTAL)" + depends on EXPERIMENTAL + depends on PM && X86_32 && KEXEC + ---help--- + Jump back from kexeced kernel to orignal kernel. + config PHYSICAL_START hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP) default "0x100000"
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi!
Quoted 6 lines
This patch implement the functionality of jumping from kexeced kernel to original kernel.
A new reboot command named
LINUX_REBOOT_CMD_KJUMPis defined to trigger the jumping to (executing) the new kernel or jumping back to the original kernel.
Could we get two reboot commands? Exec loaded kernel seems to be quite different operation than "jump back".
How do I test these patches? kexec -p <bzImage>, then kexec -j?
Quoted 4 lines
arch/i386/kernel/machine_kexec.c +4
-0+static unsigned long kexec_backup_addr = ~0UL ; + +/* kexec_backup= specifies the location of backuped 0~640k memory of +* crashed kernel.
arch/i386/kernel/machine_kexec.c line 210
Quoted 10 lines
arch/i386/kernel/machine_kexec.c +10
-0+*/ +static int __init parse_kexec_backup (char *arg) +{ +if (!arg) +return -EINVAL ; + + kexec_backup_addr =memparse (arg, &arg); +return 0 ; +} +early_param ("kexec_backup" , parse_kexec_backup);
New kernel parameters should be documented. (Plus I do not know how to use this one, please help :-).
Quoted 4 lines
kernel/kexec.c +4
-0+int kexec_flags; + +static unsigned long kexec_jump_buf_pfn; +
kernel/kexec.c line 1156
Quoted 10 lines
kernel/kexec.c +10
-0+static int __init parse_kexec_jump_buf_pfn (char *arg) +{ +if (!arg) +return -EINVAL ; + + kexec_jump_buf_pfn =memparse (arg, &arg); + kexec_flags |=KEXEC_FLAGS_IS_KEXECED_KERNEL ; +return 0 ; +} +early_param ("kexec_jump_buf_pfn" , parse_kexec_jump_buf_pfn);
This one should be documented, too, I'd guess. (Is that internal, kernel-to-kernel communication?)
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 6 lines
This patch implement the functionality of jumping from kexeced kernel to original kernel.
A new reboot command named
LINUX_REBOOT_CMD_KJUMPis defined to trigger the jumping to (executing) the new kernel or jumping back to the original kernel.
Could we get two reboot commands? Exec loaded kernel seems to be quite different operation than "jump back".
How do I test these patches? kexec -p <bzImage>, then kexec -j?
Quoted 4 lines
arch/i386/kernel/machine_kexec.c +4
-0+static unsigned long kexec_backup_addr = ~0UL ; + +/* kexec_backup= specifies the location of backuped 0~640k memory of +* crashed kernel.
arch/i386/kernel/machine_kexec.c line 210
Quoted 10 lines
arch/i386/kernel/machine_kexec.c +10
-0+*/ +static int __init parse_kexec_backup (char *arg) +{ +if (!arg) +return -EINVAL ; + + kexec_backup_addr =memparse (arg, &arg); +return 0 ; +} +early_param ("kexec_backup" , parse_kexec_backup);
New kernel parameters should be documented. (Plus I do not know how to use this one, please help :-).
Quoted 4 lines
kernel/kexec.c +4
-0+int kexec_flags; + +static unsigned long kexec_jump_buf_pfn; +
kernel/kexec.c line 1156
Quoted 10 lines
kernel/kexec.c +10
-0+static int __init parse_kexec_jump_buf_pfn (char *arg) +{ +if (!arg) +return -EINVAL ; + + kexec_jump_buf_pfn =memparse (arg, &arg); + kexec_flags |=KEXEC_FLAGS_IS_KEXECED_KERNEL ; +return 0 ; +} +early_param ("kexec_jump_buf_pfn" , parse_kexec_jump_buf_pfn);
This one should be documented, too, I'd guess. (Is that internal, kernel-to-kernel communication?)
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 11 lines · Pavel Machek
Hi!
Quoted 6 lines
This patch implement the functionality of jumping from kexeced kernel to original kernel.
A new reboot command named
LINUX_REBOOT_CMD_KJUMPis defined to trigger the jumping to (executing) the new kernel or jumping back to the original kernel.Could we get two reboot commands? Exec loaded kernel seems to be quite different operation than "jump back".
Exec loaded kernel for jumping back is also different from exec loaded kernel normally.
Maybe the two reboot operations in kexec jump can be seen as "jump to" and "jump back"?
Quoted 1 line
How do I test these patches? kexec -p <bzImage>, then kexec -j?
Yes.
Quoted 9 lines
Quoted 9 lines
arch/i386/kernel/machine_kexec.c +9
-0+static unsigned long kexec_backup_addr = ~0UL ; + +/* kexec_backup= specifies the location of backuped 0~640k memory of +* crashed kernel. +*/ +static int __init parse_kexec_backup (char *arg) +{ +if (!arg) +return -EINVAL ;
Quoted 8 lines
arch/i386/kernel/machine_kexec.c line 210
Quoted 5 lines
arch/i386/kernel/machine_kexec.c +5
-0+ + kexec_backup_addr =memparse (arg, &arg); +return 0 ; +} +early_param ("kexec_backup" , parse_kexec_backup);New kernel parameters should be documented. (Plus I do not know how to use this one, please help :-).
This kernel parameter will be added to kernel command line by kexec-tools automatically.
I will add corresponding document in next version.
Quoted 10 lines
Quoted 10 lines
kernel/kexec.c +9
-0+int kexec_flags; + +static unsigned long kexec_jump_buf_pfn; + +static int __init parse_kexec_jump_buf_pfn (char *arg) +{ +if (!arg) +return -EINVAL ; +
Quoted 8 lines
kernel/kexec.c line 1156
Quoted 5 lines
kernel/kexec.c +5
-0+ kexec_jump_buf_pfn =memparse (arg, &arg); + kexec_flags |=KEXEC_FLAGS_IS_KEXECED_KERNEL ; +return 0 ; +} +early_param ("kexec_jump_buf_pfn" , parse_kexec_jump_buf_pfn);This one should be documented, too, I'd guess. (Is that internal, kernel-to-kernel communication?)
Document will be added in next version too.
This parameter is used for kernel-to-kernel communication. But now, it must be setup by user, as in usage guide.
Best Regards,
Huang Ying
Quoted 11 lines · Pavel Machek
Hi!
Quoted 6 lines
This patch implement the functionality of jumping from kexeced kernel to original kernel.
A new reboot command named
LINUX_REBOOT_CMD_KJUMPis defined to trigger the jumping to (executing) the new kernel or jumping back to the original kernel.Could we get two reboot commands? Exec loaded kernel seems to be quite different operation than "jump back".
Exec loaded kernel for jumping back is also different from exec loaded kernel normally.
Maybe the two reboot operations in kexec jump can be seen as "jump to" and "jump back"?
Quoted 1 line
How do I test these patches? kexec -p <bzImage>, then kexec -j?
Yes.
Quoted 9 lines
Quoted 9 lines
arch/i386/kernel/machine_kexec.c +9
-0+static unsigned long kexec_backup_addr = ~0UL ; + +/* kexec_backup= specifies the location of backuped 0~640k memory of +* crashed kernel. +*/ +static int __init parse_kexec_backup (char *arg) +{ +if (!arg) +return -EINVAL ;
Quoted 8 lines
arch/i386/kernel/machine_kexec.c line 210
Quoted 5 lines
arch/i386/kernel/machine_kexec.c +5
-0+ + kexec_backup_addr =memparse (arg, &arg); +return 0 ; +} +early_param ("kexec_backup" , parse_kexec_backup);New kernel parameters should be documented. (Plus I do not know how to use this one, please help :-).
This kernel parameter will be added to kernel command line by kexec-tools automatically.
I will add corresponding document in next version.
Quoted 10 lines
Quoted 10 lines
kernel/kexec.c +9
-0+int kexec_flags; + +static unsigned long kexec_jump_buf_pfn; + +static int __init parse_kexec_jump_buf_pfn (char *arg) +{ +if (!arg) +return -EINVAL ; +
Quoted 8 lines
kernel/kexec.c line 1156
Quoted 5 lines
kernel/kexec.c +5
-0+ kexec_jump_buf_pfn =memparse (arg, &arg); + kexec_flags |=KEXEC_FLAGS_IS_KEXECED_KERNEL ; +return 0 ; +} +early_param ("kexec_jump_buf_pfn" , parse_kexec_jump_buf_pfn);This one should be documented, too, I'd guess. (Is that internal, kernel-to-kernel communication?)
Document will be added in next version too.
This parameter is used for kernel-to-kernel communication. But now, it must be setup by user, as in usage guide.
Best Regards,
Huang Ying
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi!
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
This patch implement the functionality of jumping from kexeced kernel to original kernel.
A new reboot command named
LINUX_REBOOT_CMD_KJUMPis defined to trigger the jumping to (executing) the new kernel or jumping back to the original kernel.
Quoted 8 lines
Quoted 2 lines
Could we get two reboot commands? Exec loaded kernel seems to be quite different operation than "jump back".
Exec loaded kernel for jumping back is also different from exec loaded kernel normally.
Maybe the two reboot operations in kexec jump can be seen as "jump to" and "jump back"?
Yes, that would be better.
Quoted 4 lines
Document will be added in next version too.
This parameter is used for kernel-to-kernel communication. But now, it must be setup by user, as in usage guide.
Thanks for your help :-).
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
This patch implement the functionality of jumping from kexeced kernel to original kernel.
A new reboot command named
LINUX_REBOOT_CMD_KJUMPis defined to trigger the jumping to (executing) the new kernel or jumping back to the original kernel.
Quoted 8 lines
Quoted 2 lines
Could we get two reboot commands? Exec loaded kernel seems to be quite different operation than "jump back".
Exec loaded kernel for jumping back is also different from exec loaded kernel normally.
Maybe the two reboot operations in kexec jump can be seen as "jump to" and "jump back"?
Yes, that would be better.
Quoted 4 lines
Document will be added in next version too.
This parameter is used for kernel-to-kernel communication. But now, it must be setup by user, as in usage guide.
Thanks for your help :-).
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Pavel,
Are you still having problem w/ kexec and the Intel NIC? What kernel are you trying to kexec? There's a problem when placing the e1000 into D3hot when an older kernel is the target of the kexec. The problem is manifested by the BARs being 0 in the kexec'd kernel. We've checked the PCI specs and believe the e1000 is behaving in a compliant way. We've seen this when trying to use kexec to boot any RHEL4 (2.6.9-basis) kernel; I've not seen it when trying to kexec 2.6.14 or later kernels.
We see work was done in later kernels to properly handle the D3hot to D0 transition that's so problematic to 2.6.9. And ugly hack that works around this problem is to not put the NIC in D3hot if we know we're going to kexec an older kernel--fortunately, this appears to be safe even when a newer kernel, that doesn't have that problem, is to be started. I published that ugly nasty patch to the kboot list as that's the environment whence we ran into the problem and it only affects older kernels.
I'll be happy to provide more detail if needed.
Signature · 7 lines
David N. Lombard, Intel, Irvine, CA I do not speak for Intel Corporation; all comments are strictly my own. _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Hi!
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
kernel/kexec.c +9
-0+int kexec_flags; + +static unsigned long kexec_jump_buf_pfn; + +static int __init parse_kexec_jump_buf_pfn (char *arg) +{ +if (!arg) +return -EINVAL ; +Quoted 8 lines
kernel/kexec.c line 1156
Quoted 5 lines
kernel/kexec.c +5
-0+ kexec_jump_buf_pfn =memparse (arg, &arg); + kexec_flags |=KEXEC_FLAGS_IS_KEXECED_KERNEL ; +return 0 ; +} +early_param ("kexec_jump_buf_pfn" , parse_kexec_jump_buf_pfn);This one should be documented, too, I'd guess. (Is that internal, kernel-to-kernel communication?)
Quoted 1 line
Document will be added in next version too.
Ping... is there some next version?
I'm stuck at the tools side currently. kexec-1.101 just won't load the kernel properly, and kexec-testing from git does not know -j option. I tried hand-patching it, but got lots of scary rejects.
Is there chance for a patch against kexec-testing?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 2 lines
Are you still having problem w/ kexec and the Intel NIC? What kernel
I'm afraid I have problem w/ kexec. I tried to get kjump to run, but thinkpad x60 will not boot with acpi=off. (And there are still some problems with tools).
Quoted 2 lines
We see work was done in later kernels to properly handle the D3hot to D0 transition that's so problematic to 2.6.9. And ugly hack that works
I'm using 2.6.23-rc2 here.
Pavel
Signature · 7 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Hi!
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
kernel/kexec.c +9
-0+int kexec_flags; + +static unsigned long kexec_jump_buf_pfn; + +static int __init parse_kexec_jump_buf_pfn (char *arg) +{ +if (!arg) +return -EINVAL ; +Quoted 8 lines
kernel/kexec.c line 1156
Quoted 5 lines
kernel/kexec.c +5
-0+ kexec_jump_buf_pfn =memparse (arg, &arg); + kexec_flags |=KEXEC_FLAGS_IS_KEXECED_KERNEL ; +return 0 ; +} +early_param ("kexec_jump_buf_pfn" , parse_kexec_jump_buf_pfn);This one should be documented, too, I'd guess. (Is that internal, kernel-to-kernel communication?)
Quoted 1 line
Document will be added in next version too.
Ping... is there some next version?
I'm stuck at the tools side currently. kexec-1.101 just won't load the kernel properly, and kexec-testing from git does not know -j option. I tried hand-patching it, but got lots of scary rejects.
Is there chance for a patch against kexec-testing?
Pavel
Signature · 7 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Hi, Pavel,
Quoted 7 lines · Pavel Machek
Ping... is there some next version?
I'm stuck at the tools side currently. kexec-1.101 just won't load the kernel properly, and kexec-testing from git does not know -j option. I tried hand-patching it, but got lots of scary rejects.
Is there chance for a patch against kexec-testing?
I have some other work to do recently. So the next version will delay for some while. :(
But now, I have a patch against kexec-tools-testing.
Best Regards,
Huang Ying
kexec/arch/i386/crashdump-x86.c +24 -0
@@ -428,6 +428,29 @@return 0 ; } +/* Adds the kexec_backup= command line parameter to command line. */ +static int cmdline_add_backup (char *cmdline,unsigned long addr) +{ +int cmdlen, len, align =1024 ; +char str[30 ], *ptr; + +/* Passing in kexec_backup=xxxK format. Saves space required +* in cmdline. Ensure 1K alignment*/ +if (addr%align) +return -1 ; + addr = addr/align; + ptr = str; +strcpy (str," kexec_backup=" ); + ptr +=strlen (str); +ultoa (addr, ptr); +strcat (str,"K" ); + len =strlen (str); + cmdlen =strlen (cmdline) + len; +if (cmdlen > (COMMAND_LINE_SIZE -1 )) +die ("Command line overflow\n" ); +strcat (cmdline, str); +return 0 ; +}/* * This routine is specific to i386 architecture to maintain the
@@ -575,6 +598,7 @@return -1 ;cmdline_add_memmap (mod_cmdline, memmap_p);cmdline_add_elfcorehdr (mod_cmdline, elfcorehdr); +cmdline_add_backup (mod_cmdline, info->backup_start);return 0 ; }
kexec/kexec-syscall.h +5 -0
@@ -21,6 +21,7 @@#define LINUX_REBOOT_CMD_KEXEC_OLD 0x81726354#define LINUX_REBOOT_CMD_KEXEC_OLD2 0x18263645#define LINUX_REBOOT_CMD_KEXEC 0x45584543 +#define LINUX_REBOOT_CMD_KJUMP 0x3928A5FD#ifdef __i386__#define __NR_kexec_load 283
@@ -63,6 +64,10 @@return (long )syscall (__NR_reboot,LINUX_REBOOT_MAGIC1 ,LINUX_REBOOT_MAGIC2 ,LINUX_REBOOT_CMD_KEXEC ,0 ); } +static inline long kexec_jump (void ) +{ +return (long )syscall (__NR_reboot,LINUX_REBOOT_MAGIC1 ,LINUX_REBOOT_MAGIC2 ,LINUX_REBOOT_CMD_KJUMP ,0 ); +}#define KEXEC_ON_CRASH 0x00000001#define KEXEC_ARCH_MASK 0xffff0000
kexec/kexec.c +24 -0
@@ -716,6 +716,17 @@return -1 ; } +/* +* Jump to the new kernel +*/ +static int my_jump (void ) +{ +int result; + + result =kexec_jump (); +return result; +} +static void version (void ) {printf (PACKAGE " " VERSION " released " RELEASE_DATE "\n" );
@@ -743,6 +754,7 @@" If capture kernel is being unloaded\n" " specify -p with -u.\n" " -e, --exec Execute a currently loaded kernel.\n" +" -j, --jump Jump to a currently loaded kernel or jump back to the previous kernel.\n" " -t, --type=TYPE Specify the new kernel is of this type.\n" " --mem-min=<addr> Specify the lowest memory address to\n" " load code into.\n"
@@ -803,6 +815,7 @@ {int do_load =1 ;int do_exec =0 ; +int do_jump =0 ;int do_shutdown =1 ;int do_sync =1 ;int do_ifdown =0 ;
@@ -858,6 +871,14 @@ do_ifdown =1 ; do_exec =1 ;break ; +case OPT_JUMP : + do_load =0 ; + do_shutdown =0 ; + do_sync =1 ; + do_ifdown =0 ; + do_exec =0 ; + do_jump =1 ; +break ;case OPT_TYPE : type = optarg;break ;
@@ -949,6 +970,9 @@if ((result ==0 ) && do_exec) { result =my_exec (); } +if ((result ==0 ) && do_jump) { + result =my_jump (); + }fflush (stdout);fflush (stderr);
kexec/kexec.h +3 -1
@@ -156,6 +156,7 @@#define OPT_FORCE 'f'#define OPT_NOIFDOWN 'x'#define OPT_EXEC 'e' +#define OPT_JUMP 'j'#define OPT_LOAD 'l'#define OPT_UNLOAD 'u'#define OPT_TYPE 't'
@@ -172,13 +173,14 @@ { "load", 0, 0, OPT_LOAD }, \ { "unload", 0, 0, OPT_UNLOAD }, \ { "exec", 0, 0, OPT_EXEC }, \ + { "jump", 0, 0, OPT_JUMP }, \ { "type", 1, 0, OPT_TYPE }, \ { "load-panic", 0, 0, OPT_PANIC }, \ { "mem-min", 1, 0, OPT_MEM_MIN }, \ { "mem-max", 1, 0, OPT_MEM_MAX }, \ { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ -#define KEXEC_OPT_STR "hvdfxluet:p" +#define KEXEC_OPT_STR "hvdfxluejt:p" extern void die(char *fmt, ...);extern void *xmalloc (size_t size);
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi, Pavel,
Quoted 7 lines · Pavel Machek
Ping... is there some next version?
I'm stuck at the tools side currently. kexec-1.101 just won't load the kernel properly, and kexec-testing from git does not know -j option. I tried hand-patching it, but got lots of scary rejects.
Is there chance for a patch against kexec-testing?
I have some other work to do recently. So the next version will delay for some while. :(
But now, I have a patch against kexec-tools-testing.
Best Regards,
Huang Ying
kexec/arch/i386/crashdump-x86.c +24 -0
@@ -428,6 +428,29 @@return 0 ; } +/* Adds the kexec_backup= command line parameter to command line. */ +static int cmdline_add_backup (char *cmdline,unsigned long addr) +{ +int cmdlen, len, align =1024 ; +char str[30 ], *ptr; + +/* Passing in kexec_backup=xxxK format. Saves space required +* in cmdline. Ensure 1K alignment*/ +if (addr%align) +return -1 ; + addr = addr/align; + ptr = str; +strcpy (str," kexec_backup=" ); + ptr +=strlen (str); +ultoa (addr, ptr); +strcat (str,"K" ); + len =strlen (str); + cmdlen =strlen (cmdline) + len; +if (cmdlen > (COMMAND_LINE_SIZE -1 )) +die ("Command line overflow\n" ); +strcat (cmdline, str); +return 0 ; +}/* * This routine is specific to i386 architecture to maintain the
@@ -575,6 +598,7 @@return -1 ;cmdline_add_memmap (mod_cmdline, memmap_p);cmdline_add_elfcorehdr (mod_cmdline, elfcorehdr); +cmdline_add_backup (mod_cmdline, info->backup_start);return 0 ; }
kexec/kexec-syscall.h +5 -0
@@ -21,6 +21,7 @@#define LINUX_REBOOT_CMD_KEXEC_OLD 0x81726354#define LINUX_REBOOT_CMD_KEXEC_OLD2 0x18263645#define LINUX_REBOOT_CMD_KEXEC 0x45584543 +#define LINUX_REBOOT_CMD_KJUMP 0x3928A5FD#ifdef __i386__#define __NR_kexec_load 283
@@ -63,6 +64,10 @@return (long )syscall (__NR_reboot,LINUX_REBOOT_MAGIC1 ,LINUX_REBOOT_MAGIC2 ,LINUX_REBOOT_CMD_KEXEC ,0 ); } +static inline long kexec_jump (void ) +{ +return (long )syscall (__NR_reboot,LINUX_REBOOT_MAGIC1 ,LINUX_REBOOT_MAGIC2 ,LINUX_REBOOT_CMD_KJUMP ,0 ); +}#define KEXEC_ON_CRASH 0x00000001#define KEXEC_ARCH_MASK 0xffff0000
kexec/kexec.c +24 -0
@@ -716,6 +716,17 @@return -1 ; } +/* +* Jump to the new kernel +*/ +static int my_jump (void ) +{ +int result; + + result =kexec_jump (); +return result; +} +static void version (void ) {printf (PACKAGE " " VERSION " released " RELEASE_DATE "\n" );
@@ -743,6 +754,7 @@" If capture kernel is being unloaded\n" " specify -p with -u.\n" " -e, --exec Execute a currently loaded kernel.\n" +" -j, --jump Jump to a currently loaded kernel or jump back to the previous kernel.\n" " -t, --type=TYPE Specify the new kernel is of this type.\n" " --mem-min=<addr> Specify the lowest memory address to\n" " load code into.\n"
@@ -803,6 +815,7 @@ {int do_load =1 ;int do_exec =0 ; +int do_jump =0 ;int do_shutdown =1 ;int do_sync =1 ;int do_ifdown =0 ;
@@ -858,6 +871,14 @@ do_ifdown =1 ; do_exec =1 ;break ; +case OPT_JUMP : + do_load =0 ; + do_shutdown =0 ; + do_sync =1 ; + do_ifdown =0 ; + do_exec =0 ; + do_jump =1 ; +break ;case OPT_TYPE : type = optarg;break ;
@@ -949,6 +970,9 @@if ((result ==0 ) && do_exec) { result =my_exec (); } +if ((result ==0 ) && do_jump) { + result =my_jump (); + }fflush (stdout);fflush (stderr);
kexec/kexec.h +3 -1
@@ -156,6 +156,7 @@#define OPT_FORCE 'f'#define OPT_NOIFDOWN 'x'#define OPT_EXEC 'e' +#define OPT_JUMP 'j'#define OPT_LOAD 'l'#define OPT_UNLOAD 'u'#define OPT_TYPE 't'
@@ -172,13 +173,14 @@ { "load", 0, 0, OPT_LOAD }, \ { "unload", 0, 0, OPT_UNLOAD }, \ { "exec", 0, 0, OPT_EXEC }, \ + { "jump", 0, 0, OPT_JUMP }, \ { "type", 1, 0, OPT_TYPE }, \ { "load-panic", 0, 0, OPT_PANIC }, \ { "mem-min", 1, 0, OPT_MEM_MIN }, \ { "mem-max", 1, 0, OPT_MEM_MAX }, \ { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ -#define KEXEC_OPT_STR "hvdfxluet:p" +#define KEXEC_OPT_STR "hvdfxluejt:p" extern void die(char *fmt, ...);extern void *xmalloc (size_t size);
Hi!
Quoted 11 lines · Pavel Machek
Quoted 7 lines
Ping... is there some next version?
I'm stuck at the tools side currently. kexec-1.101 just won't load the kernel properly, and kexec-testing from git does not know -j option. I tried hand-patching it, but got lots of scary rejects.
Is there chance for a patch against kexec-testing?
I have some other work to do recently. So the next version will delay for some while. :(
Ok, I got it to work -- thanks a lot.
Yes, acpi=off is mandatory. Unfortunately, thinkpad x60 does not boot with acpi=off (should we add another test to linux firmware kit? Machines should still boot in acpi=off mode...). acpi=off noapic nolapic nosmp makes it boot, and that in turn makes kjump work.
Screen is not refreshed on kjump back to original kernel, but I guess that's to be expected. I did not play with framebuffer, yet.
Maybe it is time to move kjump functionality into -mm and kexec-testing?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 11 lines · Pavel Machek
Quoted 7 lines
Ping... is there some next version?
I'm stuck at the tools side currently. kexec-1.101 just won't load the kernel properly, and kexec-testing from git does not know -j option. I tried hand-patching it, but got lots of scary rejects.
Is there chance for a patch against kexec-testing?
I have some other work to do recently. So the next version will delay for some while. :(
Ok, I got it to work -- thanks a lot.
Yes, acpi=off is mandatory. Unfortunately, thinkpad x60 does not boot with acpi=off (should we add another test to linux firmware kit? Machines should still boot in acpi=off mode...). acpi=off noapic nolapic nosmp makes it boot, and that in turn makes kjump work.
Screen is not refreshed on kjump back to original kernel, but I guess that's to be expected. I did not play with framebuffer, yet.
Maybe it is time to move kjump functionality into -mm and kexec-testing?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 7 lines · Pavel Machek
Ok, I got it to work -- thanks a lot.
Yes, acpi=off is mandatory. Unfortunately, thinkpad x60 does not boot with acpi=off (should we add another test to linux firmware kit? Machines should still boot in acpi=off mode...). acpi=off noapic nolapic nosmp makes it boot, and that in turn makes kjump work.
Quoted 5 lines
Screen is not refreshed on kjump back to original kernel, but I guess that's to be expected. I did not play with framebuffer, yet.
Maybe it is time to move kjump functionality into -mm and kexec-testing?
Now I have worked out a full kexec based hibernation prototype, including kexec, write out the image, reboot, restore the memory and jump back. I will release it recently. :)
Best Regards,
Huang Ying
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 7 lines · Pavel Machek
Ok, I got it to work -- thanks a lot.
Yes, acpi=off is mandatory. Unfortunately, thinkpad x60 does not boot with acpi=off (should we add another test to linux firmware kit? Machines should still boot in acpi=off mode...). acpi=off noapic nolapic nosmp makes it boot, and that in turn makes kjump work.
Quoted 5 lines
Screen is not refreshed on kjump back to original kernel, but I guess that's to be expected. I did not play with framebuffer, yet.
Maybe it is time to move kjump functionality into -mm and kexec-testing?
Now I have worked out a full kexec based hibernation prototype, including kexec, write out the image, reboot, restore the memory and jump back. I will release it recently. :)
Best Regards,
Huang Ying