Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Add support for vmlinuz.bin appended dtb

Add support for detecting a vmlinuz.bin appended dtb and overriding
the boot arguments to match the UHI interface.

To ensure _edata / __apendend_dtb points to the actual end of the
binary, align the data section to 16 bytes instead of the address
cursor.

Due to ld.script not going through the preprocessor, we can't check
for MIPS_ZBOOT_APPENDED_DTB being enabled, so always reserve space
for it. It should have no consequences for booting without it enabled
except 1 MiB more ram usage during the uncompressing stage.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Cc: linux-mips@linux-mips.org
Cc: devicetree@vger.kernel.org
Cc: John Crispin <blogic@openwrt.org>
Cc: Kevin Cernekee <cernekee@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: Andrew Bresticker <abrestic@chromium.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: James Hartley <James.Hartley@imgtec.com>
Patchwork: https://patchwork.linux-mips.org/patch/9741/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Jonas Gorski and committed by
Ralf Baechle
c0b4e101 1da8f179

+39 -1
+18
arch/mips/Kconfig
··· 2702 2702 look like a DTB header after a reboot if no actual DTB is appended 2703 2703 to vmlinux.bin. Do not leave this option active in a production kernel 2704 2704 if you don't intend to always append a DTB. 2705 + 2706 + config MIPS_ZBOOT_APPENDED_DTB 2707 + bool "vmlinuz.bin" 2708 + depends on SYS_SUPPORTS_ZBOOT 2709 + help 2710 + With this option, the boot code will look for a device tree binary 2711 + DTB) appended to raw vmlinuz.bin (with decompressor). 2712 + (e.g. cat vmlinuz.bin <filename>.dtb > vmlinuz_w_dtb). 2713 + 2714 + This is meant as a backward compatibility convenience for those 2715 + systems with a bootloader that can't be upgraded to accommodate 2716 + the documented boot protocol using a device tree. 2717 + 2718 + Beware that there is very little in terms of protection against 2719 + this option being confused by leftover garbage in memory that might 2720 + look like a DTB header after a reboot if no actual DTB is appended 2721 + to vmlinuz.bin. Do not leave this option active in a production kernel 2722 + if you don't intend to always append a DTB. 2705 2723 endchoice 2706 2724 2707 2725 endmenu
+16
arch/mips/boot/compressed/head.S
··· 25 25 move s2, a2 26 26 move s3, a3 27 27 28 + #ifdef CONFIG_MIPS_ZBOOT_APPENDED_DTB 29 + PTR_LA t0, __appended_dtb 30 + #ifdef CONFIG_CPU_BIG_ENDIAN 31 + li t1, 0xd00dfeed 32 + #else 33 + li t1, 0xedfe0dd0 34 + #endif 35 + lw t2, (t0) 36 + bne t1, t2, not_found 37 + nop 38 + 39 + move s1, t0 40 + PTR_LI s0, -2 41 + not_found: 42 + #endif 43 + 28 44 /* Clear BSS */ 29 45 PTR_LA a0, _edata 30 46 PTR_LA a2, _end
+5 -1
arch/mips/boot/compressed/ld.script
··· 29 29 *(.image) 30 30 __image_end = .; 31 31 CONSTRUCTORS 32 + . = ALIGN(16); 32 33 } 33 - . = ALIGN(16); 34 + __appended_dtb = .; 35 + /* leave space for appended DTB */ 36 + . += 0x100000; 37 + 34 38 _edata = .; 35 39 /* End of data section */ 36 40