Skip to contentSkip to conversation

kexec based hibernation: kexec jump

RFC PATCH In review Huang, Ying 2 participants 7 messages Aug 27, 2007 – Sep 3, 2007

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/2 kexec based hibernation: kexec jump

ChangeLog 2007/8/25

1. The reboot command LINUX_REBOOT_CMD_KJUMP is splited into to two reboot command to reflect the different function.

2. Document is added for added kernel parameters.

3. /sys/kernel/kexec_jump_buf_pfn is made writable, it is used for memory image restoring.

4. Console restoring after jumping back is implemented.

ChangeLog 2007/7/15

1. The kexec jump implementation is put into the kexec/kdump framework instead of software suspend framework. The device and CPU state save/restore code of software suspend is called when needed.

2. The same code path is used for both kexec a new kernel and jump back to original kernel.

---

This patch implements the functionality of jumping from the kexeced kernel back to the original kernel.

Two new reboot command named LINUX_REBOOT_CMD_KJUMP_TO and LINUX_REBOOT_CMD_KJUMP_BACK are defined to trigger the jumping to (executing) the new kernel and 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.

---

 Documentation/kernel-parameters.txt |    8 +++
 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               |   16 ++++++
 include/linux/reboot.h              |    2 
 kernel/kexec.c                      |   92 ++++++++++++++++++++++++++++++++++++
 kernel/ksysfs.c                     |   21 ++++++++
 kernel/power/Kconfig                |    2 
 kernel/sys.c                        |   16 ++++++
 12 files changed, 301 insertions(+), 1 deletion(-)
arch/i386/kernel/machine_kexec.c +59 -0
Index: linux-2.6.23-rc3/arch/i386/kernel/machine_kexec.c
===================================================================
@@ -10,6 +10,7 @@
 #include <linux/kexec.h>
 #include <linux/delay.h>
 #include <linux/init.h>
+#include <linux/highmem.h>
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
@@ -169,3 +170,61 @@
 	return 0;
 }
 early_param("crashkernel", parse_crashkernel);
+
+#ifdef CONFIG_KEXEC_JUMP
+int machine_kexec_jump(void)
+{
+	asmlinkage int (*real_jump)(void *buf);
+	unsigned long jump_buf_pfn;
+	void *jump_buf;
+
+	if (!(kexec_jump_flags & KEXEC_JUMP_FLAG_IS_KEXECED_KERNEL) &&
+	    !kexec_crash_image)
+		return -EINVAL;
+	jump_buf_pfn = kexec_get_jump_buf_pfn(0);
+	if (!jump_buf_pfn)
+		return -EINVAL;
+	jump_buf = kmap_atomic_pfn(jump_buf_pfn, KM_PTE0);
+	memcpy(jump_buf + PAGE_SIZE/2, machine_kexec_real_jump, PAGE_SIZE/2);
+	real_jump = jump_buf + PAGE_SIZE/2;
+
+	if (!real_jump(jump_buf))
+		machine_kexec(kexec_crash_image);
+	kunmap_atomic(jump_buf, KM_PTE0);
+	return 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;
+
+	kexec_backup_addr = memparse(arg, &arg);
+	return 0;
+}
+early_param("kexec_backup", parse_kexec_backup);
+
+void kexec_restore_backup(void)
+{
+	void *vaddr;
+	void *vaddr_backup;
+	unsigned long paddr;
+
+	if (kexec_backup_addr == ~0UL)
+		return;
+
+	for (paddr = 0; paddr < 640 * 1024; paddr += PAGE_SIZE) {
+		vaddr = kmap_atomic_pfn(paddr >> PAGE_SHIFT, KM_PTE0);
+		vaddr_backup = kmap_atomic_pfn((paddr+kexec_backup_addr) >> PAGE_SHIFT,
+					       KM_PTE1);
+		memcpy(vaddr, vaddr_backup, PAGE_SIZE);
+		kunmap_atomic(vaddr, KM_PTE0);
+		kunmap_atomic(vaddr_backup, KM_PTE1);
+	}
+}
+#endif /* CONFIG_KEXEC_JUMP */
include/asm-i386/kexec.h +4 -0
Index: linux-2.6.23-rc3/include/asm-i386/kexec.h
===================================================================
@@ -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 +16 -0
Index: linux-2.6.23-rc3/include/linux/kexec.h
===================================================================
@@ -1,6 +1,11 @@
 #ifndef LINUX_KEXEC_H
 #define LINUX_KEXEC_H
 
+#ifdef CONFIG_KEXEC_JUMP
+#define KEXEC_JUMP_FLAG_IS_KEXECED_KERNEL     0x1
+#endif /* CONFIG_KEXEC_JUMP */
+
+#ifndef __ASSEMBLY__
 #ifdef CONFIG_KEXEC
 #include <linux/types.h>
 #include <linux/list.h>
@@ -161,4 +166,15 @@
 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_jump_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_set_jump_buf_pfn(unsigned long pfn);
+extern void kexec_restore_backup(void);
+#endif /* CONFIG_KEXEC_JUMP */
+#endif /* !__ASSEMBLY__ */
+
 #endif /* LINUX_KEXEC_H */
kernel/kexec.c +92 -0

101 lines not on this page · raw message

kernel/ksysfs.c +21 -0
Index: linux-2.6.23-rc3/kernel/ksysfs.c
===================================================================
@@ -60,6 +60,24 @@
 	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));
+}
+static ssize_t kexec_jump_buf_pfn_store(struct kset *kset, const char *page,
+					size_t count)
+{
+	unsigned long pfn;
+
+	pfn = simple_strtoul(page, NULL, 0);
+	kexec_set_jump_buf_pfn(pfn);
+	return count;
+}
+
+KERNEL_ATTR_RW(kexec_jump_buf_pfn);
+#endif /* CONFIG_KEXEC_JUMP */
 #endif /* CONFIG_KEXEC */
 
 /*
@@ -95,6 +113,9 @@
 #ifdef CONFIG_KEXEC
 	&kexec_loaded_attr.attr,
 	&kexec_crash_loaded_attr.attr,
+#ifdef CONFIG_KEXEC_JUMP
+	&kexec_jump_buf_pfn_attr.attr,
+#endif
 #endif
 	NULL
 };
arch/i386/kernel/kexec_jump.S new file +74 -0

74 lines not on this page · raw message

kernel/sys.c +16 -0
Index: linux-2.6.23-rc3/kernel/sys.c
===================================================================
@@ -424,6 +424,22 @@
 		unlock_kernel();
 		return -EINVAL;
 
+#ifdef CONFIG_KEXEC_JUMP
+	case LINUX_REBOOT_CMD_KJUMP_BACK:
+		if (!(kexec_jump_flags & KEXEC_JUMP_FLAG_IS_KEXECED_KERNEL)) {
+			unlock_kernel();
+			return -EINVAL;
+		}
+		/* fall through */
+	case LINUX_REBOOT_CMD_KJUMP_TO:
+		{
+			int ret;
+			ret = kexec_jump();
+			unlock_kernel();
+			return ret;
+		}
+#endif
+
 #ifdef CONFIG_HIBERNATION
 	case LINUX_REBOOT_CMD_SW_SUSPEND:
 		{
include/linux/reboot.h +2 -0
Index: linux-2.6.23-rc3/include/linux/reboot.h
===================================================================
@@ -33,6 +33,8 @@
 #define	LINUX_REBOOT_CMD_RESTART2	0xA1B2C3D4
 #define	LINUX_REBOOT_CMD_SW_SUSPEND	0xD000FCE2
 #define	LINUX_REBOOT_CMD_KEXEC		0x45584543
+#define	LINUX_REBOOT_CMD_KJUMP_TO	0x3928A5FD
+#define	LINUX_REBOOT_CMD_KJUMP_BACK	0x4A39B60E
 
 
 #ifdef __KERNEL__
arch/i386/Kconfig +7 -0
Index: linux-2.6.23-rc3/arch/i386/Kconfig
===================================================================
@@ -828,6 +828,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 "0x1000000" if X86_NUMAQ
arch/i386/kernel/Makefile +1 -0
Index: linux-2.6.23-rc3/arch/i386/kernel/Makefile
===================================================================
@@ -30,6 +30,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
Documentation/kernel-parameters.txt +8 -0
Index: linux-2.6.23-rc3/Documentation/kernel-parameters.txt
===================================================================
@@ -899,6 +899,14 @@
 
 	keepinitrd	[HW,ARM]
 
+	kexec_backup	[X86-32]
+			Specifies physical address of backup area for 0~640k
+			memory area of original kernel.
+
+	kexec_jump_buf_pfn	[X86-32]
+			Specifies page frame number of jump buffer page used
+			to jump between original kernel and kexeced kernel.
+
 	kstack=N	[X86-32,X86-64] Print N words from the kernel stack
 			in oops dumps.
 
kernel/power/Kconfig +1 -1
Index: linux-2.6.23-rc3/kernel/power/Kconfig
===================================================================
@@ -70,7 +70,7 @@
 
 config PM_SLEEP
 	bool
-	depends on SUSPEND || HIBERNATION
+	depends on SUSPEND || HIBERNATION || KEXEC_JUMP
 	default y
 
 config SUSPEND_UP_POSSIBLE
#1 lore raw

Hi!

Quoted 8 lines

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.

Looks quite ok to me...

include/asm-i386/kexec.h line 99

Quoted 11 lines

Index: linux-2.6.23-rc3/include/asm-i386/kexec.h
===================================================================

include/asm-i386/kexec.h +3 -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

Is it really neccessery to have ifdef here?

include/asm-i386/kexec.h line 102

Quoted 3 lines
include/asm-i386/kexec.h +3 -0
+#ifdef CONFIG_KEXEC_JUMP
+#define KEXEC_JUMP_FLAG_IS_KEXECED_KERNEL     0x1
+#endif /* CONFIG_KEXEC_JUMP */

And here? ... It would be nice to use slightly shorter identifier. 'KJUMP_IS_KEXECED' should be enough.

Quoted 5 lines
include/asm-i386/kexec.h +5 -0
+/*
+ * Must be relocatable PIC code callable as a C function
+ */
+#define HALF_PAGE_ALIGNED (1 << (PAGE_SHIFT-1))
+

include/asm-i386/kexec.h

Quoted 10 lines
include/asm-i386/kexec.h +10 -0
+#define EBX	0x0
+#define ESI	0x4
+#define EDI	0x8
+#define EBP	0xc
+#define ESP	0x10
+#define CR0	0x14
+#define CR3	0x18
+#define CR4	0x1c
+#define FLAG	0x20
+#define RET	0x24

Hmm, is this enough? Should it use struct ptregs for normal registers? What about segment registers -- they could change between kernel version. Should some kind of 'version of kjump protocol' be introduced?

What about CX/DX/fpu state? GDT pointer?

Actually I think that you _do_ need to save FPU. You should probably use relevant swsusp parts here.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#2 lore raw
In reply to Huang, Ying

Hi!

Quoted 8 lines

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.

Looks quite ok to me...

include/asm-i386/kexec.h line 99

Quoted 11 lines

Index: linux-2.6.23-rc3/include/asm-i386/kexec.h
===================================================================

include/asm-i386/kexec.h +3 -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

Is it really neccessery to have ifdef here?

include/asm-i386/kexec.h line 102

Quoted 3 lines
include/asm-i386/kexec.h +3 -0
+#ifdef CONFIG_KEXEC_JUMP
+#define KEXEC_JUMP_FLAG_IS_KEXECED_KERNEL     0x1
+#endif /* CONFIG_KEXEC_JUMP */

And here? ... It would be nice to use slightly shorter identifier. 'KJUMP_IS_KEXECED' should be enough.

Quoted 5 lines
include/asm-i386/kexec.h +5 -0
+/*
+ * Must be relocatable PIC code callable as a C function
+ */
+#define HALF_PAGE_ALIGNED (1 << (PAGE_SHIFT-1))
+

include/asm-i386/kexec.h

Quoted 10 lines
include/asm-i386/kexec.h +10 -0
+#define EBX	0x0
+#define ESI	0x4
+#define EDI	0x8
+#define EBP	0xc
+#define ESP	0x10
+#define CR0	0x14
+#define CR3	0x18
+#define CR4	0x1c
+#define FLAG	0x20
+#define RET	0x24

Hmm, is this enough? Should it use struct ptregs for normal registers? What about segment registers -- they could change between kernel version. Should some kind of 'version of kjump protocol' be introduced?

What about CX/DX/fpu state? GDT pointer?

Actually I think that you _do_ need to save FPU. You should probably use relevant swsusp parts 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
#3 lore raw
Quoted 22 lines · Pavel Machek

Hi!

Quoted 8 lines

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.

Looks quite ok to me...

Quoted 8 lines

Index: linux-2.6.23-rc3/include/asm-i386/kexec.h
===================================================================

include/asm-i386/kexec.h +0 -0
@@ -94,6 +94,10 @@
 		unsigned long start_address,
 		unsigned int has_pae) ATTRIB_NORET;
 
Quoted 5 lines

include/asm-i386/kexec.h line 99

Quoted 3 lines
include/asm-i386/kexec.h +3 -0
+#ifdef CONFIG_KEXEC_JUMP
+extern asmlinkage int machine_kexec_real_jump(void *buf);
+#endif

Is it really neccessery to have ifdef here?

It is not necessary. I will fix it in the next version.

Quoted 6 lines

include/asm-i386/kexec.h line 102

Quoted 3 lines
include/asm-i386/kexec.h +3 -0
+#ifdef CONFIG_KEXEC_JUMP
+#define KEXEC_JUMP_FLAG_IS_KEXECED_KERNEL     0x1
+#endif /* CONFIG_KEXEC_JUMP */

And here? ... It would be nice to use slightly shorter identifier. 'KJUMP_IS_KEXECED' should be enough.

Yes, that is nicer. I will fix it.

Quoted 12 lines
Quoted 12 lines
include/asm-i386/kexec.h +12 -0
+/*
+ * Must be relocatable PIC code callable as a C function
+ */
+#define HALF_PAGE_ALIGNED (1 << (PAGE_SHIFT-1))
+
+#define EBX	0x0
+#define ESI	0x4
+#define EDI	0x8
+#define EBP	0xc
+#define ESP	0x10
+#define CR0	0x14
+#define CR3	0x18
Quoted 8 lines

include/asm-i386/kexec.h

Quoted 3 lines
include/asm-i386/kexec.h +3 -0
+#define CR4	0x1c
+#define FLAG	0x20
+#define RET	0x24

Hmm, is this enough? Should it use struct ptregs for normal registers? What about segment registers -- they could change between kernel version. Should some kind of 'version of kjump protocol' be introduced?

All "preserve" registers defined in ABI are saved, I think that is sufficient. The "swsusp_arch_suspend" saves only these registers too.

An extensible inter-kernel kjump protocol and corresponding version number seems sensible. I will work on this.

Quoted 5 lines

What about CX/DX/fpu state? GDT pointer?

Actually I think that you _do_ need to save FPU. You should probably use relevant swsusp parts here.

Before and after "machine_kexec_jump" is called, the save_processor_state() and restore_processor_state() are called, where the MTRR/FPU/GDT/IDT/TR/segments/cr are saved and restored. These two functions come from swsusp. Thanks swsusp guys. :)

Best Regards,
Huang Ying

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#6 lore raw
In reply to Pavel Machek
Quoted 22 lines · Pavel Machek

Hi!

Quoted 8 lines

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.

Looks quite ok to me...

Quoted 8 lines

Index: linux-2.6.23-rc3/include/asm-i386/kexec.h
===================================================================

include/asm-i386/kexec.h +0 -0
@@ -94,6 +94,10 @@
 		unsigned long start_address,
 		unsigned int has_pae) ATTRIB_NORET;
 
Quoted 5 lines

include/asm-i386/kexec.h line 99

Quoted 3 lines
include/asm-i386/kexec.h +3 -0
+#ifdef CONFIG_KEXEC_JUMP
+extern asmlinkage int machine_kexec_real_jump(void *buf);
+#endif

Is it really neccessery to have ifdef here?

It is not necessary. I will fix it in the next version.

Quoted 6 lines

include/asm-i386/kexec.h line 102

Quoted 3 lines
include/asm-i386/kexec.h +3 -0
+#ifdef CONFIG_KEXEC_JUMP
+#define KEXEC_JUMP_FLAG_IS_KEXECED_KERNEL     0x1
+#endif /* CONFIG_KEXEC_JUMP */

And here? ... It would be nice to use slightly shorter identifier. 'KJUMP_IS_KEXECED' should be enough.

Yes, that is nicer. I will fix it.

Quoted 12 lines
Quoted 12 lines
include/asm-i386/kexec.h +12 -0
+/*
+ * Must be relocatable PIC code callable as a C function
+ */
+#define HALF_PAGE_ALIGNED (1 << (PAGE_SHIFT-1))
+
+#define EBX	0x0
+#define ESI	0x4
+#define EDI	0x8
+#define EBP	0xc
+#define ESP	0x10
+#define CR0	0x14
+#define CR3	0x18
Quoted 8 lines

include/asm-i386/kexec.h

Quoted 3 lines
include/asm-i386/kexec.h +3 -0
+#define CR4	0x1c
+#define FLAG	0x20
+#define RET	0x24

Hmm, is this enough? Should it use struct ptregs for normal registers? What about segment registers -- they could change between kernel version. Should some kind of 'version of kjump protocol' be introduced?

All "preserve" registers defined in ABI are saved, I think that is sufficient. The "swsusp_arch_suspend" saves only these registers too.

An extensible inter-kernel kjump protocol and corresponding version number seems sensible. I will work on this.

Quoted 5 lines

What about CX/DX/fpu state? GDT pointer?

Actually I think that you _do_ need to save FPU. You should probably use relevant swsusp parts here.

Before and after "machine_kexec_jump" is called, the save_processor_state() and restore_processor_state() are called, where the MTRR/FPU/GDT/IDT/TR/segments/cr are saved and restored. These two functions come from swsusp. Thanks swsusp guys. :)

Best Regards,
Huang Ying

#4 lore raw
In reply to Huang, Ying

Hi!

Quoted 11 lines
Quoted 9 lines

include/asm-i386/kexec.h line 99

Quoted 7 lines
include/asm-i386/kexec.h +3 -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

Is it really neccessery to have ifdef here?

It is not necessary. I will fix it in the next version.

Looking forward to next version :-).

Quoted 10 lines
Quoted 9 lines

arch/i386/kernel/kexec_jump.S line 28

Quoted 4 lines
arch/i386/kernel/kexec_jump.S new file +4 -0
+#define CR3	0x18
+#define CR4	0x1c
+#define FLAG	0x20
+#define RET	0x24

Hmm, is this enough? Should it use struct ptregs for normal registers? What about segment registers -- they could change between kernel version. Should some kind of 'version of kjump protocol' be introduced?

Quoted 5 lines

All "preserve" registers defined in ABI are saved, I think that is sufficient. The "swsusp_arch_suspend" saves only these registers too.

An extensible inter-kernel kjump protocol and corresponding version number seems sensible. I will work on this.

Ok, perhaps that can wait after initial merge.

Quoted 9 lines
Quoted 4 lines

What about CX/DX/fpu state? GDT pointer?

Actually I think that you _do_ need to save FPU. You should probably use relevant swsusp parts here.

Before and after "machine_kexec_jump" is called, the save_processor_state() and restore_processor_state() are called, where the MTRR/FPU/GDT/IDT/TR/segments/cr are saved and restored. These two functions come from swsusp. Thanks swsusp guys. :)

So I'm blind. Sorry for the noise.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#5 lore raw
In reply to Huang, Ying

Hi!

Quoted 11 lines
Quoted 9 lines

include/asm-i386/kexec.h line 99

Quoted 7 lines
include/asm-i386/kexec.h +3 -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

Is it really neccessery to have ifdef here?

It is not necessary. I will fix it in the next version.

Looking forward to next version :-).

Quoted 10 lines
Quoted 9 lines

arch/i386/kernel/kexec_jump.S line 28

Quoted 4 lines
arch/i386/kernel/kexec_jump.S new file +4 -0
+#define CR3	0x18
+#define CR4	0x1c
+#define FLAG	0x20
+#define RET	0x24

Hmm, is this enough? Should it use struct ptregs for normal registers? What about segment registers -- they could change between kernel version. Should some kind of 'version of kjump protocol' be introduced?

Quoted 5 lines

All "preserve" registers defined in ABI are saved, I think that is sufficient. The "swsusp_arch_suspend" saves only these registers too.

An extensible inter-kernel kjump protocol and corresponding version number seems sensible. I will work on this.

Ok, perhaps that can wait after initial merge.

Quoted 9 lines
Quoted 4 lines

What about CX/DX/fpu state? GDT pointer?

Actually I think that you _do_ need to save FPU. You should probably use relevant swsusp parts here.

Before and after "machine_kexec_jump" is called, the save_processor_state() and restore_processor_state() are called, where the MTRR/FPU/GDT/IDT/TR/segments/cr are saved and restored. These two functions come from swsusp. Thanks swsusp guys. :)

So I'm blind. Sorry for the noise.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html