M. Mohan Kumar | 2 Jan 2009 15:08
Picon

[PATCH] ppc64: Support for relocatable kernel in kexec-tools

Support for relocatable kernel in kexec-tools

This patch is based on the  patch sent by Milton Miller with the subject [PATCH 1/2
 kexec-tools] ppc64: new relocatble kernel activation ABI

http://patchwork.ozlabs.org/patch/5378/

Even with the above patch, the relocatable kernel always move to physical
address 0 (ie PHYSICAL_START). Following patch fixes this problem by marking
a local variable to 1 in purgatory during kdump kernel load time (kexec -p).
After a crash, purgatory sets __run_at_load variable location in the kernel
to 1 if the local variable is set to 1. So that the kernel will be running
as a relocatable kernel.

Signed-off-by: M. Mohan Kumar <mohan@...>
Signed-off-by: Milton Miller <miltonm@...>
---
 kexec/arch/ppc64/crashdump-ppc64.h |    2 ++
 kexec/arch/ppc64/kexec-elf-ppc64.c |   17 +++++++++++++++++
 purgatory/arch/ppc64/v2wrap.S      |   25 ++++++++++++-------------
 3 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/kexec/arch/ppc64/crashdump-ppc64.h b/kexec/arch/ppc64/crashdump-ppc64.h
index 9608782..be02213 100644
--- a/kexec/arch/ppc64/crashdump-ppc64.h
+++ b/kexec/arch/ppc64/crashdump-ppc64.h
 <at>  <at>  -23,6 +23,8  <at>  <at>  void add_usable_mem_rgns(unsigned long long base, unsigned long long size);
 #define _ALIGN_UP(addr,size)	(((addr)+((size)-1))&(~((size)-1)))
 #define _ALIGN_DOWN(addr,size)	((addr)&(~((size)-1)))

(Continue reading)

Milton Miller | 2 Jan 2009 19:39
Favicon

Re: [PATCH] ppc64: Support for relocatable kernel in kexec-tools


On Jan 2, 2009, at 8:08 AM, M. Mohan Kumar wrote:

> Support for relocatable kernel in kexec-tools
>
> This patch is based on the  patch sent by Milton Miller with the 
> subject [PATCH 1/2
>  kexec-tools] ppc64: new relocatble kernel activation ABI
>
> http://patchwork.ozlabs.org/patch/5378/
>
> Even with the above patch, the relocatable kernel always move to 
> physical
> address 0 (ie PHYSICAL_START). Following patch fixes this problem by 
> marking
> a local variable to 1 in purgatory during kdump kernel load time 
> (kexec -p).
> After a crash, purgatory sets __run_at_load variable location in the 
> kernel
> to 1 if the local variable is set to 1. So that the kernel will be 
> running
> as a relocatable kernel.
>
> Signed-off-by: M. Mohan Kumar <mohan@...>
> Signed-off-by: Milton Miller <miltonm@...>

your sign-off should have been after mine as you were making changes to 
my patch.

I actually completed my own testing last night with a slightly 
(Continue reading)

Milton Miller | 2 Jan 2009 21:42
Favicon

[PATCH 0/5 + 2] kexec updates

Follwing this mail are 5 patches for kexec userspace and two for the
kernel.  The first fixes an array overflow and the second updates
userspace to the merged 2.6.28 kdump support.  The remaining are
cleanups and warning fixes, including one for the common code.

The two patchs for the kernel are independent.

milton
Milton Miller | 2 Jan 2009 21:42
Favicon

[PATCH 0/5 + 2] kexec updates

Follwing this mail are 5 patches for kexec userspace and two for the
kernel.  The first fixes an array overflow and the second updates
userspace to the merged 2.6.28 kdump support.  The remaining are
cleanups and warning fixes, including one for the common code.

The two patchs for the kernel are independent.

milton
Milton Miller | 2 Jan 2009 21:44
Favicon

(unknown)

Subject [PATCH kexec-tools 1/5] ppc64: always check number of ranges when adding
Date: Fri, 02 Jan 2009 14:43:49 -0600
Subject: (No subject header)
X-Originating-IP: 205.232.218.102

make the idom "always call realloc_memory_ranges when filling a range entry"

