linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility
@ 2011-09-14  5:41 Nicolas Pitre
  2011-09-14  5:41 ` [PATCH 1/6] ARM: zImage: ensure it is always a multiple of 64 bits in size Nicolas Pitre
                   ` (9 more replies)
  0 siblings, 10 replies; 24+ messages in thread
From: Nicolas Pitre @ 2011-09-14  5:41 UTC (permalink / raw)
  To: linux-arm-kernel

This is the latest incarnation of my patch series allowing a DTB
to be appended to zImage, including the ATAG conversion wrapper and
other minor cleanups.

This can also be pulled from:

	git://git.linaro.org/people/nico/linux zImage_DTB_append

This works for me on the test setup I have.
ACKs/Tested-By's would be appreciated.  




Nicolas

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

* [PATCH 1/6] ARM: zImage: ensure it is always a multiple of 64 bits in size
  2011-09-14  5:41 [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility Nicolas Pitre
@ 2011-09-14  5:41 ` Nicolas Pitre
  2011-09-14  5:41 ` [PATCH 2/6] ARM: zImage: Allow the appending of a device tree binary Nicolas Pitre
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 24+ messages in thread
From: Nicolas Pitre @ 2011-09-14  5:41 UTC (permalink / raw)
  To: linux-arm-kernel

From: Nicolas Pitre <nicolas.pitre@linaro.org>

This is needed for proper alignment when the DTB appending feature
is used.

Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Acked-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/boot/compressed/vmlinux.lds.in |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/compressed/vmlinux.lds.in b/arch/arm/boot/compressed/vmlinux.lds.in
index 4e728834a1..4919f2ac8b 100644
--- a/arch/arm/boot/compressed/vmlinux.lds.in
+++ b/arch/arm/boot/compressed/vmlinux.lds.in
@@ -51,6 +51,10 @@ SECTIONS
   _got_start = .;
   .got			: { *(.got) }
   _got_end = .;
+
+  /* ensure the zImage file size is always a multiple of 64 bits */
+  /* (without a dummy byte, ld just ignores the empty section) */
+  .pad			: { BYTE(0); . = ALIGN(8); }
   _edata = .;
 
   . = BSS_START;
-- 
1.7.7-rc0

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

* [PATCH 2/6] ARM: zImage: Allow the appending of a device tree binary
  2011-09-14  5:41 [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility Nicolas Pitre
  2011-09-14  5:41 ` [PATCH 1/6] ARM: zImage: ensure it is always a multiple of 64 bits in size Nicolas Pitre
@ 2011-09-14  5:41 ` Nicolas Pitre
  2011-09-14 13:32   ` Dave Martin
  2011-09-14  5:41 ` [PATCH 3/6] ARM: zImage: make sure appended DTB doesn't get overwritten by kernel .bss Nicolas Pitre
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 24+ messages in thread
From: Nicolas Pitre @ 2011-09-14  5:41 UTC (permalink / raw)
  To: linux-arm-kernel

From: Nicolas Pitre <nicolas.pitre@linaro.org>

This patch provides the ability to boot using a device tree that is appended
to the raw binary zImage (e.g. cat zImage <filename>.dtb > zImage_w_dtb).

Signed-off-by: John Bonesio <bones@secretlab.ca>
[nico: adjusted to latest zImage changes plus additional cleanups]
Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/Kconfig                |    8 ++++
 arch/arm/boot/compressed/head.S |   70 +++++++++++++++++++++++++++++++++++++--
 2 files changed, 75 insertions(+), 3 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5ebc5d922e..83323c2b1f 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1781,6 +1781,14 @@ config ZBOOT_ROM_SH_MOBILE_SDHI
 
 endchoice
 
+config ARM_APPENDED_DTB
+	bool "Use appended device tree blob to zImage"
+	depends on OF && !ZBOOT_ROM
+	help
+	  With this option, the boot code will look for a device tree binary
+	  (dtb) appended to zImage
+	  (e.g. cat zImage <filename>.dtb > zImage_w_dtb).
+
 config CMDLINE
 	string "Default kernel command string"
 	default ""
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index e95a598960..3ce5738ddb 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -216,6 +216,59 @@ restart:	adr	r0, LC0
 		mov	r10, r6
 #endif
 
+		mov	r5, #0			@ init dtb size to 0
+#ifdef CONFIG_ARM_APPENDED_DTB
+/*
+ *   r0  = delta
+ *   r2  = BSS start
+ *   r3  = BSS end
+ *   r4  = final kernel address
+ *   r5  = appended dtb size (still unknown)
+ *   r6  = _edata
+ *   r7  = architecture ID
+ *   r8  = atags/device tree pointer
+ *   r9  = size of decompressed image
+ *   r10 = end of this image, including  bss/stack/malloc space if non XIP
+ *   r11 = GOT start
+ *   r12 = GOT end
+ *   sp  = stack pointer
+ *
+ * if there are device trees (dtb) appended to zImage, advance r10 so that the
+ * dtb data will get relocated along with the kernel if necessary.
+ */
+
+		ldr	lr, [r6, #0]
+#ifndef __ARMEB__
+		ldr	r1, =0xedfe0dd0		@ sig is 0xd00dfeed big endian
+#else
+		ldr	r1, =0xd00dfeed
+#endif
+		cmp	lr, r1
+		bne	dtb_check_done		@ not found
+
+		mov	r8, r6			@ use the appended device tree
+
+		/* Get the dtb's size */
+		ldr	r5, [r6, #4]
+#ifndef __ARMEB__
+		/* convert r5 (dtb size) to little endian */
+		eor	r1, r5, r5, ror #16
+		bic	r1, r1, #0x00ff0000
+		mov	r5, r5, ror #8
+		eor	r5, r5, r1, lsr #8
+#endif
+
+		/* preserve 64-bit alignment */
+		add	r5, r5, #7
+		bic	r5, r5, #7
+
+		/* relocate some pointers past the appended dtb */
+		add	r6, r6, r5
+		add	r10, r10, r5
+		add	sp, sp, r5
+dtb_check_done:
+#endif
+
 /*
  * Check to see if we will overwrite ourselves.
  *   r4  = final kernel address
@@ -285,14 +338,16 @@ wont_overwrite:
  *   r2  = BSS start
  *   r3  = BSS end
  *   r4  = kernel execution address
+ *   r5  = appended dtb size (0 if not present)
  *   r7  = architecture ID
  *   r8  = atags pointer
  *   r11 = GOT start
  *   r12 = GOT end
  *   sp  = stack pointer
  */
-		teq	r0, #0
+		orrs	r1, r0, r5
 		beq	not_relocated
+
 		add	r11, r11, r0
 		add	r12, r12, r0
 
@@ -307,12 +362,21 @@ wont_overwrite:
 
 		/*
 		 * Relocate all entries in the GOT table.
+		 * Bump bss entries to _edata + dtb size
 		 */
 1:		ldr	r1, [r11, #0]		@ relocate entries in the GOT
-		add	r1, r1, r0		@ table.  This fixes up the
-		str	r1, [r11], #4		@ C references.
+		add	r1, r1, r0		@ This fixes up C references
+		cmp	r1, r2			@ if entry >= bss_start &&
+		cmphs	r3, r1			@       bss_end > entry
+		addhi	r1, r1, r5		@    entry += dtb size
+		str	r1, [r11], #4		@ next entry
 		cmp	r11, r12
 		blo	1b
+
+		/* bump our bss pointers too */
+		add	r2, r2, r5
+		add	r3, r3, r5
+
 #else
 
 		/*
-- 
1.7.7-rc0

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

* [PATCH 3/6] ARM: zImage: make sure appended DTB doesn't get overwritten by kernel .bss
  2011-09-14  5:41 [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility Nicolas Pitre
  2011-09-14  5:41 ` [PATCH 1/6] ARM: zImage: ensure it is always a multiple of 64 bits in size Nicolas Pitre
  2011-09-14  5:41 ` [PATCH 2/6] ARM: zImage: Allow the appending of a device tree binary Nicolas Pitre
@ 2011-09-14  5:41 ` Nicolas Pitre
  2011-09-14  5:41 ` [PATCH 4/6] ARM: zImage: gather some string functions into string.c Nicolas Pitre
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 24+ messages in thread
From: Nicolas Pitre @ 2011-09-14  5:41 UTC (permalink / raw)
  To: linux-arm-kernel

From: Nicolas Pitre <nicolas.pitre@linaro.org>

The appended DTB gets relocated with the decompressor code to get out
of the way of the decompressed kernel.  However the kernel's .bss section
may be larger than the relocated code and data, and then the DTB gets
overwritten.  Let's make sure the relocation takes care of moving zImage
far enough so no such conflict with .bss occurs.

Thanks to Tony Lindgren <tony@atomide.com> for figuring out this issue.

While at it, let's clean up the code a bit so that the wont_overwrite
symbol is used while determining if a conflict exists, making the above
change more precise as well as eliminating some ARM/THUMB alternates.

Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Acked-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/boot/compressed/Makefile |    3 +++
 arch/arm/boot/compressed/head.S   |   19 +++++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index 0c74a6fab9..4867647b97 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -104,6 +104,9 @@ endif
 ccflags-y := -fpic -fno-builtin
 asflags-y := -Wa,-march=all
 
+# Supply kernel BSS size to the decompressor via a linker symbol.
+KBSS_SZ = $(shell size $(obj)/../../../../vmlinux | awk 'END{print $$3}')
+LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)
 # Supply ZRELADDR to the decompressor via a linker symbol.
 ifneq ($(CONFIG_AUTO_ZRELADDR),y)
 LDFLAGS_vmlinux += --defsym zreladdr=$(ZRELADDR)
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 3ce5738ddb..ba5c552f8c 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -248,6 +248,18 @@ restart:	adr	r0, LC0
 
 		mov	r8, r6			@ use the appended device tree
 
+		/*
+		 * Make sure that the DTB doesn't end up in the final
+		 * kernel's .bss area. To do so, we adjust the decompressed
+		 * kernel size to compensate if that .bss size is larger
+		 * than the relocated code.
+		 */
+		ldr	r5, =_kernel_bss_size
+		adr	r1, wont_overwrite
+		sub	r1, r6, r1
+		subs	r1, r5, r1
+		addhi	r9, r9, r1
+
 		/* Get the dtb's size */
 		ldr	r5, [r6, #4]
 #ifndef __ARMEB__
@@ -276,15 +288,14 @@ dtb_check_done:
  *   r10 = end of this image, including  bss/stack/malloc space if non XIP
  * We basically want:
  *   r4 - 16k page directory >= r10 -> OK
- *   r4 + image length <= current position (pc) -> OK
+ *   r4 + image length <= address of wont_overwrite -> OK
  */
 		add	r10, r10, #16384
 		cmp	r4, r10
 		bhs	wont_overwrite
 		add	r10, r4, r9
-   ARM(		cmp	r10, pc		)
- THUMB(		mov	lr, pc		)
- THUMB(		cmp	r10, lr		)
+		adr	r9, wont_overwrite
+		cmp	r10, r9
 		bls	wont_overwrite
 
 /*
-- 
1.7.7-rc0

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

* [PATCH 4/6] ARM: zImage: gather some string functions into string.c
  2011-09-14  5:41 [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility Nicolas Pitre
                   ` (2 preceding siblings ...)
  2011-09-14  5:41 ` [PATCH 3/6] ARM: zImage: make sure appended DTB doesn't get overwritten by kernel .bss Nicolas Pitre
@ 2011-09-14  5:41 ` Nicolas Pitre
  2011-09-14 13:13   ` Dave Martin
  2011-09-14  5:41 ` [PATCH 5/6] ARM: zImage: allow supplementing appended DTB with traditional ATAG data Nicolas Pitre
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 24+ messages in thread
From: Nicolas Pitre @ 2011-09-14  5:41 UTC (permalink / raw)
  To: linux-arm-kernel

From: Nicolas Pitre <nicolas.pitre@linaro.org>

This is a small subset of string functions needed by commits to come.
Except for memcpy() which is unchanged from its original location, their
implementation is meant to be small, and -Os is enforced to prevent gcc
from doing pointless loop unrolling.

Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
---
 arch/arm/boot/compressed/Makefile |    4 +
 arch/arm/boot/compressed/misc.c   |   42 +------------
 arch/arm/boot/compressed/string.c |  127 +++++++++++++++++++++++++++++++++++++
 3 files changed, 132 insertions(+), 41 deletions(-)
 create mode 100644 arch/arm/boot/compressed/string.c

diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index 4867647b97..c20ddc69d9 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -26,6 +26,10 @@ HEAD	= head.o
 OBJS	+= misc.o decompress.o
 FONTC	= $(srctree)/drivers/video/console/font_acorn_8x8.c
 
+# string library code (-Os is enforced to keep it much smaller)
+OBJS		+= string.o
+CFLAGS_string.o	:= -Os
+
 #
 # Architecture dependencies
 #
diff --git a/arch/arm/boot/compressed/misc.c b/arch/arm/boot/compressed/misc.c
index 832d37236c..8e2a8fca5e 100644
--- a/arch/arm/boot/compressed/misc.c
+++ b/arch/arm/boot/compressed/misc.c
@@ -18,14 +18,9 @@
 
 unsigned int __machine_arch_type;
 
-#define _LINUX_STRING_H_
-
 #include <linux/compiler.h>	/* for inline */
-#include <linux/types.h>	/* for size_t */
-#include <linux/stddef.h>	/* for NULL */
+#include <linux/types.h>
 #include <linux/linkage.h>
-#include <asm/string.h>
-
 
 static void putstr(const char *ptr);
 extern void error(char *x);
@@ -101,41 +96,6 @@ static void putstr(const char *ptr)
 	flush();
 }
 
-
-void *memcpy(void *__dest, __const void *__src, size_t __n)
-{
-	int i = 0;
-	unsigned char *d = (unsigned char *)__dest, *s = (unsigned char *)__src;
-
-	for (i = __n >> 3; i > 0; i--) {
-		*d++ = *s++;
-		*d++ = *s++;
-		*d++ = *s++;
-		*d++ = *s++;
-		*d++ = *s++;
-		*d++ = *s++;
-		*d++ = *s++;
-		*d++ = *s++;
-	}
-
-	if (__n & 1 << 2) {
-		*d++ = *s++;
-		*d++ = *s++;
-		*d++ = *s++;
-		*d++ = *s++;
-	}
-
-	if (__n & 1 << 1) {
-		*d++ = *s++;
-		*d++ = *s++;
-	}
-
-	if (__n & 1)
-		*d++ = *s++;
-
-	return __dest;
-}
-
 /*
  * gzip declarations
  */
diff --git a/arch/arm/boot/compressed/string.c b/arch/arm/boot/compressed/string.c
new file mode 100644
index 0000000000..36e53ef920
--- /dev/null
+++ b/arch/arm/boot/compressed/string.c
@@ -0,0 +1,127 @@
+/*
+ * arch/arm/boot/compressed/string.c
+ *
+ * Small subset of simple string routines
+ */
+
+#include <linux/string.h>
+
+void *memcpy(void *__dest, __const void *__src, size_t __n)
+{
+	int i = 0;
+	unsigned char *d = (unsigned char *)__dest, *s = (unsigned char *)__src;
+
+	for (i = __n >> 3; i > 0; i--) {
+		*d++ = *s++;
+		*d++ = *s++;
+		*d++ = *s++;
+		*d++ = *s++;
+		*d++ = *s++;
+		*d++ = *s++;
+		*d++ = *s++;
+		*d++ = *s++;
+	}
+
+	if (__n & 1 << 2) {
+		*d++ = *s++;
+		*d++ = *s++;
+		*d++ = *s++;
+		*d++ = *s++;
+	}
+
+	if (__n & 1 << 1) {
+		*d++ = *s++;
+		*d++ = *s++;
+	}
+
+	if (__n & 1)
+		*d++ = *s++;
+
+	return __dest;
+}
+
+void *memmove(void *__dest, __const void *__src, size_t count)
+{
+	unsigned char *d = __dest;
+	const unsigned char *s = __src;
+
+	if (__dest == __src)
+		return __dest;
+
+	if (__dest < __src)
+		return memcpy(__dest, __src, count);
+
+	while (count--)
+		d[count] = s[count];
+	return __dest;
+}
+
+size_t strlen(const char *s)
+{
+	const char *sc = s;
+
+	while (*sc != '\0')
+		sc++;
+	return sc - s;
+}
+
+int memcmp(const void *cs, const void *ct, size_t count)
+{
+	const unsigned char *su1 = cs, *su2 = ct, *end = su1 + count;
+	int res = 0;
+
+	while (su1 < end) {
+		res = *su1++ - *su2++;
+		if (res)
+			break;
+	}
+	return res;
+}
+
+int strcmp(const char *cs, const char *ct)
+{
+	unsigned char c1, c2;
+	int res = 0;
+
+	do {
+		c1 = *cs++;
+		c2 = *ct++;
+		res = c1 - c2;
+		if (res)
+			break;
+	} while (c1);
+	return res;
+}
+
+void *memchr(const void *s, int c, size_t count)
+{
+	const unsigned char *p = s;
+
+	while (count--)
+		if ((unsigned char)c == *p++)
+			return (void *)(p - 1);
+	return NULL;
+}
+
+char *strchr(const char *s, int c)
+{
+	while (*s != (char)c)
+		if (*s++ == '\0')
+			return NULL;
+	return (char *)s;
+}
+
+#undef memset
+
+void *memset(void *s, int c, size_t count)
+{
+	char *xs = s;
+	while (count--)
+		*xs++ = c;
+	return s;
+}
+
+void __memzero(void *s, size_t count)
+{
+	memset(s, 0, count);
+}
-- 
1.7.7-rc0

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

* [PATCH 5/6] ARM: zImage: allow supplementing appended DTB with traditional ATAG data
  2011-09-14  5:41 [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility Nicolas Pitre
                   ` (3 preceding siblings ...)
  2011-09-14  5:41 ` [PATCH 4/6] ARM: zImage: gather some string functions into string.c Nicolas Pitre
@ 2011-09-14  5:41 ` Nicolas Pitre
  2011-09-14  5:41 ` [PATCH 6/6] ARM: zImage: prevent constant copy+rebuild of lib1funcs.S Nicolas Pitre
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 24+ messages in thread
From: Nicolas Pitre @ 2011-09-14  5:41 UTC (permalink / raw)
  To: linux-arm-kernel

From: Nicolas Pitre <nicolas.pitre@linaro.org>

Some old bootloaders can't be updated to a device tree capable one,
yet they provide ATAGs with memory configuration, the ramdisk address,
the kernel cmdline string, etc.  To allow a device tree enabled
kernel to be used with such bootloaders, it is necessary to convert those
ATAGs into FDT properties and fold them into the DTB appended to zImage.

Currently the following ATAGs are converted:

	ATAG_CMDLINE
	ATAG_MEM
	ATAG_INITRD2

If the corresponding information already exists in the appended DTB, it
is replaced, otherwise the required node is created to hold it.

The code looks for ATAGs at the location pointed by the value of r2 upon
entry into the zImage code.  If no ATAGs are found there, an attempt at
finding ATAGs at the typical 0x100 offset from start of RAM is made.
Otherwise the DTB is left unchanged.

Thisstarted from an older patch from John Bonesio <bones@secretlab.ca>,
with contributions from David Brown <davidb@codeaurora.org>.

Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
---
 arch/arm/Kconfig                        |   11 ++++
 arch/arm/boot/compressed/.gitignore     |    9 +++
 arch/arm/boot/compressed/Makefile       |   21 ++++++-
 arch/arm/boot/compressed/atags_to_fdt.c |   97 +++++++++++++++++++++++++++++++
 arch/arm/boot/compressed/head.S         |   32 ++++++++++
 arch/arm/boot/compressed/libfdt_env.h   |   15 +++++
 6 files changed, 183 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/boot/compressed/atags_to_fdt.c
 create mode 100644 arch/arm/boot/compressed/libfdt_env.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 83323c2b1f..4ea9974bc7 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1789,6 +1789,17 @@ config ARM_APPENDED_DTB
 	  (dtb) appended to zImage
 	  (e.g. cat zImage <filename>.dtb > zImage_w_dtb).
 
+config ARM_ATAG_DTB_COMPAT
+	bool "Supplement the appended DTB with traditional ATAG information"
+	depends on ARM_APPENDED_DTB
+	help
+	  Some old bootloaders can't be updated to a DTB capable one, yet
+	  they provide ATAGs with memory configuration, the ramdisk address,
+	  the kernel cmdline string, etc.  To allow a device tree enabled
+	  kernel to be used with such bootloaders, this option allows
+	  zImage to extract the information from the ATAG list and store it
+	  at run time into the appended DTB.
+
 config CMDLINE
 	string "Default kernel command string"
 	default ""
diff --git a/arch/arm/boot/compressed/.gitignore b/arch/arm/boot/compressed/.gitignore
index c6028967d3..e0936a1485 100644
--- a/arch/arm/boot/compressed/.gitignore
+++ b/arch/arm/boot/compressed/.gitignore
@@ -5,3 +5,12 @@ piggy.lzo
 piggy.lzma
 vmlinux
 vmlinux.lds
+
+# borrowed libfdt files
+fdt.c
+fdt.h
+fdt_ro.c
+fdt_rw.c
+fdt_wip.c
+libfdt.h
+libfdt_internal.h
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index c20ddc69d9..ce2bef536e 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -93,19 +93,36 @@ suffix_$(CONFIG_KERNEL_GZIP) = gzip
 suffix_$(CONFIG_KERNEL_LZO)  = lzo
 suffix_$(CONFIG_KERNEL_LZMA) = lzma
 
+# Borrowed libfdt files for the ATAG compatibility mode
+
+libfdt		:= fdt_rw.c fdt_ro.c fdt_wip.c fdt.c
+libfdt_hdrs	:= fdt.h libfdt.h libfdt_internal.h
+
+libfdt_objs	:= $(addsuffix .o, $(basename $(libfdt)))
+
+$(addprefix $(obj)/,$(libfdt) $(libfdt_hdrs)): $(obj)/%: $(srctree)/scripts/dtc/libfdt/%
+	$(call cmd,shipped)
+
+$(addprefix $(obj)/,$(libfdt_objs) atags_to_fdt.o): \
+	$(addprefix $(obj)/,$(libfdt_hdrs))
+
+ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
+OBJS	+= $(libfdt_objs) atags_to_fdt.o 
+endif
+
 targets       := vmlinux vmlinux.lds \
 		 piggy.$(suffix_y) piggy.$(suffix_y).o \
 		 font.o font.c head.o misc.o $(OBJS)
 
 # Make sure files are removed during clean
-extra-y       += piggy.gzip piggy.lzo piggy.lzma lib1funcs.S
+extra-y       += piggy.gzip piggy.lzo piggy.lzma lib1funcs.S $(libfdt) $(libfdt_hdrs)
 
 ifeq ($(CONFIG_FUNCTION_TRACER),y)
 ORIG_CFLAGS := $(KBUILD_CFLAGS)
 KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
 endif
 
-ccflags-y := -fpic -fno-builtin
+ccflags-y := -fpic -fno-builtin -I$(obj)
 asflags-y := -Wa,-march=all
 
 # Supply kernel BSS size to the decompressor via a linker symbol.
diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c
new file mode 100644
index 0000000000..e0f637d3e8
--- /dev/null
+++ b/arch/arm/boot/compressed/atags_to_fdt.c
@@ -0,0 +1,97 @@
+#include <asm/setup.h>
+#include <libfdt.h>
+
+static int node_offset(void *fdt, const char *node_path)
+{
+	int offset = fdt_path_offset(fdt, node_path);
+	if (offset == -FDT_ERR_NOTFOUND)
+		offset = fdt_add_subnode(fdt, 0, node_path);
+	return offset;
+}
+
+static int setprop(void *fdt, const char *node_path, const char *property,
+		   uint32_t *val_array, int size)
+{
+	int offset = node_offset(fdt, node_path);
+	if (offset < 0)
+		return offset;
+	return fdt_setprop(fdt, offset, property, val_array, size);
+}
+
+static int setprop_string(void *fdt, const char *node_path,
+			  const char *property, const char *string)
+{
+	int offset = node_offset(fdt, node_path);
+	if (offset < 0)
+		return offset;
+	return fdt_setprop_string(fdt, offset, property, string);
+}
+
+static int setprop_cell(void *fdt, const char *node_path,
+			const char *property, uint32_t val)
+{
+	int offset = node_offset(fdt, node_path);
+	if (offset < 0)
+		return offset;
+	return fdt_setprop_cell(fdt, offset, property, val);
+}
+
+/*
+ * Convert and fold provided ATAGs into the provided FDT.
+ *
+ * REturn values:
+ *    = 0 -> pretend success
+ *    = 1 -> bad ATAG (may retry with another possible ATAG pointer)
+ *    < 0 -> error from libfdt
+ */
+int atags_to_fdt(void *atag_list, void *fdt, int total_space)
+{
+	struct tag *atag = atag_list;
+	uint32_t mem_reg_property[2 * NR_BANKS];
+	int memcount = 0;
+	int ret;
+
+	/* make sure we've got an aligned pointer */
+	if ((u32)atag_list & 0x3)
+		return 1;
+
+	/* if we get a DTB here we're done already */
+	if (*(u32 *)atag_list == fdt32_to_cpu(FDT_MAGIC))
+	       return 0;	
+
+	/* validate the ATAG */
+	if (atag->hdr.tag != ATAG_CORE ||
+	    (atag->hdr.size != tag_size(tag_core) &&
+	     atag->hdr.size != 2))
+		return 1;
+
+	/* let's give it all the room it could need */
+	ret = fdt_open_into(fdt, fdt, total_space);
+	if (ret < 0)
+		return ret;
+
+	for_each_tag(atag, atag_list) {
+		if (atag->hdr.tag == ATAG_CMDLINE) {
+			setprop_string(fdt, "/chosen", "bootargs",
+					atag->u.cmdline.cmdline);
+		} else if (atag->hdr.tag == ATAG_MEM) {
+			if (memcount >= sizeof(mem_reg_property)/4)
+				continue;
+			mem_reg_property[memcount++] = cpu_to_fdt32(atag->u.mem.start);
+			mem_reg_property[memcount++] = cpu_to_fdt32(atag->u.mem.size);
+		} else if (atag->hdr.tag == ATAG_INITRD2) {
+			uint32_t initrd_start, initrd_size;
+			initrd_start = atag->u.initrd.start;
+			initrd_size = atag->u.initrd.size;
+			setprop_cell(fdt, "/chosen", "linux,initrd-start",
+					initrd_start);
+			setprop_cell(fdt, "/chosen", "linux,initrd-end",
+					initrd_start + initrd_size);
+		}
+	}
+
+	if (memcount)
+		setprop(fdt, "/memory", "reg", mem_reg_property, 4*memcount);
+
+	return fdt_pack(fdt);
+}
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index ba5c552f8c..d79b83c5bd 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -246,6 +246,38 @@ restart:	adr	r0, LC0
 		cmp	lr, r1
 		bne	dtb_check_done		@ not found
 
+#ifdef CONFIG_ARM_ATAG_DTB_COMPAT
+		/*
+		 * OK... Let's do some funky business here.
+		 * If we do have a DTB appended to zImage, and we do have
+		 * an ATAG list around, we want the later to be translated
+		 * and folded into the former here.  To be on the safe side,
+		 * let's temporarily move  the stack away into the malloc
+		 * area.  No GOT fixup has occurred yet, but none of the
+		 * code we're about to call uses any global variable.
+		*/
+		add	sp, sp, #0x10000
+		stmfd	sp!, {r0-r3, ip, lr}
+		mov	r0, r8
+		mov	r1, r6
+		sub	r2, sp, r6
+		bl	atags_to_fdt
+		
+		/*
+		 * If returned value is 1, there is no ATAG at the location
+		 * pointed by r8.  Try the typical 0x100 offset from start
+		 * of RAM and hope for the best.
+		 */
+		cmp	r0, #1
+		sub	r0, r4, #(TEXT_OFFSET - 0x100)
+		mov	r1, r6
+		sub	r2, sp, r6
+		blne	atags_to_fdt
+
+		ldmfd	sp!, {r0-r3, ip, lr}
+		sub	sp, sp, #0x10000
+#endif
+
 		mov	r8, r6			@ use the appended device tree
 
 		/*
diff --git a/arch/arm/boot/compressed/libfdt_env.h b/arch/arm/boot/compressed/libfdt_env.h
new file mode 100644
index 0000000000..1f4e71876b
--- /dev/null
+++ b/arch/arm/boot/compressed/libfdt_env.h
@@ -0,0 +1,15 @@
+#ifndef _ARM_LIBFDT_ENV_H
+#define _ARM_LIBFDT_ENV_H
+
+#include <linux/types.h>
+#include <linux/string.h>
+#include <asm/byteorder.h>
+
+#define fdt16_to_cpu(x)		be16_to_cpu(x)
+#define cpu_to_fdt16(x)		cpu_to_be16(x)
+#define fdt32_to_cpu(x)		be32_to_cpu(x)
+#define cpu_to_fdt32(x)		cpu_to_be32(x)
+#define fdt64_to_cpu(x)		be64_to_cpu(x)
+#define cpu_to_fdt64(x)		cpu_to_be64(x)
+
+#endif
-- 
1.7.7-rc0

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

* [PATCH 6/6] ARM: zImage: prevent constant copy+rebuild of lib1funcs.S
  2011-09-14  5:41 [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility Nicolas Pitre
                   ` (4 preceding siblings ...)
  2011-09-14  5:41 ` [PATCH 5/6] ARM: zImage: allow supplementing appended DTB with traditional ATAG data Nicolas Pitre
@ 2011-09-14  5:41 ` Nicolas Pitre
  2011-09-16  3:58   ` Stephen Boyd
  2011-09-14  8:54 ` [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility Shawn Guo
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 24+ messages in thread
From: Nicolas Pitre @ 2011-09-14  5:41 UTC (permalink / raw)
  To: linux-arm-kernel

From: Nicolas Pitre <nicolas.pitre@linaro.org>

The rule to copy this file doesn't have to be forced.  However
lib1funcs.[So] have to be listed amongst the targets.

This prevents zImage from being recreated needlessly.

Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
---
 arch/arm/boot/compressed/Makefile |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index ce2bef536e..db1fd260ed 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -112,7 +112,7 @@ endif
 
 targets       := vmlinux vmlinux.lds \
 		 piggy.$(suffix_y) piggy.$(suffix_y).o \
-		 font.o font.c head.o misc.o $(OBJS)
+		 lib1funcs.o lib1funcs.S font.o font.c head.o misc.o $(OBJS)
 
 # Make sure files are removed during clean
 extra-y       += piggy.gzip piggy.lzo piggy.lzma lib1funcs.S $(libfdt) $(libfdt_hdrs)
@@ -147,7 +147,7 @@ LDFLAGS_vmlinux += -T
 # For __aeabi_uidivmod
 lib1funcs = $(obj)/lib1funcs.o
 
-$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S FORCE
+$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S
 	$(call cmd,shipped)
 
 # We need to prevent any GOTOFF relocs being used with references
-- 
1.7.7-rc0

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

* [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility
  2011-09-14  5:41 [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility Nicolas Pitre
                   ` (5 preceding siblings ...)
  2011-09-14  5:41 ` [PATCH 6/6] ARM: zImage: prevent constant copy+rebuild of lib1funcs.S Nicolas Pitre
@ 2011-09-14  8:54 ` Shawn Guo
  2011-09-14 13:19 ` Dave Martin
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 24+ messages in thread
From: Shawn Guo @ 2011-09-14  8:54 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 14, 2011 at 01:41:40AM -0400, Nicolas Pitre wrote:
> This is the latest incarnation of my patch series allowing a DTB
> to be appended to zImage, including the ATAG conversion wrapper and
> other minor cleanups.
> 
> This can also be pulled from:
> 
> 	git://git.linaro.org/people/nico/linux zImage_DTB_append
> 
> This works for me on the test setup I have.
> ACKs/Tested-By's would be appreciated.  
> 
Tested-by: Shawn Guo <shawn.guo@linaro.org> (on imx6q)

-- 
Regards,
Shawn

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

* [PATCH 4/6] ARM: zImage: gather some string functions into string.c
  2011-09-14  5:41 ` [PATCH 4/6] ARM: zImage: gather some string functions into string.c Nicolas Pitre
@ 2011-09-14 13:13   ` Dave Martin
  2011-09-14 13:45     ` Nicolas Pitre
  0 siblings, 1 reply; 24+ messages in thread
From: Dave Martin @ 2011-09-14 13:13 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 14, 2011 at 01:41:44AM -0400, Nicolas Pitre wrote:
> From: Nicolas Pitre <nicolas.pitre@linaro.org>
> 
> This is a small subset of string functions needed by commits to come.
> Except for memcpy() which is unchanged from its original location, their
> implementation is meant to be small, and -Os is enforced to prevent gcc
> from doing pointless loop unrolling.
> 
> Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
> ---
>  arch/arm/boot/compressed/Makefile |    4 +
>  arch/arm/boot/compressed/misc.c   |   42 +------------
>  arch/arm/boot/compressed/string.c |  127 +++++++++++++++++++++++++++++++++++++
>  3 files changed, 132 insertions(+), 41 deletions(-)
>  create mode 100644 arch/arm/boot/compressed/string.c
> 
> diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
> index 4867647b97..c20ddc69d9 100644
> --- a/arch/arm/boot/compressed/Makefile
> +++ b/arch/arm/boot/compressed/Makefile
> @@ -26,6 +26,10 @@ HEAD	= head.o
>  OBJS	+= misc.o decompress.o
>  FONTC	= $(srctree)/drivers/video/console/font_acorn_8x8.c
>  
> +# string library code (-Os is enforced to keep it much smaller)
> +OBJS		+= string.o
> +CFLAGS_string.o	:= -Os
> +
>  #
>  # Architecture dependencies
>  #
> diff --git a/arch/arm/boot/compressed/misc.c b/arch/arm/boot/compressed/misc.c
> index 832d37236c..8e2a8fca5e 100644
> --- a/arch/arm/boot/compressed/misc.c
> +++ b/arch/arm/boot/compressed/misc.c
> @@ -18,14 +18,9 @@
>  
>  unsigned int __machine_arch_type;
>  
> -#define _LINUX_STRING_H_
> -
>  #include <linux/compiler.h>	/* for inline */
> -#include <linux/types.h>	/* for size_t */
> -#include <linux/stddef.h>	/* for NULL */
> +#include <linux/types.h>
>  #include <linux/linkage.h>
> -#include <asm/string.h>
> -
>  
>  static void putstr(const char *ptr);
>  extern void error(char *x);
> @@ -101,41 +96,6 @@ static void putstr(const char *ptr)
>  	flush();
>  }
>  
> -
> -void *memcpy(void *__dest, __const void *__src, size_t __n)
> -{
> -	int i = 0;
> -	unsigned char *d = (unsigned char *)__dest, *s = (unsigned char *)__src;
> -
> -	for (i = __n >> 3; i > 0; i--) {
> -		*d++ = *s++;
> -		*d++ = *s++;
> -		*d++ = *s++;
> -		*d++ = *s++;
> -		*d++ = *s++;
> -		*d++ = *s++;
> -		*d++ = *s++;
> -		*d++ = *s++;
> -	}
> -
> -	if (__n & 1 << 2) {
> -		*d++ = *s++;
> -		*d++ = *s++;
> -		*d++ = *s++;
> -		*d++ = *s++;
> -	}
> -
> -	if (__n & 1 << 1) {
> -		*d++ = *s++;
> -		*d++ = *s++;
> -	}
> -
> -	if (__n & 1)
> -		*d++ = *s++;
> -
> -	return __dest;
> -}

Have you seen this?
http://en.wikipedia.org/wiki/Duff%27s_device

Once I finished vomiting, this actually struck be as rather neat.

If I've understood right, it seems a good fit for the manual unrolling
you do here.

Cheers
---Dave

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

* [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility
  2011-09-14  5:41 [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility Nicolas Pitre
                   ` (6 preceding siblings ...)
  2011-09-14  8:54 ` [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility Shawn Guo
@ 2011-09-14 13:19 ` Dave Martin
  2011-09-14 15:26 ` Thomas Abraham
  2011-09-14 22:56 ` David Brown
  9 siblings, 0 replies; 24+ messages in thread
From: Dave Martin @ 2011-09-14 13:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 14, 2011 at 01:41:40AM -0400, Nicolas Pitre wrote:
> This is the latest incarnation of my patch series allowing a DTB
> to be appended to zImage, including the ATAG conversion wrapper and
> other minor cleanups.
> 
> This can also be pulled from:
> 
> 	git://git.linaro.org/people/nico/linux zImage_DTB_append
> 
> This works for me on the test setup I have.
> ACKs/Tested-By's would be appreciated.  

For the series:

Tested-by: Dave Martin <dave.martin@linaro.org>

Tested in Thumb-2 with my almost-ready vexpress DT patches,
including the ATAG merging support.

Cheers
---Dave

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

* [PATCH 2/6] ARM: zImage: Allow the appending of a device tree binary
  2011-09-14  5:41 ` [PATCH 2/6] ARM: zImage: Allow the appending of a device tree binary Nicolas Pitre
@ 2011-09-14 13:32   ` Dave Martin
  2011-09-14 14:04     ` Nicolas Pitre
  0 siblings, 1 reply; 24+ messages in thread
From: Dave Martin @ 2011-09-14 13:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 14, 2011 at 01:41:42AM -0400, Nicolas Pitre wrote:
> From: Nicolas Pitre <nicolas.pitre@linaro.org>
> 
> This patch provides the ability to boot using a device tree that is appended
> to the raw binary zImage (e.g. cat zImage <filename>.dtb > zImage_w_dtb).
> 
> Signed-off-by: John Bonesio <bones@secretlab.ca>
> [nico: adjusted to latest zImage changes plus additional cleanups]
> Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
> Acked-by: Grant Likely <grant.likely@secretlab.ca>
> Acked-by: Tony Lindgren <tony@atomide.com>
> ---
>  arch/arm/Kconfig                |    8 ++++
>  arch/arm/boot/compressed/head.S |   70 +++++++++++++++++++++++++++++++++++++--
>  2 files changed, 75 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 5ebc5d922e..83323c2b1f 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1781,6 +1781,14 @@ config ZBOOT_ROM_SH_MOBILE_SDHI
>  
>  endchoice
>  
> +config ARM_APPENDED_DTB
> +	bool "Use appended device tree blob to zImage"
> +	depends on OF && !ZBOOT_ROM
> +	help
> +	  With this option, the boot code will look for a device tree binary
> +	  (dtb) appended to zImage
> +	  (e.g. cat zImage <filename>.dtb > zImage_w_dtb).
> +
>  config CMDLINE
>  	string "Default kernel command string"
>  	default ""
> diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
> index e95a598960..3ce5738ddb 100644
> --- a/arch/arm/boot/compressed/head.S
> +++ b/arch/arm/boot/compressed/head.S
> @@ -216,6 +216,59 @@ restart:	adr	r0, LC0
>  		mov	r10, r6
>  #endif
>  
> +		mov	r5, #0			@ init dtb size to 0
> +#ifdef CONFIG_ARM_APPENDED_DTB
> +/*
> + *   r0  = delta
> + *   r2  = BSS start
> + *   r3  = BSS end
> + *   r4  = final kernel address
> + *   r5  = appended dtb size (still unknown)
> + *   r6  = _edata
> + *   r7  = architecture ID
> + *   r8  = atags/device tree pointer
> + *   r9  = size of decompressed image
> + *   r10 = end of this image, including  bss/stack/malloc space if non XIP
> + *   r11 = GOT start
> + *   r12 = GOT end
> + *   sp  = stack pointer
> + *
> + * if there are device trees (dtb) appended to zImage, advance r10 so that the
> + * dtb data will get relocated along with the kernel if necessary.
> + */
> +
> +		ldr	lr, [r6, #0]
> +#ifndef __ARMEB__
> +		ldr	r1, =0xedfe0dd0		@ sig is 0xd00dfeed big endian
> +#else
> +		ldr	r1, =0xd00dfeed
> +#endif

Do we worry that garbage in memory after the zImage might match this
magic number?

For example, if an ordinary userspace program allocates a huge number
of pages and fills them with bogus device tree headers, is there a chance
that the those headers could remain in memory across a reboot?

In principle this could lead to a security hole on platforms where the
boot images don't append a device tree, by allowing an attacker to
override the bootargs etc.

I don't know whether this is exploitable in practice, but it's worth
thinking about (apologies if it's already been discussed)


A possible workaround is to put a relative pointer or a flag at the
start of the zImage, which we can poke with a non-zero value when
the device tree is appended.

This makes appending the device tree non-trivial, but it's still pretty
simple to do; something like:

$ echo 'boo' | dd bs=4 count=1 seek=4 conv=notrunc of=zImage
$ cat dtb >>zImage

(Where I assume that the affected word in the zImage is initially not
'boo').

Cheers
---Dave

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

* [PATCH 4/6] ARM: zImage: gather some string functions into string.c
  2011-09-14 13:13   ` Dave Martin
@ 2011-09-14 13:45     ` Nicolas Pitre
  2011-09-14 14:23       ` Dave Martin
  0 siblings, 1 reply; 24+ messages in thread
From: Nicolas Pitre @ 2011-09-14 13:45 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 14 Sep 2011, Dave Martin wrote:

> Have you seen this?
> http://en.wikipedia.org/wiki/Duff%27s_device

Yeah... I did stumble across something similar in the gcc test suite.

> Once I finished vomiting, this actually struck be as rather neat.
> 
> If I've understood right, it seems a good fit for the manual unrolling
> you do here.

Maybe.  However this patch is about moving code, not "improving" it.  ;-)


Nicolas

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

* [PATCH 2/6] ARM: zImage: Allow the appending of a device tree binary
  2011-09-14 13:32   ` Dave Martin
@ 2011-09-14 14:04     ` Nicolas Pitre
  2011-09-14 14:20       ` Dave Martin
  0 siblings, 1 reply; 24+ messages in thread
From: Nicolas Pitre @ 2011-09-14 14:04 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 14 Sep 2011, Dave Martin wrote:

> On Wed, Sep 14, 2011 at 01:41:42AM -0400, Nicolas Pitre wrote:
> > From: Nicolas Pitre <nicolas.pitre@linaro.org>
> > 
> > This patch provides the ability to boot using a device tree that is appended
> > to the raw binary zImage (e.g. cat zImage <filename>.dtb > zImage_w_dtb).
> > 
> > Signed-off-by: John Bonesio <bones@secretlab.ca>
> > [nico: adjusted to latest zImage changes plus additional cleanups]
> > Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
> > Acked-by: Grant Likely <grant.likely@secretlab.ca>
> > Acked-by: Tony Lindgren <tony@atomide.com>
> > ---
> >  arch/arm/Kconfig                |    8 ++++
> >  arch/arm/boot/compressed/head.S |   70 +++++++++++++++++++++++++++++++++++++--
> >  2 files changed, 75 insertions(+), 3 deletions(-)
> > 
> > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > index 5ebc5d922e..83323c2b1f 100644
> > --- a/arch/arm/Kconfig
> > +++ b/arch/arm/Kconfig
> > @@ -1781,6 +1781,14 @@ config ZBOOT_ROM_SH_MOBILE_SDHI
> >  
> >  endchoice
> >  
> > +config ARM_APPENDED_DTB
> > +	bool "Use appended device tree blob to zImage"
> > +	depends on OF && !ZBOOT_ROM
> > +	help
> > +	  With this option, the boot code will look for a device tree binary
> > +	  (dtb) appended to zImage
> > +	  (e.g. cat zImage <filename>.dtb > zImage_w_dtb).
> > +
> >  config CMDLINE
> >  	string "Default kernel command string"
> >  	default ""
> > diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
> > index e95a598960..3ce5738ddb 100644
> > --- a/arch/arm/boot/compressed/head.S
> > +++ b/arch/arm/boot/compressed/head.S
> > @@ -216,6 +216,59 @@ restart:	adr	r0, LC0
> >  		mov	r10, r6
> >  #endif
> >  
> > +		mov	r5, #0			@ init dtb size to 0
> > +#ifdef CONFIG_ARM_APPENDED_DTB
> > +/*
> > + *   r0  = delta
> > + *   r2  = BSS start
> > + *   r3  = BSS end
> > + *   r4  = final kernel address
> > + *   r5  = appended dtb size (still unknown)
> > + *   r6  = _edata
> > + *   r7  = architecture ID
> > + *   r8  = atags/device tree pointer
> > + *   r9  = size of decompressed image
> > + *   r10 = end of this image, including  bss/stack/malloc space if non XIP
> > + *   r11 = GOT start
> > + *   r12 = GOT end
> > + *   sp  = stack pointer
> > + *
> > + * if there are device trees (dtb) appended to zImage, advance r10 so that the
> > + * dtb data will get relocated along with the kernel if necessary.
> > + */
> > +
> > +		ldr	lr, [r6, #0]
> > +#ifndef __ARMEB__
> > +		ldr	r1, =0xedfe0dd0		@ sig is 0xd00dfeed big endian
> > +#else
> > +		ldr	r1, =0xd00dfeed
> > +#endif
> 
> Do we worry that garbage in memory after the zImage might match this
> magic number?
> 
> For example, if an ordinary userspace program allocates a huge number
> of pages and fills them with bogus device tree headers, is there a chance
> that the those headers could remain in memory across a reboot?

In theory this _could_ be possible.  However I don't expect this feature 
to be enabled if you are not going to actually use it, especially in a 
production setup.  If you are not appending a DTB to your kernel then 
there is simply no point keeping this config option set (normally you 
should use this option only because you have no other choices).


Nicolas

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

* [PATCH 2/6] ARM: zImage: Allow the appending of a device tree binary
  2011-09-14 14:04     ` Nicolas Pitre
@ 2011-09-14 14:20       ` Dave Martin
  2011-09-14 15:10         ` Nicolas Pitre
  0 siblings, 1 reply; 24+ messages in thread
From: Dave Martin @ 2011-09-14 14:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 14, 2011 at 10:04:28AM -0400, Nicolas Pitre wrote:
> On Wed, 14 Sep 2011, Dave Martin wrote:
> 
> > On Wed, Sep 14, 2011 at 01:41:42AM -0400, Nicolas Pitre wrote:
> > > From: Nicolas Pitre <nicolas.pitre@linaro.org>
> > > 
> > > This patch provides the ability to boot using a device tree that is appended
> > > to the raw binary zImage (e.g. cat zImage <filename>.dtb > zImage_w_dtb).
> > > 
> > > Signed-off-by: John Bonesio <bones@secretlab.ca>
> > > [nico: adjusted to latest zImage changes plus additional cleanups]
> > > Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
> > > Acked-by: Grant Likely <grant.likely@secretlab.ca>
> > > Acked-by: Tony Lindgren <tony@atomide.com>
> > > ---
> > >  arch/arm/Kconfig                |    8 ++++
> > >  arch/arm/boot/compressed/head.S |   70 +++++++++++++++++++++++++++++++++++++--
> > >  2 files changed, 75 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > > index 5ebc5d922e..83323c2b1f 100644
> > > --- a/arch/arm/Kconfig
> > > +++ b/arch/arm/Kconfig
> > > @@ -1781,6 +1781,14 @@ config ZBOOT_ROM_SH_MOBILE_SDHI
> > >  
> > >  endchoice
> > >  
> > > +config ARM_APPENDED_DTB
> > > +	bool "Use appended device tree blob to zImage"
> > > +	depends on OF && !ZBOOT_ROM
> > > +	help
> > > +	  With this option, the boot code will look for a device tree binary
> > > +	  (dtb) appended to zImage
> > > +	  (e.g. cat zImage <filename>.dtb > zImage_w_dtb).
> > > +
> > >  config CMDLINE
> > >  	string "Default kernel command string"
> > >  	default ""
> > > diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
> > > index e95a598960..3ce5738ddb 100644
> > > --- a/arch/arm/boot/compressed/head.S
> > > +++ b/arch/arm/boot/compressed/head.S
> > > @@ -216,6 +216,59 @@ restart:	adr	r0, LC0
> > >  		mov	r10, r6
> > >  #endif
> > >  
> > > +		mov	r5, #0			@ init dtb size to 0
> > > +#ifdef CONFIG_ARM_APPENDED_DTB
> > > +/*
> > > + *   r0  = delta
> > > + *   r2  = BSS start
> > > + *   r3  = BSS end
> > > + *   r4  = final kernel address
> > > + *   r5  = appended dtb size (still unknown)
> > > + *   r6  = _edata
> > > + *   r7  = architecture ID
> > > + *   r8  = atags/device tree pointer
> > > + *   r9  = size of decompressed image
> > > + *   r10 = end of this image, including  bss/stack/malloc space if non XIP
> > > + *   r11 = GOT start
> > > + *   r12 = GOT end
> > > + *   sp  = stack pointer
> > > + *
> > > + * if there are device trees (dtb) appended to zImage, advance r10 so that the
> > > + * dtb data will get relocated along with the kernel if necessary.
> > > + */
> > > +
> > > +		ldr	lr, [r6, #0]
> > > +#ifndef __ARMEB__
> > > +		ldr	r1, =0xedfe0dd0		@ sig is 0xd00dfeed big endian
> > > +#else
> > > +		ldr	r1, =0xd00dfeed
> > > +#endif
> > 
> > Do we worry that garbage in memory after the zImage might match this
> > magic number?
> > 
> > For example, if an ordinary userspace program allocates a huge number
> > of pages and fills them with bogus device tree headers, is there a chance
> > that the those headers could remain in memory across a reboot?
> 
> In theory this _could_ be possible.  However I don't expect this feature 
> to be enabled if you are not going to actually use it, especially in a 
> production setup.  If you are not appending a DTB to your kernel then 
> there is simply no point keeping this config option set (normally you 
> should use this option only because you have no other choices).

That seems reasonable.

Should we document this recommendation, in the Kconfig help or
Documentation/?


On the other hand, if there's any chance this might need to be fixed later,
it could make sense to fix it now, particularly given that the fix is simple
(based on the assumption that whatever is documented, people can and will
sometimes do the wrong thing when deploying a platform...)

Anyway, I don't have a strong feeling on this myself.

Cheers
---Dave

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

* [PATCH 4/6] ARM: zImage: gather some string functions into string.c
  2011-09-14 13:45     ` Nicolas Pitre
@ 2011-09-14 14:23       ` Dave Martin
  2011-09-14 14:43         ` Nicolas Pitre
  0 siblings, 1 reply; 24+ messages in thread
From: Dave Martin @ 2011-09-14 14:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 14, 2011 at 09:45:00AM -0400, Nicolas Pitre wrote:
> On Wed, 14 Sep 2011, Dave Martin wrote:
> 
> > Have you seen this?
> > http://en.wikipedia.org/wiki/Duff%27s_device
> 
> Yeah... I did stumble across something similar in the gcc test suite.
> 
> > Once I finished vomiting, this actually struck be as rather neat.
> > 
> > If I've understood right, it seems a good fit for the manual unrolling
> > you do here.
> 
> Maybe.  However this patch is about moving code, not "improving" it.  ;-)

Fair enough -- it was really just a side-comment rather than an issue
with the patch.

---Dave

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

* [PATCH 4/6] ARM: zImage: gather some string functions into string.c
  2011-09-14 14:23       ` Dave Martin
@ 2011-09-14 14:43         ` Nicolas Pitre
  0 siblings, 0 replies; 24+ messages in thread
From: Nicolas Pitre @ 2011-09-14 14:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 14 Sep 2011, Dave Martin wrote:

> On Wed, Sep 14, 2011 at 09:45:00AM -0400, Nicolas Pitre wrote:
> > On Wed, 14 Sep 2011, Dave Martin wrote:
> > 
> > > Have you seen this?
> > > http://en.wikipedia.org/wiki/Duff%27s_device
> > 
> > Yeah... I did stumble across something similar in the gcc test suite.
> > 
> > > Once I finished vomiting, this actually struck be as rather neat.
> > > 
> > > If I've understood right, it seems a good fit for the manual unrolling
> > > you do here.
> > 
> > Maybe.  However this patch is about moving code, not "improving" it.  ;-)
> 
> Fair enough -- it was really just a side-comment rather than an issue
> with the patch.

Might be worth investigating separately though.


Nicolas

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

* [PATCH 2/6] ARM: zImage: Allow the appending of a device tree binary
  2011-09-14 14:20       ` Dave Martin
@ 2011-09-14 15:10         ` Nicolas Pitre
  2011-09-14 16:10           ` Dave Martin
  0 siblings, 1 reply; 24+ messages in thread
From: Nicolas Pitre @ 2011-09-14 15:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 14 Sep 2011, Dave Martin wrote:

> On Wed, Sep 14, 2011 at 10:04:28AM -0400, Nicolas Pitre wrote:
> > On Wed, 14 Sep 2011, Dave Martin wrote:
> > 
> > > On Wed, Sep 14, 2011 at 01:41:42AM -0400, Nicolas Pitre wrote:
> > > > From: Nicolas Pitre <nicolas.pitre@linaro.org>
> > > > 
> > > > This patch provides the ability to boot using a device tree that is appended
> > > > to the raw binary zImage (e.g. cat zImage <filename>.dtb > zImage_w_dtb).
> > > > 
> > > > Signed-off-by: John Bonesio <bones@secretlab.ca>
> > > > [nico: adjusted to latest zImage changes plus additional cleanups]
> > > > Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
> > > > Acked-by: Grant Likely <grant.likely@secretlab.ca>
> > > > Acked-by: Tony Lindgren <tony@atomide.com>
> > > > ---
> > > >  arch/arm/Kconfig                |    8 ++++
> > > >  arch/arm/boot/compressed/head.S |   70 +++++++++++++++++++++++++++++++++++++--
> > > >  2 files changed, 75 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > > > index 5ebc5d922e..83323c2b1f 100644
> > > > --- a/arch/arm/Kconfig
> > > > +++ b/arch/arm/Kconfig
> > > > @@ -1781,6 +1781,14 @@ config ZBOOT_ROM_SH_MOBILE_SDHI
> > > >  
> > > >  endchoice
> > > >  
> > > > +config ARM_APPENDED_DTB
> > > > +	bool "Use appended device tree blob to zImage"
> > > > +	depends on OF && !ZBOOT_ROM
> > > > +	help
> > > > +	  With this option, the boot code will look for a device tree binary
> > > > +	  (dtb) appended to zImage
> > > > +	  (e.g. cat zImage <filename>.dtb > zImage_w_dtb).
> > > > +
> > > >  config CMDLINE
> > > >  	string "Default kernel command string"
> > > >  	default ""
> > > > diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
> > > > index e95a598960..3ce5738ddb 100644
> > > > --- a/arch/arm/boot/compressed/head.S
> > > > +++ b/arch/arm/boot/compressed/head.S
> > > > @@ -216,6 +216,59 @@ restart:	adr	r0, LC0
> > > >  		mov	r10, r6
> > > >  #endif
> > > >  
> > > > +		mov	r5, #0			@ init dtb size to 0
> > > > +#ifdef CONFIG_ARM_APPENDED_DTB
> > > > +/*
> > > > + *   r0  = delta
> > > > + *   r2  = BSS start
> > > > + *   r3  = BSS end
> > > > + *   r4  = final kernel address
> > > > + *   r5  = appended dtb size (still unknown)
> > > > + *   r6  = _edata
> > > > + *   r7  = architecture ID
> > > > + *   r8  = atags/device tree pointer
> > > > + *   r9  = size of decompressed image
> > > > + *   r10 = end of this image, including  bss/stack/malloc space if non XIP
> > > > + *   r11 = GOT start
> > > > + *   r12 = GOT end
> > > > + *   sp  = stack pointer
> > > > + *
> > > > + * if there are device trees (dtb) appended to zImage, advance r10 so that the
> > > > + * dtb data will get relocated along with the kernel if necessary.
> > > > + */
> > > > +
> > > > +		ldr	lr, [r6, #0]
> > > > +#ifndef __ARMEB__
> > > > +		ldr	r1, =0xedfe0dd0		@ sig is 0xd00dfeed big endian
> > > > +#else
> > > > +		ldr	r1, =0xd00dfeed
> > > > +#endif
> > > 
> > > Do we worry that garbage in memory after the zImage might match this
> > > magic number?
> > > 
> > > For example, if an ordinary userspace program allocates a huge number
> > > of pages and fills them with bogus device tree headers, is there a chance
> > > that the those headers could remain in memory across a reboot?
> > 
> > In theory this _could_ be possible.  However I don't expect this feature 
> > to be enabled if you are not going to actually use it, especially in a 
> > production setup.  If you are not appending a DTB to your kernel then 
> > there is simply no point keeping this config option set (normally you 
> > should use this option only because you have no other choices).
> 
> That seems reasonable.
> 
> Should we document this recommendation, in the Kconfig help or
> Documentation/?

I'll add some scary wording to the help text, and make it depend on 
EXPERIMENTAL as well.  I prefer not to impose some expectations on the 
zImage layout for this even if not in use, like being stuck with an 
offset that we'll always have to guard against corruption due to people 
blindly scripting the zImage poking you suggested even when it is not 
needed.

People will find ways to screw it up if they really want to anyway.  So 
I'd lean towards keeping this simple and not create any legacy around 
this hopefully temporary accommodation feature.


Nicolas

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

* [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility
  2011-09-14  5:41 [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility Nicolas Pitre
                   ` (7 preceding siblings ...)
  2011-09-14 13:19 ` Dave Martin
@ 2011-09-14 15:26 ` Thomas Abraham
  2011-09-14 22:56 ` David Brown
  9 siblings, 0 replies; 24+ messages in thread
From: Thomas Abraham @ 2011-09-14 15:26 UTC (permalink / raw)
  To: linux-arm-kernel

On 14 September 2011 11:11, Nicolas Pitre <nico@fluxnic.net> wrote:
> This is the latest incarnation of my patch series allowing a DTB
> to be appended to zImage, including the ATAG conversion wrapper and
> other minor cleanups.
>
> This can also be pulled from:
>
> ? ? ? ?git://git.linaro.org/people/nico/linux zImage_DTB_append
>
> This works for me on the test setup I have.
> ACKs/Tested-By's would be appreciated.


Works fine for Exynos4 device tree support.

Tested-by: Thomas Abraham <thomas.abraham@linaro.org>

>
>
>
>
> Nicolas
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

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

* [PATCH 2/6] ARM: zImage: Allow the appending of a device tree binary
  2011-09-14 15:10         ` Nicolas Pitre
@ 2011-09-14 16:10           ` Dave Martin
  0 siblings, 0 replies; 24+ messages in thread
From: Dave Martin @ 2011-09-14 16:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 14, 2011 at 11:10:44AM -0400, Nicolas Pitre wrote:
> On Wed, 14 Sep 2011, Dave Martin wrote:
> 
> > On Wed, Sep 14, 2011 at 10:04:28AM -0400, Nicolas Pitre wrote:
> > > On Wed, 14 Sep 2011, Dave Martin wrote:
> > > 

[...]

> > > > Do we worry that garbage in memory after the zImage might match this
> > > > magic number?
> > > > 
> > > > For example, if an ordinary userspace program allocates a huge number
> > > > of pages and fills them with bogus device tree headers, is there a chance
> > > > that the those headers could remain in memory across a reboot?
> > > 
> > > In theory this _could_ be possible.  However I don't expect this feature 
> > > to be enabled if you are not going to actually use it, especially in a 
> > > production setup.  If you are not appending a DTB to your kernel then 
> > > there is simply no point keeping this config option set (normally you 
> > > should use this option only because you have no other choices).
> > 
> > That seems reasonable.
> > 
> > Should we document this recommendation, in the Kconfig help or
> > Documentation/?
> 
> I'll add some scary wording to the help text, and make it depend on 
> EXPERIMENTAL as well.  I prefer not to impose some expectations on the 
> zImage layout for this even if not in use, like being stuck with an 
> offset that we'll always have to guard against corruption due to people 
> blindly scripting the zImage poking you suggested even when it is not 
> needed.
> 
> People will find ways to screw it up if they really want to anyway.  So 
> I'd lean towards keeping this simple and not create any legacy around 
> this hopefully temporary accommodation feature.

Yeah, sure -- I think documentating it is enough for now.

And I agree we don't really want to reinvent the rdev nastiness for zImages...

Cheers
---Dave

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

* [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility
  2011-09-14  5:41 [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility Nicolas Pitre
                   ` (8 preceding siblings ...)
  2011-09-14 15:26 ` Thomas Abraham
@ 2011-09-14 22:56 ` David Brown
  9 siblings, 0 replies; 24+ messages in thread
From: David Brown @ 2011-09-14 22:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 14, 2011 at 01:41:40AM -0400, Nicolas Pitre wrote:

> This is the latest incarnation of my patch series allowing a DTB
> to be appended to zImage, including the ATAG conversion wrapper and
> other minor cleanups.
> 
> This can also be pulled from:
> 
> 	git://git.linaro.org/people/nico/linux zImage_DTB_append
> 
> This works for me on the test setup I have.
> ACKs/Tested-By's would be appreciated.  

on MSM8660:

Tested-by: David Brown <davidb@codeaurora.org>

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

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

* [PATCH 6/6] ARM: zImage: prevent constant copy+rebuild of lib1funcs.S
  2011-09-14  5:41 ` [PATCH 6/6] ARM: zImage: prevent constant copy+rebuild of lib1funcs.S Nicolas Pitre
@ 2011-09-16  3:58   ` Stephen Boyd
  2011-09-16  4:48     ` Nicolas Pitre
  2011-09-16  7:15     ` Russell King - ARM Linux
  0 siblings, 2 replies; 24+ messages in thread
From: Stephen Boyd @ 2011-09-16  3:58 UTC (permalink / raw)
  To: linux-arm-kernel

On 09/13/11 22:41, Nicolas Pitre wrote:
> From: Nicolas Pitre <nicolas.pitre@linaro.org>
>
> The rule to copy this file doesn't have to be forced.  However
> lib1funcs.[So] have to be listed amongst the targets.
>
> This prevents zImage from being recreated needlessly.
>
> Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
> ---
>  arch/arm/boot/compressed/Makefile |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
> index ce2bef536e..db1fd260ed 100644
> --- a/arch/arm/boot/compressed/Makefile
> +++ b/arch/arm/boot/compressed/Makefile
> @@ -112,7 +112,7 @@ endif
>  
>  targets       := vmlinux vmlinux.lds \
>  		 piggy.$(suffix_y) piggy.$(suffix_y).o \
> -		 font.o font.c head.o misc.o $(OBJS)
> +		 lib1funcs.o lib1funcs.S font.o font.c head.o misc.o $(OBJS)
>  
>  # Make sure files are removed during clean
>  extra-y       += piggy.gzip piggy.lzo piggy.lzma lib1funcs.S $(libfdt) $(libfdt_hdrs)
> @@ -147,7 +147,7 @@ LDFLAGS_vmlinux += -T
>  # For __aeabi_uidivmod
>  lib1funcs = $(obj)/lib1funcs.o
>  
> -$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S FORCE
> +$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S
>  	$(call cmd,shipped)
>  
>  # We need to prevent any GOTOFF relocs being used with references

I already posted a very similar patch and put it into Russell's patch
tracker. Can't you just use that instead?

http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=7016/1
http://lists.arm.linux.org.uk/lurker/message/20110812.190002.18f88875.en.html

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

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

* [PATCH 6/6] ARM: zImage: prevent constant copy+rebuild of lib1funcs.S
  2011-09-16  3:58   ` Stephen Boyd
@ 2011-09-16  4:48     ` Nicolas Pitre
  2011-09-16  7:15     ` Russell King - ARM Linux
  1 sibling, 0 replies; 24+ messages in thread
From: Nicolas Pitre @ 2011-09-16  4:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 15 Sep 2011, Stephen Boyd wrote:

> On 09/13/11 22:41, Nicolas Pitre wrote:
> > From: Nicolas Pitre <nicolas.pitre@linaro.org>
> >
> > The rule to copy this file doesn't have to be forced.  However
> > lib1funcs.[So] have to be listed amongst the targets.
> >
> > This prevents zImage from being recreated needlessly.
> >
> > Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
> > ---
> >  arch/arm/boot/compressed/Makefile |    4 ++--
> >  1 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
> > index ce2bef536e..db1fd260ed 100644
> > --- a/arch/arm/boot/compressed/Makefile
> > +++ b/arch/arm/boot/compressed/Makefile
> > @@ -112,7 +112,7 @@ endif
> >  
> >  targets       := vmlinux vmlinux.lds \
> >  		 piggy.$(suffix_y) piggy.$(suffix_y).o \
> > -		 font.o font.c head.o misc.o $(OBJS)
> > +		 lib1funcs.o lib1funcs.S font.o font.c head.o misc.o $(OBJS)
> >  
> >  # Make sure files are removed during clean
> >  extra-y       += piggy.gzip piggy.lzo piggy.lzma lib1funcs.S $(libfdt) $(libfdt_hdrs)
> > @@ -147,7 +147,7 @@ LDFLAGS_vmlinux += -T
> >  # For __aeabi_uidivmod
> >  lib1funcs = $(obj)/lib1funcs.o
> >  
> > -$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S FORCE
> > +$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S
> >  	$(call cmd,shipped)
> >  
> >  # We need to prevent any GOTOFF relocs being used with references
> 
> I already posted a very similar patch and put it into Russell's patch
> tracker. Can't you just use that instead?

I remember this was discussed, but I forgot that you actually did send a 
patch.  Either version is fine with me.

Hmmm. My version has been merged in RMK's devel-stable branch already 
though.


Nicolas

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

* [PATCH 6/6] ARM: zImage: prevent constant copy+rebuild of lib1funcs.S
  2011-09-16  3:58   ` Stephen Boyd
  2011-09-16  4:48     ` Nicolas Pitre
@ 2011-09-16  7:15     ` Russell King - ARM Linux
  2011-09-16 17:20       ` Stephen Boyd
  1 sibling, 1 reply; 24+ messages in thread
From: Russell King - ARM Linux @ 2011-09-16  7:15 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 15, 2011 at 08:58:39PM -0700, Stephen Boyd wrote:
> On 09/13/11 22:41, Nicolas Pitre wrote:
> > From: Nicolas Pitre <nicolas.pitre@linaro.org>
> >
> > The rule to copy this file doesn't have to be forced.  However
> > lib1funcs.[So] have to be listed amongst the targets.
> >
> > This prevents zImage from being recreated needlessly.
> >
> > Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
> > ---
> >  arch/arm/boot/compressed/Makefile |    4 ++--
> >  1 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
> > index ce2bef536e..db1fd260ed 100644
> > --- a/arch/arm/boot/compressed/Makefile
> > +++ b/arch/arm/boot/compressed/Makefile
> > @@ -112,7 +112,7 @@ endif
> >  
> >  targets       := vmlinux vmlinux.lds \
> >  		 piggy.$(suffix_y) piggy.$(suffix_y).o \
> > -		 font.o font.c head.o misc.o $(OBJS)
> > +		 lib1funcs.o lib1funcs.S font.o font.c head.o misc.o $(OBJS)
> >  
> >  # Make sure files are removed during clean
> >  extra-y       += piggy.gzip piggy.lzo piggy.lzma lib1funcs.S $(libfdt) $(libfdt_hdrs)
> > @@ -147,7 +147,7 @@ LDFLAGS_vmlinux += -T
> >  # For __aeabi_uidivmod
> >  lib1funcs = $(obj)/lib1funcs.o
> >  
> > -$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S FORCE
> > +$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S
> >  	$(call cmd,shipped)
> >  
> >  # We need to prevent any GOTOFF relocs being used with references
> 
> I already posted a very similar patch and put it into Russell's patch
> tracker. Can't you just use that instead?

You did, but then there followed quite a lengthy discussion about it
so I avoided applying it.  The discussion didn't seem to really reach
any conclusion wrt the patch so I didn't know what to do about it.

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

* [PATCH 6/6] ARM: zImage: prevent constant copy+rebuild of lib1funcs.S
  2011-09-16  7:15     ` Russell King - ARM Linux
@ 2011-09-16 17:20       ` Stephen Boyd
  0 siblings, 0 replies; 24+ messages in thread
From: Stephen Boyd @ 2011-09-16 17:20 UTC (permalink / raw)
  To: linux-arm-kernel

On 9/16/2011 12:15 AM, Russell King - ARM Linux wrote:
> On Thu, Sep 15, 2011 at 08:58:39PM -0700, Stephen Boyd wrote:
>>
>> I already posted a very similar patch and put it into Russell's patch
>> tracker. Can't you just use that instead?
> You did, but then there followed quite a lengthy discussion about it
> so I avoided applying it.  The discussion didn't seem to really reach
> any conclusion wrt the patch so I didn't know what to do about it.

I was under the impression that the kbuild stuff would come later and so
it was safe to apply the patch now (apparently it was because that
happened here).

I guess next time I'll push harder.

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

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

end of thread, other threads:[~2011-09-16 17:20 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-14  5:41 [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility Nicolas Pitre
2011-09-14  5:41 ` [PATCH 1/6] ARM: zImage: ensure it is always a multiple of 64 bits in size Nicolas Pitre
2011-09-14  5:41 ` [PATCH 2/6] ARM: zImage: Allow the appending of a device tree binary Nicolas Pitre
2011-09-14 13:32   ` Dave Martin
2011-09-14 14:04     ` Nicolas Pitre
2011-09-14 14:20       ` Dave Martin
2011-09-14 15:10         ` Nicolas Pitre
2011-09-14 16:10           ` Dave Martin
2011-09-14  5:41 ` [PATCH 3/6] ARM: zImage: make sure appended DTB doesn't get overwritten by kernel .bss Nicolas Pitre
2011-09-14  5:41 ` [PATCH 4/6] ARM: zImage: gather some string functions into string.c Nicolas Pitre
2011-09-14 13:13   ` Dave Martin
2011-09-14 13:45     ` Nicolas Pitre
2011-09-14 14:23       ` Dave Martin
2011-09-14 14:43         ` Nicolas Pitre
2011-09-14  5:41 ` [PATCH 5/6] ARM: zImage: allow supplementing appended DTB with traditional ATAG data Nicolas Pitre
2011-09-14  5:41 ` [PATCH 6/6] ARM: zImage: prevent constant copy+rebuild of lib1funcs.S Nicolas Pitre
2011-09-16  3:58   ` Stephen Boyd
2011-09-16  4:48     ` Nicolas Pitre
2011-09-16  7:15     ` Russell King - ARM Linux
2011-09-16 17:20       ` Stephen Boyd
2011-09-14  8:54 ` [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility Shawn Guo
2011-09-14 13:19 ` Dave Martin
2011-09-14 15:26 ` Thomas Abraham
2011-09-14 22:56 ` David Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).