public inbox for kexec@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] kexec-zImage-arm: simply cmdline-related DTB resizing
@ 2012-12-19 23:19 Stephen Warren
  2012-12-20  2:01 ` Daniel Mack
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Warren @ 2012-12-19 23:19 UTC (permalink / raw)
  To: Eric Biederman; +Cc: Stephen Warren, kexec, Daniel Mack

From: Stephen Warren <swarren@nvidia.com>

When resizing a dtb to add the command-line, only resize the DTB once,
rather than once to add the /chosen node, and once to add the bootargs
property.

Also, simply add 1K of overhead (beyond strlen(cmdline)) to the buffer,
to avoid requiring precise knowledge of the size impact of the requested
FTB changes. In particular, some padding is performed when setting
property values, which was not accounted for in the current code, which
caused failures to set the bootargs values in some cases.

Cc: Daniel Mack <zonque@gmail.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 kexec/arch/arm/kexec-zImage-arm.c |   21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index 0950897..db29a7b 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -370,31 +370,22 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 				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) {
-					dtb_length = fdt_totalsize(dtb_buf)
-							+ strlen(node_name) + 1
-							+ sizeof(struct fdt_node_header)
-							+ FDT_TAGSIZE;
-					dtb_buf = xrealloc(dtb_buf, dtb_length);
-					fdt_set_totalsize(dtb_buf, dtb_length);
+				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;
 				}
 
-				dtb_length = fdt_totalsize(dtb_buf)
-						+ strlen(prop_name)
-						+ strlen(command_line) + 1
-						+ sizeof(struct fdt_property);
-				dtb_buf = xrealloc(dtb_buf, dtb_length);
-				fdt_set_totalsize(dtb_buf, dtb_length);
-
 				if (fdt_setprop(dtb_buf, off, prop_name,
 						command_line, strlen(command_line) + 1) != 0) {
 					fprintf(stderr, "FDT: Error setting %s/%s property.\n",
-- 
1.7.10.4


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

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

end of thread, other threads:[~2012-12-23  7:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-19 23:19 [PATCH] kexec-zImage-arm: simply cmdline-related DTB resizing Stephen Warren
2012-12-20  2:01 ` Daniel Mack
2012-12-23  7:14   ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox