Re: [PATCH -v2 6/8] kexec jump: fix for lockdep

2008-08-11 Thread Peter Zijlstra
On Mon, 2008-08-11 at 08:59 +0800, Huang Ying wrote:
 On Fri, 2008-08-08 at 12:13 +0200, Peter Zijlstra wrote:
  On Fri, 2008-08-08 at 14:52 +0800, Huang Ying wrote:
   Replace local_irq_disable() with raw_local_irq_disable() to prevent
   lockdep complain.
  Uhhm, please provide more information - just using raw_* to silence
  lockdep is generally the wrong thing to do.
 
 In traditional kexec, the new kernel will replace current one, so the
 irq is simply disabled. But now jumping back from kexeced kernel is
 supported, so the irq should be enabled again.
 
 The code sequence of irq during kexec jump is as follow:
 
 local_irq_disable(); /* in kernel_kexec() */
 local_irq_disable(); /* in machine_kexec() */
 local_irq_enable(); /* in kernel_kexec() */
 
 The disable and enable is not match. Maybe another method is to use
 local_irq_save(), local_irq_restore() pair in machine_kexec(), so the
 disable and enable is matched.

And its the machine kernel's lockdep instance that goes complain?

whichever annotation gets used - and I think I can agree that raw_*
might be approriate there, this should be accompanied with a rather
elaborate changelog and preferably a comment in the code too. Without
such we'll be wondering in the years to come WTH happens here.



___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH -v2 6/8] kexec jump: fix for lockdep

2008-08-11 Thread Huang Ying
On Mon, 2008-08-11 at 08:09 +0200, Peter Zijlstra wrote:
 On Mon, 2008-08-11 at 08:59 +0800, Huang Ying wrote:
  On Fri, 2008-08-08 at 12:13 +0200, Peter Zijlstra wrote:
   On Fri, 2008-08-08 at 14:52 +0800, Huang Ying wrote:
Replace local_irq_disable() with raw_local_irq_disable() to prevent
lockdep complain.
   Uhhm, please provide more information - just using raw_* to silence
   lockdep is generally the wrong thing to do.
  
  In traditional kexec, the new kernel will replace current one, so the
  irq is simply disabled. But now jumping back from kexeced kernel is
  supported, so the irq should be enabled again.
  
  The code sequence of irq during kexec jump is as follow:
  
  local_irq_disable(); /* in kernel_kexec() */
  local_irq_disable(); /* in machine_kexec() */
  local_irq_enable(); /* in kernel_kexec() */
  
  The disable and enable is not match. Maybe another method is to use
  local_irq_save(), local_irq_restore() pair in machine_kexec(), so the
  disable and enable is matched.
 
 And its the machine kernel's lockdep instance that goes complain?
 
 whichever annotation gets used - and I think I can agree that raw_*
 might be approriate there, this should be accompanied with a rather
 elaborate changelog and preferably a comment in the code too. Without
 such we'll be wondering in the years to come WTH happens here.

Sorry, I find there is no complain from lockdep. Un-paired irq
disable/enable has no problem with lockdep, just increase something such
as redundant_hardirqs_off. Please ignore this thread.

Best Regards,
Huang Ying



___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH -v2 7/8] kexec jump: ftrace_enabled_save/restore

2008-08-11 Thread Steven Rostedt

On Mon, 11 Aug 2008, Huang Ying wrote:

 Hi, Steven,
 
 On Fri, 2008-08-08 at 10:30 -0400, Steven Rostedt wrote:
 [...]
  The only problem with this approach is what happens if the user changes 
  the enabled in between these two calls. This would make ftrace 
  inconsistent.
  
  I have a patch from the -rt tree that handles what you want. It is 
  attached below. Not sure how well it will apply to mainline.
  
  I really need to go through the rt patch set and start submitting a bunch 
  of clean-up/fixes to mainline. We've been meaning to do it, just have been 
  distracted :-(
 
 Your version is better in general sense. Thank you very much!
 
 But in this specific situation of kexec/kjump. The execution environment
 is that other CPUs are disabled, local irq is disabled, and it is not
 permitted to switch to other process. But it is safe and sufficient to
 use non-locked version here.
 
 So to satisfy both demands, I think it is better to provide both
 version, locked and non-locked. What do you think about that?

Sounds good,

I'm looking forward to the patch ;-)

-- Steve


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH -v2 7/8] kexec jump: ftrace_enabled_save/restore

2008-08-11 Thread Vivek Goyal
On Mon, Aug 11, 2008 at 09:22:21AM +0800, Huang Ying wrote:
 Hi, Steven,
 
 On Fri, 2008-08-08 at 10:30 -0400, Steven Rostedt wrote:
 [...]
  The only problem with this approach is what happens if the user changes 
  the enabled in between these two calls. This would make ftrace 
  inconsistent.
  
  I have a patch from the -rt tree that handles what you want. It is 
  attached below. Not sure how well it will apply to mainline.
  
  I really need to go through the rt patch set and start submitting a bunch 
  of clean-up/fixes to mainline. We've been meaning to do it, just have been 
  distracted :-(
 
 Your version is better in general sense. Thank you very much!
 
 But in this specific situation of kexec/kjump. The execution environment
 is that other CPUs are disabled, local irq is disabled, and it is not
 permitted to switch to other process. But it is safe and sufficient to
 use non-locked version here.
 
 So to satisfy both demands, I think it is better to provide both
 version, locked and non-locked. What do you think about that?
 

Huang,

So you want to use a non-locked version from optimization point of view?
So that we don't end up taking and release a lock?

Thanks
Vivek

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[patch] kexec and kdump documentation for xen

2008-08-11 Thread Simon Horman
Add guide to using the kexec and kdump facility in xen.

Signed-off-by: Simon Horman [EMAIL PROTECTED]

--- 
I the work on this document using an ia64 machine and qemu emulating x86_32.
I am yet to verify it on x86_32 hardware or x86_64.
Index: xen-unstable.hg/docs/misc/kexec_and_kdump.txt
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ xen-unstable.hg/docs/misc/kexec_and_kdump.txt   2008-08-12 
00:11:45.0 +1000
@@ -0,0 +1,213 @@
+
+===
+Kexec and Kdump for Xen
+===
+
+This is a breif guide to using Kexec and Kdump in conjunction with Xen.
+This functionaly works at the level of the hypervisor and dom0 kernel.
+And will thus affect all guests running on a machine.
+
+At this stage it does not work in conjunction with domU kernels.
+
+This document should be read in conjunction with
+Documentation/kdump/kdump.txt from the Linux kernel source.
+Some of the information in this document has been
+sourced from that document.
+
+
+Kexec
+=
+
+It is possible to kexec from Xen or Linux to either Xen or Linux.
+
+Pattern| Before Kexec   | After Kexec
+---++
+Xen - Xen | first hypervisor  | second hypervisor 
+   | dom0 kernel| dom0 kernel
+---++
+Xen   - Linux | first hypervisor  | second kernel
+   | dom0 kernel|
+---++
+Linux - Xen   | first kernel   | second hypervisor 
+   || dom0 kernel
+---++
+Linux - Linux | first kernel   | second kernel
+
+If you are kexecing to Xen then you will also need to preapare the second
+hypervisor and dom0 kernel that will run after kexec. These may be the same
+as the first hypervisor and dom0 kernel that are used before kexec if you
+are kexecing from Xen to Xen.
+
+If you are kexecing to Linux then you will need to prepare the second Linux
+kernel that will run after kexec. In the case that you are kexecing from
+Linux, it may be the same as the first kernel image that that runs before
+kexec.
+
+Regardless of which kexec pattern you wish to run, you will
+need to have kexec-tools installed. This provides the kexec command.
+
+1. Load
+---
+
+Before kexecing the second kernel or hypervisor  dom0 kernel
+need to be loaded into the running hypervisor or kernel using
+the kexec command.
+
+  a. To kexec to Xen (Xen-Xen or Linux-Xen)
+
+  kexec -l --append=XEN_ARGS -- DOM0_ARGS \
+   --vmm=XEN_IMAGE DOM0_IMAGE KEXEC_ARGS
+
+  where:
+XEN_ARGS: command line arguments to the xen hypervisor
+  On x86 the no-real-mode argument should be included
+DOM0_ARGS: command line arguments to the dom0 kernel
+XEN_IMAGE: xen hypervisor image
+DOM0_IMAGE: dom0 kernel image
+KEXEC_ARGS: additional kexec-tools command line arguments
+
+  e.g. kexec -l --append no-real-mode --vmm=/boot/xen.gz /boot/vmlinuz.gz
+
+  OR
+
+  b. To kexec to Linux (Xen-Linux or Linux-Linux)
+
+  kexec -l LINUX_IMAGE --append $LINUX_ARGS KEXEC_ARGS
+
+  where:
+LINUX_IMAGE: the second linux kernel image
+LINUX_ARGS: command line arguments to the second linux kernel
+KEXEC_ARGS: additional kexec-tools command line arguments
+
+  e.g. kexec -l /boot/second-vmlinuz.gz
+
+2. Execute
+--
+
+Once the second kernel is loaded, it can be executed at any time.
+If you don't see the second kernel booting within a second or so,
+you are in trouble :(
+
+   kexec -e
+
+Kdump
+=
+
+It is possible to kdump from Xen or Linux to a Linux crash kernel.
+It is not possible to use xen as a crash kernel.
+
+Pattern| Before Kexec   | After Kexec
+---++
+Xen - Linux   | first hypervisor  | crash kernel
+   | dom0 kernel|
+---++
+Linux - Linux | first kernel   | crash kernel
+
+Regardless of if you are kdumping from Xen or Linux you will need to
+prepare a linux crash kernel.  You will also need to have kexec-tools
+installed. This provides the kexec command.
+
+0. Set-Up The Crash Kernel Region
+-
+
+In order to use kdump an area of memory has to be reserved at boot time.
+This is the area of memory that the crash kernel will use, thus allowing it
+to run without disrupting the memory used by the first kernel. This area is
+called the crash kernel region and is reserved using the crashkernel
+command line parameter to the Xen hypervisor. It has two forms:
+
+  i) crashkernel=size
+
+ This is the simplest and recommended way to reserve the crash kernel
+ region. Just specify how large the region should be and the hypervisor
+ will find a good location for it. A good size to 

Re: [PATCH -v2 7/8] kexec jump: ftrace_enabled_save/restore

2008-08-11 Thread Huang Ying
Hi, Vivek,

On Mon, 2008-08-11 at 09:51 -0400, Vivek Goyal wrote:
[...]
 So you want to use a non-locked version from optimization point of view?
 So that we don't end up taking and release a lock?

Not from optimization point of view. machine_kexec() may be called from
crash_kexec(), where it is not permitted to take and release a lock.

Best Regards,
Huang Ying



___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [LTP] [RFC] [KDUMP] [PROPOSED WORK] kdump on Xen hypervisor and guests, more tests for utilities, like makedumpfile, mkdumprd, kexec etc

2008-08-11 Thread Cai Qian
Hi Subrata,

From: Subrata Modak [EMAIL PROTECTED]
Subject: Re: [LTP] [RFC] [KDUMP] [PROPOSED WORK] kdump on Xen hypervisor and 
guests, more tests for utilities, like makedumpfile, mkdumprd, kexec etc
Date: Mon, 11 Aug 2008 19:02:47 +0530

 Cai,
 
 Any headway in this front ?
 

I have all test cases finished, but I am working on implementing a
suitable harness to run those tests.

CaiQian

 Regards--
 Subrata
 
 On Thu, 2008-07-24 at 05:11 +0530, Subrata Modak wrote:
  Hi Cai,
  
  Some patches in Bits and Pieces regarding this nearby ?
  
  Regards--
  Subrata
  
   
   Yes. Initally, I put this item to a relative low priority, partly
   because kdump config options and init scripts are tend to be
   distro-specific, so it won't be easy to write portable tests for
   different distros. In addition, lots of config options are not easy to
   be tested automately, like raw disk target, vfat disk target, and
   network target etc, as testers have to setup those name manually. But,
   you are right, those are high priority tests for kexec/kdump in distro
   release, we tested most of those options manually for RHEL anyway and we
   had some automated tests of it, which I'll try to submit to LTP as many
   as possible. For those manual tests, I'll also try to find some ways to
   automate them. For example, for different dump targets, it is possible
   to verify the generated initrd file as expected.
   

 == increase coverages for new kexec/kdump development efforts ==
 - new reserved region syntax in Kernel.

Another important thing we need to focus on is driver testing. Drivers
can fail to initialize in second kernel and kdump will fail. Can we do
something so that we can do following.
   
   
   That isn't something I have not thought of. For RHEL release testing, we
   will have a workflow to run those tests on any storage/network drivers,
   and it will report back testing results and driver matrix. However, this
   workflow is very distro-specific, and depends on the test farm it is
   using, so it does not make any sense to put it here.
   
- Collect the machine statistics on which kdump was tested and send
  the reports to a common place. Especially capture the storage/network
  driver data which can be probably be available through LTP site.

   
   That sounds like a good idea to me.
   
- Also capture how much memory was reserved on what architecture and
  whether it worked or not. This will help us verify for sure that how
 much memory to reserve for second kernel on various architectures.
   
   
   This is something could be done. I'll have a look at it.
   
   Thanks,
   CaiQian
   
Thanks
Vivek
  
  
  -
  This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
  Build the coolest Linux based applications with Moblin SDK  win great 
  prizes
  Grand prize is a trip for two to an Open Source event anywhere in the world
  http://moblin-contest.org/redirect.php?banner_id=100url=/
  ___
  Ltp-list mailing list
  [EMAIL PROTECTED]
  https://lists.sourceforge.net/lists/listinfo/ltp-list
 

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH -v3 1/7] kexec jump: clean up #ifdef and comments

