All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Two patches for kexec for arm
@ 2014-03-20  2:36 Wang Nan
  2014-03-20  2:36 ` [PATCH 1/2] kexec: align initrd when no --image-size passed Wang Nan
  2014-03-20  2:36 ` [PATCH 2/2] kexec: pass initrd position in dtb Wang Nan
  0 siblings, 2 replies; 10+ messages in thread
From: Wang Nan @ 2014-03-20  2:36 UTC (permalink / raw)
  To: dyoung; +Cc: Wang Nan, Simon Horman, kexec, Geng Hui

Hi Dave and Simon,

   Sorry for the long delay. We have discussed kexec on arm at January
   this year:
   http://lists.infradead.org/pipermail/kexec/2014-February/011031.html

   I rewrite 2 patches and tested on QEMU, both crash dump and normal
   kexec is okay (kernel is 3.10.33). Please check.

   The first patch makes initrd to be loaded at page boundary.

   The second patch passes kernel command line and initrd infomation
   through dtb.

   Without these two patches kexec, failed to work on arm.

   I tested using following commands:

Start qemu:
$ qemu-system-arm -kernel $KERNEL_PATH -M versatilepb -initrd $INITRD_PATH \
       -no-reboot -show-cursor  -vnc 0.0.0.0:0 -machine type=vexpress-a9 \
       -cpu cortex-a9 -m 512  --append "console=ttyAMA0 \
       ip=192.168.7.2::192.168.7.1:255.255.255.0 mem=512M highres=off \
       rdinit=/sbin/init crashkernel=72M@0x70000000" -serial stdio


Crash dump case:
$ kexec -p /zImage -d -t zImage --dtb=/vexpress-v2p-ca9-512m.dtb \
        --initrd=/initrd.cpio.gz \
	--command-line="maxcpus=1 console=ttyAMA0 highres=off \
	rdinit=/sbin/init"
$ echo c > /proc/sysrq-trigger


kexec case:
$ kexec -f /zImage -d -t zImage --dtb=/vexpress-v2p-ca9-512m.dtb \
        --initrd=initrd.cpio.gz --command-line="maxcpus=1 console=ttyAMA0 \
        highres=off rdinit=/sbin/init"


Kernel configuration is based on arch/arm/configs/vexpress_defconfig,
with CONFIG_KEXEC selected.

Because we use only 512m memory, related dtb must be modified (in crash
dump case, it is no problem because memory size is clamped by command
line, but it is essential in normal kexec case). I haven't
check atags.

vexpress-v2p-ca9-512m.dtb is generated by
arch/arm/boot/dts/vexpress-v2p-ca9.dts with following patch:

--- vexpress-v2p-ca9.dts	2014-02-25 13:06:34.000000000 +0800
+++ vexpress-v2p-ca9-512m.dts	2014-03-19 17:14:40.000000000 +0800
@@ -64,7 +64,7 @@
 
 	memory@60000000 {
 		device_type = "memory";
-		reg = <0x60000000 0x40000000>;
+		reg = <0x60000000 0x20000000>;
 	};
 
 	clcd@10020000 {

WangNan (2):
  kexec: align initrd when no --image-size passed
  kexec: pass initrd position in dtb

 kexec/arch/arm/kexec-zImage-arm.c | 88 +++++++++++++++++++++++++++------------
 1 file changed, 61 insertions(+), 27 deletions(-)

-- 
1.8.4


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

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

* [PATCH 1/2] kexec: align initrd when no --image-size passed
  2014-03-20  2:36 [PATCH 0/2] Two patches for kexec for arm Wang Nan
@ 2014-03-20  2:36 ` Wang Nan
  2014-03-20  3:25   ` Dave Young
  2014-03-20  2:36 ` [PATCH 2/2] kexec: pass initrd position in dtb Wang Nan
  1 sibling, 1 reply; 10+ messages in thread
From: Wang Nan @ 2014-03-20  2:36 UTC (permalink / raw)
  To: dyoung; +Cc: Wang Nan, Simon Horman, kexec, Geng Hui

Before this patch, when no --image-size passed, initrd_base is caculated using
base + len * 4, which is unaligned, and unable to pass check in
add_segment_phys_virt():

	if (base & (pagesize -1)) {
		die("Base address: 0x%lx is not page aligned\n", base);
	}

This patch also uses getpagesize() instead of hard encoded 4096.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Simon Horman <horms@verge.net.au>
Cc: Dave Young <dyoung@redhat.com>
Cc: Geng Hui <hui.geng@huawei.com>
---
 kexec/arch/arm/kexec-zImage-arm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index 792187a..8a35018 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -347,11 +347,11 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 		/* If the image size was passed as command line argument,
 		 * use that value for determining the address for initrd,
 		 * atags and dtb images. page-align the given length.*/
-		initrd_base = base + _ALIGN(kexec_arm_image_size, 4096);
+		initrd_base = base + _ALIGN(kexec_arm_image_size, getpagesize());
 	} else {
 		/* Otherwise, assume the maximum kernel compression ratio
 		 * is 4, and just to be safe, place ramdisk after that */
-		initrd_base = base + len * 4;
+		initrd_base = base + _ALIGN(len * 4, getpagesize());
 	}
 
 	if (use_atags) {
-- 
1.8.4


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

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

* [PATCH 2/2] kexec: pass initrd position in dtb
  2014-03-20  2:36 [PATCH 0/2] Two patches for kexec for arm Wang Nan
  2014-03-20  2:36 ` [PATCH 1/2] kexec: align initrd when no --image-size passed Wang Nan
@ 2014-03-20  2:36 ` Wang Nan
  2014-03-20  3:26   ` Dave Young
  1 sibling, 1 reply; 10+ messages in thread
From: Wang Nan @ 2014-03-20  2:36 UTC (permalink / raw)
  To: dyoung; +Cc: Wang Nan, Simon Horman, kexec, Geng Hui

This patch append the position of initrd to dtb when loading arm kernel
and initrd without using atag.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Simon Horman <horms@verge.net.au>
Cc: Dave Young <dyoung@redhat.com>
Cc: Geng Hui <hui.geng@huawei.com>
---
 kexec/arch/arm/kexec-zImage-arm.c | 84 +++++++++++++++++++++++++++------------
 1 file changed, 59 insertions(+), 25 deletions(-)

diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index 8a35018..15d8829 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -20,6 +20,7 @@
 #include "kexec-arm.h"
 #include "../../fs2dt.h"
 #include "crashdump-arm.h"
+#include "libfdt_internal.h"
 
 #define BOOT_PARAMS_SIZE 1536
 
@@ -216,6 +217,47 @@ int atag_arm_load(struct kexec_info *info, unsigned long base,
 	return 0;
 }
 
+static int setup_dtb_prop(char **bufp, off_t *sizep, const char *node_name,
+		const char *prop_name, const void *val, int len)
+{
+	char *dtb_buf;
+	int off;
+
+	if ((bufp == NULL) || (sizep == NULL) || (*bufp == NULL))
+		die("Internal error\n");
+
+	dtb_buf = *bufp;
+
+	*sizep = fdt_totalsize(*bufp) + FDT_TAGSIZE + len +
+		FDT_TAGALIGN(strlen(node_name) + 1) +
+		FDT_TAGALIGN(strlen(prop_name) + 1) +
+		sizeof(struct fdt_property);
+
+	dtb_buf = xrealloc(dtb_buf, *sizep);
+	if (dtb_buf == NULL)
+		die("xrealloc failed\n");
+	*bufp = dtb_buf;
+
+	fdt_set_totalsize(dtb_buf, *sizep);
+
+	/* check if the subnode already exists */
+	off = fdt_path_offset(dtb_buf, node_name);
+
+	if (off == -FDT_ERR_NOTFOUND)
+		off = fdt_add_subnode(dtb_buf, off, node_name);
+	if (off < 0) {
+		fprintf(stderr, "FDT: Error adding %s node.\n", node_name);
+		return -1;
+	}
+	if (fdt_setprop(dtb_buf, off, prop_name,
+				val, len) != 0) {
+		fprintf(stderr, "FDT: Error setting %s/%s property.\n",
+				node_name, prop_name);
+		return -1;
+	}
+	return 0;
+}
+
 int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 	struct kexec_info *info)
 {
@@ -375,32 +417,11 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 			}
 
 			if (command_line) {
-				const char *node_name = "/chosen";
-				const char *prop_name = "bootargs";
-				int off;
-
-				dtb_length = fdt_totalsize(dtb_buf) + 1024 +
-					strlen(command_line);
-				dtb_buf = xrealloc(dtb_buf, dtb_length);
-				fdt_set_totalsize(dtb_buf, dtb_length);
-
-				/* check if a /choosen subnode already exists */
-				off = fdt_path_offset(dtb_buf, node_name);
-
-				if (off == -FDT_ERR_NOTFOUND)
-					off = fdt_add_subnode(dtb_buf, off, node_name);
-
-				if (off < 0) {
-					fprintf(stderr, "FDT: Error adding %s node.\n", node_name);
+				/* Error should have been reported */
+				if (setup_dtb_prop(&dtb_buf, &dtb_length, "/chosen",
+						"bootargs", command_line,
+						strlen(command_line) + 1))
 					return -1;
-				}
-
-				if (fdt_setprop(dtb_buf, off, prop_name,
-						command_line, strlen(command_line) + 1) != 0) {
-					fprintf(stderr, "FDT: Error setting %s/%s property.\n",
-						node_name, prop_name);
-					return -1;
-				}
 			}
 		} else {
 			/*
@@ -417,6 +438,19 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 		if (ramdisk) {
 			add_segment(info, ramdisk_buf, initrd_size,
 			            initrd_base, initrd_size);
+
+			unsigned long start, end;
+			start = cpu_to_be32((unsigned long)(initrd_base));
+			end = cpu_to_be32((unsigned long)(initrd_base + initrd_size));
+
+			if (setup_dtb_prop(&dtb_buf, &dtb_length, "/chosen",
+					"linux,initrd-start", &start,
+					sizeof(start)))
+				return -1;
+			if (setup_dtb_prop(&dtb_buf, &dtb_length, "/chosen",
+					"linux,initrd-end", &end,
+					sizeof(end)))
+				return -1;
 		}
 
 		/* Stick the dtb at the end of the initrd and page
-- 
1.8.4


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

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

* Re: [PATCH 1/2] kexec: align initrd when no --image-size passed
  2014-03-20  2:36 ` [PATCH 1/2] kexec: align initrd when no --image-size passed Wang Nan
@ 2014-03-20  3:25   ` Dave Young
  2014-03-20  3:51     ` Simon Horman
  0 siblings, 1 reply; 10+ messages in thread
From: Dave Young @ 2014-03-20  3:25 UTC (permalink / raw)
  To: Wang Nan; +Cc: Simon Horman, kexec, Geng Hui

On 03/20/14 at 10:36am, Wang Nan wrote:
> Before this patch, when no --image-size passed, initrd_base is caculated using
> base + len * 4, which is unaligned, and unable to pass check in
> add_segment_phys_virt():
> 
> 	if (base & (pagesize -1)) {
> 		die("Base address: 0x%lx is not page aligned\n", base);
> 	}
> 
> This patch also uses getpagesize() instead of hard encoded 4096.
> 
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Dave Young <dyoung@redhat.com>
> Cc: Geng Hui <hui.geng@huawei.com>
> ---
>  kexec/arch/arm/kexec-zImage-arm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
> index 792187a..8a35018 100644
> --- a/kexec/arch/arm/kexec-zImage-arm.c
> +++ b/kexec/arch/arm/kexec-zImage-arm.c
> @@ -347,11 +347,11 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
>  		/* If the image size was passed as command line argument,
>  		 * use that value for determining the address for initrd,
>  		 * atags and dtb images. page-align the given length.*/
> -		initrd_base = base + _ALIGN(kexec_arm_image_size, 4096);
> +		initrd_base = base + _ALIGN(kexec_arm_image_size, getpagesize());
>  	} else {
>  		/* Otherwise, assume the maximum kernel compression ratio
>  		 * is 4, and just to be safe, place ramdisk after that */
> -		initrd_base = base + len * 4;
> +		initrd_base = base + _ALIGN(len * 4, getpagesize());
>  	}
>  
>  	if (use_atags) {
> -- 
> 1.8.4
> 

Acked-by: Dave Young <dyoung@redhat.com>

Thanks
Dave

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

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

* Re: [PATCH 2/2] kexec: pass initrd position in dtb
  2014-03-20  2:36 ` [PATCH 2/2] kexec: pass initrd position in dtb Wang Nan
@ 2014-03-20  3:26   ` Dave Young
  2014-03-20  3:34     ` Dave Young
  0 siblings, 1 reply; 10+ messages in thread
From: Dave Young @ 2014-03-20  3:26 UTC (permalink / raw)
  To: Wang Nan; +Cc: Simon Horman, kexec, Geng Hui

On 03/20/14 at 10:36am, Wang Nan wrote:
> This patch append the position of initrd to dtb when loading arm kernel
> and initrd without using atag.
> 
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Dave Young <dyoung@redhat.com>
> Cc: Geng Hui <hui.geng@huawei.com>
> ---
>  kexec/arch/arm/kexec-zImage-arm.c | 84 +++++++++++++++++++++++++++------------
>  1 file changed, 59 insertions(+), 25 deletions(-)
> 
> diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
> index 8a35018..15d8829 100644
> --- a/kexec/arch/arm/kexec-zImage-arm.c
> +++ b/kexec/arch/arm/kexec-zImage-arm.c
> @@ -20,6 +20,7 @@
>  #include "kexec-arm.h"
>  #include "../../fs2dt.h"
>  #include "crashdump-arm.h"
> +#include "libfdt_internal.h"

I guess it's for the FDT_TAGALIGN and FDT_TAGSIZE?
libfdt_internal.h should be used as internal header for libfdt, a better way is
adding another patch which move these 2 macros to fdt.h

Otherwise I'm fine with this patch.

Thanks
Dave

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

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

* Re: [PATCH 2/2] kexec: pass initrd position in dtb
  2014-03-20  3:26   ` Dave Young
@ 2014-03-20  3:34     ` Dave Young
  2014-03-20  3:57       ` Wang Nan
  0 siblings, 1 reply; 10+ messages in thread
From: Dave Young @ 2014-03-20  3:34 UTC (permalink / raw)
  To: Wang Nan; +Cc: Simon Horman, kexec, Geng Hui

On 03/20/14 at 11:26am, Dave Young wrote:
> On 03/20/14 at 10:36am, Wang Nan wrote:
> > This patch append the position of initrd to dtb when loading arm kernel
> > and initrd without using atag.
> > 
> > Signed-off-by: Wang Nan <wangnan0@huawei.com>
> > Cc: Simon Horman <horms@verge.net.au>
> > Cc: Dave Young <dyoung@redhat.com>
> > Cc: Geng Hui <hui.geng@huawei.com>
> > ---
> >  kexec/arch/arm/kexec-zImage-arm.c | 84 +++++++++++++++++++++++++++------------
> >  1 file changed, 59 insertions(+), 25 deletions(-)
> > 
> > diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
> > index 8a35018..15d8829 100644
> > --- a/kexec/arch/arm/kexec-zImage-arm.c
> > +++ b/kexec/arch/arm/kexec-zImage-arm.c
> > @@ -20,6 +20,7 @@
> >  #include "kexec-arm.h"
> >  #include "../../fs2dt.h"
> >  #include "crashdump-arm.h"
> > +#include "libfdt_internal.h"
> 
> I guess it's for the FDT_TAGALIGN and FDT_TAGSIZE?
> libfdt_internal.h should be used as internal header for libfdt, a better way is
> adding another patch which move these 2 macros to fdt.h

Or moving your new function setup_dtb_prop to libfdt, I'm not sure if it works on
other arch though.

> Thanks
> Dave

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

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

* Re: [PATCH 1/2] kexec: align initrd when no --image-size passed
  2014-03-20  3:25   ` Dave Young
@ 2014-03-20  3:51     ` Simon Horman
  0 siblings, 0 replies; 10+ messages in thread
From: Simon Horman @ 2014-03-20  3:51 UTC (permalink / raw)
  To: Dave Young; +Cc: Wang Nan, kexec, Geng Hui

On Thu, Mar 20, 2014 at 11:25:07AM +0800, Dave Young wrote:
> On 03/20/14 at 10:36am, Wang Nan wrote:
> > Before this patch, when no --image-size passed, initrd_base is caculated using
> > base + len * 4, which is unaligned, and unable to pass check in
> > add_segment_phys_virt():
> > 
> > 	if (base & (pagesize -1)) {
> > 		die("Base address: 0x%lx is not page aligned\n", base);
> > 	}
> > 
> > This patch also uses getpagesize() instead of hard encoded 4096.
> > 
> > Signed-off-by: Wang Nan <wangnan0@huawei.com>
> > Cc: Simon Horman <horms@verge.net.au>
> > Cc: Dave Young <dyoung@redhat.com>
> > Cc: Geng Hui <hui.geng@huawei.com>
> > ---
> >  kexec/arch/arm/kexec-zImage-arm.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
> > index 792187a..8a35018 100644
> > --- a/kexec/arch/arm/kexec-zImage-arm.c
> > +++ b/kexec/arch/arm/kexec-zImage-arm.c
> > @@ -347,11 +347,11 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
> >  		/* If the image size was passed as command line argument,
> >  		 * use that value for determining the address for initrd,
> >  		 * atags and dtb images. page-align the given length.*/
> > -		initrd_base = base + _ALIGN(kexec_arm_image_size, 4096);
> > +		initrd_base = base + _ALIGN(kexec_arm_image_size, getpagesize());
> >  	} else {
> >  		/* Otherwise, assume the maximum kernel compression ratio
> >  		 * is 4, and just to be safe, place ramdisk after that */
> > -		initrd_base = base + len * 4;
> > +		initrd_base = base + _ALIGN(len * 4, getpagesize());
> >  	}
> >  
> >  	if (use_atags) {
> > -- 
> > 1.8.4
> > 
> 
> Acked-by: Dave Young <dyoung@redhat.com>

Thanks, applied.

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

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

* Re: [PATCH 2/2] kexec: pass initrd position in dtb
  2014-03-20  3:34     ` Dave Young
@ 2014-03-20  3:57       ` Wang Nan
  2014-03-20  5:37         ` Dave Young
  2014-03-20  5:41         ` Dave Young
  0 siblings, 2 replies; 10+ messages in thread
From: Wang Nan @ 2014-03-20  3:57 UTC (permalink / raw)
  To: Dave Young; +Cc: Simon Horman, kexec, Geng Hui

On 2014/3/20 11:34, Dave Young wrote:
> On 03/20/14 at 11:26am, Dave Young wrote:
>> On 03/20/14 at 10:36am, Wang Nan wrote:
>>> This patch append the position of initrd to dtb when loading arm kernel
>>> and initrd without using atag.
>>>
>>> Signed-off-by: Wang Nan <wangnan0@huawei.com>
>>> Cc: Simon Horman <horms@verge.net.au>
>>> Cc: Dave Young <dyoung@redhat.com>
>>> Cc: Geng Hui <hui.geng@huawei.com>
>>> ---
>>>  kexec/arch/arm/kexec-zImage-arm.c | 84 +++++++++++++++++++++++++++------------
>>>  1 file changed, 59 insertions(+), 25 deletions(-)
>>>
>>> diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
>>> index 8a35018..15d8829 100644
>>> --- a/kexec/arch/arm/kexec-zImage-arm.c
>>> +++ b/kexec/arch/arm/kexec-zImage-arm.c
>>> @@ -20,6 +20,7 @@
>>>  #include "kexec-arm.h"
>>>  #include "../../fs2dt.h"
>>>  #include "crashdump-arm.h"
>>> +#include "libfdt_internal.h"
>>
>> I guess it's for the FDT_TAGALIGN and FDT_TAGSIZE?
>> libfdt_internal.h should be used as internal header for libfdt, a better way is
>> adding another patch which move these 2 macros to fdt.h
> 
> Or moving your new function setup_dtb_prop to libfdt, I'm not sure if it works on
> other arch though.
> 
>> Thanks
>> Dave


What about following midification (FDT_TAGSIZE is in fdt.h)?
I'll send it formally if you agree this one.

diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index 15d8829..1cd4ed0 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -20,7 +20,6 @@
 #include "kexec-arm.h"
 #include "../../fs2dt.h"
 #include "crashdump-arm.h"
-#include "libfdt_internal.h"

 #define BOOT_PARAMS_SIZE 1536

@@ -229,8 +228,8 @@ static int setup_dtb_prop(char **bufp, off_t *sizep, const char *node_name,
        dtb_buf = *bufp;

        *sizep = fdt_totalsize(*bufp) + FDT_TAGSIZE + len +
-               FDT_TAGALIGN(strlen(node_name) + 1) +
-               FDT_TAGALIGN(strlen(prop_name) + 1) +
+               _ALIGN(strlen(node_name) + 1, FDT_TAGSIZE) +
+               _ALIGN(strlen(prop_name) + 1, FDT_TAGSIZE) +
                sizeof(struct fdt_property);

        dtb_buf = xrealloc(dtb_buf, *sizep);


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

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

* Re: [PATCH 2/2] kexec: pass initrd position in dtb
  2014-03-20  3:57       ` Wang Nan
@ 2014-03-20  5:37         ` Dave Young
  2014-03-20  5:41         ` Dave Young
  1 sibling, 0 replies; 10+ messages in thread
From: Dave Young @ 2014-03-20  5:37 UTC (permalink / raw)
  To: Wang Nan; +Cc: Simon Horman, kexec, Geng Hui

On 03/20/14 at 11:57am, Wang Nan wrote:
> On 2014/3/20 11:34, Dave Young wrote:
> > On 03/20/14 at 11:26am, Dave Young wrote:
> >> On 03/20/14 at 10:36am, Wang Nan wrote:
> >>> This patch append the position of initrd to dtb when loading arm kernel
> >>> and initrd without using atag.
> >>>
> >>> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> >>> Cc: Simon Horman <horms@verge.net.au>
> >>> Cc: Dave Young <dyoung@redhat.com>
> >>> Cc: Geng Hui <hui.geng@huawei.com>
> >>> ---
> >>>  kexec/arch/arm/kexec-zImage-arm.c | 84 +++++++++++++++++++++++++++------------
> >>>  1 file changed, 59 insertions(+), 25 deletions(-)
> >>>
> >>> diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
> >>> index 8a35018..15d8829 100644
> >>> --- a/kexec/arch/arm/kexec-zImage-arm.c
> >>> +++ b/kexec/arch/arm/kexec-zImage-arm.c
> >>> @@ -20,6 +20,7 @@
> >>>  #include "kexec-arm.h"
> >>>  #include "../../fs2dt.h"
> >>>  #include "crashdump-arm.h"
> >>> +#include "libfdt_internal.h"
> >>
> >> I guess it's for the FDT_TAGALIGN and FDT_TAGSIZE?
> >> libfdt_internal.h should be used as internal header for libfdt, a better way is
> >> adding another patch which move these 2 macros to fdt.h
> > 
> > Or moving your new function setup_dtb_prop to libfdt, I'm not sure if it works on
> > other arch though.
> > 
> >> Thanks
> >> Dave
> 
> 
> What about following midification (FDT_TAGSIZE is in fdt.h)?
> I'll send it formally if you agree this one.
> 
> diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
> index 15d8829..1cd4ed0 100644
> --- a/kexec/arch/arm/kexec-zImage-arm.c
> +++ b/kexec/arch/arm/kexec-zImage-arm.c
> @@ -20,7 +20,6 @@
>  #include "kexec-arm.h"
>  #include "../../fs2dt.h"
>  #include "crashdump-arm.h"
> -#include "libfdt_internal.h"
> 
>  #define BOOT_PARAMS_SIZE 1536
> 
> @@ -229,8 +228,8 @@ static int setup_dtb_prop(char **bufp, off_t *sizep, const char *node_name,
>         dtb_buf = *bufp;
> 
>         *sizep = fdt_totalsize(*bufp) + FDT_TAGSIZE + len +
> -               FDT_TAGALIGN(strlen(node_name) + 1) +
> -               FDT_TAGALIGN(strlen(prop_name) + 1) +
> +               _ALIGN(strlen(node_name) + 1, FDT_TAGSIZE) +
> +               _ALIGN(strlen(prop_name) + 1, FDT_TAGSIZE) +
>                 sizeof(struct fdt_property);
> 
>         dtb_buf = xrealloc(dtb_buf, *sizep);
> 

Looks good...

Thanks
Dave

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

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

* Re: [PATCH 2/2] kexec: pass initrd position in dtb
  2014-03-20  3:57       ` Wang Nan
  2014-03-20  5:37         ` Dave Young
@ 2014-03-20  5:41         ` Dave Young
  1 sibling, 0 replies; 10+ messages in thread
From: Dave Young @ 2014-03-20  5:41 UTC (permalink / raw)
  To: Wang Nan; +Cc: Simon Horman, kexec, Geng Hui

On 03/20/14 at 11:57am, Wang Nan wrote:
> On 2014/3/20 11:34, Dave Young wrote:
> > On 03/20/14 at 11:26am, Dave Young wrote:
> >> On 03/20/14 at 10:36am, Wang Nan wrote:
> >>> This patch append the position of initrd to dtb when loading arm kernel
> >>> and initrd without using atag.
> >>>
> >>> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> >>> Cc: Simon Horman <horms@verge.net.au>
> >>> Cc: Dave Young <dyoung@redhat.com>
> >>> Cc: Geng Hui <hui.geng@huawei.com>
> >>> ---
> >>>  kexec/arch/arm/kexec-zImage-arm.c | 84 +++++++++++++++++++++++++++------------
> >>>  1 file changed, 59 insertions(+), 25 deletions(-)
> >>>
> >>> diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
> >>> index 8a35018..15d8829 100644
> >>> --- a/kexec/arch/arm/kexec-zImage-arm.c
> >>> +++ b/kexec/arch/arm/kexec-zImage-arm.c
> >>> @@ -20,6 +20,7 @@
> >>>  #include "kexec-arm.h"
> >>>  #include "../../fs2dt.h"
> >>>  #include "crashdump-arm.h"
> >>> +#include "libfdt_internal.h"
> >>
> >> I guess it's for the FDT_TAGALIGN and FDT_TAGSIZE?
> >> libfdt_internal.h should be used as internal header for libfdt, a better way is
> >> adding another patch which move these 2 macros to fdt.h
> > 
> > Or moving your new function setup_dtb_prop to libfdt, I'm not sure if it works on
> > other arch though.
> > 
> >> Thanks
> >> Dave
> 
> 
> What about following midification (FDT_TAGSIZE is in fdt.h)?
> I'll send it formally if you agree this one.

Another problem is this patch is doing 2 things:
  * add a new function and use it for cmdline prop
  * append initrd prop

So please split it to 2 patches.

Thanks
Dave

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

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

end of thread, other threads:[~2014-03-20  6:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-20  2:36 [PATCH 0/2] Two patches for kexec for arm Wang Nan
2014-03-20  2:36 ` [PATCH 1/2] kexec: align initrd when no --image-size passed Wang Nan
2014-03-20  3:25   ` Dave Young
2014-03-20  3:51     ` Simon Horman
2014-03-20  2:36 ` [PATCH 2/2] kexec: pass initrd position in dtb Wang Nan
2014-03-20  3:26   ` Dave Young
2014-03-20  3:34     ` Dave Young
2014-03-20  3:57       ` Wang Nan
2014-03-20  5:37         ` Dave Young
2014-03-20  5:41         ` Dave Young

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.