[PATCH 2/3] ARM: Use armlinux_bootparams address for DTB

Alexander Shiyan shc_work at mail.ru
Wed Jul 10 03:00:40 EDT 2013


In some cases, the address of the devicetree, which is obtained
dynamically, may be located in the kernel text area, which leads
to overwrite devicetree by kernel. The patch uses the address for
devicetree, provided by board, if it possible.

Signed-off-by: Alexander Shiyan <shc_work at mail.ru>
---
 arch/arm/lib/armlinux.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/arch/arm/lib/armlinux.c b/arch/arm/lib/armlinux.c
index 84372af..4aa3414 100644
--- a/arch/arm/lib/armlinux.c
+++ b/arch/arm/lib/armlinux.c
@@ -262,17 +262,23 @@ void start_linux(void *adr, int swap, unsigned long initrd_address,
 		unsigned long initrd_size, void *oftree, int verbose)
 {
 	void (*kernel)(int zero, int arch, void *params) = adr;
-	void *params = NULL;
 	int architecture;
 
 	if (oftree) {
+		if (armlinux_bootparams) {
+			struct fdt_header *header = oftree;
+
+			memcpy(armlinux_bootparams, oftree,
+			       fdt32_to_cpu(header->totalsize));
+		} else
+			armlinux_bootparams = oftree;
+
 		if (verbose)
-			printf("booting Linux kernel with devicetree\n");
-		params = oftree;
-	} else {
+			printf("booting Linux kernel with devicetree at 0x%p\n",
+			       armlinux_bootparams);
+	} else
 		setup_tags(initrd_address, initrd_size, swap, verbose);
-		params = armlinux_bootparams;
-	}
+
 	architecture = armlinux_get_architecture();
 
 	shutdown_barebox();
@@ -290,10 +296,10 @@ void start_linux(void *adr, int swap, unsigned long initrd_address,
 		"mov r2, %1\n"
 		"bx %2\n"
 		:
-		: "r" (architecture), "r" (params), "r" (kernel)
+		: "r" (architecture), "r" (armlinux_bootparams), "r" (kernel)
 		: "r0", "r1", "r2"
 	);
 #else
-	kernel(0, architecture, params);
+	kernel(0, architecture, armlinux_bootparams);
 #endif
 }
-- 
1.8.1.5




More information about the barebox mailing list