All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kdump/kexec: calculate note size at compile time
@ 2007-03-28  6:18 Simon Horman
  2007-03-28  6:43 ` Vivek Goyal
  0 siblings, 1 reply; 12+ messages in thread
From: Simon Horman @ 2007-03-28  6:18 UTC (permalink / raw)
  To: fastboot, linux-kernel; +Cc: Vivek Goyal, Andrew Morton

Currently the size of the per-cpu region reserved to save crash
notes is set by the per-architecture value MAX_NOTE_BYTES. Which
in turn is currently set to 1024 on all supported architectures.

While testing ia64 I recently discovered that this value is
in fact too small. The particular setup I was using actually
needs 1172 bytes. This lead to very tedious failure mode
where the tail of one elf note would overwrite the head of 
another if they ended up being alocated sequentially by kmalloc,
which was often the case.

It seems to me that a far better approach is to caclculate the size
that the area needs to be. This patch does just that.

If a simpler stop-gap patch for ia64 to be squeezed into 2.6.21(.X) 
is needed then this should be as easy as making MAX_NOTE_BYTES
larger in arch/asm-ia64/kexec.h. Perhaps 2048 would be a good choice.
However, I think that the approach in this patch is a much more robust idea.

Signed-off-by: Simon Horman <horms@verge.net.au>

 include/asm-arm/kexec.h     |    2 --
 include/asm-i386/kexec.h    |    2 --
 include/asm-ia64/kexec.h    |    2 --
 include/asm-mips/kexec.h    |    2 --
 include/asm-powerpc/kexec.h |    2 --
 include/asm-s390/kexec.h    |    2 --
 include/asm-sh/kexec.h      |    2 --
 include/asm-x86_64/kexec.h  |    2 --
 include/linux/kexec.h       |   11 ++++++++++-
 9 files changed, 10 insertions(+), 17 deletions(-)

Index: linux-2.6/include/asm-ia64/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-ia64/kexec.h	2007-03-28 13:07:11.000000000 +0900
+++ linux-2.6/include/asm-ia64/kexec.h	2007-03-28 09:51:27.000000000 +0900
@@ -14,8 +14,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_IA_64
 
-#define MAX_NOTE_BYTES 1024
-
 #define kexec_flush_icache_page(page) do { \
                 unsigned long page_addr = (unsigned long)page_address(page); \
                 flush_icache_range(page_addr, page_addr + PAGE_SIZE); \
Index: linux-2.6/include/linux/kexec.h
===================================================================
--- linux-2.6.orig/include/linux/kexec.h	2007-03-28 09:42:14.000000000 +0900
+++ linux-2.6/include/linux/kexec.h	2007-03-28 12:32:50.000000000 +0900
@@ -7,6 +7,8 @@
 #include <linux/linkage.h>
 #include <linux/compat.h>
 #include <linux/ioport.h>
+#include <linux/elfcore.h>
+#include <linux/elf.h>
 #include <asm/kexec.h>
 
 /* Verify architecture specific macros are defined */
@@ -31,6 +33,13 @@
 #error KEXEC_ARCH not defined
 #endif
 
+#define KEXEC_NOTE_NAME "CORE"
+#define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
+#define KEXEC_NOTE_NAME_BYTES ALIGN(strlen(KEXEC_NOTE_NAME) + 1, 4)
+#define KEXEC_NOTE_BODY_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+#define KEXEC_NOTE_BYTES ( (KEXEC_NOTE_HEAD_BYTES * 2) + \
+			   KEXEC_NOTE_NAME_BYTES + KEXEC_NOTE_BODY_BYTES )
+
 /*
  * This structure is used to hold the arguments that are used when loading
  * kernel binaries.
@@ -136,7 +145,7 @@
 /* Location of a reserved region to hold the crash kernel.
  */
 extern struct resource crashk_res;
-typedef u32 note_buf_t[MAX_NOTE_BYTES/4];
+typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4];
 extern note_buf_t *crash_notes;
 
 
Index: linux-2.6/include/asm-arm/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-arm/kexec.h	2007-03-28 13:08:43.000000000 +0900
+++ linux-2.6/include/asm-arm/kexec.h	2007-03-28 13:08:47.000000000 +0900
@@ -16,8 +16,6 @@
 
 #ifndef __ASSEMBLY__
 
-#define MAX_NOTE_BYTES 1024
-
 struct kimage;
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
Index: linux-2.6/include/asm-i386/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-i386/kexec.h	2007-03-28 13:08:43.000000000 +0900
+++ linux-2.6/include/asm-i386/kexec.h	2007-03-28 13:08:47.000000000 +0900
@@ -47,8 +47,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_386
 
-#define MAX_NOTE_BYTES 1024
-
 /* CPU does not save ss and esp on stack if execution is already
  * running in kernel mode at the time of NMI occurrence. This code
  * fixes it.
Index: linux-2.6/include/asm-mips/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-mips/kexec.h	2007-03-28 13:08:43.000000000 +0900
+++ linux-2.6/include/asm-mips/kexec.h	2007-03-28 13:08:47.000000000 +0900
@@ -21,8 +21,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_MIPS
 
-#define MAX_NOTE_BYTES 1024
-
 static inline void crash_setup_regs(struct pt_regs *newregs,
 				    struct pt_regs *oldregs)
 {
Index: linux-2.6/include/asm-powerpc/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-powerpc/kexec.h	2007-03-28 13:08:43.000000000 +0900
+++ linux-2.6/include/asm-powerpc/kexec.h	2007-03-28 13:08:47.000000000 +0900
@@ -108,8 +108,6 @@
 					struct pt_regs *oldregs) { }
 #endif /* !__powerpc64 __ */
 
-#define MAX_NOTE_BYTES 1024
-
 extern void kexec_smp_wait(void);	/* get and clear naca physid, wait for
 					  master to copy new code to 0 */
 extern int crashing_cpu;
Index: linux-2.6/include/asm-s390/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-s390/kexec.h	2007-03-28 13:08:43.000000000 +0900
+++ linux-2.6/include/asm-s390/kexec.h	2007-03-28 13:08:47.000000000 +0900
@@ -34,8 +34,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_S390
 
-#define MAX_NOTE_BYTES 1024
-
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
 					struct pt_regs *oldregs) { }
Index: linux-2.6/include/asm-sh/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-sh/kexec.h	2007-03-28 13:08:43.000000000 +0900
+++ linux-2.6/include/asm-sh/kexec.h	2007-03-28 13:08:47.000000000 +0900
@@ -23,8 +23,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_SH
 
-#define MAX_NOTE_BYTES 1024
-
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
 					struct pt_regs *oldregs) { }
Index: linux-2.6/include/asm-x86_64/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-x86_64/kexec.h	2007-03-28 13:08:43.000000000 +0900
+++ linux-2.6/include/asm-x86_64/kexec.h	2007-03-28 13:08:47.000000000 +0900
@@ -48,8 +48,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_X86_64
 
-#define MAX_NOTE_BYTES 1024
-
 /*
  * Saving the registers of the cpu on which panic occured in
  * crash_kexec to save a valid sp. The registers of other cpus

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] kdump/kexec: calculate note size at compile time
  2007-03-28  6:18 [PATCH] kdump/kexec: calculate note size at compile time Simon Horman
@ 2007-03-28  6:43 ` Vivek Goyal
  2007-03-28  7:13   ` Horms
  0 siblings, 1 reply; 12+ messages in thread
From: Vivek Goyal @ 2007-03-28  6:43 UTC (permalink / raw)
  To: Simon Horman; +Cc: fastboot, linux-kernel, Andrew Morton

On Wed, Mar 28, 2007 at 03:18:58PM +0900, Simon Horman wrote:
> Currently the size of the per-cpu region reserved to save crash
> notes is set by the per-architecture value MAX_NOTE_BYTES. Which
> in turn is currently set to 1024 on all supported architectures.
> 
> While testing ia64 I recently discovered that this value is
> in fact too small. The particular setup I was using actually
> needs 1172 bytes. This lead to very tedious failure mode
> where the tail of one elf note would overwrite the head of 
> another if they ended up being alocated sequentially by kmalloc,
> which was often the case.
> 
> It seems to me that a far better approach is to caclculate the size
> that the area needs to be. This patch does just that.
> 
> If a simpler stop-gap patch for ia64 to be squeezed into 2.6.21(.X) 
> is needed then this should be as easy as making MAX_NOTE_BYTES
> larger in arch/asm-ia64/kexec.h. Perhaps 2048 would be a good choice.
> However, I think that the approach in this patch is a much more robust idea.
> 

Makes sense to me. Calculating the size based on elf_prstatus is better
than hardcoding it to some value.

A minor query is inlined below.

[..]
> ===================================================================
> --- linux-2.6.orig/include/linux/kexec.h	2007-03-28 09:42:14.000000000 +0900
> +++ linux-2.6/include/linux/kexec.h	2007-03-28 12:32:50.000000000 +0900
> @@ -7,6 +7,8 @@
>  #include <linux/linkage.h>
>  #include <linux/compat.h>
>  #include <linux/ioport.h>
> +#include <linux/elfcore.h>
> +#include <linux/elf.h>
>  #include <asm/kexec.h>
> 
>  /* Verify architecture specific macros are defined */
> @@ -31,6 +33,13 @@
>  #error KEXEC_ARCH not defined
>  #endif
> 
> +#define KEXEC_NOTE_NAME "CORE"
> +#define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
> +#define KEXEC_NOTE_NAME_BYTES ALIGN(strlen(KEXEC_NOTE_NAME) + 1, 4)
> +#define KEXEC_NOTE_BODY_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
> +#define KEXEC_NOTE_BYTES ( (KEXEC_NOTE_HEAD_BYTES * 2) + \

Why are we multiplying KEXEC_NOTE_HEAD_BYTES with 2?

Thanks
Vivek

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] kdump/kexec: calculate note size at compile time
  2007-03-28  6:43 ` Vivek Goyal
