MIPS: keep firmwmare arguments with appended dtb
Subsystems (3)
cover MIPS: keep firmwmare arguments with appended dtb
The following two patches modify the appended dtb and UHI detection in a way to allow keeping all four firmware arguments.
Patch one changes the handling of ZBOOT appended dtbs by copying the appended dtb to the place where the extracted kernel will expect it. This takes advantage of the fact that the compression Makefile recipe will always append the uncompressed kernel size to the compressed kernel if not done by the compression format itself.
This has the nice side effect that we don't need to special case ZBOOT appended dtb anymore.
Patch two then introduces a new global variable for a UHI passed dtb address, and stores the appended dtb's address in there if support is enabled, or the UHI passed address if the arguments match the UHI interface. It will only do a FDT MAGIC sanity check for appended dtbs, and not for UHI passed ones, since just because a0 is -2, doesn't mean a1 will contain a valid address.
Both have been run tested on BMIPS on BCM9EJTAGPRB.
Jonas Gorski (2):
MIPS: ZBOOT: copy appended dtb to the end of the kernel
MIPS: store the appended dtb address in a variable
arch/mips/Kconfig | 22 ++-------------------- arch/mips/ath79/setup.c | 4 ++-- arch/mips/bmips/setup.c | 4 ++-- arch/mips/boot/compressed/Makefile | 1 + arch/mips/boot/compressed/decompress.c | 21 +++++++++++++++++++++ arch/mips/boot/compressed/head.S | 16 ---------------- arch/mips/include/asm/bootinfo.h | 4 ++++ arch/mips/kernel/head.S | 21 ++++++++++++++------- arch/mips/kernel/setup.c | 4 ++++ arch/mips/lantiq/prom.c | 4 ++-- arch/mips/pic32/pic32mzda/init.c | 4 ++-- 11 files changed, 54 insertions(+), 51 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/2 MIPS: ZBOOT: copy appended dtb to the end of the kernel
Instead of rewriting the arguments, just move the appended dtb to where the decompressed kernel expects it. This eliminates the need for special casing vmlinuz.bin appended dtb files.
--- arch/mips/Kconfig | 22 ++-------------------- arch/mips/boot/compressed/Makefile | 1 + arch/mips/boot/compressed/decompress.c | 21 +++++++++++++++++++++ arch/mips/boot/compressed/head.S | 16 ---------------- 4 files changed, 24 insertions(+), 36 deletions(-)
arch/mips/Kconfig +2 -20
@@ -2885,10 +2885,10 @@ choice the documented boot protocol using a device tree. config MIPS_RAW_APPENDED_DTB - bool "vmlinux.bin" + bool "vmlinux.bin or vmlinuz.bin" help With this option, the boot code will look for a device tree binary - DTB) appended to raw vmlinux.bin (without decompressor). + DTB) appended to raw vmlinux.bin or vmlinuz.bin. (e.g. cat vmlinux.bin <filename>.dtb > vmlinux_w_dtb). This is meant as a backward compatibility convenience for those
@@ -2900,24 +2900,6 @@ choice look like a DTB header after a reboot if no actual DTB is appended to vmlinux.bin. Do not leave this option active in a production kernel if you don't intend to always append a DTB. - - config MIPS_ZBOOT_APPENDED_DTB - bool "vmlinuz.bin" - depends on SYS_SUPPORTS_ZBOOT - help - With this option, the boot code will look for a device tree binary - DTB) appended to raw vmlinuz.bin (with decompressor). - (e.g. cat vmlinuz.bin <filename>.dtb > vmlinuz_w_dtb). - - This is meant as a backward compatibility convenience for those - systems with a bootloader that can't be upgraded to accommodate - the documented boot protocol using a device tree. - - Beware that there is very little in terms of protection against - this option being confused by leftover garbage in memory that might - look like a DTB header after a reboot if no actual DTB is appended - to vmlinuz.bin. Do not leave this option active in a production kernel - if you don't intend to always append a DTB. endchoice choice
arch/mips/boot/compressed/Makefile +1 -0
@@ -29,6 +29,7 @@ KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS) + # decompressor objects (linked with vmlinuz) vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o
arch/mips/boot/compressed/decompress.c +21 -0
@@ -36,6 +36,12 @@ extern void puthex(unsigned long long val);#define puthex (val) do {} while (0)#endif +#ifdef CONFIG_MIPS_RAW_APPENDED_DTB +#include <linux/libfdt.h> + +extern char __appended_dtb[]; +#endif +void error (char *x) {puts ("\n\n" );
@@ -114,6 +120,21 @@ void decompress_kernel(unsigned long boot_heap_start)__decompress ((char *)zimage_start, zimage_size,0 ,0 , (void *)VMLINUX_LOAD_ADDRESS_ULL ,0 ,0 , error); +#ifdef CONFIG_MIPS_RAW_APPENDED_DTB +if (fdt_magic ((void *)&__appended_dtb) ==FDT_MAGIC ) { +unsigned int image_size, dtb_size; + + dtb_size =fdt_totalsize ((void *)&__appended_dtb); + +/* last four bytes is always image size in little endian */ + image_size =le32_to_cpup ((void *)&__image_end -4 ); + +/* copy dtb to where the booted kernel will expect it */ +memcpy ((void *)VMLINUX_LOAD_ADDRESS_ULL + image_size, + __appended_dtb, dtb_size); + } +#endif +/* FIXME: should we flush cache here? */ puts ("Now, booting the kernel...\n" ); }
arch/mips/boot/compressed/head.S +0 -16
@@ -25,22 +25,6 @@ start: move s2, a2 move s3, a3 -#ifdef CONFIG_MIPS_ZBOOT_APPENDED_DTB - PTR_LA t0, __appended_dtb -#ifdef CONFIG_CPU_BIG_ENDIAN - li t1, 0xd00dfeed -#else - li t1, 0xedfe0dd0 -#endif - lw t2, (t0) - bne t1, t2, not_found - nop - - move s1, t0 - PTR_LI s0, -2 -not_found: -#endif - /* Clear BSS */ PTR_LA a0, _edata PTR_LA a2, _end
Signature · 1 line
2.1.4
Re: [PATCH 1/2] MIPS: ZBOOT: copy appended dtb to the end of the kernel
Quoted 59 lines · On Fri, 17 Jun 2016 14:07:39 +0200 Jonas Gorski <[email protected]> wrote:
Instead of rewriting the arguments, just move the appended dtb to where the decompressed kernel expects it. This eliminates the need for special casing vmlinuz.bin appended dtb files.
Signed-off-by Jonas Gorski <[email protected]>--- arch/mips/Kconfig | 22 ++-------------------- arch/mips/boot/compressed/Makefile | 1 + arch/mips/boot/compressed/decompress.c | 21 +++++++++++++++++++++ arch/mips/boot/compressed/head.S | 16 ---------------- 4 files changed, 24 insertions(+), 36 deletions(-)arch/mips/Kconfig +2
-20@@ -2885,10 +2885,10 @@ choice the documented boot protocol using a device tree. config MIPS_RAW_APPENDED_DTB - bool "vmlinux.bin" + bool "vmlinux.bin or vmlinuz.bin" help With this option, the boot code will look for a device tree binary - DTB) appended to raw vmlinux.bin (without decompressor). + DTB) appended to raw vmlinux.bin or vmlinuz.bin. (e.g. cat vmlinux.bin <filename>.dtb > vmlinux_w_dtb). This is meant as a backward compatibility convenience for those@@ -2900,24 +2900,6 @@ choice look like a DTB header after a reboot if no actual DTB is appended to vmlinux.bin. Do not leave this option active in a production kernel if you don't intend to always append a DTB. - - config MIPS_ZBOOT_APPENDED_DTB - bool "vmlinuz.bin" - depends on SYS_SUPPORTS_ZBOOT - help - With this option, the boot code will look for a device tree binary - DTB) appended to raw vmlinuz.bin (with decompressor). - (e.g. cat vmlinuz.bin <filename>.dtb > vmlinuz_w_dtb). - - This is meant as a backward compatibility convenience for those - systems with a bootloader that can't be upgraded to accommodate - the documented boot protocol using a device tree. - - Beware that there is very little in terms of protection against - this option being confused by leftover garbage in memory that might - look like a DTB header after a reboot if no actual DTB is appended - to vmlinuz.bin. Do not leave this option active in a production kernel - if you don't intend to always append a DTB. endchoice choicearch/mips/boot/compressed/Makefile +0
-0
arch/mips/boot/compressed/Makefile KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ · line 32
Quoted 4 lines
arch/mips/boot/compressed/Makefile +1
-0@@ -29,6 +29,7 @@ KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS) +
Could you please remote this extra empty line?
arch/mips/boot/compressed/decompress.c extern void puthex(unsigned long long val); · line 39
Quoted 12 lines
arch/mips/boot/compressed/Makefile +0
-0# decompressor objects (linked with vmlinuz) vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.oarch/mips/boot/compressed/decompress.c +1
-0@@ -36,6 +36,12 @@ extern void puthex(unsigned long long val);#define puthex (val) do {} while (0)#endif +#ifdef CONFIG_MIPS_RAW_APPENDED_DTB
Do we really need this '#ifdef' here?
arch/mips/boot/compressed/decompress.c extern void puthex(unsigned long long val); · line 44
Quoted 5 lines
arch/mips/boot/compressed/decompress.c +5
-0+#include <linux/libfdt.h> + +extern char __appended_dtb[]; +#endif +
--
Best regards,
Antony Pavlov
Re: [PATCH 1/2] MIPS: ZBOOT: copy appended dtb to the end of the kernel
Hi Antony,
Quoted 65 lines · Antony Pavlov
Quoted 62 lines · On Fri, 17 Jun 2016 14:07:39 +0200 Jonas Gorski <[email protected]> wrote:
Instead of rewriting the arguments, just move the appended dtb to where the decompressed kernel expects it. This eliminates the need for special casing vmlinuz.bin appended dtb files.
Signed-off-by Jonas Gorski <[email protected]>--- arch/mips/Kconfig | 22 ++-------------------- arch/mips/boot/compressed/Makefile | 1 + arch/mips/boot/compressed/decompress.c | 21 +++++++++++++++++++++ arch/mips/boot/compressed/head.S | 16 ---------------- 4 files changed, 24 insertions(+), 36 deletions(-)arch/mips/Kconfig +2
-20@@ -2885,10 +2885,10 @@ choice the documented boot protocol using a device tree. config MIPS_RAW_APPENDED_DTB - bool "vmlinux.bin" + bool "vmlinux.bin or vmlinuz.bin" help With this option, the boot code will look for a device tree binary - DTB) appended to raw vmlinux.bin (without decompressor). + DTB) appended to raw vmlinux.bin or vmlinuz.bin. (e.g. cat vmlinux.bin <filename>.dtb > vmlinux_w_dtb). This is meant as a backward compatibility convenience for those@@ -2900,24 +2900,6 @@ choice look like a DTB header after a reboot if no actual DTB is appended to vmlinux.bin. Do not leave this option active in a production kernel if you don't intend to always append a DTB. - - config MIPS_ZBOOT_APPENDED_DTB - bool "vmlinuz.bin" - depends on SYS_SUPPORTS_ZBOOT - help - With this option, the boot code will look for a device tree binary - DTB) appended to raw vmlinuz.bin (with decompressor). - (e.g. cat vmlinuz.bin <filename>.dtb > vmlinuz_w_dtb). - - This is meant as a backward compatibility convenience for those - systems with a bootloader that can't be upgraded to accommodate - the documented boot protocol using a device tree. - - Beware that there is very little in terms of protection against - this option being confused by leftover garbage in memory that might - look like a DTB header after a reboot if no actual DTB is appended - to vmlinuz.bin. Do not leave this option active in a production kernel - if you don't intend to always append a DTB. endchoice choicearch/mips/boot/compressed/Makefile +0
-0@@ -29,6 +29,7 @@ KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS)
Quoted 3 lines
arch/mips/boot/compressed/Makefile KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ · line 32
Quoted 1 line
arch/mips/boot/compressed/Makefile +1
-0+Could you please remote this extra empty line?
Oops, that must have slipped through. Fixed locally.
Quoted 11 lines
Quoted 11 lines
arch/mips/boot/compressed/Makefile +0
-0# decompressor objects (linked with vmlinuz) vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.oarch/mips/boot/compressed/decompress.c +0
-0@@ -36,6 +36,12 @@ extern void puthex(unsigned long long val);#define puthex (val) do {} while (0)#endif
Quoted 3 lines
arch/mips/boot/compressed/decompress.c extern void puthex(unsigned long long val); · line 39
Quoted 1 line
arch/mips/boot/compressed/decompress.c +1
-0+#ifdef CONFIG_MIPS_RAW_APPENDED_DTB Do we really need this '#ifdef' here?
No we don't, I was under the assumption the __appended_dtb is only available when appended dtb support is enabled, for for the decompressor it is always defined. At least gcc doesn't seem to complain about it being unused in a quick test compile. Fixed locally.
Quoted 2 lines
arch/mips/boot/compressed/decompress.c extern void puthex(unsigned long long val); · line 40
Quoted 2 lines
arch/mips/boot/compressed/decompress.c +1
-0+#include <linux/libfdt.h>
And moved this one to the other #includes.
Quoted 4 lines
arch/mips/boot/compressed/decompress.c extern void puthex(unsigned long long val); · line 44
Quoted 4 lines
arch/mips/boot/compressed/decompress.c +4
-0+ +extern char __appended_dtb[]; +#endif +
Jonas
Re: [PATCH 1/2] MIPS: ZBOOT: copy appended dtb to the end of the kernel
Quoted 89 lines · On Fri, 17 Jun 2016 16:44:09 +0200 Jonas Gorski <[email protected]> wrote:
Hi Antony,
Quoted 65 lines · Antony Pavlov
Quoted 62 lines · On Fri, 17 Jun 2016 14:07:39 +0200 Jonas Gorski <[email protected]> wrote:
Instead of rewriting the arguments, just move the appended dtb to where the decompressed kernel expects it. This eliminates the need for special casing vmlinuz.bin appended dtb files.
Signed-off-by Jonas Gorski <[email protected]>--- arch/mips/Kconfig | 22 ++-------------------- arch/mips/boot/compressed/Makefile | 1 + arch/mips/boot/compressed/decompress.c | 21 +++++++++++++++++++++ arch/mips/boot/compressed/head.S | 16 ---------------- 4 files changed, 24 insertions(+), 36 deletions(-)arch/mips/Kconfig +2
-20@@ -2885,10 +2885,10 @@ choice the documented boot protocol using a device tree. config MIPS_RAW_APPENDED_DTB - bool "vmlinux.bin" + bool "vmlinux.bin or vmlinuz.bin" help With this option, the boot code will look for a device tree binary - DTB) appended to raw vmlinux.bin (without decompressor). + DTB) appended to raw vmlinux.bin or vmlinuz.bin. (e.g. cat vmlinux.bin <filename>.dtb > vmlinux_w_dtb). This is meant as a backward compatibility convenience for those@@ -2900,24 +2900,6 @@ choice look like a DTB header after a reboot if no actual DTB is appended to vmlinux.bin. Do not leave this option active in a production kernel if you don't intend to always append a DTB. - - config MIPS_ZBOOT_APPENDED_DTB - bool "vmlinuz.bin" - depends on SYS_SUPPORTS_ZBOOT - help - With this option, the boot code will look for a device tree binary - DTB) appended to raw vmlinuz.bin (with decompressor). - (e.g. cat vmlinuz.bin <filename>.dtb > vmlinuz_w_dtb). - - This is meant as a backward compatibility convenience for those - systems with a bootloader that can't be upgraded to accommodate - the documented boot protocol using a device tree. - - Beware that there is very little in terms of protection against - this option being confused by leftover garbage in memory that might - look like a DTB header after a reboot if no actual DTB is appended - to vmlinuz.bin. Do not leave this option active in a production kernel - if you don't intend to always append a DTB. endchoice choicearch/mips/boot/compressed/Makefile +0
-0@@ -29,6 +29,7 @@ KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS)Quoted 3 lines
arch/mips/boot/compressed/Makefile KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ · line 32
Quoted 1 line
arch/mips/boot/compressed/Makefile +1
-0+Could you please remote this extra empty line?
Oops, that must have slipped through. Fixed locally.
Quoted 11 lines
Quoted 11 lines
arch/mips/boot/compressed/Makefile +0
-0# decompressor objects (linked with vmlinuz) vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.oarch/mips/boot/compressed/decompress.c +0
-0@@ -36,6 +36,12 @@ extern void puthex(unsigned long long val);#define puthex (val) do {} while (0)#endif Quoted 3 lines
arch/mips/boot/compressed/decompress.c extern void puthex(unsigned long long val); · line 39
Quoted 1 line
arch/mips/boot/compressed/decompress.c +1
-0+#ifdef CONFIG_MIPS_RAW_APPENDED_DTB Do we really need this '#ifdef' here?
Quoted 5 lines
No we don't, I was under the assumption the
__appended_dtbis only available when appended dtb support is enabled, for for the decompressor it is always defined. At least gcc doesn't seem to complain about it being unused in a quick test compile. Fixed locally.
Now the __appended_dtb variable is always available. You can make the next step and try to transform your
+#ifdef CONFIG_MIPS_RAW_APPENDED_DTB
+ if (fdt_magic((void *)&__appended_dtb) == FDT_MAGIC) {
+ unsigned int image_size, dtb_size;into something like this
+ if (IS_ENABLED(CONFIG_MIPS_RAW_APPENDED_DTB) &&
+ fdt_magic((void *)&__appended_dtb) == FDT_MAGIC) {
+ unsigned int image_size, dtb_size;
Using IS_ENABLED instead of #if/#ifdef the compiler can check all the code.
--
Best regards,
Antony Pavlov
PATCH 2/2 MIPS: store the appended dtb address in a variable
In reply to Jonas GorskiInstead of rewriting the arguments to match the UHI spec, store the address of a appended or UHI supplied dtb in fw_supplied_dtb.
That way the original bootloader arguments are kept intact while still making the use of an appended dtb invisible for mach code.
Mach code can still find out if it is an appended dtb by comparing fw_arg1 with fw_supplied_dtb.
--- arch/mips/ath79/setup.c | 4 ++-- arch/mips/bmips/setup.c | 4 ++-- arch/mips/include/asm/bootinfo.h | 4 ++++ arch/mips/kernel/head.S | 21 ++++++++++++++------- arch/mips/kernel/setup.c | 4 ++++ arch/mips/lantiq/prom.c | 4 ++-- arch/mips/pic32/pic32mzda/init.c | 4 ++-- 7 files changed, 30 insertions(+), 15 deletions(-)
arch/mips/ath79/setup.c +2 -2
@@ -204,8 +204,8 @@ void __init plat_mem_setup(void) fdt_start =fw_getenvl ("fdt_start" );if (fdt_start)__dt_setup_arch ((void *)KSEG0ADDR (fdt_start)); -else if (fw_arg0 ==-2 ) -__dt_setup_arch ((void *)KSEG0ADDR (fw_arg1)); +else if (fw_passed_dtb) +__dt_setup_arch ((void *)KSEG0ADDR (fw_passed_dtb));if (mips_machtype !=ATH79_MACH_GENERIC_OF ) { ath79_reset_base = ioremap_nocache(AR71XX_RESET_BASE,
arch/mips/bmips/setup.c +2 -2
@@ -162,8 +162,8 @@ void __init plat_mem_setup(void)/* intended to somewhat resemble ARM; see Documentation/arm/Booting */ if (fw_arg0 ==0 && fw_arg1 ==0xffffffff ) dtb =phys_to_virt (fw_arg2); -else if (fw_arg0 ==-2 )/* UHI interface */ - dtb = (void *)fw_arg1; +else if (fw_passed_dtb)/* UHI interface */ + dtb = (void *)fw_passed_dtb;else if (__dtb_start != __dtb_end) dtb = (void *)__dtb_start;else
arch/mips/include/asm/bootinfo.h +4 -0
@@ -127,6 +127,10 @@ extern char arcs_cmdline[COMMAND_LINE_SIZE];*/ extern unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3; +#ifdef CONFIG_USE_OF +extern unsigned long fw_passed_dtb; +#endif +/* * Platform memory detection hook called by setup_arch */
arch/mips/kernel/head.S +14 -7
@@ -93,21 +93,24 @@ NESTED(kernel_entry, 16, sp) # kernel entry point jr t0 0: +#ifdef CONFIG_USE_OF #ifdef CONFIG_MIPS_RAW_APPENDED_DTB - PTR_LA t0, __appended_dtb + PTR_LA t2, __appended_dtb #ifdef CONFIG_CPU_BIG_ENDIAN li t1, 0xd00dfeed #else li t1, 0xedfe0dd0 #endif - lw t2, (t0) - bne t1, t2, not_found - nop + lw t0, (t2) + beq t0, t1, dtb_found +#endif + li t1, -2 + beq a0, t1, dtb_found + move t2, a1 - move a1, t0 - PTR_LI a0, -2 -not_found: + li t2, 0 +dtb_found: #endif PTR_LA t0, __bss_start # clear .bss LONG_S zero, (t0)
@@ -122,6 +125,10 @@ not_found: LONG_S a2, fw_arg2 LONG_S a3, fw_arg3 +#ifdef CONFIG_USE_OF + LONG_S t2, fw_passed_dtb +#endif + MTC0 zero, CP0_CONTEXT # clear context register PTR_LA $28, init_thread_union /* Set the SP after an empty pt_regs. */
arch/mips/kernel/setup.c +4 -0
@@ -875,6 +875,10 @@ void __init setup_arch(char **cmdline_p)unsigned long kernelsp[NR_CPUS ];unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3; +#ifdef CONFIG_USE_OF +unsigned long fw_passed_dtb; +#endif +#ifdef CONFIG_DEBUG_FS struct dentry *mips_debugfs_dir;static int __init debugfs_mips (void )
arch/mips/lantiq/prom.c +2 -2
@@ -74,8 +74,8 @@ void __init plat_mem_setup(void)set_io_port_base ((unsigned long )KSEG1 ); -if (fw_arg0 ==-2 )/* UHI interface */ - dtb = (void *)fw_arg1; +if (fw_passed_dtb)/* UHI interface */ + dtb = (void *)fw_passed_dtb;else if (__dtb_start != __dtb_end) dtb = (void *)__dtb_start;else
arch/mips/pic32/pic32mzda/init.c +2 -2
@@ -33,8 +33,8 @@ static ulong get_fdtaddr(void) {ulong ftaddr =0 ; -if ((fw_arg0 ==-2 ) && fw_arg1 && !fw_arg2 && !fw_arg3) -return (ulong )fw_arg1; +if (fw_passed_dtb && !fw_arg2 && !fw_arg3) +return (ulong )fw_passed_dtb;if (__dtb_start < __dtb_end) ftaddr = (ulong )__dtb_start;
Signature · 1 line
2.1.4
Re: [PATCH 2/2] MIPS: store the appended dtb address in a variable
arch/mips/pic32/pic32mzda/init.c static ulong get_fdtaddr(void) · line 37
Quoted 9 lines · Jonas Gorski
+++
b/arch/mips/pic32/pic32mzda/init.carch/mips/pic32/pic32mzda/init.c +2
-2@@ -33,8 +33,8 @@ static ulong get_fdtaddr(void) {ulong ftaddr =0 ; -if ((fw_arg0 ==-2 ) && fw_arg1 && !fw_arg2 && !fw_arg3) -return (ulong )fw_arg1; +if (fw_passed_dtb && !fw_arg2 && !fw_arg3) +return (ulong )fw_passed_dtb;
This part potentially violates the UHI spec. If fw_passed_dtb is valid but fw_arg0 > 0, fw_arg2 may still be a valid envp. Comparing otherwise undefined values to zero is also incorrect.
Re: [PATCH 2/2] MIPS: store the appended dtb address in a variable
Hi Daniel,
Quoted 6 lines · Daniel Gimpelevich
Quoted 5 lines · Jonas Gorski
+++
b/arch/mips/pic32/pic32mzda/init.carch/mips/pic32/pic32mzda/init.c +0
-0@@ -33,8 +33,8 @@ static ulong get_fdtaddr(void) {ulong ftaddr =0 ;
Quoted 8 lines
arch/mips/pic32/pic32mzda/init.c static ulong get_fdtaddr(void) · line 37
Quoted 4 lines
arch/mips/pic32/pic32mzda/init.c +2
-2-if ((fw_arg0 ==-2 ) && fw_arg1 && !fw_arg2 && !fw_arg3) -return (ulong )fw_arg1; +if (fw_passed_dtb && !fw_arg2 && !fw_arg3) +return (ulong )fw_passed_dtb;This part potentially violates the UHI spec. If
fw_passed_dtbis valid butfw_arg0> 0,fw_arg2may still be a valid envp. Comparing otherwise undefined values to zero is also incorrect.
That was true before and is still true after my changes, so nothing added by me. This would be something for the pic32 maintainers (or users) to comment on/fix.
Jonas