3.11-rc7 big endian - atags and bootloader updates
This series is to better support older bootloaders, especially the ones that still pass some information in the ATAGS structure used by pre-fdt booting. The series is available at:
git://git.baserock.org/delta/linux baserock/311-rc7/be/atags-v2
PATCH 1/5 ARM: add CPU_BE8_BOOT_LE configuration
Add configuration for booting a BE8 system from a LE boot environment.
--- arch/arm/mm/Kconfig | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/mm/Kconfig +7 -0
@@ -712,6 +712,13 @@ config CPU_ENDIAN_BE8 help Support for the BE-8 (big-endian) mode on ARMv6 and ARMv7 processors. +config CPU_BE8_BOOT_LE + bool "Boot BE system from LE loader" + depends on CPU_ENDIAN_BE8 + help + Support for running BE-8 (big-endian) from a boot environment that is + running in LE mode. + config CPU_ENDIAN_BE32 bool depends on CPU_BIG_ENDIAN
Signature · 1 line
1.7.10.4
PATCH 2/5 ARM: fixup head for atag verification
In reply to Ben DooksIf we booted LE but running BE8, ensure we read ATAGs data from head code in the correct mode.
--- arch/arm/kernel/head-common.S | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/kernel/head-common.S +8 -0
@@ -21,6 +21,12 @@ #define OF_DT_MAGIC 0xedfe0dd0 /* 0xd00dfeed in big-endian */ #endif +#ifdef CONFIG_CPU_BE8_BOOT_LE +#define BE8_LE(x...) x +#else +#define BE8_LE(x...) +#endif + /* * Exception handling. Something went wrong and we can't proceed. We * ought to tell the user, but since we don't have any guarantee that
@@ -53,10 +59,12 @@ __vet_atags: cmp r5, r6 beq 2f #endif +BE8_LE( rev r5, r5 ) cmp r5, #ATAG_CORE_SIZE @ is first tag ATAG_CORE? cmpne r5, #ATAG_CORE_SIZE_EMPTY bne 1f ldr r5, [r2, #4] +BE8_LE( rev r5, r5 ) ldr r6, =ATAG_CORE cmp r5, r6 bne 1f
Signature · 1 line
1.7.10.4
PATCH 3/5 ARM: add atag32_to_cpu() function
In reply to Ben DooksAdd atag32_to_cpu() function to allow code manipulating ATAGs to deal with the case where the boot-loader was in little-endian and Linux is running big-endian.
--- arch/arm/include/uapi/asm/setup.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
arch/arm/include/uapi/asm/setup.h +9 -2
@@ -175,13 +175,20 @@ struct tagtable {#define tag_member_present (tag,member) \ ((unsigned long)(&((struct tag *)0L)->member + 1) \ - <= (tag)->hdr.size * 4) + <= atag32_to_cpu((tag)->hdr.size) * 4) -#define tag_next (t) ((struct tag *)((__u32 *)(t) + (t)->hdr.size)) +#define tag_next (t) ((struct tag *)((__u32 *)(t) + atag32_to_cpu((t)->hdr.size)))#define tag_size (type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2)#define for_each_tag (t,base) \ for (t = base; t->hdr.size; t = tag_next(t)) +#ifdef CONFIG_CPU_BE8_BOOT_LE +#define atag32_to_cpu (x) le32_to_cpu(x) +#define cpu_to_atag32 (x) cpu_to_le32(x) +#else +#define cpu_to_atag32 (x) x +#define atag32_to_cpu (x) x +#endif #endif /* _UAPI__ASMARM_SETUP_H */
Signature · 1 line
1.7.10.4
PATCH 4/5 ARM: update atag-to-fdt code to be endian agnostic
In reply to Ben DooksThe atag-to-fdt code can now use the conversion function we introduced previously to avoid it having to know about the endian-ness of the environment which booted the processor.
--- arch/arm/boot/compressed/atags_to_fdt.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
arch/arm/boot/compressed/atags_to_fdt.c +14 -13
@@ -121,9 +121,9 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)return 0 ;/* validate the ATAG */ -if (atag->hdr.tag !=ATAG_CORE || - (atag->hdr.size !=tag_size (tag_core) && - atag->hdr.size !=2 )) +if (atag->hdr.tag !=cpu_to_atag32 (ATAG_CORE ) || + (atag->hdr.size !=cpu_to_atag32 (tag_size (tag_core)) && + atag->hdr.size !=cpu_to_atag32 (2 )))return 1 ;/* let's give it all the room it could need */
@@ -132,7 +132,7 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)return ret;for_each_tag (atag, atag_list) { -if (atag->hdr.tag ==ATAG_CMDLINE ) { +if (atag->hdr.tag ==cpu_to_atag32 (ATAG_CMDLINE )) {/* Append the ATAGS command line to the device tree * command line. * NB: This means that if the same parameter is set in
@@ -145,11 +145,12 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)else setprop_string (fdt,"/chosen" ,"bootargs" , atag->u.cmdline.cmdline); - }else if (atag->hdr.tag ==ATAG_MEM ) { + }else if (atag->hdr.tag ==cpu_to_atag32 (ATAG_MEM )) {if (memcount >=sizeof (mem_reg_property)/4 )continue ; -if (!atag->u.mem.size) +if (!atag32_to_cpu (atag->u.mem.size))continue ; + memsize =get_cell_size (fdt);if (memsize ==2 ) {
@@ -159,20 +160,20 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)uint64_t *mem_reg_prop64 = (uint64_t *)mem_reg_property; mem_reg_prop64[memcount++] = -cpu_to_fdt64 (atag->u.mem.start); +cpu_to_fdt64 (atag32_to_cpu (atag->u.mem.start)); mem_reg_prop64[memcount++] = -cpu_to_fdt64 (atag->u.mem.size); +cpu_to_fdt64 (atag32_to_cpu (atag->u.mem.size)); }else { mem_reg_property[memcount++] = -cpu_to_fdt32 (atag->u.mem.start); +cpu_to_fdt32 (atag32_to_cpu (atag->u.mem.start)); mem_reg_property[memcount++] = -cpu_to_fdt32 (atag->u.mem.size); +cpu_to_fdt32 (atag32_to_cpu (atag->u.mem.size)); } - }else if (atag->hdr.tag ==ATAG_INITRD2 ) { + }else if (atag->hdr.tag ==cpu_to_atag32 (ATAG_INITRD2 )) {uint32_t initrd_start, initrd_size; - initrd_start = atag->u.initrd.start; - initrd_size = atag->u.initrd.size; + initrd_start =atag32_to_cpu (atag->u.initrd.start); + initrd_size =atag32_to_cpu (atag->u.initrd.size);setprop_cell (fdt,"/chosen" ,"linux,initrd-start" , initrd_start); setprop_cell(fdt, "/chosen", "linux,initrd-end",
Signature · 1 line
1.7.10.4
PATCH 5/5 ARM: ensure loader information in LE format for BE kernels
In reply to Ben DooksFrom: Nico Pitre <[email protected]>
If the loader for the system is assuming we are booting a BE kernel from a LE loading environment, then ensure that the magic number and image start/end values are in little endian format.
--- arch/arm/boot/compressed/Makefile | 5 ++++- arch/arm/boot/compressed/head.S | 7 ++++--- arch/arm/boot/compressed/vmlinux.lds.in | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-)
arch/arm/boot/compressed/Makefile +4 -1
@@ -196,8 +196,11 @@ CFLAGS_font.o := -Dstatic= $(obj)/font.c: $(FONTC) $(call cmd,shipped) -$(obj)/vmlinux.lds: $(obj)/vmlinux.lds.in arch/arm/boot/Makefile $(KCONFIG_CONFIG) +$(obj)/vmlinux.lds.S: $(obj)/vmlinux.lds.in arch/arm/boot/Makefile $(KCONFIG_CONFIG) @sed "$(SEDFLAGS)" < $< > $@ +$(obj)/vmlinux.lds: $(obj)/vmlinux.lds.S + $(call if_changed,cpp_lds_S) + $(obj)/hyp-stub.S: $(srctree)/arch/$(SRCARCH)/kernel/hyp-stub.S $(call cmd,shipped)
arch/arm/boot/compressed/head.S +4 -3
@@ -130,9 +130,10 @@ start: THUMB( adr r12, BSYM(1f) ) THUMB( bx r12 ) - .word 0x016f2818 @ Magic numbers to help the loader - .word start @ absolute load/run zImage address - .word _edata @ zImage end address + .word _magic_sig @ Magic numbers to help the loader + .word _magic_start @ absolute load/run zImage address + .word _magic_end @ zImage end address + THUMB( .thumb ) 1: ARM_BE8( setend be ) @ go BE8 if compiled for BE8
arch/arm/boot/compressed/vmlinux.lds.in +14 -0
@@ -7,6 +7,16 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ + +#ifdef CONFIG_CPU_BE8_BOOT_LE +#define ZIMAGE_MAGIC(x) ( (((x) >> 24) & 0x000000ff) | \ + (((x) >> 8) & 0x0000ff00) | \ + (((x) << 8) & 0x00ff0000) | \ + (((x) << 24) & 0xff000000) ) +#else +#define ZIMAGE_MAGIC(x) (x) +#endif + OUTPUT_ARCH(arm) ENTRY(_start) SECTIONS
@@ -57,6 +67,10 @@ SECTIONS .pad : { BYTE(0); . = ALIGN(8); } _edata = .; + _magic_sig = ZIMAGE_MAGIC(0x016f2818); + _magic_start = ZIMAGE_MAGIC(_start); + _magic_end = ZIMAGE_MAGIC(_edata); + . = BSS_START; __bss_start = .; .bss : { *(.bss) }
Signature · 1 line
1.7.10.4