@ 2007-03-28  7:13   ` Horms
  2007-03-28  8:08     ` Vivek Goyal
  0 siblings, 1 reply; 12+ messages in thread
From: Horms @ 2007-03-28  7:13 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: fastboot, linux-kernel, Andrew Morton

On Wed, Mar 28, 2007 at 12:13:53PM +0530, Vivek Goyal wrote:
> On Wed, Mar 28, 2007 at 03:18:58PM +0900, Simon Horman wrote:
> > Currently the size of the per-cpu region reserved to save crash
> > notes is set by the per-architecture value MAX_NOTE_BYTES. Which
> > in turn is currently set to 1024 on all supported architectures.
> > 
> > While testing ia64 I recently discovered that this value is
> > in fact too small. The particular setup I was using actually
> > needs 1172 bytes. This lead to very tedious failure mode
> > where the tail of one elf note would overwrite the head of 
> > another if they ended up being alocated sequentially by kmalloc,
> > which was often the case.
> > 
> > It seems to me that a far better approach is to caclculate the size
> > that the area needs to be. This patch does just that.
> > 
> > If a simpler stop-gap patch for ia64 to be squeezed into 2.6.21(.X) 
> > is needed then this should be as easy as making MAX_NOTE_BYTES
> > larger in arch/asm-ia64/kexec.h. Perhaps 2048 would be a good choice.
> > However, I think that the approach in this patch is a much more robust idea.
> > 
> 
> Makes sense to me. Calculating the size based on elf_prstatus is better
> than hardcoding it to some value.
> 
> A minor query is inlined below.
> 
> [..]
> > ===================================================================
> > --- linux-2.6.orig/include/linux/kexec.h	2007-03-28 09:42:14.000000000 +0900
> > +++ linux-2.6/include/linux/kexec.h	2007-03-28 12:32:50.000000000 +0900
> > @@ -7,6 +7,8 @@
> >  #include <linux/linkage.h>
> >  #include <linux/compat.h>
> >  #include <linux/ioport.h>
> > +#include <linux/elfcore.h>
> > +#include <linux/elf.h>
> >  #include <asm/kexec.h>
> > 
> >  /* Verify architecture specific macros are defined */
> > @@ -31,6 +33,13 @@
> >  #error KEXEC_ARCH not defined
> >  #endif
> > 
> > +#define KEXEC_NOTE_NAME "CORE"
> > +#define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
> > +#define KEXEC_NOTE_NAME_BYTES ALIGN(strlen(KEXEC_NOTE_NAME) + 1, 4)
> > +#define KEXEC_NOTE_BODY_BYTES ALIGN(sizeof(struct elf_prstatus), 4)

DESC is probably a better name that BODY here, I meant to update
that before posting. An updated version is below.

> > +#define KEXEC_NOTE_BYTES ( (KEXEC_NOTE_HEAD_BYTES * 2) + \
> 
> Why are we multiplying KEXEC_NOTE_HEAD_BYTES with 2?

The way that the note merging code works in vmcore it assumes that
the area is a list of notes. And there is a terminating note that
has all the header values set to 0, and nothing else. So the time 2
is for the space to store the terminating note.

This structure isn't entirely neccessary, and if we were to modify the
mergeing code in vmcore (which runs in the second kernel) it could be
changed.

-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/

[PATCH] kdump/kexec: calculate note size at compile time

Currently the size of the per-cpu region reserved to save crash
notes is set by the per-architecture value MAX_NOTE_BYTES. Which
in turn is currently set to 1024 on all supported architectures.

While testing ia64 I recently discovered that this value is
in fact too small. The particular setup I was using actually
needs 1172 bytes. This lead to very tedious failure mode
where the tail of one elf note would overwrite the head of 
another if they ended up being alocated sequentially by kmalloc,
which was often the case.

It seems to me that a far better approach is to caclculate the size
that the area needs to be. This patch does just that.

If a simpler stop-gap patch for ia64 to be squeezed into 2.6.21(.X) 
is needed then this should be as easy as making MAX_NOTE_BYTES
larger in arch/asm-ia64/kexec.h. Perhaps 2048 would be a good choice.
However, I think that the approach in this patch is a much more robust idea.

Signed-off-by: Simon Horman <horms@verge.net.au>

 include/asm-arm/kexec.h     |    2 --
 include/asm-i386/kexec.h    |    2 --
 include/asm-ia64/kexec.h    |    2 --
 include/asm-mips/kexec.h    |    2 --
 include/asm-powerpc/kexec.h |    2 --
 include/asm-s390/kexec.h    |    2 --
 include/asm-sh/kexec.h      |    2 --
 include/asm-x86_64/kexec.h  |    2 --
 include/linux/kexec.h       |   11 ++++++++++-
 9 files changed, 10 insertions(+), 17 deletions(-)

Index: linux-2.6/include/asm-ia64/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-ia64/kexec.h	2007-03-28 15:57:15.000000000 +0900
+++ linux-2.6/include/asm-ia64/kexec.h	2007-03-28 15:57:17.000000000 +0900
@@ -14,8 +14,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_IA_64
 
-#define MAX_NOTE_BYTES 1024
-
 #define kexec_flush_icache_page(page) do { \
                 unsigned long page_addr = (unsigned long)page_address(page); \
                 flush_icache_range(page_addr, page_addr + PAGE_SIZE); \
Index: linux-2.6/include/linux/kexec.h
===================================================================
--- linux-2.6.orig/include/linux/kexec.h	2007-03-28 15:57:15.000000000 +0900
+++ linux-2.6/include/linux/kexec.h	2007-03-28 16:00:11.000000000 +0900
@@ -7,6 +7,8 @@
 #include <linux/linkage.h>
 #include <linux/compat.h>
 #include <linux/ioport.h>
+#include <linux/elfcore.h>
+#include <linux/elf.h>
 #include <asm/kexec.h>
 
 /* Verify architecture specific macros are defined */
@@ -31,6 +33,13 @@
 #error KEXEC_ARCH not defined
 #endif
 
+#define KEXEC_NOTE_NAME "CORE"
+#define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
+#define KEXEC_NOTE_NAME_BYTES ALIGN(strlen(KEXEC_NOTE_NAME) + 1, 4)
+#define KEXEC_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+#define KEXEC_NOTE_BYTES ( (KEXEC_NOTE_HEAD_BYTES * 2) + \
+			   KEXEC_NOTE_NAME_BYTES + KEXEC_NOTE_DESC_BYTES )
+
 /*
  * This structure is used to hold the arguments that are used when loading
  * kernel binaries.
@@ -136,7 +145,7 @@
 /* Location of a reserved region to hold the crash kernel.
  */
 extern struct resource crashk_res;
-typedef u32 note_buf_t[MAX_NOTE_BYTES/4];
+typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4];
 extern note_buf_t *crash_notes;
 
 
Index: linux-2.6/include/asm-arm/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-arm/kexec.h	2007-03-28 15:57:15.000000000 +0900
+++ linux-2.6/include/asm-arm/kexec.h	2007-03-28 15:57:17.000000000 +0900
@@ -16,8 +16,6 @@
 
 #ifndef __ASSEMBLY__
 
-#define MAX_NOTE_BYTES 1024
-
 struct kimage;
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
Index: linux-2.6/include/asm-i386/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-i386/kexec.h	2007-03-28 15:57:15.000000000 +0900
+++ linux-2.6/include/asm-i386/kexec.h	2007-03-28 15:57:17.000000000 +0900
@@ -47,8 +47,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_386
 
-#define MAX_NOTE_BYTES 1024
-
 /* CPU does not save ss and esp on stack if execution is already
  * running in kernel mode at the time of NMI occurrence. This code
  * fixes it.
Index: linux-2.6/include/asm-mips/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-mips/kexec.h	2007-03-28 15:57:15.000000000 +0900
+++ linux-2.6/include/asm-mips/kexec.h	2007-03-28 15:57:17.000000000 +0900
@@ -21,8 +21,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_MIPS
 
-#define MAX_NOTE_BYTES 1024
-
 static inline void crash_setup_regs(struct pt_regs *newregs,
 				    struct pt_regs *oldregs)
 {
Index: linux-2.6/include/asm-powerpc/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-powerpc/kexec.h	2007-03-28 15:57:15.000000000 +0900
+++ linux-2.6/include/asm-powerpc/kexec.h	2007-03-28 15:57:17.000000000 +0900
@@ -108,8 +108,6 @@
 					struct pt_regs *oldregs) { }
 #endif /* !__powerpc64 __ */
 
-#define MAX_NOTE_BYTES 1024
-
 extern void kexec_smp_wait(void);	/* get and clear naca physid, wait for
 					  master to copy new code to 0 */
 extern int crashing_cpu;
Index: linux-2.6/include/asm-s390/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-s390/kexec.h	2007-03-28 15:57:15.000000000 +0900
+++ linux-2.6/include/asm-s390/kexec.h	2007-03-28 15:57:17.000000000 +0900
@@ -34,8 +34,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_S390
 
-#define MAX_NOTE_BYTES 1024
-
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
 					struct pt_regs *oldregs) { }
Index: linux-2.6/include/asm-sh/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-sh/kexec.h	2007-03-28 15:57:15.000000000 +0900
+++ linux-2.6/include/asm-sh/kexec.h	2007-03-28 15:57:17.000000000 +0900
@@ -23,8 +23,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_SH
 
-#define MAX_NOTE_BYTES 1024
-
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
 					struct pt_regs *oldregs) { }
Index: linux-2.6/include/asm-x86_64/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-x86_64/kexec.h	2007-03-28 15:57:15.000000000 +0900
+++ linux-2.6/include/asm-x86_64/kexec.h	2007-03-28 15:57:17.000000000 +0900
@@ -48,8 +48,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_X86_64
 
-#define MAX_NOTE_BYTES 1024
-
 /*
  * Saving the registers of the cpu on which panic occured in
  * crash_kexec to save a valid sp. The registers of other cpus

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] kdump/kexec: calculate note size at compile time
  2007-03-28  7:13   ` Horms
@ 2007-03-28  8:08     ` Vivek Goyal
  2007-03-29  3:30       ` Simon Horman
  0 siblings, 1 reply; 12+ messages in thread
From: Vivek Goyal @ 2007-03-28  8:08 UTC (permalink / raw)
  To: Horms; +Cc: fastboot, linux-kernel, Andrew Morton

On Wed, Mar 28, 2007 at 04:13:20PM +0900, Horms wrote:
[..]
> 
> DESC is probably a better name that BODY here, I meant to update
> that before posting. An updated version is below.
> 
> > > +#define KEXEC_NOTE_BYTES ( (KEXEC_NOTE_HEAD_BYTES * 2) + \
> > 
> > Why are we multiplying KEXEC_NOTE_HEAD_BYTES with 2?
> 
> The way that the note merging code works in vmcore it assumes that
> the area is a list of notes. And there is a terminating note that
> has all the header values set to 0, and nothing else. So the time 2
> is for the space to store the terminating note.
> 

Ok.. Got it. Looks fine to me. 

Thanks
Vivek

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] kdump/kexec: calculate note size at compile time
  2007-03-28  8:08     ` Vivek Goyal
@ 2007-03-29  3:30       ` Simon Horman
  2007-03-29  3:44         ` Vivek Goyal
  2007-03-30  0:41         ` Andrew Morton
  0 siblings, 2 replies; 12+ messages in thread
From: Simon Horman @ 2007-03-29  3:30 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: fastboot, linux-kernel, Andrew Morton

Hi,

this is a(nother) minor update to this patch. 
Explanation below.

-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/

[PATCH] kdump/kexec: calculate note size at compile time

Currently the size of the per-cpu region reserved to save crash
notes is set by the per-architecture value MAX_NOTE_BYTES. Which
in turn is currently set to 1024 on all supported architectures.

While testing ia64 I recently discovered that this value is
in fact too small. The particular setup I was using actually
needs 1172 bytes. This lead to very tedious failure mode
where the tail of one elf note would overwrite the head of
another if they ended up being alocated sequentially by kmalloc,
which was often the case.

It seems to me that a far better approach is to caclculate the size
that the area needs to be. This patch does just that.

If a simpler stop-gap patch for ia64 to be squeezed into 2.6.21(.X)
is needed then this should be as easy as making MAX_NOTE_BYTES
larger in arch/asm-ia64/kexec.h. Perhaps 2048 would be a good choice.
However, I think that the approach in this patch is a much more robust
idea.

Update I:

  Changed KEXEC_NOTE_HEAD_BYTES to KEXEC_NOTE_DESC_BYTES in line
  with the name of the relevant field in struct elf_note

Update II:

  * Use KEXEC_NOTE_NAME instead of "CORE" in kernel/kexec.c and
    arch/ia64/kernel/crash.c just to be extra sure that the data
    used to calculate the size, and the data stuffed into the reserved
    area is the same.

    Incidently, the ia64 code really ought to use the generic code.
    I am working on a patch for this. But it is not urgent.

  * Added Ack from Vivek, which was actually for the update I version
    of the patch. If this is wrong, please tell me.

Acked-by:  Vivek Goyal <vgoyal@in.ibm.com>
Signed-off-by: Simon Horman <horms@verge.net.au>

 arch/ia64/kernel/crash.c    |    2 +-
 include/asm-arm/kexec.h     |    2 --
 include/asm-i386/kexec.h    |    2 --
 include/asm-ia64/kexec.h    |    2 --
 include/asm-mips/kexec.h    |    2 --
 include/asm-powerpc/kexec.h |    2 --
 include/asm-s390/kexec.h    |    2 --
 include/asm-sh/kexec.h      |    2 --
 include/asm-x86_64/kexec.h  |    2 --
 include/linux/kexec.h       |   11 ++++++++++-
 kernel/kexec.c              |    2 +-
 11 files changed, 12 insertions(+), 19 deletions(-)

Index: linux-2.6/include/asm-ia64/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-ia64/kexec.h	2007-03-28 18:50:25.000000000 +0900
+++ linux-2.6/include/asm-ia64/kexec.h	2007-03-29 12:19:10.000000000 +0900
@@ -14,8 +14,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_IA_64
 
-#define MAX_NOTE_BYTES 1024
-
 #define kexec_flush_icache_page(page) do { \
                 unsigned long page_addr = (unsigned long)page_address(page); \
                 flush_icache_range(page_addr, page_addr + PAGE_SIZE); \
Index: linux-2.6/include/linux/kexec.h
===================================================================
--- linux-2.6.orig/include/linux/kexec.h	2007-03-28 18:50:25.000000000 +0900
+++ linux-2.6/include/linux/kexec.h	2007-03-29 12:19:10.000000000 +0900
@@ -7,6 +7,8 @@
 #include <linux/linkage.h>
 #include <linux/compat.h>
 #include <linux/ioport.h>
+#include <linux/elfcore.h>
+#include <linux/elf.h>
 #include <asm/kexec.h>
 
 /* Verify architecture specific macros are defined */
@@ -31,6 +33,13 @@
 #error KEXEC_ARCH not defined
 #endif
 
+#define KEXEC_NOTE_NAME "CORE"
+#define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
+#define KEXEC_NOTE_NAME_BYTES ALIGN(strlen(KEXEC_NOTE_NAME) + 1, 4)
+#define KEXEC_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+#define KEXEC_NOTE_BYTES ( (KEXEC_NOTE_HEAD_BYTES * 2) + \
+			   KEXEC_NOTE_NAME_BYTES + KEXEC_NOTE_DESC_BYTES )
+
 /*
  * This structure is used to hold the arguments that are used when loading
  * kernel binaries.
@@ -136,7 +145,7 @@
 /* Location of a reserved region to hold the crash kernel.
  */
 extern struct resource crashk_res;
-typedef u32 note_buf_t[MAX_NOTE_BYTES/4];
+typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4];
 extern note_buf_t *crash_notes;
 
 
Index: linux-2.6/include/asm-arm/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-arm/kexec.h	2007-03-28 18:50:25.000000000 +0900
+++ linux-2.6/include/asm-arm/kexec.h	2007-03-29 12:19:10.000000000 +0900
@@ -16,8 +16,6 @@
 
 #ifndef __ASSEMBLY__
 
-#define MAX_NOTE_BYTES 1024
-
 struct kimage;
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
Index: linux-2.6/include/asm-i386/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-i386/kexec.h	2007-03-28 18:50:25.000000000 +0900
+++ linux-2.6/include/asm-i386/kexec.h	2007-03-29 12:19:10.000000000 +0900
@@ -47,8 +47,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_386
 
-#define MAX_NOTE_BYTES 1024
-
 /* CPU does not save ss and esp on stack if execution is already
  * running in kernel mode at the time of NMI occurrence. This code
  * fixes it.
Index: linux-2.6/include/asm-mips/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-mips/kexec.h	2007-03-28 18:50:25.000000000 +0900
+++ linux-2.6/include/asm-mips/kexec.h	2007-03-29 12:19:10.000000000 +0900
@@ -21,8 +21,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_MIPS
 
-#define MAX_NOTE_BYTES 1024
-
 static inline void crash_setup_regs(struct pt_regs *newregs,
 				    struct pt_regs *oldregs)
 {
Index: linux-2.6/include/asm-powerpc/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-powerpc/kexec.h	2007-03-28 18:50:25.000000000 +0900
+++ linux-2.6/include/asm-powerpc/kexec.h	2007-03-29 12:19:10.000000000 +0900
@@ -108,8 +108,6 @@
 					struct pt_regs *oldregs) { }
 #endif /* !__powerpc64 __ */
 
-#define MAX_NOTE_BYTES 1024
-
 extern void kexec_smp_wait(void);	/* get and clear naca physid, wait for
 					  master to copy new code to 0 */
 extern int crashing_cpu;
Index: linux-2.6/include/asm-s390/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-s390/kexec.h	2007-03-28 18:50:25.000000000 +0900
+++ linux-2.6/include/asm-s390/kexec.h	2007-03-29 12:19:10.000000000 +0900
@@ -34,8 +34,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_S390
 
-#define MAX_NOTE_BYTES 1024
-
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
 					struct pt_regs *oldregs) { }
Index: linux-2.6/include/asm-sh/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-sh/kexec.h	2007-03-28 18:50:25.000000000 +0900
+++ linux-2.6/include/asm-sh/kexec.h	2007-03-29 12:19:10.000000000 +0900
@@ -23,8 +23,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_SH
 
-#define MAX_NOTE_BYTES 1024
-
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
 					struct pt_regs *oldregs) { }
Index: linux-2.6/include/asm-x86_64/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-x86_64/kexec.h	2007-03-28 18:50:25.000000000 +0900
+++ linux-2.6/include/asm-x86_64/kexec.h	2007-03-29 12:19:10.000000000 +0900
@@ -48,8 +48,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_X86_64
 
-#define MAX_NOTE_BYTES 1024
-
 /*
  * Saving the registers of the cpu on which panic occured in
  * crash_kexec to save a valid sp. The registers of other cpus
Index: linux-2.6/arch/ia64/kernel/crash.c
===================================================================
--- linux-2.6.orig/arch/ia64/kernel/crash.c	2007-03-29 12:22:07.000000000 +0900
+++ linux-2.6/arch/ia64/kernel/crash.c	2007-03-29 12:22:24.000000000 +0900
@@ -74,7 +74,7 @@
 	buf = (u64 *) per_cpu_ptr(crash_notes, cpu);
 	if (!buf)
 		return;
-	buf = append_elf_note(buf, "CORE", NT_PRSTATUS, prstatus,
+	buf = append_elf_note(buf, KEXEC_NOTE_NAME, NT_PRSTATUS, prstatus,
 			sizeof(*prstatus));
 	final_note(buf);
 }
Index: linux-2.6/kernel/kexec.c
===================================================================
--- linux-2.6.orig/kernel/kexec.c	2007-03-29 12:22:07.000000000 +0900
+++ linux-2.6/kernel/kexec.c	2007-03-29 12:22:24.000000000 +0900
@@ -1118,7 +1118,7 @@
 	memset(&prstatus, 0, sizeof(prstatus));
 	prstatus.pr_pid = current->pid;
 	elf_core_copy_regs(&prstatus.pr_reg, regs);
-	buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
+	buf = append_elf_note(buf, KEXEC_NOTE_NAME, NT_PRSTATUS, &prstatus,
 				sizeof(prstatus));
 	final_note(buf);
 }

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] kdump/kexec: calculate note size at compile time
  2007-03-29  3:30       ` Simon Horman
@ 2007-03-29  3:44         ` Vivek Goyal
  2007-03-29  3:48           ` Simon Horman
  2007-03-30  0:41         ` Andrew Morton
  1 sibling, 1 reply; 12+ messages in thread
From: Vivek Goyal @ 2007-03-29  3:44 UTC (permalink / raw)
  To: Simon Horman; +Cc: fastboot, linux-kernel, Andrew Morton

On Thu, Mar 29, 2007 at 12:30:59PM +0900, Simon Horman wrote:
> Hi,
> 
> this is a(nother) minor update to this patch. 
> Explanation below.
> 
> -- 
> Horms
>   H: http://www.vergenet.net/~horms/
>   W: http://www.valinux.co.jp/en/
> 
> [PATCH] kdump/kexec: calculate note size at compile time
> 
> Currently the size of the per-cpu region reserved to save crash
> notes is set by the per-architecture value MAX_NOTE_BYTES. Which
> in turn is currently set to 1024 on all supported architectures.
> 
> While testing ia64 I recently discovered that this value is
> in fact too small. The particular setup I was using actually
> needs 1172 bytes. This lead to very tedious failure mode
> where the tail of one elf note would overwrite the head of
> another if they ended up being alocated sequentially by kmalloc,
> which was often the case.
> 
> It seems to me that a far better approach is to caclculate the size
> that the area needs to be. This patch does just that.
> 
> If a simpler stop-gap patch for ia64 to be squeezed into 2.6.21(.X)
> is needed then this should be as easy as making MAX_NOTE_BYTES
> larger in arch/asm-ia64/kexec.h. Perhaps 2048 would be a good choice.
> However, I think that the approach in this patch is a much more robust
> idea.
> 
> Update I:
> 
>   Changed KEXEC_NOTE_HEAD_BYTES to KEXEC_NOTE_DESC_BYTES in line
>   with the name of the relevant field in struct elf_note
> 
> Update II:
> 
>   * Use KEXEC_NOTE_NAME instead of "CORE" in kernel/kexec.c and
>     arch/ia64/kernel/crash.c just to be extra sure that the data
>     used to calculate the size, and the data stuffed into the reserved
>     area is the same.
> 
>     Incidently, the ia64 code really ought to use the generic code.
>     I am working on a patch for this. But it is not urgent.
> 

Looks good. Another patch to make ia64 also use generic kexec code
for note generation would be nice.

Thanks
Vivek

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] kdump/kexec: calculate note size at compile time
  2007-03-29  3:44         ` Vivek Goyal
@ 2007-03-29  3:48           ` Simon Horman
  0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2007-03-29  3:48 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: fastboot, linux-kernel, Andrew Morton

On Thu, Mar 29, 2007 at 09:14:21AM +0530, Vivek Goyal wrote:
> On Thu, Mar 29, 2007 at 12:30:59PM +0900, Simon Horman wrote:
> > Hi,
> > 
> > this is a(nother) minor update to this patch. 
> > Explanation below.
> > 
> > -- 
> > Horms
> >   H: http://www.vergenet.net/~horms/
> >   W: http://www.valinux.co.jp/en/
> > 
> > [PATCH] kdump/kexec: calculate note size at compile time
> > 
> > Currently the size of the per-cpu region reserved to save crash
> > notes is set by the per-architecture value MAX_NOTE_BYTES. Which
> > in turn is currently set to 1024 on all supported architectures.
> > 
> > While testing ia64 I recently discovered that this value is
> > in fact too small. The particular setup I was using actually
> > needs 1172 bytes. This lead to very tedious failure mode
> > where the tail of one elf note would overwrite the head of
> > another if they ended up being alocated sequentially by kmalloc,
> > which was often the case.
> > 
> > It seems to me that a far better approach is to caclculate the size
> > that the area needs to be. This patch does just that.
> > 
> > If a simpler stop-gap patch for ia64 to be squeezed into 2.6.21(.X)
> > is needed then this should be as easy as making MAX_NOTE_BYTES
> > larger in arch/asm-ia64/kexec.h. Perhaps 2048 would be a good choice.
> > However, I think that the approach in this patch is a much more robust
> > idea.
> > 
> > Update I:
> > 
> >   Changed KEXEC_NOTE_HEAD_BYTES to KEXEC_NOTE_DESC_BYTES in line
> >   with the name of the relevant field in struct elf_note
> > 
> > Update II:
> > 
> >   * Use KEXEC_NOTE_NAME instead of "CORE" in kernel/kexec.c and
> >     arch/ia64/kernel/crash.c just to be extra sure that the data
> >     used to calculate the size, and the data stuffed into the reserved
> >     area is the same.
> > 
> >     Incidently, the ia64 code really ought to use the generic code.
> >     I am working on a patch for this. But it is not urgent.
> > 
> 
> Looks good. Another patch to make ia64 also use generic kexec code
> for note generation would be nice.

Thanks, I will make it so :-)

-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] kdump/kexec: calculate note size at compile time
  2007-03-29  3:30       ` Simon Horman
  2007-03-29  3:44         ` Vivek Goyal
@ 2007-03-30  0:41         ` Andrew Morton
  2007-03-30  2:34           ` Simon Horman
  2007-04-02  4:48           ` Simon Horman
  1 sibling, 2 replies; 12+ messages in thread
From: Andrew Morton @ 2007-03-30  0:41 UTC (permalink / raw)
  To: Simon Horman; +Cc: Vivek Goyal, fastboot, linux-kernel

On Thu, 29 Mar 2007 12:30:59 +0900
Simon Horman <horms@verge.net.au> wrote:

> [PATCH] kdump/kexec: calculate note size at compile time

i386 allmodconfig, gcc-4.1.0:

In file included from init/initramfs.c:508:
include/linux/kexec.h:148: error: variable-size type declared outside of any function

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] kdump/kexec: calculate note size at compile time
  2007-03-30  0:41         ` Andrew Morton
@ 2007-03-30  2:34           ` Simon Horman
  2007-04-02  4:48           ` Simon Horman
  1 sibling, 0 replies; 12+ messages in thread
From: Simon Horman @ 2007-03-30  2:34 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Vivek Goyal, fastboot, linux-kernel

On Thu, Mar 29, 2007 at 05:41:45PM -0700, Andrew Morton wrote:
> On Thu, 29 Mar 2007 12:30:59 +0900
> Simon Horman <horms@verge.net.au> wrote:
> 
> > [PATCH] kdump/kexec: calculate note size at compile time
> 
> i386 allmodconfig, gcc-4.1.0:
> 
> In file included from init/initramfs.c:508:
> include/linux/kexec.h:148: error: variable-size type declared outside of any function

Thanks, I will look into this.

-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] kdump/kexec: calculate note size at compile time
  2007-03-30  0:41         ` Andrew Morton
  2007-03-30  2:34           ` Simon Horman
@ 2007-04-02  4:48           ` Simon Horman
  2007-04-02 10:10             ` Simon Horman
  1 sibling, 1 reply; 12+ messages in thread
From: Simon Horman @ 2007-04-02  4:48 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Vivek Goyal, fastboot, linux-kernel

On Thu, Mar 29, 2007 at 05:41:45PM -0700, Andrew Morton wrote:
> On Thu, 29 Mar 2007 12:30:59 +0900
> Simon Horman <horms@verge.net.au> wrote:
> 
> > [PATCH] kdump/kexec: calculate note size at compile time
> 
> i386 allmodconfig, gcc-4.1.0:
> 
> In file included from init/initramfs.c:508:
> include/linux/kexec.h:148: error: variable-size type declared outside of any function

Hi,

this problem appears to be caused by the use of strlen() inside the
definition of KEXEC_NOTE_NAME_BYTES. I have removed this and the patch
now compiles cleanly using gcc 4.1.2 on i386 allmodconfig, which
previously gave the same error as above.

-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/

[PATCH] kdump/kexec: calculate note size at compile time

Currently the size of the per-cpu region reserved to save crash
notes is set by the per-architecture value MAX_NOTE_BYTES. Which
in turn is currently set to 1024 on all supported architectures.

While testing ia64 I recently discovered that this value is
in fact too small. The particular setup I was using actually
needs 1172 bytes. This lead to very tedious failure mode
where the tail of one elf note would overwrite the head of
another if they ended up being alocated sequentially by kmalloc,
which was often the case.

It seems to me that a far better approach is to caclculate the size
that the area needs to be. This patch does just that.

If a simpler stop-gap patch for ia64 to be squeezed into 2.6.21(.X)
is needed then this should be as easy as making MAX_NOTE_BYTES
larger in arch/asm-ia64/kexec.h. Perhaps 2048 would be a good choice.
However, I think that the approach in this patch is a much more robust
idea.

Acked-by:  Vivek Goyal <vgoyal@in.ibm.com>
Signed-off-by: Simon Horman <horms@verge.net.au>

 include/asm-arm/kexec.h     |    2 --
 include/asm-i386/kexec.h    |    2 --
 include/asm-ia64/kexec.h    |    2 --
 include/asm-mips/kexec.h    |    2 --
 include/asm-powerpc/kexec.h |    2 --
 include/asm-s390/kexec.h    |    2 --
 include/asm-sh/kexec.h      |    2 --
 include/asm-x86_64/kexec.h  |    2 --
 include/linux/kexec.h       |   10 +++++++++-
 9 files changed, 9 insertions(+), 17 deletions(-)
Index: linux-2.6/include/asm-ia64/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-ia64/kexec.h	2007-04-02 11:56:00.000000000 +0900
+++ linux-2.6/include/asm-ia64/kexec.h	2007-04-02 13:21:15.000000000 +0900
@@ -14,8 +14,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_IA_64
 
-#define MAX_NOTE_BYTES 1024
-
 #define kexec_flush_icache_page(page) do { \
                 unsigned long page_addr = (unsigned long)page_address(page); \
                 flush_icache_range(page_addr, page_addr + PAGE_SIZE); \
Index: linux-2.6/include/linux/kexec.h
===================================================================
--- linux-2.6.orig/include/linux/kexec.h	2007-04-02 11:56:00.000000000 +0900
+++ linux-2.6/include/linux/kexec.h	2007-04-02 13:45:31.000000000 +0900
@@ -7,6 +7,8 @@
 #include <linux/linkage.h>
 #include <linux/compat.h>
 #include <linux/ioport.h>
+#include <linux/elfcore.h>
+#include <linux/elf.h>
 #include <asm/kexec.h>
 
 /* Verify architecture specific macros are defined */
@@ -31,6 +33,12 @@
 #error KEXEC_ARCH not defined
 #endif
 
+#define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
+#define KEXEC_NOTE_NAME_BYTES 8 /* ALIGN(strlen("CORE") + 1, 4) */
+#define KEXEC_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+#define KEXEC_NOTE_BYTES ( (KEXEC_NOTE_HEAD_BYTES * 2) + \
+			   KEXEC_NOTE_NAME_BYTES + KEXEC_NOTE_DESC_BYTES )
+
 /*
  * This structure is used to hold the arguments that are used when loading
  * kernel binaries.
@@ -136,7 +144,7 @@
 /* Location of a reserved region to hold the crash kernel.
  */
 extern struct resource crashk_res;
-typedef u32 note_buf_t[MAX_NOTE_BYTES/4];
+typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4];
 extern note_buf_t *crash_notes;
 
 
Index: linux-2.6/include/asm-arm/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-arm/kexec.h	2007-04-02 11:56:00.000000000 +0900
+++ linux-2.6/include/asm-arm/kexec.h	2007-04-02 13:21:15.000000000 +0900
@@ -16,8 +16,6 @@
 
 #ifndef __ASSEMBLY__
 
-#define MAX_NOTE_BYTES 1024
-
 struct kimage;
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
Index: linux-2.6/include/asm-i386/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-i386/kexec.h	2007-04-02 11:56:00.000000000 +0900
+++ linux-2.6/include/asm-i386/kexec.h	2007-04-02 13:21:15.000000000 +0900
@@ -47,8 +47,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_386
 
-#define MAX_NOTE_BYTES 1024
-
 /* CPU does not save ss and esp on stack if execution is already
  * running in kernel mode at the time of NMI occurrence. This code
  * fixes it.
Index: linux-2.6/include/asm-mips/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-mips/kexec.h	2007-04-02 11:56:00.000000000 +0900
+++ linux-2.6/include/asm-mips/kexec.h	2007-04-02 13:21:15.000000000 +0900
@@ -21,8 +21,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_MIPS
 
-#define MAX_NOTE_BYTES 1024
-
 static inline void crash_setup_regs(struct pt_regs *newregs,
 				    struct pt_regs *oldregs)
 {
Index: linux-2.6/include/asm-powerpc/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-powerpc/kexec.h	2007-04-02 11:56:00.000000000 +0900
+++ linux-2.6/include/asm-powerpc/kexec.h	2007-04-02 13:21:15.000000000 +0900
@@ -108,8 +108,6 @@
 					struct pt_regs *oldregs) { }
 #endif /* !__powerpc64 __ */
 
-#define MAX_NOTE_BYTES 1024
-
 extern void kexec_smp_wait(void);	/* get and clear naca physid, wait for
 					  master to copy new code to 0 */
 extern int crashing_cpu;
Index: linux-2.6/include/asm-s390/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-s390/kexec.h	2007-04-02 11:56:00.000000000 +0900
+++ linux-2.6/include/asm-s390/kexec.h	2007-04-02 13:21:15.000000000 +0900
@@ -34,8 +34,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_S390
 
-#define MAX_NOTE_BYTES 1024
-
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
 					struct pt_regs *oldregs) { }
Index: linux-2.6/include/asm-sh/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-sh/kexec.h	2007-04-02 11:56:00.000000000 +0900
+++ linux-2.6/include/asm-sh/kexec.h	2007-04-02 13:21:15.000000000 +0900
@@ -23,8 +23,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_SH
 
-#define MAX_NOTE_BYTES 1024
-
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
 					struct pt_regs *oldregs) { }
Index: linux-2.6/include/asm-x86_64/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-x86_64/kexec.h	2007-04-02 11:56:00.000000000 +0900
+++ linux-2.6/include/asm-x86_64/kexec.h	2007-04-02 13:21:15.000000000 +0900
@@ -48,8 +48,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_X86_64
 
-#define MAX_NOTE_BYTES 1024
-
 /*
  * Saving the registers of the cpu on which panic occured in
  * crash_kexec to save a valid sp. The registers of other cpus

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] kdump/kexec: calculate note size at compile time
  2007-04-02  4:48           ` Simon Horman
@ 2007-04-02 10:10             ` Simon Horman
  0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2007-04-02 10:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Vivek Goyal, fastboot, linux-kernel, Milton Miller

On Mon, Apr 02, 2007 at 01:48:48PM +0900, Simon Horman wrote:
> On Thu, Mar 29, 2007 at 05:41:45PM -0700, Andrew Morton wrote:
> > On Thu, 29 Mar 2007 12:30:59 +0900
> > Simon Horman <horms@verge.net.au> wrote:
> > 
> > > [PATCH] kdump/kexec: calculate note size at compile time
> > 
> > i386 allmodconfig, gcc-4.1.0:
> > 
> > In file included from init/initramfs.c:508:
> > include/linux/kexec.h:148: error: variable-size type declared outside of any function
> 
> Hi,
> 
> this problem appears to be caused by the use of strlen() inside the
> definition of KEXEC_NOTE_NAME_BYTES. I have removed this and the patch
> now compiles cleanly using gcc 4.1.2 on i386 allmodconfig, which
> previously gave the same error as above.

Hi,

Here is a further update to this patch which uses
sizeof(KEXEC_NOTE_NAME_BYTES) as suggested by Milton Miller.
It also adds a comment describing why space for two struct elf_note
is needed, as that question has come up a few times.

-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/


[PATCH] kdump/kexec: calculate note size at compile time

Currently the size of the per-cpu region reserved to save crash
notes is set by the per-architecture value MAX_NOTE_BYTES. Which
in turn is currently set to 1024 on all supported architectures.

While testing ia64 I recently discovered that this value is
in fact too small. The particular setup I was using actually
needs 1172 bytes. This lead to very tedious failure mode
where the tail of one elf note would overwrite the head of
another if they ended up being alocated sequentially by kmalloc,
which was often the case.

It seems to me that a far better approach is to caclculate the size
that the area needs to be. This patch does just that.

If a simpler stop-gap patch for ia64 to be squeezed into 2.6.21(.X)
is needed then this should be as easy as making MAX_NOTE_BYTES
larger in arch/asm-ia64/kexec.h. Perhaps 2048 would be a good choice.
However, I think that the approach in this patch is a much more robust
idea.

Acked-by:  Vivek Goyal <vgoyal@in.ibm.com>
Signed-off-by: Simon Horman <horms@verge.net.au>

 include/asm-arm/kexec.h     |    2 --
 include/asm-i386/kexec.h    |    2 --
 include/asm-ia64/kexec.h    |    2 --
 include/asm-mips/kexec.h    |    2 --
 include/asm-powerpc/kexec.h |    2 --
 include/asm-s390/kexec.h    |    2 --
 include/asm-sh/kexec.h      |    2 --
 include/asm-x86_64/kexec.h  |    2 --
 include/linux/kexec.h       |   10 +++++++++-
 9 files changed, 9 insertions(+), 17 deletions(-)
Index: linux-2.6/include/asm-ia64/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-ia64/kexec.h	2007-04-02 14:53:00.000000000 +0900
+++ linux-2.6/include/asm-ia64/kexec.h	2007-04-02 14:53:07.000000000 +0900
@@ -14,8 +14,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_IA_64
 
-#define MAX_NOTE_BYTES 1024
-
 #define kexec_flush_icache_page(page) do { \
                 unsigned long page_addr = (unsigned long)page_address(page); \
                 flush_icache_range(page_addr, page_addr + PAGE_SIZE); \
Index: linux-2.6/include/linux/kexec.h
===================================================================
--- linux-2.6.orig/include/linux/kexec.h	2007-04-02 14:53:00.000000000 +0900
+++ linux-2.6/include/linux/kexec.h	2007-04-02 17:17:08.000000000 +0900
@@ -7,6 +7,8 @@
 #include <linux/linkage.h>
 #include <linux/compat.h>
 #include <linux/ioport.h>
+#include <linux/elfcore.h>
+#include <linux/elf.h>
 #include <asm/kexec.h>
 
 /* Verify architecture specific macros are defined */
@@ -31,6 +33,18 @@
 #error KEXEC_ARCH not defined
 #endif
 
+#define KEXEC_NOTE_NAME "CORE"
+#define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
+#define KEXEC_NOTE_NAME_BYTES ALIGN(sizeof("CORE"), 4) /* N.B: Includes '\0' */
+#define KEXEC_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+/* The notes are read and combined by the code in vmcore.c running
+ * in the second-kernel after kdump is performed. This code
+ * expects the notes area to be a list of notes, terminated
+ * by a "NULL" note header. The "* 2" below is to provide space
+ * for the terminating note header */
+#define KEXEC_NOTE_BYTES ( (KEXEC_NOTE_HEAD_BYTES * 2) + \
+			   KEXEC_NOTE_NAME_BYTES + KEXEC_NOTE_DESC_BYTES )
+
 /*
  * This structure is used to hold the arguments that are used when loading
  * kernel binaries.
@@ -136,7 +150,7 @@
 /* Location of a reserved region to hold the crash kernel.
  */
 extern struct resource crashk_res;
-typedef u32 note_buf_t[MAX_NOTE_BYTES/4];
+typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4];
 extern note_buf_t *crash_notes;
 
 
Index: linux-2.6/include/asm-arm/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-arm/kexec.h	2007-04-02 14:53:00.000000000 +0900
+++ linux-2.6/include/asm-arm/kexec.h	2007-04-02 14:53:07.000000000 +0900
@@ -16,8 +16,6 @@
 
 #ifndef __ASSEMBLY__
 
-#define MAX_NOTE_BYTES 1024
-
 struct kimage;
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
Index: linux-2.6/include/asm-i386/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-i386/kexec.h	2007-04-02 14:53:00.000000000 +0900
+++ linux-2.6/include/asm-i386/kexec.h	2007-04-02 14:53:07.000000000 +0900
@@ -47,8 +47,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_386
 
-#define MAX_NOTE_BYTES 1024
-
 /* CPU does not save ss and esp on stack if execution is already
  * running in kernel mode at the time of NMI occurrence. This code
  * fixes it.
Index: linux-2.6/include/asm-mips/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-mips/kexec.h	2007-04-02 14:53:00.000000000 +0900
+++ linux-2.6/include/asm-mips/kexec.h	2007-04-02 14:53:07.000000000 +0900
@@ -21,8 +21,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_MIPS
 
-#define MAX_NOTE_BYTES 1024
-
 static inline void crash_setup_regs(struct pt_regs *newregs,
 				    struct pt_regs *oldregs)
 {
Index: linux-2.6/include/asm-powerpc/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-powerpc/kexec.h	2007-04-02 14:53:00.000000000 +0900
+++ linux-2.6/include/asm-powerpc/kexec.h	2007-04-02 14:53:07.000000000 +0900
@@ -108,8 +108,6 @@
 					struct pt_regs *oldregs) { }
 #endif /* !__powerpc64 __ */
 
-#define MAX_NOTE_BYTES 1024
-
 extern void kexec_smp_wait(void);	/* get and clear naca physid, wait for
 					  master to copy new code to 0 */
 extern int crashing_cpu;
Index: linux-2.6/include/asm-s390/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-s390/kexec.h	2007-04-02 14:53:00.000000000 +0900
+++ linux-2.6/include/asm-s390/kexec.h	2007-04-02 14:53:07.000000000 +0900
@@ -34,8 +34,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_S390
 
-#define MAX_NOTE_BYTES 1024
-
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
 					struct pt_regs *oldregs) { }
Index: linux-2.6/include/asm-sh/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-sh/kexec.h	2007-04-02 14:53:00.000000000 +0900
+++ linux-2.6/include/asm-sh/kexec.h	2007-04-02 14:53:07.000000000 +0900
@@ -23,8 +23,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_SH
 
-#define MAX_NOTE_BYTES 1024
-
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
 					struct pt_regs *oldregs) { }
Index: linux-2.6/include/asm-x86_64/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-x86_64/kexec.h	2007-04-02 14:53:00.000000000 +0900
+++ linux-2.6/include/asm-x86_64/kexec.h	2007-04-02 14:53:07.000000000 +0900
@@ -48,8 +48,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_X86_64
 
-#define MAX_NOTE_BYTES 1024
-
 /*
  * Saving the registers of the cpu on which panic occured in
  * crash_kexec to save a valid sp. The registers of other cpus
Index: linux-2.6/arch/ia64/kernel/crash.c
===================================================================
--- linux-2.6.orig/arch/ia64/kernel/crash.c	2007-04-02 17:05:52.000000000 +0900
+++ linux-2.6/arch/ia64/kernel/crash.c	2007-04-02 17:05:58.000000000 +0900
@@ -74,7 +74,7 @@
 	buf = (u64 *) per_cpu_ptr(crash_notes, cpu);
 	if (!buf)
 		return;
-	buf = append_elf_note(buf, "CORE", NT_PRSTATUS, prstatus,
+	buf = append_elf_note(buf, KEXEC_NOTE_NAME, NT_PRSTATUS, prstatus,
 			sizeof(*prstatus));
 	final_note(buf);
 }
Index: linux-2.6/kernel/kexec.c
===================================================================
--- linux-2.6.orig/kernel/kexec.c	2007-04-02 17:05:26.000000000 +0900
+++ linux-2.6/kernel/kexec.c	2007-04-02 17:05:40.000000000 +0900
@@ -1118,7 +1118,7 @@
 	memset(&prstatus, 0, sizeof(prstatus));
 	prstatus.pr_pid = current->pid;
 	elf_core_copy_regs(&prstatus.pr_reg, regs);
-	buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
+	buf = append_elf_note(buf, KEXEC_NOTE_NAME, NT_PRSTATUS, &prstatus,
 				sizeof(prstatus));
 	final_note(buf);
 }


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] kdump/kexec: calculate note size at compile time
@ 2007-04-03  9:37 Simon Horman
  0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2007-04-03  9:37 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Vivek Goyal, fastboot, linux-kernel, Milton Miller

[PATCH] kdump/kexec: calculate note size at compile time

Currently the size of the per-cpu region reserved to save crash
notes is set by the per-architecture value MAX_NOTE_BYTES. Which
in turn is currently set to 1024 on all supported architectures.

While testing ia64 I recently discovered that this value is
in fact too small. The particular setup I was using actually
needs 1172 bytes. This lead to very tedious failure mode
where the tail of one elf note would overwrite the head of
another if they ended up being alocated sequentially by kmalloc,
which was often the case.

It seems to me that a far better approach is to caclculate the size
that the area needs to be. This patch does just that.

If a simpler stop-gap patch for ia64 to be squeezed into 2.6.21(.X)
is needed then this should be as easy as making MAX_NOTE_BYTES
larger in arch/asm-ia64/kexec.h. Perhaps 2048 would be a good choice.
However, I think that the approach in this patch is a much more robust
idea.

Signed-off-by: Simon Horman <horms@verge.net.au>
Acked-by:  Vivek Goyal <vgoyal@in.ibm.com>
--- 

 As suggested by Milton Miller

 * Changed KEXEC_NOTE_NAME_BYTES to KEXEC_CORE_NOTE_NAME_BYTES and
   KEXEC_NOTE_DESC_BYTES to KEXEC_CORE_NOTE_DESC_BYTES to avoid
   a possible name-clash if additional notes are added in the future.

 * Use KEXEC_CORE_NOTE_NAME in the definition of KEXEC_CORE_NOTE_NAME_BYTES

 * Clean up comment about the notes area being a lit of notes

 arch/ia64/kernel/crash.c    |    2 +-
 include/asm-arm/kexec.h     |    2 --
 include/asm-i386/kexec.h    |    2 --
 include/asm-ia64/kexec.h    |    2 --
 include/asm-mips/kexec.h    |    2 --
 include/asm-powerpc/kexec.h |    2 --
 include/asm-s390/kexec.h    |    2 --
 include/asm-sh/kexec.h      |    2 --
 include/asm-x86_64/kexec.h  |    2 --
 include/linux/kexec.h       |   17 ++++++++++++++++-
 kernel/kexec.c              |    4 ++--
 11 files changed, 19 insertions(+), 20 deletions(-)
Index: linux-2.6/include/asm-ia64/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-ia64/kexec.h	2007-04-02 21:50:46.000000000 +0900
+++ linux-2.6/include/asm-ia64/kexec.h	2007-04-03 18:14:39.000000000 +0900
@@ -14,8 +14,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_IA_64
 
-#define MAX_NOTE_BYTES 1024
-
 #define kexec_flush_icache_page(page) do { \
                 unsigned long page_addr = (unsigned long)page_address(page); \
                 flush_icache_range(page_addr, page_addr + PAGE_SIZE); \
Index: linux-2.6/include/linux/kexec.h
===================================================================
--- linux-2.6.orig/include/linux/kexec.h	2007-04-02 21:50:46.000000000 +0900
+++ linux-2.6/include/linux/kexec.h	2007-04-03 18:19:03.000000000 +0900
@@ -7,6 +7,8 @@
 #include <linux/linkage.h>
 #include <linux/compat.h>
 #include <linux/ioport.h>
+#include <linux/elfcore.h>
+#include <linux/elf.h>
 #include <asm/kexec.h>
 
 /* Verify architecture specific macros are defined */
@@ -31,6 +33,19 @@
 #error KEXEC_ARCH not defined
 #endif
 
+#define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
+#define KEXEC_CORE_NOTE_NAME "CORE"
+#define KEXEC_CORE_NOTE_NAME_BYTES ALIGN(sizeof(KEXEC_CORE_NOTE_NAME), 4)
+#define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+/*
+ * The per-cpu notes area is a list of notes terminated by a "NULL"
+ * note header.  For kdump, the code in vmcore.c runs in the context
+ * of the second kernel to combine them into one note.
+ */
+#define KEXEC_NOTE_BYTES ( (KEXEC_NOTE_HEAD_BYTES * 2) +		\
+			    KEXEC_CORE_NOTE_NAME_BYTES +		\
+			    KEXEC_CORE_NOTE_DESC_BYTES )
+
 /*
  * This structure is used to hold the arguments that are used when loading
  * kernel binaries.
@@ -136,7 +151,7 @@
 /* Location of a reserved region to hold the crash kernel.
  */
 extern struct resource crashk_res;
-typedef u32 note_buf_t[MAX_NOTE_BYTES/4];
+typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4];
 extern note_buf_t *crash_notes;
 
 
Index: linux-2.6/include/asm-arm/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-arm/kexec.h	2007-04-02 21:50:46.000000000 +0900
+++ linux-2.6/include/asm-arm/kexec.h	2007-04-03 18:14:39.000000000 +0900
@@ -16,8 +16,6 @@
 
 #ifndef __ASSEMBLY__
 
-#define MAX_NOTE_BYTES 1024
-
 struct kimage;
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
Index: linux-2.6/include/asm-i386/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-i386/kexec.h	2007-04-02 21:50:46.000000000 +0900
+++ linux-2.6/include/asm-i386/kexec.h	2007-04-03 18:14:39.000000000 +0900
@@ -47,8 +47,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_386
 
-#define MAX_NOTE_BYTES 1024
-
 /* CPU does not save ss and esp on stack if execution is already
  * running in kernel mode at the time of NMI occurrence. This code
  * fixes it.
Index: linux-2.6/include/asm-mips/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-mips/kexec.h	2007-04-02 21:50:46.000000000 +0900
+++ linux-2.6/include/asm-mips/kexec.h	2007-04-03 18:14:39.000000000 +0900
@@ -21,8 +21,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_MIPS
 
-#define MAX_NOTE_BYTES 1024
-
 static inline void crash_setup_regs(struct pt_regs *newregs,
 				    struct pt_regs *oldregs)
 {
Index: linux-2.6/include/asm-powerpc/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-powerpc/kexec.h	2007-04-02 21:50:46.000000000 +0900
+++ linux-2.6/include/asm-powerpc/kexec.h	2007-04-03 18:14:39.000000000 +0900
@@ -108,8 +108,6 @@
 					struct pt_regs *oldregs) { }
 #endif /* !__powerpc64 __ */
 
-#define MAX_NOTE_BYTES 1024
-
 extern void kexec_smp_wait(void);	/* get and clear naca physid, wait for
 					  master to copy new code to 0 */
 extern int crashing_cpu;
Index: linux-2.6/include/asm-s390/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-s390/kexec.h	2007-04-02 21:50:46.000000000 +0900
+++ linux-2.6/include/asm-s390/kexec.h	2007-04-03 18:14:39.000000000 +0900
@@ -34,8 +34,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_S390
 
-#define MAX_NOTE_BYTES 1024
-
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
 					struct pt_regs *oldregs) { }
Index: linux-2.6/include/asm-sh/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-sh/kexec.h	2007-04-02 21:50:46.000000000 +0900
+++ linux-2.6/include/asm-sh/kexec.h	2007-04-03 18:14:39.000000000 +0900
@@ -23,8 +23,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_SH
 
-#define MAX_NOTE_BYTES 1024
-
 /* Provide a dummy definition to avoid build failures. */
 static inline void crash_setup_regs(struct pt_regs *newregs,
 					struct pt_regs *oldregs) { }
Index: linux-2.6/include/asm-x86_64/kexec.h
===================================================================
--- linux-2.6.orig/include/asm-x86_64/kexec.h	2007-04-02 21:50:46.000000000 +0900
+++ linux-2.6/include/asm-x86_64/kexec.h	2007-04-03 18:14:39.000000000 +0900
@@ -48,8 +48,6 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_X86_64
 
-#define MAX_NOTE_BYTES 1024
-
 /*
  * Saving the registers of the cpu on which panic occured in
  * crash_kexec to save a valid sp. The registers of other cpus
Index: linux-2.6/arch/ia64/kernel/crash.c
===================================================================
--- linux-2.6.orig/arch/ia64/kernel/crash.c	2007-04-02 21:50:46.000000000 +0900
+++ linux-2.6/arch/ia64/kernel/crash.c	2007-04-03 18:19:36.000000000 +0900
@@ -74,7 +74,7 @@
 	buf = (u64 *) per_cpu_ptr(crash_notes, cpu);
 	if (!buf)
 		return;
-	buf = append_elf_note(buf, "CORE", NT_PRSTATUS, prstatus,
+	buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_PRSTATUS, prstatus,
 			sizeof(*prstatus));
 	final_note(buf);
 }
Index: linux-2.6/kernel/kexec.c
===================================================================
--- linux-2.6.orig/kernel/kexec.c	2007-04-02 21:50:46.000000000 +0900
+++ linux-2.6/kernel/kexec.c	2007-04-03 18:20:36.000000000 +0900
@@ -1118,8 +1118,8 @@
 	memset(&prstatus, 0, sizeof(prstatus));
 	prstatus.pr_pid = current->pid;
 	elf_core_copy_regs(&prstatus.pr_reg, regs);
-	buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
-				sizeof(prstatus));
+	buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_PRSTATUS,
+		      	      &prstatus, sizeof(prstatus));
 	final_note(buf);
 }
 

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2007-04-03  9:38 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-28  6:18 [PATCH] kdump/kexec: calculate note size at compile time Simon Horman
2007-03-28  6:43 ` Vivek Goyal
2007-03-28  7:13   ` Horms
2007-03-28  8:08     ` Vivek Goyal
2007-03-29  3:30       ` Simon Horman
2007-03-29  3:44         ` Vivek Goyal
2007-03-29  3:48           ` Simon Horman
2007-03-30  0:41         ` Andrew Morton
2007-03-30  2:34           ` Simon Horman
2007-04-02  4:48           ` Simon Horman
2007-04-02 10:10             ` Simon Horman
2007-04-03  9:37 Simon Horman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.