kexec jump -v11: save/restore device state
Subsystems (6)
PATCH 2/2 kexec jump -v11: 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=yCONFIG_RELOCATABLE=yCONFIG_KEXEC=yCONFIG_CRASH_DUMP=yCONFIG_PM=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.gz6. 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.
ChangeLog:
v11:
- Add disable_IO_APIC() to machine_kexec() to put IO APIC into legacy mode before executing new kernel.
- Base on top of new hibernation/restore device driver callback.
v10:
- Split from original kexec_jump patch.
Now, only the i386 architecture is supported. The patchset is based on Linux kernel 2.6.26-rc5-mm1, and has been tested on IBM T42 with ACPI on and off.
--- arch/x86/kernel/machine_kexec_32.c | 6 +++++ include/linux/suspend.h | 2 + kernel/kexec.c | 43 ++++++++++++++++++++++++++++++++++++- kernel/power/power.h | 2 - 4 files changed, 50 insertions(+), 3 deletions(-)
kernel/kexec.c +42 -1
@@ -25,6 +25,10 @@#include <linux/utsname.h> #include <linux/numa.h> #include <linux/suspend.h> +#include <linux/freezer.h> +#include <linux/pm.h> +#include <linux/cpu.h> +#include <linux/console.h> #include <asm/page.h> #include <asm/uaccess.h>
@@ -1427,8 +1431,34 @@ module_init(crash_save_vmcoreinfo_init)int kexec_jump (struct kimage *image) { +int error =0 ; + +mutex_lock (&pm_mutex);if (image->preserve_context) { +pm_prepare_console (); + error =freeze_processes (); +if (error) { + error = -EBUSY ; + goto Exit; + } +suspend_console (); + error =device_suspend (PMSG_FREEZE ); +if (error) + goto Resume_console; + error =disable_nonboot_cpus (); +if (error) + goto Resume_devices;local_irq_disable (); +/* At this point, device_suspend() has been called, +* but *not* device_power_down(). We *must* +* device_power_down() now. Otherwise, drivers for +* some devices (e.g. interrupt controllers) become +* desynchronized with the actual state of the +* hardware at resume time, and evil weirdness ensues. +*/ + error =device_power_down (PMSG_FREEZE ); +if (error) + goto Enable_irqs;save_processor_state (); }
@@ -1436,7 +1466,18 @@ int kexec_jump(struct kimage *image)if (image->preserve_context) {restore_processor_state (); +device_power_up (PMSG_RESTORE ); + Enable_irqs:local_irq_enable (); +enable_nonboot_cpus (); + Resume_devices: +device_resume (PMSG_RESTORE ); + Resume_console: +resume_console (); +thaw_processes (); + Exit: +pm_restore_console (); } -return 0 ; +mutex_unlock (&pm_mutex); +return error; }
kernel/power/power.h +0 -2
@@ -53,8 +53,6 @@ extern int hibernation_platform_enter(voextern int pfn_is_nosave (unsigned long ); -extern struct mutex pm_mutex; -#define power_attr (_name) \ static struct kobj_attribute _name##_attr = { \ .attr = { \
include/linux/suspend.h +2 -0
@@ -266,4 +266,6 @@ static inline void register_nosave_regio }#endif +extern struct mutex pm_mutex; +#endif /* _LINUX_SUSPEND_H */
arch/x86/kernel/machine_kexec_32.c +6 -0
@@ -125,6 +125,12 @@ void machine_kexec(struct kimage *image)/* Interrupts aren't acceptable while we reboot */ local_irq_disable (); +if (image->preserve_context) { +#ifdef CONFIG_X86_IO_APIC +disable_IO_APIC (); +#endif + } + control_page =page_address (image->control_code_page);memcpy (control_page, relocate_kernel,PAGE_SIZE /2 );
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Len Brown
reviewerQuoted 10 lines · Ying
This patch implements devices state save/restore before after kexec.
This patch together with features in
kexec_jumppatch 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.
What part of ACPI's role in hibernation are you trying to avoid
1. enabling wake devices
2. removing power from the system
3. something else?
thanks,
-Len
Len Brown
reviewerQuoted 10 lines · Ying
This patch implements devices state save/restore before after kexec.
This patch together with features in
kexec_jumppatch 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.
What part of ACPI's role in hibernation are you trying to avoid
1. enabling wake devices
2. removing power from the system
3. something else?
thanks,
-Len
Quoted 14 lines · Len Brown
Quoted 10 lines · Ying
This patch implements devices state save/restore before after kexec.
This patch together with features in
kexec_jumppatch 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.
Quoted 4 lines
What part of ACPI's role in hibernation are you trying to avoid
1. enabling wake devices
2. removing power from the system
3. something else?
ACPI S5 is used instead of S4 for this simple hibernation implementation. That is, before creating the hibernation image, the ACPI _PTS is not executed, devices are not put into low power state and wake devices are not enabled. After creating the hibernation image, the image is saved to disk and system is shutdown (go to S5). When resuming from hibernated image, ACPI _BFS and _WAK are not executed too.
Best Regards,
Huang Ying
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Len Brown
reviewerQuoted 20 lines · Ying
Quoted 14 lines · Len Brown
Quoted 10 lines · Ying
This patch implements devices state save/restore before after kexec.
This patch together with features in
kexec_jumppatch 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.
Quoted 4 lines
What part of ACPI's role in hibernation are you trying to avoid
1. enabling wake devices
2. removing power from the system
3. something else?
Quoted 6 lines
ACPI S5 is used instead of S4 for this simple hibernation implementation. That is, before creating the hibernation image, the ACPI
_PTSis not executed, devices are not put into low power state and wake devices are not enabled. After creating the hibernation image, the image is saved to disk and system is shutdown (go to S5). When resuming from hibernated image, ACPI_BFSand_WAKare not executed too.
Doesn't that resume the devices and their drivers into an unknown state?
-Len
Len Brown
reviewerQuoted 20 lines · Ying
Quoted 14 lines · Len Brown
Quoted 10 lines · Ying
This patch implements devices state save/restore before after kexec.
This patch together with features in
kexec_jumppatch 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.
Quoted 4 lines
What part of ACPI's role in hibernation are you trying to avoid
1. enabling wake devices
2. removing power from the system
3. something else?
Quoted 6 lines
ACPI S5 is used instead of S4 for this simple hibernation implementation. That is, before creating the hibernation image, the ACPI
_PTSis not executed, devices are not put into low power state and wake devices are not enabled. After creating the hibernation image, the image is saved to disk and system is shutdown (go to S5). When resuming from hibernated image, ACPI_BFSand_WAKare not executed too.
Doesn't that resume the devices and their drivers into an unknown state?
-Len
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 21 lines · Len Brown
Quoted 20 lines · Ying
Quoted 18 lines · Len Brown
Quoted 10 lines · Ying
This patch implements devices state save/restore before after kexec.
This patch together with features in
kexec_jumppatch 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.
What part of ACPI's role in hibernation are you trying to avoid
1. enabling wake devices
2. removing power from the system
3. something else?
Quoted 8 lines
Quoted 6 lines
ACPI S5 is used instead of S4 for this simple hibernation implementation. That is, before creating the hibernation image, the ACPI
_PTSis not executed, devices are not put into low power state and wake devices are not enabled. After creating the hibernation image, the image is saved to disk and system is shutdown (go to S5). When resuming from hibernated image, ACPI_BFSand_WAKare not executed too.Doesn't that resume the devices and their drivers into an unknown state?
device_suspend(PMSG_FREEZE) and device_power_down(PMSG_FREEZE) are called before hibernation; device_power_up(PMSG_RESTORE) and device_resume(PMSG_RESTORE) are called after restore. The new hibernation/restore device driver callbacks introduced by Rafael is used. So I think the device/driver state will be saved/restored properly.
It is planed to support ACPI S4 in the future. But I think a hibernation scheme without ACPI may be useful in some situation too.
Best Regards,
Huang Ying
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 21 lines · Len Brown
Quoted 20 lines · Ying
Quoted 18 lines · Len Brown
Quoted 10 lines · Ying
This patch implements devices state save/restore before after kexec.
This patch together with features in
kexec_jumppatch 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.
What part of ACPI's role in hibernation are you trying to avoid
1. enabling wake devices
2. removing power from the system
3. something else?
Quoted 8 lines
Quoted 6 lines
ACPI S5 is used instead of S4 for this simple hibernation implementation. That is, before creating the hibernation image, the ACPI
_PTSis not executed, devices are not put into low power state and wake devices are not enabled. After creating the hibernation image, the image is saved to disk and system is shutdown (go to S5). When resuming from hibernated image, ACPI_BFSand_WAKare not executed too.Doesn't that resume the devices and their drivers into an unknown state?
device_suspend(PMSG_FREEZE) and device_power_down(PMSG_FREEZE) are called before hibernation; device_power_up(PMSG_RESTORE) and device_resume(PMSG_RESTORE) are called after restore. The new hibernation/restore device driver callbacks introduced by Rafael is used. So I think the device/driver state will be saved/restored properly.
It is planed to support ACPI S4 in the future. But I think a hibernation scheme without ACPI may be useful in some situation too.
Best Regards,
Huang Ying
Quoted 20 lines · Ying
Quoted 14 lines · Len Brown
Quoted 10 lines · Ying
This patch implements devices state save/restore before after kexec.
This patch together with features in
kexec_jumppatch 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.
Quoted 4 lines
What part of ACPI's role in hibernation are you trying to avoid
1. enabling wake devices
2. removing power from the system
3. something else?
Quoted 6 lines
ACPI S5 is used instead of S4 for this simple hibernation implementation. That is, before creating the hibernation image, the ACPI
_PTSis not executed, devices are not put into low power state and wake devices are not enabled. After creating the hibernation image, the image is saved to disk and system is shutdown (go to S5). When resuming from hibernated image, ACPI_BFSand_WAKare not executed too.
Hi huang,
Can't we implement ACPI S5 state as an option in current hibernation framework? Or kexec jump is a requirement for that?
Thanks
Vivek
Quoted 20 lines · Ying
Quoted 14 lines · Len Brown
Quoted 10 lines · Ying
This patch implements devices state save/restore before after kexec.
This patch together with features in
kexec_jumppatch 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.
Quoted 4 lines
What part of ACPI's role in hibernation are you trying to avoid
1. enabling wake devices
2. removing power from the system
3. something else?
Quoted 6 lines
ACPI S5 is used instead of S4 for this simple hibernation implementation. That is, before creating the hibernation image, the ACPI
_PTSis not executed, devices are not put into low power state and wake devices are not enabled. After creating the hibernation image, the image is saved to disk and system is shutdown (go to S5). When resuming from hibernated image, ACPI_BFSand_WAKare not executed too.
Hi huang,
Can't we implement ACPI S5 state as an option in current hibernation framework? Or kexec jump is a requirement for that?
Thanks
Vivek
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi, Vivek,
On Fri, 2008-06-13 at 14:05 -0400, Vivek Goyal wrote:
[...]
Quoted 3 lines
Can't we implement ACPI S5 state as an option in current hibernation framework? Or kexec jump is a requirement for that?
ACPI S5 has been implemented in current hibernation framework. If you do:
echo shutdown > /sys/power/disk
ACPI S5 instead of S4 will be used. That is, corresponding ACPI method is not executed.
Best Regards,
Huang Ying
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi, Vivek,
On Fri, 2008-06-13 at 14:05 -0400, Vivek Goyal wrote:
[...]
Quoted 3 lines
Can't we implement ACPI S5 state as an option in current hibernation framework? Or kexec jump is a requirement for that?
ACPI S5 has been implemented in current hibernation framework. If you do:
echo shutdown > /sys/power/disk
ACPI S5 instead of S4 will be used. That is, corresponding ACPI method is not executed.
Best Regards,
Huang Ying
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Quoted 14 lines · Len Brown
Quoted 10 lines · Ying
This patch implements devices state save/restore before after kexec.
This patch together with features in
kexec_jumppatch 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.
Quoted 4 lines
What part of ACPI's role in hibernation are you trying to avoid
1. enabling wake devices
2. removing power from the system
3. something else?
ACPI S5 is used instead of S4 for this simple hibernation implementation. That is, before creating the hibernation image, the ACPI _PTS is not executed, devices are not put into low power state and wake devices are not enabled. After creating the hibernation image, the image is saved to disk and system is shutdown (go to S5). When resuming from hibernated image, ACPI _BFS and _WAK are not executed too.
Best Regards,
Huang Ying
Quoted 79 lines · Ying
This patch implements devices state save/restore before after kexec.
This patch together with features in
kexec_jumppatch 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=yCONFIG_RELOCATABLE=yCONFIG_KEXEC=yCONFIG_CRASH_DUMP=yCONFIG_PM=y2. 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.gz6. Boot the kernel B with following shell command line:
/sbin/kexec-e7. 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:
Quoted 9 lines
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/vmcoredump.elfThen you can shutdown the machine as normal.
8. Boot kernel compiled in step 1 (kernel C). Use the rootfs.gz as root file system.
One of the concerns raised by hibernation people in the past was to use single boot loader entry to boot normally as well while resuming a kernel.
So in this case a user either needs to maintain two boot-loader entries or modify it on the fly. I wished there was a better way to handle that.
I am more interested in ability to have multiple kernel loaded in RAM and capability to switch between them. Allows me to take non-disruptive core dumps and somebody wanted to snapshots the kernels. That should still work.
[..]
arch/x86/kernel/machine_kexec_32.c void machine_kexec(struct kimage *image) · line 131
Quoted 10 lines
arch/x86/kernel/machine_kexec_32.c +4
-0@@ -125,6 +125,12 @@ void machine_kexec(struct kimage *image)/* Interrupts aren't acceptable while we reboot */ local_irq_disable (); +if (image->preserve_context) { +#ifdef CONFIG_X86_IO_APIC +disable_IO_APIC (); +#endif
I think it would be a good idea to put some kind of comment here. We need to put APICs in legacy mode so that we can get timer interrupts in second kernel. kexec/kdump paths already have calls to disable_IO_APIC() in one form or other. kexec jump path also needs one.
Thanks
Vivek
Quoted 79 lines · Ying
This patch implements devices state save/restore before after kexec.
This patch together with features in
kexec_jumppatch 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=yCONFIG_RELOCATABLE=yCONFIG_KEXEC=yCONFIG_CRASH_DUMP=yCONFIG_PM=y2. 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.gz6. Boot the kernel B with following shell command line:
/sbin/kexec-e7. 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:
Quoted 9 lines
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/vmcoredump.elfThen you can shutdown the machine as normal.
8. Boot kernel compiled in step 1 (kernel C). Use the rootfs.gz as root file system.
One of the concerns raised by hibernation people in the past was to use single boot loader entry to boot normally as well while resuming a kernel.
So in this case a user either needs to maintain two boot-loader entries or modify it on the fly. I wished there was a better way to handle that.
I am more interested in ability to have multiple kernel loaded in RAM and capability to switch between them. Allows me to take non-disruptive core dumps and somebody wanted to snapshots the kernels. That should still work.
[..]
arch/x86/kernel/machine_kexec_32.c void machine_kexec(struct kimage *image) · line 131
Quoted 10 lines
arch/x86/kernel/machine_kexec_32.c +4
-0@@ -125,6 +125,12 @@ void machine_kexec(struct kimage *image)/* Interrupts aren't acceptable while we reboot */ local_irq_disable (); +if (image->preserve_context) { +#ifdef CONFIG_X86_IO_APIC +disable_IO_APIC (); +#endif
I think it would be a good idea to put some kind of comment here. We need to put APICs in legacy mode so that we can get timer interrupts in second kernel. kexec/kdump paths already have calls to disable_IO_APIC() in one form or other. kexec jump path also needs one.
Thanks
Vivek
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
On Wed, 2008-06-11 at 12:30 -0400, Vivek Goyal wrote:
[...]
Quoted 43 lines
Quoted 33 lines
Usage example of simple hibernation:
1. Compile and install patched kernel with following options selected:
CONFIG_X86_32=yCONFIG_RELOCATABLE=yCONFIG_KEXEC=yCONFIG_CRASH_DUMP=yCONFIG_PM=y2. 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.gz6. Boot the kernel B with following shell command line:
/sbin/kexec-e7. 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:
Quoted 9 lines
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/vmcoredump.elfThen you can shutdown the machine as normal.
8. Boot kernel compiled in step 1 (kernel C). Use the rootfs.gz as root file system.
Quoted 5 lines
One of the concerns raised by hibernation people in the past was to use single boot loader entry to boot normally as well while resuming a kernel.
So in this case a user either needs to maintain two boot-loader entries or modify it on the fly. I wished there was a better way to handle that.
Now it is not needed to have two boot-loader entries, just one is enough. Step 4 and step 8 can share the same boot-loader entries. The rootfs.gz can be the normal initramfs or initrd when deployment. In rootfs.gz, if there is a valid hibernation image, the hibernated system will be restored, otherwise, normal boot process follows.
Quoted 13 lines
I am more interested in ability to have multiple kernel loaded in RAM and capability to switch between them. Allows me to take non-disruptive core dumps and somebody wanted to snapshots the kernels. That should still work.
[..]
Quoted 6 lines
arch/x86/kernel/machine_kexec_32.c +0
-0@@ -125,6 +125,12 @@ void machine_kexec(struct kimage *image)/* Interrupts aren't acceptable while we reboot */ local_irq_disable ();
Quoted 9 lines
arch/x86/kernel/machine_kexec_32.c void machine_kexec(struct kimage *image) · line 131
Quoted 4 lines
arch/x86/kernel/machine_kexec_32.c +4
-0+if (image->preserve_context) { +#ifdef CONFIG_X86_IO_APIC +disable_IO_APIC (); +#endif I think it would be a good idea to put some kind of comment here. We need to put APICs in legacy mode so that we can get timer interrupts in second kernel. kexec/kdump paths already have calls to
disable_IO_APIC()in one form or other. kexec jump path also needs one.
OK. I will add it.
Best Regards,
Huang Ying
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 48 lines · Ying
On Wed, 2008-06-11 at 12:30 -0400, Vivek Goyal wrote:
[...]Quoted 46 lines
Quoted 33 lines
Usage example of simple hibernation:
1. Compile and install patched kernel with following options selected:
CONFIG_X86_32=yCONFIG_RELOCATABLE=yCONFIG_KEXEC=yCONFIG_CRASH_DUMP=yCONFIG_PM=y2. 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.gz6. Boot the kernel B with following shell command line:
/sbin/kexec-e7. 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:
Quoted 9 lines
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/vmcoredump.elfThen you can shutdown the machine as normal.
8. Boot kernel compiled in step 1 (kernel C). Use the rootfs.gz as root file system.
One of the concerns raised by hibernation people in the past was to use single boot loader entry to boot normally as well while resuming a kernel.
Quoted 9 lines
Quoted 2 lines
So in this case a user either needs to maintain two boot-loader entries or modify it on the fly. I wished there was a better way to handle that.
Now it is not needed to have two boot-loader entries, just one is enough. Step 4 and step 8 can share the same boot-loader entries. The rootfs.gz can be the normal initramfs or initrd when deployment. In rootfs.gz, if there is a valid hibernation image, the hibernated system will be restored, otherwise, normal boot process follows.
Few things I don't understand.
- Are you saying that hibernated image will be saved in initrd (rootfs.gz)? But that saving is only in RAM, we never write back it to disk?
- I thought we probably have to dedicate a raw partition kind of thing for saving image and then modify boot loader command line to something similar to, "resume=partition". Then initrd can go hunting for image in respective partition (as specified by command line parameter) and if image is not available then continue with normal boot.
Thanks
Vivek
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Quoted 48 lines · Ying
On Wed, 2008-06-11 at 12:30 -0400, Vivek Goyal wrote:
[...]Quoted 46 lines
Quoted 33 lines
Usage example of simple hibernation:
1. Compile and install patched kernel with following options selected:
CONFIG_X86_32=yCONFIG_RELOCATABLE=yCONFIG_KEXEC=yCONFIG_CRASH_DUMP=yCONFIG_PM=y2. 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.gz6. Boot the kernel B with following shell command line:
/sbin/kexec-e7. 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:
Quoted 9 lines
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/vmcoredump.elfThen you can shutdown the machine as normal.
8. Boot kernel compiled in step 1 (kernel C). Use the rootfs.gz as root file system.
One of the concerns raised by hibernation people in the past was to use single boot loader entry to boot normally as well while resuming a kernel.
Quoted 9 lines
Quoted 2 lines
So in this case a user either needs to maintain two boot-loader entries or modify it on the fly. I wished there was a better way to handle that.
Now it is not needed to have two boot-loader entries, just one is enough. Step 4 and step 8 can share the same boot-loader entries. The rootfs.gz can be the normal initramfs or initrd when deployment. In rootfs.gz, if there is a valid hibernation image, the hibernated system will be restored, otherwise, normal boot process follows.
Few things I don't understand.
- Are you saying that hibernated image will be saved in initrd (rootfs.gz)? But that saving is only in RAM, we never write back it to disk?
- I thought we probably have to dedicate a raw partition kind of thing for saving image and then modify boot loader command line to something similar to, "resume=partition". Then initrd can go hunting for image in respective partition (as specified by command line parameter) and if image is not available then continue with normal boot.
Thanks
Vivek
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
On Thu, 2008-06-12 at 09:02 -0400, Vivek Goyal wrote:
[...]
Quoted 5 lines
Few things I don't understand.
- Are you saying that hibernated image will be saved in initrd (rootfs.gz)? But that saving is only in RAM, we never write back it to disk?
No. Hibernated image should be saved in a dedicated raw partition as you said below.
Quoted 5 lines
- I thought we probably have to dedicate a raw partition kind of thing for saving image and then modify boot loader command line to something similar to, "resume=partition". Then initrd can go hunting for image in respective partition (as specified by command line parameter) and if image is not available then continue with normal boot.
Yes. But the boot-loader command line only need to be changed during system install or hibernation setup. We need not change the location of "hibernation partition" frequently.
So I think one boot-loader command line is sufficient for:
- normal boot
- normal boot a system to be hibernated
- boot helper system to restore the hibernated system
Best Regards,
Huang Ying
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
On Thu, 2008-06-12 at 09:02 -0400, Vivek Goyal wrote:
[...]
Quoted 5 lines
Few things I don't understand.
- Are you saying that hibernated image will be saved in initrd (rootfs.gz)? But that saving is only in RAM, we never write back it to disk?
No. Hibernated image should be saved in a dedicated raw partition as you said below.
Quoted 5 lines
- I thought we probably have to dedicate a raw partition kind of thing for saving image and then modify boot loader command line to something similar to, "resume=partition". Then initrd can go hunting for image in respective partition (as specified by command line parameter) and if image is not available then continue with normal boot.
Yes. But the boot-loader command line only need to be changed during system install or hibernation setup. We need not change the location of "hibernation partition" frequently.
So I think one boot-loader command line is sufficient for:
- normal boot
- normal boot a system to be hibernated
- boot helper system to restore the hibernated system
Best Regards,
Huang Ying
On Wed, 2008-06-11 at 12:30 -0400, Vivek Goyal wrote:
[...]
Quoted 43 lines
Quoted 33 lines
Usage example of simple hibernation:
1. Compile and install patched kernel with following options selected:
CONFIG_X86_32=yCONFIG_RELOCATABLE=yCONFIG_KEXEC=yCONFIG_CRASH_DUMP=yCONFIG_PM=y2. 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.gz6. Boot the kernel B with following shell command line:
/sbin/kexec-e7. 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:
Quoted 9 lines
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/vmcoredump.elfThen you can shutdown the machine as normal.
8. Boot kernel compiled in step 1 (kernel C). Use the rootfs.gz as root file system.
Quoted 5 lines
One of the concerns raised by hibernation people in the past was to use single boot loader entry to boot normally as well while resuming a kernel.
So in this case a user either needs to maintain two boot-loader entries or modify it on the fly. I wished there was a better way to handle that.
Now it is not needed to have two boot-loader entries, just one is enough. Step 4 and step 8 can share the same boot-loader entries. The rootfs.gz can be the normal initramfs or initrd when deployment. In rootfs.gz, if there is a valid hibernation image, the hibernated system will be restored, otherwise, normal boot process follows.
Quoted 13 lines
I am more interested in ability to have multiple kernel loaded in RAM and capability to switch between them. Allows me to take non-disruptive core dumps and somebody wanted to snapshots the kernels. That should still work.
[..]
Quoted 6 lines
arch/x86/kernel/machine_kexec_32.c +0
-0@@ -125,6 +125,12 @@ void machine_kexec(struct kimage *image)/* Interrupts aren't acceptable while we reboot */ local_irq_disable ();
Quoted 9 lines
arch/x86/kernel/machine_kexec_32.c void machine_kexec(struct kimage *image) · line 131
Quoted 4 lines
arch/x86/kernel/machine_kexec_32.c +4
-0+if (image->preserve_context) { +#ifdef CONFIG_X86_IO_APIC +disable_IO_APIC (); +#endif I think it would be a good idea to put some kind of comment here. We need to put APICs in legacy mode so that we can get timer interrupts in second kernel. kexec/kdump paths already have calls to
disable_IO_APIC()in one form or other. kexec jump path also needs one.
OK. I will add it.
Best Regards,
Huang Ying
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm