[linux-pm] [PATH 1/1] Kexec jump - v2 - kexec jump

[linux-pm] [PATH 1/1] Kexec jump - v2 - kexec jump

Post by Pavel Mach » Fri, 17 Aug 2007 22:10:09


Hi!


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
--
(english) http://www.yqcomputer.com/ ~pavelmachek
(cesky, pictures) http://www.yqcomputer.com/ ~pavel/picture/horses/blog.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/
 
 
 

[linux-pm] [PATH 1/1] Kexec jump - v2 - kexec jump

Post by Huang, Yin » Sat, 18 Aug 2007 15:20:06

i, Pavel,

On Thu, 2007-08-16 at 12:26 +0200, Pavel Machek wrote:

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

Index: kexec-tools/kexec/arch/i386/crashdump-x86.c
===================================================================
--- kexec-tools.orig/kexec/arch/i386/crashdump-x86.c 2007-08-17 13:48:51.000000000 +0800
+++ kexec-tools/kexec/arch/i386/crashdump-x86.c 2007-08-17 13:49:50.000000000 +0800
@@ -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;
}

Index: kexec-tools/kexec/kexec-syscall.h
===================================================================
--- kexec-tools.orig/kexec/kexec-syscall.h 2007-08-17 13:48:51.000000000 +0800
+++ kexec-tools/kexec/kexec-syscall.h 2007-08-17 13:49:50.000000000 +0800
@@ -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
Index: kexec-tools/kexec/kexec.c
===================================================================
--- kexec-tools.orig/kexec/kexec.c 2007-08-17 13:48:51.000000000 +0800
+++ kexec-tools/kexec/kexec.c 2007-08-17 13:49:50.000000000 +0800
@@ -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 @@
{

 
 
 

[linux-pm] [PATH 1/1] Kexec jump - v2 - kexec jump

Post by Pavel Mach » Wed, 22 Aug 2007 23:00:20

Hi!



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
--
(english) http://www.yqcomputer.com/ ~pavelmachek
(cesky, pictures) http://www.yqcomputer.com/ ~pavel/picture/horses/blog.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/
 
 
 

[linux-pm] [PATH 1/1] Kexec jump - v2 - kexec jump

Post by Huang, Yin » Thu, 23 Aug 2007 16:00:12


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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/