kexec was core dumping after using 5 exclude_range pairs when only 3
were allocated.

also delcare realloc_memory_ranges to take no arguments.

Signed-off-by: Milton Miller <miltonm <at> bga.com>

Index: kexec-tools/kexec/arch/ppc64/kexec-ppc64.c
===================================================================
--- kexec-tools.orig/kexec/arch/ppc64/kexec-ppc64.c	2009-01-02 02:08:58.000000000 -0600
+++ kexec-tools/kexec/arch/ppc64/kexec-ppc64.c	2009-01-02 02:09:08.000000000 -0600
 <at>  <at>  -96,7 +96,7  <at>  <at>  err1:

 }

-static int realloc_memory_ranges()
+static int realloc_memory_ranges(void)
 {
 	size_t memory_range_len;

 <at>  <at>  -469,6 +469,8  <at>  <at>  static int get_devtree_details(unsigned 
 				exclude_range[i].start = initrd_start;
 				exclude_range[i].end = initrd_end;
(Continue reading)

Milton Miller | 2 Jan 2009 21:44
Favicon

(unknown)

Subject [PATCH kexec-tools 2/5] ppc64: update kdump for 2.6.28 relocatable kernel
Date: Fri, 02 Jan 2009 14:44:01 -0600
Subject: (No subject header)
X-Originating-IP: 205.232.218.102

The kernel updated its ABI to tell the relocatable kernel to run
where it was loaded.

We now need to set a flag in the kernel image.  Since we only have
the kernel image avialable as const data to kexec-tools c code, set
the flag in the copy we put in purgatory, and have it set the flag
in the kernel (after purgatory has run its checksum).  To simplfy
the purgatory code we can always copy the flag word back to the
kernel as the c code made a copy of the original flag value.

Signed-off-by: Milton Miller <miltonm <at> bga.com>
---
v3: 
purgatory now copies the flag to the kernel master entrypoint instead of
the kernel reading the value copied to 0 with the slave spinloop.

rename the local varable to my_run_at_load to be more consistent, and
change its type to uint32_t from unsigned int

Index: kexec-tools/purgatory/arch/ppc64/v2wrap.S
===================================================================
--- kexec-tools.orig/purgatory/arch/ppc64/v2wrap.S	2009-01-01 21:46:15.000000000 -0600
+++ kexec-tools/purgatory/arch/ppc64/v2wrap.S	2009-01-01 22:01:10.000000000 -0600
 <at>  <at>  -45,11 +45,14  <at>  <at> 
 	oris    rn,rn,name## <at> h;         \
(Continue reading)

Milton Miller | 2 Jan 2009 21:44
Favicon

(unknown)

Subject [PATCH kexec-tools 3/5] ppc64: segments may be reordered
Date: Fri, 02 Jan 2009 14:44:13 -0600
Subject: (No subject header)
X-Originating-IP: 205.232.218.102

Instead of fetching data from the segment array, remember the address
when added and find the kernel text from the parsed elf header.

While add_segment (and hence add_buffer) always adds to the end of
the list of segments, it sorts the previous segments before each
allocation.  In some layouts, the device tree or initrd will fit
in a hole below the the kernel.   When that happens, the previus
code mis-patches purgatory and the kexec fails.

Signed-off-by: Milton Miller <miltonm <at> bga.com>
---

The only safe reference is to info->segments[info->nr_segments]

 kexec/arch/ppc64/kexec-elf-ppc64.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

Index: kexec-tools/kexec/arch/ppc64/kexec-elf-ppc64.c
===================================================================
--- kexec-tools.orig/kexec/arch/ppc64/kexec-elf-ppc64.c	2009-01-01 21:46:24.000000000 -0600
+++ kexec-tools/kexec/arch/ppc64/kexec-elf-ppc64.c	2009-01-02 01:48:28.000000000 -0600
 <at>  <at>  -86,7 +86,7  <at>  <at>  int elf_ppc64_load(int argc, char **argv
 	size_t size;
 	uint64_t *rsvmap_ptr;
 	struct bootblock *bb_ptr;
(Continue reading)

Milton Miller | 2 Jan 2009 21:44
Favicon

(unknown)

Subject [PATCH kexec-tools 4/5] ppc64: cleanups
Date: Fri, 02 Jan 2009 14:44:26 -0600
Subject: (No subject header)
X-Originating-IP: 205.232.218.102

don't copy purgatory, as elf-load-rel does that for us (like x86_64).

move function declarations from c to h files

remove casts between void  * and various pointers

change some pointers between char and unsigned char *

change args to be vars of the right type instead of casting or
copying between types

Signed-off-by: Milton Miller <miltonm <at> bga.com>
---
we still need to cast purgatory or we get a signed-ness warning on the pointer

Index: kexec-tools/kexec/arch/ppc64/fs2dt.c
===================================================================
--- kexec-tools.orig/kexec/arch/ppc64/fs2dt.c	2009-01-02 02:16:17.000000000 -0600
+++ kexec-tools/kexec/arch/ppc64/fs2dt.c	2009-01-02 02:16:19.000000000 -0600
 <at>  <at>  -46,8 +46,6  <at>  <at>  static unsigned long long mem_rsrv[2*MEM

 static int crash_param = 0;
 static char local_cmdline[COMMAND_LINE_SIZE] = { "" };
-static unsigned *dt_len; /* changed len of modified cmdline
-			    in flat device-tree */
(Continue reading)

Milton Miller | 2 Jan 2009 21:44
Favicon

(unknown)

Subject [PATCH kexec-tools 5/5] entry wants to be void *
Date: Fri, 02 Jan 2009 14:44:40 -0600
Subject: (No subject header)
X-Originating-IP: 205.232.218.102

The kexec info struct defines entry to be a void *, so pass around the
user supplied value as one.

This fixes the following warning:

gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include
-Iinclude/ -I./kexec/arch/ppc64/include  -c -MD -o kexec/kexec.o kexec/kexec.c
kexec/kexec.c: In function ‘my_load’:
kexec/kexec.c:773: warning: assignment makes pointer from integer without a cast

Signed-off-by: Milton Miller <miltonm <at> bga.com>
---

Index: kexec-tools/kexec/kexec.c
===================================================================
--- kexec-tools.orig/kexec/kexec.c	2009-01-02 02:54:37.000000000 -0600
+++ kexec-tools/kexec/kexec.c	2009-01-02 02:55:06.000000000 -0600
 <at>  <at>  -666,7 +666,7  <at>  <at>  static void update_purgatory(struct kexe
  *	Load the new kernel
  */
 static int my_load(const char *type, int fileind, int argc, char **argv,
-		   unsigned long kexec_flags, unsigned long entry)
+		   unsigned long kexec_flags, void *entry)
 {
 	char *kernel;
(Continue reading)

Milton Miller | 2 Jan 2009 21:46
Favicon

[PATCH] powerpc: make dummy section a valid note header

We are declaring the dummy section (used to work around a binutils
bug) as PT_NOTE, but we don't have enough bytes for it to be a valid
note header, and kexec userspace complains:

Warning: Elf Note name is not null terminated
Warning: append= option is not passed. Using the first kernel root partition
Warning: Elf Note name is not null terminated

Instead of using the arbitray value 0xf177 (aka "fill"), declare a
no-name no-description note of type 0.

Signed-off-by: Milton Miller <miltonm <at> bga.com>
---
verified on binutils-2.6.17 that the workaround still works (that
is we get a phdr that does not have all zeros in the paddr field,
and a relocatable kernel booted).

Index: common/arch/powerpc/kernel/vmlinux.lds.S
===================================================================
--- common.orig/arch/powerpc/kernel/vmlinux.lds.S	2009-01-02 01:07:12.000000000 -0600
+++ common/arch/powerpc/kernel/vmlinux.lds.S	2009-01-02 01:18:00.000000000 -0600
 <at>  <at>  -87,7 +87,9  <at>  <at>  SECTIONS
 	/* The dummy segment contents for the bug workaround mentioned above
 	   near PHDRS.  */
 	.dummy : AT(ADDR(.dummy) - LOAD_OFFSET) {
-		LONG(0xf177)
+		LONG(0)
+		LONG(0)
+		LONG(0)
 	} :kernel :dummy
(Continue reading)


Gmane