2008-08-11 Thread Huang Ying
Move if (kexec_image-preserve_context) { ... } into #ifdef
CONFIG_KEXEC_JUMP to make code looks cleaner.

Fix no longer correct comments of kernel_kexec().

Signed-off-by: Huang Ying [EMAIL PROTECTED]
Acked-by: Vivek Goyal [EMAIL PROTECTED]

---
 kernel/kexec.c |   17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1426,11 +1426,9 @@ static int __init crash_save_vmcoreinfo_
 
 module_init(crash_save_vmcoreinfo_init)
 
-/**
- * kernel_kexec - reboot the system
- *
- * Move into place and start executing a preloaded standalone
- * executable.  If nothing was preloaded return an error.
+/*
+ * Move into place and start executing a preloaded standalone
+ * executable.  If nothing was preloaded return an error.
  */
 int kernel_kexec(void)
 {
@@ -1443,8 +1441,8 @@ int kernel_kexec(void)
goto Unlock;
}
 
-   if (kexec_image-preserve_context) {
 #ifdef CONFIG_KEXEC_JUMP
+   if (kexec_image-preserve_context) {
mutex_lock(pm_mutex);
pm_prepare_console();
error = freeze_processes();
@@ -1471,8 +1469,9 @@ int kernel_kexec(void)
if (error)
goto Enable_irqs;
save_processor_state();
+   } else
 #endif
-   } else {
+   {
blocking_notifier_call_chain(reboot_notifier_list,
 SYS_RESTART, NULL);
system_state = SYSTEM_RESTART;
@@ -1484,8 +1483,8 @@ int kernel_kexec(void)
 
machine_kexec(kexec_image);
 
-   if (kexec_image-preserve_context) {
 #ifdef CONFIG_KEXEC_JUMP
+   if (kexec_image-preserve_context) {
restore_processor_state();
device_power_up(PMSG_RESTORE);
  Enable_irqs:
@@ -1499,8 +1498,8 @@ int kernel_kexec(void)
  Restore_console:
pm_restore_console();
mutex_unlock(pm_mutex);
-#endif
}
+#endif
 
  Unlock:
xchg(kexec_lock, 0);



___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH -v3 7/7] kexec jump: fix for ftrace

2008-08-11 Thread Huang Ying
Ftrace depends on some processor state that we destroyed during kexec
and restored by restore_processor_state(). So save_processor_state()
and restore_processor_state() are moved into machine_kexec() and
ftrace is restored after restore_processor_state().

Signed-off-by: Huang Ying [EMAIL PROTECTED]

---
 arch/x86/kernel/machine_kexec_32.c |   16 +++-
 kernel/kexec.c |2 --
 2 files changed, 15 insertions(+), 3 deletions(-)

--- a/arch/x86/kernel/machine_kexec_32.c
+++ b/arch/x86/kernel/machine_kexec_32.c
@@ -12,6 +12,7 @@
 #include linux/init.h
 #include linux/numa.h
 #include linux/ftrace.h
+#include linux/suspend.h
 
 #include asm/pgtable.h
 #include asm/pgalloc.h
@@ -113,6 +114,7 @@ void machine_kexec(struct kimage *image)
 {
unsigned long page_list[PAGES_NR];
void *control_page;
+   int save_ftrace_enabled;
asmlinkage unsigned long
(*relocate_kernel_ptr)(unsigned long indirection_page,
   unsigned long control_page,
@@ -120,7 +122,12 @@ void machine_kexec(struct kimage *image)
   unsigned int has_pae,
   unsigned int preserve_context);
 
-   tracer_disable();
+#ifdef CONFIG_KEXEC_JUMP
+   if (kexec_image-preserve_context)
+   save_processor_state();
+#endif
+
+   save_ftrace_enabled = __ftrace_enabled_save();
 
/* Interrupts aren't acceptable while we reboot */
local_irq_disable();
@@ -178,6 +185,13 @@ void machine_kexec(struct kimage *image)
   (unsigned long)page_list,
   image-start, cpu_has_pae,
   image-preserve_context);
+
+#ifdef CONFIG_KEXEC_JUMP
+   if (kexec_image-preserve_context)
+   restore_processor_state();
+#endif
+
+   __ftrace_enabled_restore(save_ftrace_enabled);
 }
 
 void arch_crash_save_vmcoreinfo(void)
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1469,7 +1469,6 @@ int kernel_kexec(void)
error = device_power_down(PMSG_FREEZE);
if (error)
goto Enable_irqs;
-   save_processor_state();
} else
 #endif
{
@@ -1482,7 +1481,6 @@ int kernel_kexec(void)
 
 #ifdef CONFIG_KEXEC_JUMP
if (kexec_image-preserve_context) {
-   restore_processor_state();
device_power_up(PMSG_RESTORE);
  Enable_irqs:
local_irq_enable();



___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH -v3 0/7] kexec jump: fixes for 2.6.27

2008-08-11 Thread Huang Ying
Hi,

This patchset fixes some issues of kexec jump for 2.6.27.

It is based on 2.6.27-rc2 and has been tested on i386 platform.


ChangeLog:

v3:

- Merge added file vmlinux_check_32.lds.S into vmlinux_32.lds.S.
- Add comments about lock for ftrace code.

v2:

- Check control code size at link time instead of run time.
- Encapsulate ftrace related code into functions.

Best Regards,
Huang Ying



___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH -v3 6/7] kexec jump: __ftrace_enabled_save/restore

2008-08-11 Thread Huang Ying
Add __ftrace_enabled_save/restore, used to disable ftrace for a
while. Now, this is used by kexec jump, which need a version without
lock, for general situation, a locked version should be used.

Signed-off-by: Huang Ying [EMAIL PROTECTED]

---
 include/linux/ftrace.h |   21 +
 1 file changed, 21 insertions(+)

--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -98,6 +98,27 @@ static inline void tracer_disable(void)
 #endif
 }
 
+/* Ftrace disable/restore without lock. Some synchronization mechanism
+ * must be used to prevent ftrace_enabled to be changed between
+ * disable/restore. */
+static inline int __ftrace_enabled_save(void)
+{
+#ifdef CONFIG_FTRACE
+   int saved_ftrace_enabled = ftrace_enabled;
+   ftrace_enabled = 0;
+   return saved_ftrace_enabled;
+#else
+   return 0;
+#endif
+}
+
+static inline void __ftrace_enabled_restore(int enabled)
+{
+#ifdef CONFIG_FTRACE
+   ftrace_enabled = enabled;
+#endif
+}
+
 #ifdef CONFIG_FRAME_POINTER
 /* TODO: need to fix this for ARM */
 # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))



___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH -v3 2/7] kexec jump: rename KEXEC_CONTROL_CODE_SIZE to KEXEC_CONTROL_PAGE_SIZE

2008-08-11 Thread Huang Ying
Rename KEXEC_CONTROL_CODE_SIZE to KEXEC_CONTROL_PAGE_SIZE, because
control page is used for not only code on some platform. For example
in kexec jump, it is used for data and stack too.

Signed-off-by: Huang Ying [EMAIL PROTECTED]

---
 arch/arm/include/asm/kexec.h |2 +-
 arch/ia64/include/asm/kexec.h|2 +-
 arch/powerpc/include/asm/kexec.h |2 +-
 arch/s390/include/asm/kexec.h|2 +-
 arch/sh/include/asm/kexec.h  |2 +-
 include/asm-mips/kexec.h |2 +-
 include/asm-x86/kexec.h  |4 ++--
 include/linux/kexec.h|4 ++--
 kernel/kexec.c   |4 ++--
 9 files changed, 12 insertions(+), 12 deletions(-)

--- a/include/asm-x86/kexec.h
+++ b/include/asm-x86/kexec.h
@@ -63,7 +63,7 @@
 /* Maximum address we can use for the control code buffer */
 # define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
 
-# define KEXEC_CONTROL_CODE_SIZE   4096
+# define KEXEC_CONTROL_PAGE_SIZE   4096
 
 /* The native architecture */
 # define KEXEC_ARCH KEXEC_ARCH_386
@@ -79,7 +79,7 @@
 # define KEXEC_CONTROL_MEMORY_LIMIT (0xFFUL)
 
 /* Allocate one page for the pdp and the second for the code */
-# define KEXEC_CONTROL_CODE_SIZE  (4096UL + 4096UL)
+# define KEXEC_CONTROL_PAGE_SIZE  (4096UL + 4096UL)
 
 /* The native architecture */
 # define KEXEC_ARCH KEXEC_ARCH_X86_64
--- a/arch/sh/include/asm/kexec.h
+++ b/arch/sh/include/asm/kexec.h
@@ -21,7 +21,7 @@
 /* Maximum address we can use for the control code buffer */
 #define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
 
-#define KEXEC_CONTROL_CODE_SIZE4096
+#define KEXEC_CONTROL_PAGE_SIZE4096
 
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_SH
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -22,7 +22,7 @@
 #define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
 #endif
 
-#define KEXEC_CONTROL_CODE_SIZE 4096
+#define KEXEC_CONTROL_PAGE_SIZE 4096
 
 /* The native architecture */
 #ifdef __powerpc64__
--- a/arch/ia64/include/asm/kexec.h
+++ b/arch/ia64/include/asm/kexec.h
@@ -9,7 +9,7 @@
 /* Maximum address we can use for the control code buffer */
 #define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
 
-#define KEXEC_CONTROL_CODE_SIZE (8192 + 8192 + 4096)
+#define KEXEC_CONTROL_PAGE_SIZE (8192 + 8192 + 4096)
 
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_IA_64
--- a/arch/s390/include/asm/kexec.h
+++ b/arch/s390/include/asm/kexec.h
@@ -31,7 +31,7 @@
 #define KEXEC_CONTROL_MEMORY_LIMIT (1UL31)
 
 /* Allocate one page for the pdp and the second for the code */
-#define KEXEC_CONTROL_CODE_SIZE 4096
+#define KEXEC_CONTROL_PAGE_SIZE 4096
 
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_S390
--- a/arch/arm/include/asm/kexec.h
+++ b/arch/arm/include/asm/kexec.h
@@ -10,7 +10,7 @@
 /* Maximum address we can use for the control code buffer */
 #define KEXEC_CONTROL_MEMORY_LIMIT (-1UL)
 
-#define KEXEC_CONTROL_CODE_SIZE4096
+#define KEXEC_CONTROL_PAGE_SIZE4096
 
 #define KEXEC_ARCH KEXEC_ARCH_ARM
 
--- a/include/asm-mips/kexec.h
+++ b/include/asm-mips/kexec.h
@@ -16,7 +16,7 @@
  /* Maximum address we can use for the control code buffer */
 #define KEXEC_CONTROL_MEMORY_LIMIT (0x2000)
 
-#define KEXEC_CONTROL_CODE_SIZE 4096
+#define KEXEC_CONTROL_PAGE_SIZE 4096
 
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_MIPS
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -242,7 +242,7 @@ static int kimage_normal_alloc(struct ki
 */
result = -ENOMEM;
image-control_code_page = kimage_alloc_control_pages(image,
-  get_order(KEXEC_CONTROL_CODE_SIZE));
+  get_order(KEXEC_CONTROL_PAGE_SIZE));
if (!image-control_code_page) {
printk(KERN_ERR Could not allocate control_code_buffer\n);
goto out;
@@ -317,7 +317,7 @@ static int kimage_crash_alloc(struct kim
 */
result = -ENOMEM;
image-control_code_page = kimage_alloc_control_pages(image,
-  get_order(KEXEC_CONTROL_CODE_SIZE));
+  get_order(KEXEC_CONTROL_PAGE_SIZE));
if (!image-control_code_page) {
printk(KERN_ERR Could not allocate control_code_buffer\n);
goto out;
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -25,8 +25,8 @@
 #error KEXEC_CONTROL_MEMORY_LIMIT not defined
 #endif
 
-#ifndef KEXEC_CONTROL_CODE_SIZE
-#error KEXEC_CONTROL_CODE_SIZE not defined
+#ifndef KEXEC_CONTROL_PAGE_SIZE
+#error KEXEC_CONTROL_PAGE_SIZE not defined
 #endif
 
 #ifndef KEXEC_ARCH



___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH -v3 4/7] kexec jump: remove duplication of kexec_restart_prepare()

2008-08-11 Thread Huang Ying
Call kernel_restart_prepare() in kernel_kexec() instead of duplicating
the code.

Signed-off-by: Huang Ying [EMAIL PROTECTED]
Acked-by: Pavel Machek [EMAIL PROTECTED]
Acked-by: Vivek Goyal [EMAIL PROTECTED]

---
 include/linux/reboot.h |1 +
 kernel/kexec.c |6 +-
 kernel/sys.c   |2 +-
 3 files changed, 3 insertions(+), 6 deletions(-)

--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -59,6 +59,7 @@ extern void machine_crash_shutdown(struc
  * Architecture independent implemenations of sys_reboot commands.
  */
 
+extern void kernel_restart_prepare(char *cmd);
 extern void kernel_restart(char *cmd);
 extern void kernel_halt(void);
 extern void kernel_power_off(void);
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -274,7 +274,7 @@ void emergency_restart(void)
 }
 EXPORT_SYMBOL_GPL(emergency_restart);
 
-static void kernel_restart_prepare(char *cmd)
+void kernel_restart_prepare(char *cmd)
 {
blocking_notifier_call_chain(reboot_notifier_list, SYS_RESTART, cmd);
system_state = SYSTEM_RESTART;
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1472,11 +1472,7 @@ int kernel_kexec(void)
} else
 #endif
{
-   blocking_notifier_call_chain(reboot_notifier_list,
-SYS_RESTART, NULL);
-   system_state = SYSTEM_RESTART;
-   device_shutdown();
-   sysdev_shutdown();
+   kernel_restart_prepare(NULL);
printk(KERN_EMERG Starting new kernel\n);
machine_shutdown();
}



___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH -v3 5/7] kexec jump: in sync with hibernation implementation

2008-08-11 Thread Huang Ying
Add device_pm_lock() and device_pm_unlock() in kernel_kexec() in sync
with current hibernation implementation.

Signed-off-by: Huang Ying [EMAIL PROTECTED]

---
 kernel/kexec.c |2 ++
 1 file changed, 2 insertions(+)

--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1457,6 +1457,7 @@ int kernel_kexec(void)
error = disable_nonboot_cpus();
if (error)
goto Resume_devices;
+   device_pm_lock();
local_irq_disable();
/* At this point, device_suspend() has been called,
 * but *not* device_power_down(). We *must*
@@ -1485,6 +1486,7 @@ int kernel_kexec(void)
device_power_up(PMSG_RESTORE);
  Enable_irqs:
local_irq_enable();
+   device_pm_unlock();
enable_nonboot_cpus();
  Resume_devices:
device_resume(PMSG_RESTORE);



___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH -v3 3/7] kexec jump: check code size in control page

2008-08-11 Thread Huang Ying
Kexec/Kexec-jump require code size in control page is less than
PAGE_SIZE/2. This patch add link-time checking for this.

ASSERT() of ld link script is used as the link-time checking
mechanism.

Signed-off-by: Huang Ying [EMAIL PROTECTED]

---
 arch/x86/kernel/machine_kexec_32.c   |2 +-
 arch/x86/kernel/relocate_kernel_32.S |   10 +++---
 arch/x86/kernel/vmlinux_32.lds.S |6 ++
 include/asm-x86/kexec.h  |4 
 4 files changed, 18 insertions(+), 4 deletions(-)

--- a/arch/x86/kernel/machine_kexec_32.c
+++ b/arch/x86/kernel/machine_kexec_32.c
@@ -138,7 +138,7 @@ void machine_kexec(struct kimage *image)
}
 
control_page = page_address(image-control_code_page);
-   memcpy(control_page, relocate_kernel, PAGE_SIZE/2);
+   memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
 
relocate_kernel_ptr = control_page;
page_list[PA_CONTROL_PAGE] = __pa(control_page);
--- a/arch/x86/kernel/relocate_kernel_32.S
+++ b/arch/x86/kernel/relocate_kernel_32.S
@@ -20,10 +20,11 @@
 #define PAGE_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
 #define PAE_PGD_ATTR (_PAGE_PRESENT)
 
-/* control_page + PAGE_SIZE/2 ~ control_page + PAGE_SIZE * 3/4 are
- * used to save some data for jumping back
+/* control_page + KEXEC_CONTROL_CODE_MAX_SIZE
+ * ~ control_page + PAGE_SIZE are used as data storage and stack for
+ * jumping back
  */
-#define DATA(offset)   (PAGE_SIZE/2+(offset))
+#define DATA(offset)   (KEXEC_CONTROL_CODE_MAX_SIZE+(offset))
 
 /* Minimal CPU state */
 #define ESPDATA(0x0)
@@ -376,3 +377,6 @@ swap_pages:
popl%ebx
popl%ebp
ret
+
+   .globl kexec_control_code_size
+.set kexec_control_code_size, . - relocate_kernel
--- a/include/asm-x86/kexec.h
+++ b/include/asm-x86/kexec.h
@@ -41,6 +41,10 @@
 # define PAGES_NR  17
 #endif
 
+#ifdef CONFIG_X86_32
+# define KEXEC_CONTROL_CODE_MAX_SIZE   2048
+#endif
+
 #ifndef __ASSEMBLY__
 
 #include linux/string.h
--- a/arch/x86/kernel/vmlinux_32.lds.S
+++ b/arch/x86/kernel/vmlinux_32.lds.S
@@ -209,3 +209,9 @@ SECTIONS
 
   DWARF_DEBUG
 }
+
+/* Link time checks */
+#include asm/kexec.h
+
+ASSERT(kexec_control_code_size = KEXEC_CONTROL_CODE_MAX_SIZE,
+   kexec control code size is too big)



___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec