ARM: put a valid "barebox" signature in the header on big-endian systems.
PATCH 1/1 ARM: put a valid "barebox" signature in the header on big-endian systems.
arch/arm/include/asm/barebox-arm-head.h +1 -2
@@ -24,8 +24,7 @@ static inline void barebox_arm_head(void)"1: b 1b\n" "1: b 1b\n"#endif -".word 0x65726162\n" /* 'bare' */ -".word 0x00786f62\n" /* 'box' */ +".asciz \"barebox\"\n" ".word _text\n" /* text base. If copied there, * barebox can skip relocation */
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 7 lines · Krzysztof Halasa
Signed-off-by Krzysztof Hałasa <[email protected]>arch/arm/include/asm/barebox-arm-head.h +0
-0
arch/arm/include/asm/barebox-arm-head.h static inline void barebox_arm_head(void) · line 29
Quoted 8 lines
arch/arm/include/asm/barebox-arm-head.h +1
-2@@ -24,8 +24,7 @@ static inline void barebox_arm_head(void)"1: b 1b\n" "1: b 1b\n"#endif -".word 0x65726162\n" /* 'bare' */ -".word 0x00786f62\n" /* 'box' */ +".asciz \"barebox\"\n" ".word _text\n" /* text base. If copied there, * barebox can skip relocation
Does the barebox filetype detection need a fix aswell?
enum filetype file_detect_type(void *_buf)
{
u32 *buf = _buf;
u8 *buf8 = _buf;
if (strncmp(buf8, "#!/bin/sh", 9) == 0)
return filetype_sh;
if (buf[8] == 0x65726162 && buf[9] == 0x00786f62)
return filetype_arm_barebox;This seems wrong on big endian systems.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 7 lines · Sascha Hauer
arch/arm/include/asm/barebox-arm-head.h static inline void barebox_arm_head(void) · line 29
Quoted 5 lines
arch/arm/include/asm/barebox-arm-head.h +1
-2-".word 0x65726162\n" /* 'bare' */ -".word 0x00786f62\n" /* 'box' */ +".asciz \"barebox\"\n" ".word _text\n" /* text base. If copied there, * barebox can skip relocation Does the barebox filetype detection need a fix aswell?
I guess so.
Quoted 7 lines
enum filetype
file_detect_type(void *_buf){ u32 *buf = _buf; u8 *buf8 = _buf; if (strncmp(buf8, "#!/bin/sh", 9) == 0) return filetype_sh;
BTW there can be a white space between "#!" part and the interpreter name.
Quoted 4 lines
if (buf[8] == 0x65726162 && buf[9] == 0x00786f62) return filetype_arm_barebox;This seems wrong on big endian systems.
Definitely.
A memcmp() would be better (I don't know about the buffer length).
Signature · 6 lines
Krzysztof Halasa _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 1 line · Krzysztof Halasa
Signed-off-by Krzysztof Hałasa <[email protected]>
Applied, thanks
Sascha
Quoted 20 lines
arch/arm/include/asm/barebox-arm-head.h +1
-2@@ -24,8 +24,7 @@ static inline void barebox_arm_head(void)"1: b 1b\n" "1: b 1b\n"#endif -".word 0x65726162\n" /* 'bare' */ -".word 0x00786f62\n" /* 'box' */ +".asciz \"barebox\"\n" ".word _text\n" /* text base. If copied there, * barebox can skip relocation */ _______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hello Krzysztof,
Quoted 7 lines · Krzysztof Halasa
Signed-off-by Krzysztof Hałasa <[email protected]>arch/arm/include/asm/barebox-arm-head.h +0
-0
arch/arm/include/asm/barebox-arm-head.h static inline void barebox_arm_head(void) · line 30
Quoted 9 lines
arch/arm/include/asm/barebox-arm-head.h +1
-2@@ -24,8 +24,7 @@ static inline void barebox_arm_head(void)"1: b 1b\n" "1: b 1b\n"#endif -".word 0x65726162\n" /* 'bare' */ -".word 0x00786f62\n" /* 'box' */ +".asciz \"barebox\"\n" ".word _text\n" /* text base. If copied there, * barebox can skip relocation */
Another downside of this patch (apart from the file type detection that still needs adaption?) is that the magic is different depending on endianess. I'm not sure if it really matters, but this change makes it harder (or at least more error prone) for tools like file(1) to detect the image type. (Well, it might be hard anyhow, as barebox does have a machine specific header anyhow depending on the machine.)
Moreover I wonder what the motivation here is to change a magic. Was it just "oh, this looks ugly"? If yes, is that enough?
Just my 0.02€ on this patch, I don't know how many big endian barebox images are out there and I don't really care (neither about big endian images nor about this change). So feel free to ignore my concerns if you know better.
Best regards
Uwe
Signature · 7 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 14 lines · Uwe Kleine-König
Hello Krzysztof,
Quoted 11 lines · Krzysztof Halasa
Signed-off-by Krzysztof Hałasa <[email protected]>arch/arm/include/asm/barebox-arm-head.h +0
-0@@ -24,8 +24,7 @@ static inline void barebox_arm_head(void)"1: b 1b\n"
"1: b 1b\n"
#endif
- ".word 0x65726162\n" /* 'bare' */
Quoted 8 lines
Quoted 5 lines
- ".word 0x00786f62\n" /* 'box' */
+ ".asciz \"barebox\"\n"
".word _text\n" /* text base. If copied there,
* barebox can skip relocation */Another downside of this patch (apart from the file type detection that still needs adaption?) is that the magic is different depending on endianess.
Can this addition to the patch fix the endianess issue?
common/filetype.c +1 -1
@@ -56,7 +56,7 @@ enum filetype file_detect_type(void *_buf)if (strncmp (buf8,"#!/bin/sh" ,9 ) ==0 )return filetype_sh; -if (buf[8 ] ==0x65726162 && buf[9 ] ==0x00786f62 ) +if (strncmp (buf8 +0x20 ,"barebox" ,7 ) ==0 )return filetype_arm_barebox;if (buf[9 ] ==0x016f2818 || buf[9 ] ==0x18286f01 )return filetype_arm_zimage;
Signature · 7 lines
Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 29 lines · Antony Pavlov
Quoted 14 lines · Uwe Kleine-König
Hello Krzysztof,
Quoted 11 lines · Krzysztof Halasa
Signed-off-by Krzysztof Hałasa <[email protected]>arch/arm/include/asm/barebox-arm-head.h +0
-0@@ -24,8 +24,7 @@ static inline void barebox_arm_head(void)"1: b 1b\n"
"1: b 1b\n"
#endif
- ".word 0x65726162\n" /* 'bare' */Quoted 8 lines
Quoted 5 lines
- ".word 0x00786f62\n" /* 'box' */
+ ".asciz \"barebox\"\n"
".word _text\n" /* text base. If copied there,
* barebox can skip relocation */Another downside of this patch (apart from the file type detection that still needs adaption?) is that the magic is different depending on endianess.
Can this addition to the patch fix the endianess issue?
common/filetype.c enum filetype file_detect_type(void *_buf) · line 59
Quoted 5 lines
common/filetype.c +1
-1@@ -56,7 +56,7 @@ enum filetype file_detect_type(void *_buf)if (strncmp (buf8,"#!/bin/sh" ,9 ) ==0 )return filetype_sh; -if (buf[8 ] ==0x65726162 && buf[9 ] ==0x00786f62 ) +if (strncmp (buf8 +0x20 ,"barebox" ,7 ) ==0 )
the original checked 8 bytes, you only check 7. Is this intended?
common/filetype.c enum filetype file_detect_type(void *_buf) · line 62
Quoted 3 lines
common/filetype.c +0
-0return filetype_arm_barebox;if (buf[9 ] ==0x016f2818 || buf[9 ] ==0x18286f01 )return filetype_arm_zimage;
Best regards
Uwe
Signature · 7 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 6 lines · Uwe Kleine-König
Quoted 6 lines
+++
b/arch/arm/include/asm/barebox-arm-head.harch/arm/include/asm/barebox-arm-head.h +0
-1@@ -24,8 +24,7 @@ static inline void barebox_arm_head(void)"1: b 1b\n" "1: b 1b\n"#endif -".word 0x65726162\n" /* 'bare' */
Quoted 8 lines
arch/arm/include/asm/barebox-arm-head.h static inline void barebox_arm_head(void) · line 30
Quoted 5 lines
arch/arm/include/asm/barebox-arm-head.h +1
-1-".word 0x00786f62\n" /* 'box' */ +".asciz \"barebox\"\n" ".word _text\n" /* text base. If copied there, * barebox can skip relocation */ Another downside of this patch (apart from the file type detection that still needs adaption?) is that the magic is different depending on endianess.
Actually it's the opposite - i.e., the magic is now always "barebox\0" and doesn't depend on endianness :-)
Without this patch, the magic changes with endianness (it becomes "erab\0xob" on BE).
Quoted 2 lines
Just my 0.02€ on this patch, I don't know how many big endian barebox images are out there
Guess I have most of these here :-)
Jean-Christophe may have some, too.
Signature · 6 lines
Krzysztof Halasa _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 17 lines · Krzysztof Halasa
Quoted 6 lines · Uwe Kleine-König
Quoted 6 lines
+++
b/arch/arm/include/asm/barebox-arm-head.harch/arm/include/asm/barebox-arm-head.h +0
-1@@ -24,8 +24,7 @@ static inline void barebox_arm_head(void)"1: b 1b\n" "1: b 1b\n"#endif -".word 0x65726162\n" /* 'bare' */ Quoted 8 lines
arch/arm/include/asm/barebox-arm-head.h static inline void barebox_arm_head(void) · line 30
Quoted 5 lines
arch/arm/include/asm/barebox-arm-head.h +1
-1-".word 0x00786f62\n" /* 'box' */ +".asciz \"barebox\"\n" ".word _text\n" /* text base. If copied there, * barebox can skip relocation */ Another downside of this patch (apart from the file type detection that still needs adaption?) is that the magic is different depending on endianess.
Quoted 5 lines
Actually it's the opposite - i.e., the magic is now always "barebox\0" and doesn't depend on endianness :-)
Without this patch, the magic changes with endianness (it becomes "erab\0xob" on BE).
This may have the upside that with this we are able to detect foreign endian images like done in the zImage support. Here we use this to know that we have to swap byte endianess before jumping to the kernel.
I probably should have chosen some arbitrary number rather than a string, then nobody would have wondered about this ;)
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox