All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/06] sh: Improved kexec support for SuperH
@ 2008-08-26 11:11 Magnus Damm
  2008-08-26 11:11 ` [PATCH 01/06] sh: Add support for sh4al-dsp processors Magnus Damm
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Magnus Damm @ 2008-08-26 11:11 UTC (permalink / raw)
  To: kexec; +Cc: horms, Magnus Damm

Here comes a few SuperH related patches. Trivial stuff - fixing up plain
kexec support. Kdump is not ready yet. I also have have a few kdump changes
in my local tree but they need more work.

[PATCH 01/06] sh: Add support for sh4al-dsp processors
[PATCH 02/06] sh: Get system memory ranges from /proc/iomem
[PATCH 03/06] sh: Add virtual addresses support
[PATCH 04/06] sh: Autodetect zImage zero page address
[PATCH 05/06] sh: Use dynamic zImage load address
[PATCH 06/06] sh: Add vmlinux support

Tested with 2.6.27-rc on SuperH Mobile processor models sh7722/sh7723.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 kexec/arch/sh/Makefile          |    5 +
 kexec/arch/sh/kexec-elf-sh.c    |  114 +++++++++++++++++++++++++++++++++++++++
 kexec/arch/sh/kexec-sh.c        |   97 ++++++++++++++++++++++-----------
 kexec/arch/sh/kexec-sh.h        |    8 ++
 kexec/arch/sh/kexec-zImage-sh.c |   96 +++++++++++++++++++++++---------
 5 files changed, 260 insertions(+), 60 deletions(-)


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

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

* [PATCH 01/06] sh: Add support for sh4al-dsp processors
  2008-08-26 11:11 [PATCH 00/06] sh: Improved kexec support for SuperH Magnus Damm
@ 2008-08-26 11:11 ` Magnus Damm
  2008-08-26 11:12 ` [PATCH 02/06] sh: Get system memory ranges from /proc/iomem Magnus Damm
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Magnus Damm @ 2008-08-26 11:11 UTC (permalink / raw)
  To: kexec; +Cc: horms, Magnus Damm

From: Magnus Damm <damm@igel.co.jp>

Add support for sh4al-dsp processors such as sh7722.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 kexec/arch/sh/kexec-sh.c |    1 +
 1 file changed, 1 insertion(+)

--- 0001/kexec/arch/sh/kexec-sh.c
+++ work/kexec/arch/sh/kexec-sh.c	2008-08-20 19:07:47.000000000 +0900
@@ -105,6 +105,7 @@ const struct arch_map_entry arches[] = {
 	{ "sh3", KEXEC_ARCH_DEFAULT },
 	{ "sh4", KEXEC_ARCH_DEFAULT },
 	{ "sh4a", KEXEC_ARCH_DEFAULT },
+	{ "sh4al-dsp", KEXEC_ARCH_DEFAULT },
 	{ 0 },
 };
 

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

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

* [PATCH 02/06] sh: Get system memory ranges from /proc/iomem
  2008-08-26 11:11 [PATCH 00/06] sh: Improved kexec support for SuperH Magnus Damm
  2008-08-26 11:11 ` [PATCH 01/06] sh: Add support for sh4al-dsp processors Magnus Damm
@ 2008-08-26 11:12 ` Magnus Damm
  2008-08-26 11:12 ` [PATCH 03/06] sh: Add virtual addresses support Magnus Damm
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Magnus Damm @ 2008-08-26 11:12 UTC (permalink / raw)
  To: kexec; +Cc: horms, Magnus Damm

From: Magnus Damm <damm@igel.co.jp>

Parse contents of /proc/iomem instead of hardcoding RAM ranges.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 kexec/arch/sh/kexec-sh.c |   26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

--- 0002/kexec/arch/sh/kexec-sh.c
+++ work/kexec/arch/sh/kexec-sh.c	2008-08-22 10:53:15.000000000 +0900
@@ -22,19 +22,31 @@
 #define MAX_MEMORY_RANGES 64
 static struct memory_range memory_range[MAX_MEMORY_RANGES];
 
+static int kexec_sh_memory_range_callback(void *data, int nr,
+					  char *str,
+					  unsigned long base,
+					  unsigned long length)
+{
+	if (nr < MAX_MEMORY_RANGES) {
+		memory_range[nr].start = base;
+		memory_range[nr].end = base + length - 1;
+		memory_range[nr].type = RANGE_RAM;
+		return 0;
+	}
+
+	return 1;
+}
+
 /* Return a sorted list of available memory ranges. */
 int get_memory_ranges(struct memory_range **range, int *ranges,
 		      unsigned long kexec_flags)
 {
-	int memory_ranges;
+	int nr;
 
-	memory_ranges = 0;
-	memory_range[memory_ranges].start = 0x08000000;
-	memory_range[memory_ranges].end   = 0x10000000;
-	memory_range[memory_ranges].type  = RANGE_RAM;
-	memory_ranges++;
+	nr = kexec_iomem_for_each_line("System RAM\n",
+				       kexec_sh_memory_range_callback, NULL);
 	*range = memory_range;
-	*ranges = memory_ranges;
+	*ranges = nr;
 	return 0;
 }
 

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

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

* [PATCH 03/06] sh: Add virtual addresses support
  2008-08-26 11:11 [PATCH 00/06] sh: Improved kexec support for SuperH Magnus Damm
  2008-08-26 11:11 ` [PATCH 01/06] sh: Add support for sh4al-dsp processors Magnus Damm
  2008-08-26 11:12 ` [PATCH 02/06] sh: Get system memory ranges from /proc/iomem Magnus Damm
@ 2008-08-26 11:12 ` Magnus Damm
  2008-08-26 11:12 ` [PATCH 04/06] sh: Autodetect zImage zero page address Magnus Damm
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Magnus Damm @ 2008-08-26 11:12 UTC (permalink / raw)
  To: kexec; +Cc: horms, Magnus Damm

From: Magnus Damm <damm@igel.co.jp>

Implement virtual-to-physical address conversion functions for SuperH.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 kexec/arch/sh/Makefile          |    4 ++++
 kexec/arch/sh/kexec-sh.c        |   29 +++++++++++++++++++++++++++++
 kexec/arch/sh/kexec-zImage-sh.c |    4 ++--
 3 files changed, 35 insertions(+), 2 deletions(-)

--- 0001/kexec/arch/sh/Makefile
+++ work/kexec/arch/sh/Makefile	2008-08-22 11:07:45.000000000 +0900
@@ -7,6 +7,10 @@ sh_KEXEC_SRCS += kexec/arch/sh/kexec-net
 sh_KEXEC_SRCS += kexec/arch/sh/kexec-elf-rel-sh.c
 sh_KEXEC_SRCS += kexec/arch/sh/netbsd_booter.S
 
+sh_ADD_BUFFER =
+sh_ADD_SEGMENT =
+sh_VIRT_TO_PHYS =
+
 dist += kexec/arch/sh/Makefile $(sh_KEXEC_SRCS)				\
 	kexec/arch/sh/kexec-sh.h					\
 	kexec/arch/sh/include/arch/options.h
--- 0003/kexec/arch/sh/kexec-sh.c
+++ work/kexec/arch/sh/kexec-sh.c	2008-08-22 11:10:31.000000000 +0900
@@ -168,3 +168,32 @@ int is_crashkernel_mem_reserved(void)
 	return 0; /* kdump is not supported on this platform (yet) */
 }
 
+unsigned long virt_to_phys(unsigned long addr)
+{
+	unsigned long seg = addr & 0xe0000000;
+	if (seg != 0x80000000 && seg != 0xc0000000)
+		die("Virtual address %p is not in P1 or P2\n", (void *)addr);
+
+	return addr - seg;
+}
+
+/*
+ * add_segment() should convert base to a physical address on superh,
+ * while the default is just to work with base as is */
+void add_segment(struct kexec_info *info, const void *buf, size_t bufsz,
+		 unsigned long base, size_t memsz)
+{
+	add_segment_phys_virt(info, buf, bufsz, base, memsz, 1);
+}
+
+/*
+ * add_buffer() should convert base to a physical address on superh,
+ * while the default is just to work with base as is */
+unsigned long add_buffer(struct kexec_info *info, const void *buf,
+			 unsigned long bufsz, unsigned long memsz,
+			 unsigned long buf_align, unsigned long buf_min,
+			 unsigned long buf_max, int buf_end)
+{
+	return add_buffer_phys_virt(info, buf, bufsz, memsz, buf_align,
+				    buf_min, buf_max, buf_end, 1);
+}
--- 0001/kexec/arch/sh/kexec-zImage-sh.c
+++ work/kexec/arch/sh/kexec-zImage-sh.c	2008-08-22 11:10:43.000000000 +0900
@@ -96,8 +96,8 @@ int zImage_sh_load(int argc, char **argv
         paraml = (unsigned long *)param;
 	// paraml[0] = 1;  // readonly flag is set as default
 
-	add_segment(info, param, 4096, empty_zero, 4096);
-	add_segment(info, buf,   len,  (area | 0x00210000), len);
+	add_segment(info, param, 4096, 0x80000000 | empty_zero, 4096);
+	add_segment(info, buf,   len,  (area | 0x80210000), len);
 
 	/* For now we don't have arguments to pass :( */
 	info->entry = (void *)(0x80210000 | area);

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

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

* [PATCH 04/06] sh: Autodetect zImage zero page address
  2008-08-26 11:11 [PATCH 00/06] sh: Improved kexec support for SuperH Magnus Damm
                   ` (2 preceding siblings ...)
  2008-08-26 11:12 ` [PATCH 03/06] sh: Add virtual addresses support Magnus Damm
@ 2008-08-26 11:12 ` Magnus Damm
  2008-08-26 11:12 ` [PATCH 05/06] sh: Use dynamic zImage load address Magnus Damm
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Magnus Damm @ 2008-08-26 11:12 UTC (permalink / raw)
  To: kexec; +Cc: horms, Magnus Damm

From: Magnus Damm <damm@igel.co.jp>

Autodetect the zero page base address for zImages on SuperH.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 kexec/arch/sh/kexec-sh.c        |   40 +++++++------------
 kexec/arch/sh/kexec-sh.h        |    3 -
 kexec/arch/sh/kexec-zImage-sh.c |   79 ++++++++++++++++++++++++++++-----------
 3 files changed, 75 insertions(+), 47 deletions(-)

--- 0004/kexec/arch/sh/kexec-sh.c
+++ work/kexec/arch/sh/kexec-sh.c	2008-08-22 12:05:08.000000000 +0900
@@ -65,16 +65,8 @@ void arch_usage(void)
     " none\n\n"
     "Default options:\n"
     " --append=\"%s\"\n"
-    " --empty-zero=0x%08x\n\n"
     " STRING of --appned is set form /proc/cmdline as default.\n"
-    " ADDRESS of --empty-zero can be set SHELL environment variable\n"
-    " KEXEC_EMPTY_ZERO as default.\n\n"
-    " ADDRESS can be get in the following method in your system. \n"
-    " 1) \"grep empty_zero /proc/kallsyms\". \n"
-    " 2) \"grep empty_zero System.map\". \n"
-    " 3) CONFIG_MEMORY_START + CONFIG_ZERO_PAGE_OFFSET in your kernel\n"
-    "    config file.\n"
-    ,get_append(), (unsigned int) get_empty_zero(NULL));
+    ,get_append());
 
 }
 
@@ -130,21 +122,6 @@ void arch_update_purgatory(struct kexec_
 {
 }
 
-
-unsigned long get_empty_zero(char *s)
-{
-        char *env;
-
-	env = getenv("KEXEC_EMPTY_ZERO");
-
-	if(s){
-	  env = s;
-	}else if(!env){
-	  env = "0x0c001000";
-	}
-	return 0x1fffffff & strtoul(env,(char **)NULL,0);
-}
-
 char append_buf[256];
 
 char *get_append(void)
@@ -162,6 +139,21 @@ char *get_append(void)
         return append_buf;
 }
 
+void kexec_sh_setup_zero_page(char *zero_page_buf, int zero_page_size,
+			      char *cmd_line)
+{
+	int n = zero_page_size - 0x100;
+
+	memset(zero_page_buf, 0, zero_page_size);
+	
+	if (cmd_line) {
+		if (n > strlen(cmd_line))
+			n = strlen(cmd_line);
+
+		memcpy(zero_page_buf + 0x100, cmd_line, n);
+		zero_page_buf[0x100 + n] = '\0';
+	}
+}
 
 int is_crashkernel_mem_reserved(void)
 {
--- 0001/kexec/arch/sh/kexec-sh.h
+++ work/kexec/arch/sh/kexec-sh.h	2008-08-22 12:05:08.000000000 +0900
@@ -12,6 +12,7 @@ int netbsd_sh_load(int argc, char **argv
 void netbsd_sh_usage(void);
 
 char *get_append(void);
-unsigned long get_empty_zero(char *s);
+void kexec_sh_setup_zero_page(char *zero_page_buf, int zero_page_size,
+			      char *cmd_line);
 
 #endif /* KEXEC_SH_H */
--- 0004/kexec/arch/sh/kexec-zImage-sh.c
+++ work/kexec/arch/sh/kexec-zImage-sh.c	2008-08-22 14:28:29.000000000 +0900
@@ -28,6 +28,24 @@
 
 static const int probe_debug = 0;
 
+#define HEAD32_KERNEL_START_ADDR 0
+#define HEAD32_DECOMPRESS_KERNEL_ADDR 1
+#define HEAD32_INIT_STACK_ADDR 2
+#define HEAD32_INIT_SR 3
+#define HEAD32_INIT_SR_VALUE 0x400000F0
+
+unsigned long zImage_head32(const char *buf, off_t len, int offs)
+{
+	unsigned long *values = (void *)buf;
+	int k;
+
+	for (k = (0x200 / 4) - 1; k > 0; k--)
+		if (values[k] != 0x00090009) /* not nop + nop padding*/
+			return values[k - offs];
+
+	return 0;
+}
+
 /*
  * zImage_sh_probe - sanity check the elf image
  *
@@ -35,10 +53,12 @@ static const int probe_debug = 0;
  */
 int zImage_sh_probe(const char *buf, off_t len)
 {
-	if (memcmp(&buf[0x202], "HdrS", 4) != 0) {
-	        fprintf(stderr, "Not a zImage\n");
+	if (memcmp(&buf[0x202], "HdrS", 4) != 0)
 	        return -1;
-	}
+
+	if (zImage_head32(buf, len, HEAD32_INIT_SR) != HEAD32_INIT_SR_VALUE)
+	        return -1;
+
 	return 0;
 }
 
@@ -54,10 +74,9 @@ int zImage_sh_load(int argc, char **argv
 	struct kexec_info *info)
 {
         char *command_line;
-	int opt;
-	unsigned long empty_zero, area;
-	unsigned char *param;
-	unsigned long *paraml;
+	int opt, k;
+	unsigned long empty_zero, area, zero_page_base, zero_page_size;
+	char *param;
 
 	static const struct option options[] = {
        	        KEXEC_ARCH_OPTIONS
@@ -67,7 +86,6 @@ int zImage_sh_load(int argc, char **argv
 	static const char short_options[] = KEXEC_ARCH_OPT_STR "";
 
 	command_line = 0;
-	empty_zero = get_empty_zero(NULL);
 	while ((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) {
 		switch (opt) {
 		default:
@@ -81,25 +99,42 @@ int zImage_sh_load(int argc, char **argv
 		case OPT_APPEND:
 			command_line = optarg;
 			break;
-		case OPT_EMPTYZERO:
-			empty_zero = get_empty_zero(optarg);
-			break;
 		}
 	}
-	param = xmalloc(4096);
-	memset(param, 0, 4096);
-	area       = empty_zero & 0x1c000000;
-	if (!command_line) {
+
+	if (!command_line)
 	        command_line = get_append();
-	}
-	strncpy(&param[256], command_line, strlen(command_line));
-        paraml = (unsigned long *)param;
-	// paraml[0] = 1;  // readonly flag is set as default
 
-	add_segment(info, param, 4096, 0x80000000 | empty_zero, 4096);
-	add_segment(info, buf,   len,  (area | 0x80210000), len);
+	/* assume the zero page is the page before the vmlinux entry point.
+	 * we don't know the page size though, but 64k seems to be max.
+	 * put several 4k zero page copies before the entry point to cover
+	 * all combinations.
+	 */
+
+	empty_zero = zImage_head32(buf, len, HEAD32_KERNEL_START_ADDR);
+
+	zero_page_size = 0x10000;
+	zero_page_base = virt_to_phys(empty_zero - zero_page_size);
+
+	while (!valid_memory_range(info, zero_page_base,
+				   zero_page_base + zero_page_size - 1)) {
+		zero_page_base += 0x1000;
+		zero_page_size -= 0x1000;
+		if (zero_page_size == 0)
+			die("Unable to determine zero page size from %p \n",
+			    (void *)empty_zero);
+	} 
+
+	param = xmalloc(zero_page_size);
+	for (k = 0; k < (zero_page_size / 0x1000); k++)
+		kexec_sh_setup_zero_page(param + (k * 0x1000), 0x1000,
+					 command_line);
 
-	/* For now we don't have arguments to pass :( */
+	add_segment(info, param, zero_page_size,
+		    0x80000000 | zero_page_base, zero_page_size);
+
+	area = empty_zero & 0x1c000000;
+	add_segment(info, buf,   len,  (area | 0x80210000), len);
 	info->entry = (void *)(0x80210000 | area);
 	return 0;
 }

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

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

* [PATCH 05/06] sh: Use dynamic zImage load address
  2008-08-26 11:11 [PATCH 00/06] sh: Improved kexec support for SuperH Magnus Damm
                   ` (3 preceding siblings ...)
  2008-08-26 11:12 ` [PATCH 04/06] sh: Autodetect zImage zero page address Magnus Damm
@ 2008-08-26 11:12 ` Magnus Damm
  2008-08-26 11:12 ` [PATCH 06/06] sh: Add vmlinux support Magnus Damm
  2008-08-27  7:05 ` [PATCH 00/06] sh: Improved kexec support for SuperH Paul Mundt
  6 siblings, 0 replies; 13+ messages in thread
From: Magnus Damm @ 2008-08-26 11:12 UTC (permalink / raw)
  To: kexec; +Cc: horms, Magnus Damm

From: Magnus Damm <damm@igel.co.jp>

Dynamically calculate SuperH zImage load address instead of hardcoding.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 kexec/arch/sh/kexec-zImage-sh.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

--- 0005/kexec/arch/sh/kexec-zImage-sh.c
+++ work/kexec/arch/sh/kexec-zImage-sh.c	2008-08-22 13:04:13.000000000 +0900
@@ -79,7 +79,8 @@ int zImage_sh_load(int argc, char **argv
 {
         char *command_line;
 	int opt, k;
-	unsigned long empty_zero, area, zero_page_base, zero_page_size;
+	unsigned long empty_zero, zero_page_base, zero_page_size;
+	unsigned long image_base;
 	char *param;
 
 	static const struct option options[] = {
@@ -137,8 +138,12 @@ int zImage_sh_load(int argc, char **argv
 	add_segment(info, param, zero_page_size,
 		    0x80000000 | zero_page_base, zero_page_size);
 
-	area = empty_zero & 0x1c000000;
-	add_segment(info, buf,   len,  (area | 0x80210000), len);
-	info->entry = (void *)(0x80210000 | area);
+	/* load image a bit above the zero page, round up to 64k
+	 * the zImage will relocate itself, but only up seems supported.
+	 */
+
+	image_base = (empty_zero + (0x10000 - 1)) & ~(0x10000 - 1);
+	add_segment(info, buf, len, image_base, len);
+	info->entry = (void *)image_base;
 	return 0;
 }

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

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

* [PATCH 06/06] sh: Add vmlinux support
  2008-08-26 11:11 [PATCH 00/06] sh: Improved kexec support for SuperH Magnus Damm
                   ` (4 preceding siblings ...)
  2008-08-26 11:12 ` [PATCH 05/06] sh: Use dynamic zImage load address Magnus Damm
@ 2008-08-26 11:12 ` Magnus Damm
  2008-08-27  2:39   ` Simon Horman
  2008-08-27  7:05 ` [PATCH 00/06] sh: Improved kexec support for SuperH Paul Mundt
  6 siblings, 1 reply; 13+ messages in thread
From: Magnus Damm @ 2008-08-26 11:12 UTC (permalink / raw)
  To: kexec; +Cc: horms, Magnus Damm

From: Magnus Damm <damm@igel.co.jp>

Add SuperH vmlinux support through a zero-page aware elf loader. Only for
kexec at this point, in the future kdump support will be added.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 kexec/arch/sh/Makefile       |    1 
 kexec/arch/sh/kexec-elf-sh.c |  114 ++++++++++++++++++++++++++++++++++++++++++
 kexec/arch/sh/kexec-sh.c     |    1 
 kexec/arch/sh/kexec-sh.h     |    5 +
 4 files changed, 121 insertions(+)

--- 0004/kexec/arch/sh/Makefile
+++ work/kexec/arch/sh/Makefile	2008-08-22 13:17:18.000000000 +0900
@@ -4,6 +4,7 @@
 sh_KEXEC_SRCS += kexec/arch/sh/kexec-sh.c
 sh_KEXEC_SRCS += kexec/arch/sh/kexec-zImage-sh.c
 sh_KEXEC_SRCS += kexec/arch/sh/kexec-netbsd-sh.c
+sh_KEXEC_SRCS += kexec/arch/sh/kexec-elf-sh.c
 sh_KEXEC_SRCS += kexec/arch/sh/kexec-elf-rel-sh.c
 sh_KEXEC_SRCS += kexec/arch/sh/netbsd_booter.S
 
--- /dev/null
+++ work/kexec/arch/sh/kexec-elf-sh.c	2008-08-22 14:24:31.000000000 +0900
@@ -0,0 +1,114 @@
+/*
+ * kexec: Linux boots Linux
+ *
+ * Copyright (C) 2008  Magnus Damm
+ *
+ * Based on x86 implementation,
+ * Copyright (C) 2003-2005  Eric Biederman (ebiederm@xmission.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation (version 2 of the License).
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <limits.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <elf.h>
+#include "../../kexec.h"
+#include "../../kexec-syscall.h"
+#include "../../kexec-elf.h"
+#include "../../kexec-elf-boot.h"
+#include <arch/options.h>
+#include "kexec-sh.h"
+
+int elf_sh_probe(const char *buf, off_t len)
+{
+	struct mem_ehdr ehdr;
+	int result;
+	result = build_elf_exec_info(buf, len, &ehdr, 0);
+	if (result < 0)
+		goto out;
+
+	/* Verify the architecuture specific bits */
+	if (ehdr.e_machine != EM_SH) {
+		result = -1;
+		goto out;
+	}
+
+	result = 0;
+ out:
+	free_elf_info(&ehdr);
+	return result;
+}
+
+void elf_sh_usage(void)
+{
+	printf("  --append=STRING       Set the kernel command line to STRING\n"
+		);
+}
+
+int elf_sh_load(int argc, char **argv, const char *buf, off_t len, 
+	struct kexec_info *info)
+{
+	struct mem_ehdr ehdr;
+	const char *command_line;
+	struct mem_sym sym;
+	int opt;
+	static const struct option options[] = {
+		KEXEC_ARCH_OPTIONS
+		{ 0, 			0, NULL, 0 },
+	};
+
+	static const char short_options[] = KEXEC_OPT_STR "";
+
+	/*
+	 * Parse the command line arguments
+	 */
+	command_line = 0;
+	while((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) {
+		switch(opt) {
+		default:
+			/* Ignore core options */
+			if (opt < OPT_ARCH_MAX) {
+				break;
+			}
+		case '?':
+			usage();
+			return -1;
+		case OPT_APPEND:
+			command_line = optarg;
+			break;
+		}
+	}
+
+	/* Load the ELF executable */
+	elf_exec_build_load(info, &ehdr, buf, len, 0);
+	info->entry = (void *)ehdr.e_entry;
+
+	/* If we're booting a vmlinux then fill in empty_zero_page */
+	if (elf_rel_find_symbol(&ehdr, "empty_zero_page", &sym) == 0) {
+		unsigned char *zp = (void *)ehdr.e_shdr[sym.st_shndx].sh_data;
+
+		kexec_sh_setup_zero_page(zp, 4096, command_line);
+	}
+
+	return 0;
+}
--- 0005/kexec/arch/sh/kexec-sh.c
+++ work/kexec/arch/sh/kexec-sh.c	2008-08-22 13:17:18.000000000 +0900
@@ -53,6 +53,7 @@ int get_memory_ranges(struct memory_rang
 /* Supported file types and callbacks */
 struct file_type file_type[] = {
        {"zImage-sh", zImage_sh_probe, zImage_sh_load, zImage_sh_usage},
+       {"elf-sh", elf_sh_probe, elf_sh_load, elf_sh_usage},
        {"netbsd-sh", netbsd_sh_probe, netbsd_sh_load, netbsd_sh_usage},
 };
 int file_types = sizeof(file_type) / sizeof(file_type[0]);
--- 0005/kexec/arch/sh/kexec-sh.h
+++ work/kexec/arch/sh/kexec-sh.h	2008-08-22 13:17:18.000000000 +0900
@@ -6,6 +6,11 @@ int zImage_sh_load(int argc, char **argv
 	struct kexec_info *info);
 void zImage_sh_usage(void);
 
+int elf_sh_probe(const char *buf, off_t len);
+int elf_sh_load(int argc, char **argv, const char *buf, off_t len,
+	struct kexec_info *info);
+void elf_sh_usage(void);
+
 int netbsd_sh_probe(const char *buf, off_t len);
 int netbsd_sh_load(int argc, char **argv, const char *buf, off_t len,
 	struct kexec_info *info);

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

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

* Re: [PATCH 06/06] sh: Add vmlinux support
  2008-08-26 11:12 ` [PATCH 06/06] sh: Add vmlinux support Magnus Damm
@ 2008-08-27  2:39   ` Simon Horman
  2008-08-27  4:10     ` Magnus Damm
  0 siblings, 1 reply; 13+ messages in thread
From: Simon Horman @ 2008-08-27  2:39 UTC (permalink / raw)
  To: Magnus Damm; +Cc: kexec

On Tue, Aug 26, 2008 at 08:12:32PM +0900, Magnus Damm wrote:
> From: Magnus Damm <damm@igel.co.jp>
> 
> Add SuperH vmlinux support through a zero-page aware elf loader. Only for
> kexec at this point, in the future kdump support will be added.

Hi Magnus,

If these series of patches are fine by you then they are fine by me.
I just have a few minor issues with this last patch.

> 
> Signed-off-by: Magnus Damm <damm@igel.co.jp>
> ---
> 
>  kexec/arch/sh/Makefile       |    1 
>  kexec/arch/sh/kexec-elf-sh.c |  114 ++++++++++++++++++++++++++++++++++++++++++
>  kexec/arch/sh/kexec-sh.c     |    1 
>  kexec/arch/sh/kexec-sh.h     |    5 +
>  4 files changed, 121 insertions(+)
> 
> --- 0004/kexec/arch/sh/Makefile
> +++ work/kexec/arch/sh/Makefile	2008-08-22 13:17:18.000000000 +0900
> @@ -4,6 +4,7 @@
>  sh_KEXEC_SRCS += kexec/arch/sh/kexec-sh.c
>  sh_KEXEC_SRCS += kexec/arch/sh/kexec-zImage-sh.c
>  sh_KEXEC_SRCS += kexec/arch/sh/kexec-netbsd-sh.c
> +sh_KEXEC_SRCS += kexec/arch/sh/kexec-elf-sh.c
>  sh_KEXEC_SRCS += kexec/arch/sh/kexec-elf-rel-sh.c
>  sh_KEXEC_SRCS += kexec/arch/sh/netbsd_booter.S
>  
> --- /dev/null
> +++ work/kexec/arch/sh/kexec-elf-sh.c	2008-08-22 14:24:31.000000000 +0900
> @@ -0,0 +1,114 @@
> +/*
> + * kexec: Linux boots Linux
> + *
> + * Copyright (C) 2008  Magnus Damm
> + *
> + * Based on x86 implementation,
> + * Copyright (C) 2003-2005  Eric Biederman (ebiederm@xmission.com)
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation (version 2 of the License).
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#define _GNU_SOURCE
> +#include <stdio.h>
> +#include <string.h>
> +#include <stdlib.h>
> +#include <errno.h>
> +#include <limits.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +#include <unistd.h>
> +#include <getopt.h>
> +#include <elf.h>
> +#include "../../kexec.h"
> +#include "../../kexec-syscall.h"
> +#include "../../kexec-elf.h"
> +#include "../../kexec-elf-boot.h"
> +#include <arch/options.h>
> +#include "kexec-sh.h"
> +
> +int elf_sh_probe(const char *buf, off_t len)
> +{
> +	struct mem_ehdr ehdr;
> +	int result;
> +	result = build_elf_exec_info(buf, len, &ehdr, 0);
> +	if (result < 0)
> +		goto out;
> +
> +	/* Verify the architecuture specific bits */
> +	if (ehdr.e_machine != EM_SH) {
> +		result = -1;
> +		goto out;
> +	}
> +
> +	result = 0;
> + out:
> +	free_elf_info(&ehdr);
> +	return result;
> +}
> +
> +void elf_sh_usage(void)
> +{
> +	printf("  --append=STRING       Set the kernel command line to STRING\n"
> +		);
> +}
> +
> +int elf_sh_load(int argc, char **argv, const char *buf, off_t len, 

The line above has trailing whitespace.

> +	struct kexec_info *info)
> +{
> +	struct mem_ehdr ehdr;
> +	const char *command_line;
> +	struct mem_sym sym;
> +	int opt;
> +	static const struct option options[] = {
> +		KEXEC_ARCH_OPTIONS
> +		{ 0, 			0, NULL, 0 },

The line above has a stray space after 0 (and before a tab).

> +	};
> +
> +	static const char short_options[] = KEXEC_OPT_STR "";
> +
> +	/*
> +	 * Parse the command line arguments
> +	 */
> +	command_line = 0;
> +	while((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) {
> +		switch(opt) {
> +		default:
> +			/* Ignore core options */
> +			if (opt < OPT_ARCH_MAX) {
> +				break;
> +			}
> +		case '?':
> +			usage();
> +			return -1;
> +		case OPT_APPEND:
> +			command_line = optarg;
> +			break;
> +		}
> +	}
> +
> +	/* Load the ELF executable */
> +	elf_exec_build_load(info, &ehdr, buf, len, 0);
> +	info->entry = (void *)ehdr.e_entry;
> +
> +	/* If we're booting a vmlinux then fill in empty_zero_page */
> +	if (elf_rel_find_symbol(&ehdr, "empty_zero_page", &sym) == 0) {
> +		unsigned char *zp = (void *)ehdr.e_shdr[sym.st_shndx].sh_data;
> +
> +		kexec_sh_setup_zero_page(zp, 4096, command_line);

kexec_sh_setup_zero_page() seems to want a signed char * as the first
argument. Does it make sense to just change zp accordingly?


> +	}
> +
> +	return 0;
> +}
> --- 0005/kexec/arch/sh/kexec-sh.c
> +++ work/kexec/arch/sh/kexec-sh.c	2008-08-22 13:17:18.000000000 +0900
> @@ -53,6 +53,7 @@ int get_memory_ranges(struct memory_rang
>  /* Supported file types and callbacks */
>  struct file_type file_type[] = {
>         {"zImage-sh", zImage_sh_probe, zImage_sh_load, zImage_sh_usage},
> +       {"elf-sh", elf_sh_probe, elf_sh_load, elf_sh_usage},
>         {"netbsd-sh", netbsd_sh_probe, netbsd_sh_load, netbsd_sh_usage},
>  };
>  int file_types = sizeof(file_type) / sizeof(file_type[0]);
> --- 0005/kexec/arch/sh/kexec-sh.h
> +++ work/kexec/arch/sh/kexec-sh.h	2008-08-22 13:17:18.000000000 +0900
> @@ -6,6 +6,11 @@ int zImage_sh_load(int argc, char **argv
>  	struct kexec_info *info);
>  void zImage_sh_usage(void);
>  
> +int elf_sh_probe(const char *buf, off_t len);
> +int elf_sh_load(int argc, char **argv, const char *buf, off_t len,
> +	struct kexec_info *info);
> +void elf_sh_usage(void);
> +
>  int netbsd_sh_probe(const char *buf, off_t len);
>  int netbsd_sh_load(int argc, char **argv, const char *buf, off_t len,
>  	struct kexec_info *info);

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

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

* Re: [PATCH 06/06] sh: Add vmlinux support
  2008-08-27  2:39   ` Simon Horman
@ 2008-08-27  4:10     ` Magnus Damm
  2008-08-27  5:40       ` Simon Horman
  0 siblings, 1 reply; 13+ messages in thread
From: Magnus Damm @ 2008-08-27  4:10 UTC (permalink / raw)
  To: Simon Horman; +Cc: kexec

[-- Attachment #1: Type: text/plain, Size: 531 bytes --]

Hi Simon,

On Wed, Aug 27, 2008 at 11:39 AM, Simon Horman <horms@verge.net.au> wrote:
> On Tue, Aug 26, 2008 at 08:12:32PM +0900, Magnus Damm wrote:
>> From: Magnus Damm <damm@igel.co.jp>
>>
>> Add SuperH vmlinux support through a zero-page aware elf loader. Only for
>> kexec at this point, in the future kdump support will be added.
>
> If these series of patches are fine by you then they are fine by me.
> I just have a few minor issues with this last patch.

How does the attached patch look?

Thanks for your help!

/ magnus

[-- Attachment #2: kexec-tools-git-superh-vmlinux-fixes-20080827.patch --]
[-- Type: application/octet-stream, Size: 1016 bytes --]

--- 0007/kexec/arch/sh/kexec-elf-sh.c
+++ work/kexec/arch/sh/kexec-elf-sh.c	2008-08-27 12:55:40.000000000 +0900
@@ -65,16 +65,16 @@ void elf_sh_usage(void)
 		);
 }
 
-int elf_sh_load(int argc, char **argv, const char *buf, off_t len, 
-	struct kexec_info *info)
+int elf_sh_load(int argc, char **argv, const char *buf, off_t len,
+		struct kexec_info *info)
 {
 	struct mem_ehdr ehdr;
-	const char *command_line;
+	char *command_line;
 	struct mem_sym sym;
 	int opt;
 	static const struct option options[] = {
 		KEXEC_ARCH_OPTIONS
-		{ 0, 			0, NULL, 0 },
+		{ 0, 0, 0, 0 },
 	};
 
 	static const char short_options[] = KEXEC_OPT_STR "";
@@ -105,7 +105,7 @@ int elf_sh_load(int argc, char **argv, c
 
 	/* If we're booting a vmlinux then fill in empty_zero_page */
 	if (elf_rel_find_symbol(&ehdr, "empty_zero_page", &sym) == 0) {
-		unsigned char *zp = (void *)ehdr.e_shdr[sym.st_shndx].sh_data;
+		char *zp = (void *)ehdr.e_shdr[sym.st_shndx].sh_data;
 
 		kexec_sh_setup_zero_page(zp, 4096, command_line);
 	}

[-- Attachment #3: Type: text/plain, Size: 143 bytes --]

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

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

* Re: [PATCH 06/06] sh: Add vmlinux support
  2008-08-27  4:10     ` Magnus Damm
@ 2008-08-27  5:40       ` Simon Horman
  2008-08-27  6:55         ` Magnus Damm
  0 siblings, 1 reply; 13+ messages in thread
From: Simon Horman @ 2008-08-27  5:40 UTC (permalink / raw)
  To: Magnus Damm; +Cc: kexec

On Wed, Aug 27, 2008 at 01:10:30PM +0900, Magnus Damm wrote:
> Hi Simon,
> 
> On Wed, Aug 27, 2008 at 11:39 AM, Simon Horman <horms@verge.net.au> wrote:
> > On Tue, Aug 26, 2008 at 08:12:32PM +0900, Magnus Damm wrote:
> >> From: Magnus Damm <damm@igel.co.jp>
> >>
> >> Add SuperH vmlinux support through a zero-page aware elf loader. Only for
> >> kexec at this point, in the future kdump support will be added.
> >
> > If these series of patches are fine by you then they are fine by me.
> > I just have a few minor issues with this last patch.
> 
> How does the attached patch look?
> 
> Thanks for your help!

Much better :-)

Should I just fold it into the last patch and push ?



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

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

* Re: [PATCH 06/06] sh: Add vmlinux support
  2008-08-27  5:40       ` Simon Horman
@ 2008-08-27  6:55         ` Magnus Damm
  2008-08-27  7:35           ` Simon Horman
  0 siblings, 1 reply; 13+ messages in thread
From: Magnus Damm @ 2008-08-27  6:55 UTC (permalink / raw)
  To: Simon Horman; +Cc: kexec

On Wed, Aug 27, 2008 at 2:40 PM, Simon Horman <horms@verge.net.au> wrote:
> On Wed, Aug 27, 2008 at 01:10:30PM +0900, Magnus Damm wrote:
>> Hi Simon,
>>
>> On Wed, Aug 27, 2008 at 11:39 AM, Simon Horman <horms@verge.net.au> wrote:
>> > On Tue, Aug 26, 2008 at 08:12:32PM +0900, Magnus Damm wrote:
>> >> From: Magnus Damm <damm@igel.co.jp>
>> >>
>> >> Add SuperH vmlinux support through a zero-page aware elf loader. Only for
>> >> kexec at this point, in the future kdump support will be added.
>> >
>> > If these series of patches are fine by you then they are fine by me.
>> > I just have a few minor issues with this last patch.
>>
>> How does the attached patch look?
>>
>> Thanks for your help!
>
> Much better :-)
>
> Should I just fold it into the last patch and push ?

Yes, that would be great! Thanks! =)

/ magnus

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

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

* Re: [PATCH 00/06] sh: Improved kexec support for SuperH
  2008-08-26 11:11 [PATCH 00/06] sh: Improved kexec support for SuperH Magnus Damm
                   ` (5 preceding siblings ...)
  2008-08-26 11:12 ` [PATCH 06/06] sh: Add vmlinux support Magnus Damm
@ 2008-08-27  7:05 ` Paul Mundt
  6 siblings, 0 replies; 13+ messages in thread
From: Paul Mundt @ 2008-08-27  7:05 UTC (permalink / raw)
  To: Magnus Damm; +Cc: horms, kexec

On Tue, Aug 26, 2008 at 08:11:50PM +0900, Magnus Damm wrote:
> Here comes a few SuperH related patches. Trivial stuff - fixing up plain
> kexec support. Kdump is not ready yet. I also have have a few kdump changes
> in my local tree but they need more work.
> 
> [PATCH 01/06] sh: Add support for sh4al-dsp processors
> [PATCH 02/06] sh: Get system memory ranges from /proc/iomem
> [PATCH 03/06] sh: Add virtual addresses support
> [PATCH 04/06] sh: Autodetect zImage zero page address
> [PATCH 05/06] sh: Use dynamic zImage load address
> [PATCH 06/06] sh: Add vmlinux support
> 
> Tested with 2.6.27-rc on SuperH Mobile processor models sh7722/sh7723.
> 
> Signed-off-by: Magnus Damm <damm@igel.co.jp>

FWIW:

Acked-by: Paul Mundt <lethal@linux-sh.org>

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

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

* Re: [PATCH 06/06] sh: Add vmlinux support
  2008-08-27  6:55         ` Magnus Damm
@ 2008-08-27  7:35           ` Simon Horman
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Horman @ 2008-08-27  7:35 UTC (permalink / raw)
  To: Magnus Damm; +Cc: Paul Mundt, kexec

On Wed, Aug 27, 2008 at 03:55:00PM +0900, Magnus Damm wrote:
> On Wed, Aug 27, 2008 at 2:40 PM, Simon Horman <horms@verge.net.au> wrote:
> > On Wed, Aug 27, 2008 at 01:10:30PM +0900, Magnus Damm wrote:
> >> Hi Simon,
> >>
> >> On Wed, Aug 27, 2008 at 11:39 AM, Simon Horman <horms@verge.net.au> wrote:
> >> > On Tue, Aug 26, 2008 at 08:12:32PM +0900, Magnus Damm wrote:
> >> >> From: Magnus Damm <damm@igel.co.jp>
> >> >>
> >> >> Add SuperH vmlinux support through a zero-page aware elf loader. Only for
> >> >> kexec at this point, in the future kdump support will be added.
> >> >
> >> > If these series of patches are fine by you then they are fine by me.
> >> > I just have a few minor issues with this last patch.
> >>
> >> How does the attached patch look?
> >>
> >> Thanks for your help!
> >
> > Much better :-)
> >
> > Should I just fold it into the last patch and push ?
> 
> Yes, that would be great! Thanks! =)

Great. I've pushed the patches and included Paul's ack.

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

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

end of thread, other threads:[~2008-08-27  7:35 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-26 11:11 [PATCH 00/06] sh: Improved kexec support for SuperH Magnus Damm
2008-08-26 11:11 ` [PATCH 01/06] sh: Add support for sh4al-dsp processors Magnus Damm
2008-08-26 11:12 ` [PATCH 02/06] sh: Get system memory ranges from /proc/iomem Magnus Damm
2008-08-26 11:12 ` [PATCH 03/06] sh: Add virtual addresses support Magnus Damm
2008-08-26 11:12 ` [PATCH 04/06] sh: Autodetect zImage zero page address Magnus Damm
2008-08-26 11:12 ` [PATCH 05/06] sh: Use dynamic zImage load address Magnus Damm
2008-08-26 11:12 ` [PATCH 06/06] sh: Add vmlinux support Magnus Damm
2008-08-27  2:39   ` Simon Horman
2008-08-27  4:10     ` Magnus Damm
2008-08-27  5:40       ` Simon Horman
2008-08-27  6:55         ` Magnus Damm
2008-08-27  7:35           ` Simon Horman
2008-08-27  7:05 ` [PATCH 00/06] sh: Improved kexec support for SuperH Paul Mundt

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.