android_kernel_motorola_sm6225/include
Huang Ying 89081d17f7 kexec jump: save/restore device state
This patch implements devices state save/restore before after kexec.

This patch together with features in kexec_jump patch can be used for
following:

- A simple hibernation implementation without ACPI support.  You can kexec a
  hibernating kernel, save the memory image of original system and shutdown
  the system.  When resuming, you restore the memory image of original system
  via ordinary kexec load then jump back.

- Kernel/system debug through making system snapshot.  You can make system
  snapshot, jump back, do some thing and make another system snapshot.

- Cooperative multi-kernel/system.  With kexec jump, you can switch between
  several kernels/systems quickly without boot process except the first time.
  This appears like swap a whole kernel/system out/in.

- A general method to call program in physical mode (paging turning
  off). This can be used to invoke BIOS code under Linux.

The following user-space tools can be used with kexec jump:

- kexec-tools needs to be patched to support kexec jump. The patches
  and the precompiled kexec can be download from the following URL:
       source: http://khibernation.sourceforge.net/download/release_v10/kexec-tools/kexec-tools-src_git_kh10.tar.bz2
       patches: http://khibernation.sourceforge.net/download/release_v10/kexec-tools/kexec-tools-patches_git_kh10.tar.bz2
       binary: http://khibernation.sourceforge.net/download/release_v10/kexec-tools/kexec_git_kh10

- makedumpfile with patches are used as memory image saving tool, it
  can exclude free pages from original kernel memory image file. The
  patches and the precompiled makedumpfile can be download from the
  following URL:
       source: http://khibernation.sourceforge.net/download/release_v10/makedumpfile/makedumpfile-src_cvs_kh10.tar.bz2
       patches: http://khibernation.sourceforge.net/download/release_v10/makedumpfile/makedumpfile-patches_cvs_kh10.tar.bz2
       binary: http://khibernation.sourceforge.net/download/release_v10/makedumpfile/makedumpfile_cvs_kh10

- An initramfs image can be used as the root file system of kexeced
  kernel. An initramfs image built with "BuildRoot" can be downloaded
  from the following URL:
       initramfs image: http://khibernation.sourceforge.net/download/release_v10/initramfs/rootfs_cvs_kh10.gz
  All user space tools above are included in the initramfs image.

Usage example of simple hibernation:

1. Compile and install patched kernel with following options selected:

CONFIG_X86_32=y
CONFIG_RELOCATABLE=y
CONFIG_KEXEC=y
CONFIG_CRASH_DUMP=y
CONFIG_PM=y
CONFIG_HIBERNATION=y
CONFIG_KEXEC_JUMP=y

2. Build an initramfs image contains kexec-tool and makedumpfile, or
   download the pre-built initramfs image, called rootfs.gz in
   following text.

3. Prepare a partition to save memory image of original kernel, called
   hibernating partition in following text.

4. Boot kernel compiled in step 1 (kernel A).

5. In the kernel A, load kernel compiled in step 1 (kernel B) with
   /sbin/kexec. The shell command line can be as follow:

   /sbin/kexec --load-preserve-context /boot/bzImage --mem-min=0x100000
     --mem-max=0xffffff --initrd=rootfs.gz

6. Boot the kernel B with following shell command line:

   /sbin/kexec -e

7. The kernel B will boot as normal kexec. In kernel B the memory
   image of kernel A can be saved into hibernating partition as
   follow:

   jump_back_entry=`cat /proc/cmdline | tr ' ' '\n' | grep kexec_jump_back_entry | cut -d '='`
   echo $jump_back_entry > kexec_jump_back_entry
   cp /proc/vmcore dump.elf

   Then you can shutdown the machine as normal.

8. Boot kernel compiled in step 1 (kernel C). Use the rootfs.gz as
   root file system.

9. In kernel C, load the memory image of kernel A as follow:

   /sbin/kexec -l --args-none --entry=`cat kexec_jump_back_entry` dump.elf

10. Jump back to the kernel A as follow:

   /sbin/kexec -e

   Then, kernel A is resumed.

Implementation point:

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.

Known issues:

- Because the segment number supported by sys_kexec_load is limited,
  hibernation image with many segments may not be load. This is
  planned to be eliminated by adding a new flag to sys_kexec_load to
  make a image can be loaded with multiple sys_kexec_load invoking.

Now, only the i386 architecture is supported.

Signed-off-by: Huang Ying <ying.huang@intel.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Nigel Cunningham <nigel@nigel.suspend2.net>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-07-26 12:00:04 -07:00
..
acpi Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6 2008-07-16 17:25:46 -07:00
asm-alpha dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
asm-arm dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
asm-avr32 dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
asm-blackfin Merge git://git.infradead.org/~dwmw2/random-2.6 2008-07-25 12:01:37 -07:00
asm-cris dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
asm-frv dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
asm-generic dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
asm-h8300 Merge git://git.infradead.org/~dwmw2/random-2.6 2008-07-25 12:01:37 -07:00
asm-ia64 dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
asm-m32r Merge git://git.infradead.org/~dwmw2/random-2.6 2008-07-25 12:01:37 -07:00
asm-m68k dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
asm-m68knommu Merge git://git.infradead.org/~dwmw2/random-2.6 2008-07-25 12:01:37 -07:00
asm-mips dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
asm-mn10300 dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
asm-parisc dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
asm-powerpc dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
asm-s390 Merge git://git.infradead.org/~dwmw2/random-2.6 2008-07-25 12:01:37 -07:00
asm-sh dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
asm-sparc dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
asm-sparc64 remove dummy asm/kvm.h files 2008-07-25 14:35:50 -04:00
asm-um Merge git://git.infradead.org/~dwmw2/random-2.6 2008-07-25 12:01:37 -07:00
asm-v850 remove the v850 port 2008-07-24 10:47:24 -07:00
asm-x86 kexec jump 2008-07-26 12:00:04 -07:00
asm-xtensa dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
crypto crypto: hash - Move ahash functions into crypto/hash.h 2008-07-10 20:35:18 +08:00
drm drm/radeon: fixup issue with radeon and PAT support. 2008-07-15 15:48:05 +10:00
keys
linux kexec jump: save/restore device state 2008-07-26 12:00:04 -07:00
math-emu
media V4L/DVB (8395): saa7134: Fix Kbuild dependency of ir-kbd-i2c 2008-07-20 07:29:03 -03:00
mtd UBI: fix checkpatch.pl errors and warnings 2008-07-24 13:36:09 +03:00
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6 2008-07-25 17:40:16 -07:00
pcmcia
rdma dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
rxrpc
scsi driver core: remove KOBJ_NAME_LEN define 2008-07-21 21:54:52 -07:00
sound ALSA: Release v1.0.17 2008-07-14 09:54:43 +02:00
video include/video/atmel_lcdc.h must #include <linux/workqueue.h> 2008-07-26 12:00:01 -07:00
xen xen: implement Xen-specific spinlocks 2008-07-16 11:15:53 +02:00
Kbuild drm: reorganise drm tree to be more future proof. 2008-07-14 10:45:01 +10:00