[PATCH 1/2 -mm] kexec based hibernation -v5: kexec jump

Previous thread: [QUESTION] I need advice for writing .suspend/.resume functions by Maxim Levitsky on Wednesday, October 10, 2007 - 11:13 pm. (4 messages)

Next thread: linux-2.6.23 - acting funny by poison on Wednesday, October 10, 2007 - 10:30 pm. (1 message)
To: Eric W. Biederman <ebiederm@...>, Pavel Machek <pavel@...>, <nigel@...>, Rafael J. Wysocki <rjw@...>, Andrew Morton <akpm@...>, Jeremy Maitin-Shepard <jbms@...>
Cc: <linux-kernel@...>, <linux-pm@...>, Kexec Mailing List <kexec@...>
Date: Wednesday, October 10, 2007 - 10:14 pm

This patch implements the functionality of jumping between the kexeced
kernel and the original kernel.

A new flag for sys_kexec_load named KEXEC_JUMP_BACK is added to
indicate that the loaded kernel image is used for jumping back.

To support jumping between two kernels, before jumping to (executing)
the new kernel and jumping back to the original kernel, the devices
are put into quiescent state, and the state of devices and CPU is
saved. After jumping back from kexeced kernel and jumping to the new
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.

To support jumping without reserving memory. One shadow backup page
(source page) is allocated for each page used by new (kexeced) kernel
(destination page). When do kexec_load, the image of new kernel is
loaded into source pages, and before executing, the destination pages
and the source pages are swapped, so the contents of destination pages
are backupped. Before jumping to the new (kexeced) kernel and after
jumping back to the original kernel, the destination pages and the
source pages are swapped too.

A jump back protocol is defined and documented.

Signed-off-by: Huang Ying <ying.huang@intel.com>

---

Index: linux-2.6.23-rc8/arch/i386/kernel/machine_kexec.c
===================================================================
--- linux-2.6.23-rc8.orig/arch/i386/kernel/machine_kexec.c 2007-10-10 10:10:22.000000000 +0800
+++ linux-2.6.23-rc8/arch/i386/kernel/machine_kexec.c 2007-10-10 10:10:27.000000000 +0800
@@ -20,6 +20,7 @@
#include <asm/cpufeature.h>
#include <asm/desc.h>
#include <asm/system.h>
+#include <asm/cacheflush.h>

#define PAGE_ALIGNED __attribute__ ((__aligned__(PAGE_SIZE)))
static u32 kexec_pgd[1024] PAGE_ALIGNED;
@@ -83,10 +84,14 @@
* reboot code buffer to allow us to avoid allocations
* later.
*
- * Currently nothing.
+ * Turn off NX bit for ...

Previous thread: [QUESTION] I need advice for writing .suspend/.resume functions by Maxim Levitsky on Wednesday, October 10, 2007 - 11:13 pm. (4 messages)

Next thread: linux-2.6.23 - acting funny by poison on Wednesday, October 10, 2007 - 10:30 pm. (1 message)