ARM: prevent misaligned array inits
PATCH 1/1 ARM: prevent misaligned array inits
Under option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
--- arch/arm/cpu/arm926ejs/orion5x/cpu.c | 4 +- arch/arm/lib/interrupts.c | 2 +- board/ti/omap2420h4/sys_info.c | 28 ++++----- common/Makefile | 3 + common/cmd_dfu.c | 2 +- doc/README.arm-unaligned-accesses | 110 ++++++++++++++++++++++++++++++++++ fs/fat/Makefile | 2 + fs/ubifs/Makefile | 3 + lib/Makefile | 3 + 9 files changed, 139 insertions(+), 18 deletions(-) create mode 100644 doc/README.arm-unaligned-accesses
arch/arm/cpu/arm926ejs/orion5x/cpu.c +2 -2
@@ -194,8 +194,8 @@ u32 orion5x_device_rev(void)*/ int print_cpuinfo (void ) { -char dev_str[] ="0x0000" ; -char rev_str[] ="0x00" ; +char dev_str[7 ];/* room enough for 0x0000 plus null byte */ +char rev_str[5 ];/* room enough for 0x00 plus null byte */ char *dev_name =NULL ;char *rev_name =NULL ;
arch/arm/lib/interrupts.c +1 -1
@@ -169,7 +169,7 @@ void do_prefetch_abort (struct pt_regs *pt_regs)void do_data_abort (struct pt_regs *pt_regs) { -printf ("data abort\n" ); +printf ("data abort\n\n MAYBE you should read doc/README.unaligned-access\n\n" );show_regs (pt_regs);bad_mode (); }
board/ti/omap2420h4/sys_info.c +14 -14
@@ -237,20 +237,20 @@ u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)*********************************************************************/ void display_board_info (u32 btype) { -char cpu_2420[] ="2420" ;/* cpu type */ -char cpu_2422[] ="2422" ; -char cpu_2423[] ="2423" ; -char db_men[] ="Menelaus" ;/* board type */ -char db_ip[] ="IP" ; -char mem_sdr[] ="mSDR" ;/* memory type */ -char mem_ddr[] ="mDDR" ; -char t_tst[] ="TST" ;/* security level */ -char t_emu[] ="EMU" ; -char t_hs[] ="HS" ; -char t_gp[] ="GP" ; -char unk[] ="?" ; - -char *cpu_s, *db_s, *mem_s, *sec_s; +static const char cpu_2420 [] ="2420" ;/* cpu type */ +static const char cpu_2422 [] ="2422" ; +static const char cpu_2423 [] ="2423" ; +static const char db_men [] ="Menelaus" ;/* board type */ +static const char db_ip [] ="IP" ; +static const char mem_sdr [] ="mSDR" ;/* memory type */ +static const char mem_ddr [] ="mDDR" ; +static const char t_tst [] ="TST" ;/* security level */ +static const char t_emu [] ="EMU" ; +static const char t_hs [] ="HS" ; +static const char t_gp [] ="GP" ; +static const char unk [] ="?" ; + +const char *cpu_s, *db_s, *mem_s, *sec_s;u32 cpu, rev, sec; rev =get_cpu_rev ();
common/Makefile +3 -0
@@ -231,6 +231,9 @@ $(obj)env_embedded.o: $(src)env_embedded.c $(obj)../tools/envcrc $(obj)../tools/envcrc: $(MAKE) -C ../tools +$(obj)hush.o: CFLAGS += -mno-unaligned-access +$(obj)fdt_support.o: CFLAGS += -mno-unaligned-access + ######################################################################### # defines $(obj).depend target
common/cmd_dfu.c +1 -1
@@ -30,7 +30,7 @@static int do_dfu (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {const char *str_env; -char s[] ="dfu" ; +char *s ="dfu" ;char *env_bkp;int ret;
doc/README.arm-unaligned-accesses new file +110 -0
110 lines not on this page · raw message
fs/fat/Makefile +2 -0
@@ -39,6 +39,8 @@ all: $(LIB) $(AOBJS) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)file.o: CFLAGS += -mno-unaligned-access #########################################################################
fs/ubifs/Makefile +3 -0
@@ -42,6 +42,9 @@ all: $(LIB) $(AOBJS) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)super.o: CFLAGS += -mno-unaligned-access + ######################################################################### # defines $(obj).depend target
lib/Makefile +3 -0
@@ -83,6 +83,9 @@ OBJS := $(addprefix $(obj),$(COBJS)) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)bzlib.o: CFLAGS += -mno-unaligned-access + ######################################################################### # defines $(obj).depend target
Signature · 1 line
1.7.9.5
PATCH v2 1/1 ARM: prevent misaligned array inits
Under option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
---
V2: fix incorrect doc file name in dabort handler message
arch/arm/cpu/arm926ejs/orion5x/cpu.c | 4 +- arch/arm/lib/interrupts.c | 2 +- board/ti/omap2420h4/sys_info.c | 28 ++++----- common/Makefile | 3 + common/cmd_dfu.c | 2 +- doc/README.arm-unaligned-accesses | 110 ++++++++++++++++++++++++++++++++++ fs/fat/Makefile | 2 + fs/ubifs/Makefile | 3 + lib/Makefile | 3 + 9 files changed, 139 insertions(+), 18 deletions(-) create mode 100644 doc/README.arm-unaligned-accesses
arch/arm/cpu/arm926ejs/orion5x/cpu.c +2 -2
@@ -194,8 +194,8 @@ u32 orion5x_device_rev(void)*/ int print_cpuinfo (void ) { -char dev_str[] ="0x0000" ; -char rev_str[] ="0x00" ; +char dev_str[7 ];/* room enough for 0x0000 plus null byte */ +char rev_str[5 ];/* room enough for 0x00 plus null byte */ char *dev_name =NULL ;char *rev_name =NULL ;
arch/arm/lib/interrupts.c +1 -1
@@ -169,7 +169,7 @@ void do_prefetch_abort (struct pt_regs *pt_regs)void do_data_abort (struct pt_regs *pt_regs) { -printf ("data abort\n" ); +printf ("data abort\n\n MAYBE you should read doc/README.unaligned-accesses\n\n" );show_regs (pt_regs);bad_mode (); }
board/ti/omap2420h4/sys_info.c +14 -14
@@ -237,20 +237,20 @@ u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)*********************************************************************/ void display_board_info (u32 btype) { -char cpu_2420[] ="2420" ;/* cpu type */ -char cpu_2422[] ="2422" ; -char cpu_2423[] ="2423" ; -char db_men[] ="Menelaus" ;/* board type */ -char db_ip[] ="IP" ; -char mem_sdr[] ="mSDR" ;/* memory type */ -char mem_ddr[] ="mDDR" ; -char t_tst[] ="TST" ;/* security level */ -char t_emu[] ="EMU" ; -char t_hs[] ="HS" ; -char t_gp[] ="GP" ; -char unk[] ="?" ; - -char *cpu_s, *db_s, *mem_s, *sec_s; +static const char cpu_2420 [] ="2420" ;/* cpu type */ +static const char cpu_2422 [] ="2422" ; +static const char cpu_2423 [] ="2423" ; +static const char db_men [] ="Menelaus" ;/* board type */ +static const char db_ip [] ="IP" ; +static const char mem_sdr [] ="mSDR" ;/* memory type */ +static const char mem_ddr [] ="mDDR" ; +static const char t_tst [] ="TST" ;/* security level */ +static const char t_emu [] ="EMU" ; +static const char t_hs [] ="HS" ; +static const char t_gp [] ="GP" ; +static const char unk [] ="?" ; + +const char *cpu_s, *db_s, *mem_s, *sec_s;u32 cpu, rev, sec; rev =get_cpu_rev ();
common/Makefile +3 -0
@@ -232,6 +232,9 @@ $(obj)env_embedded.o: $(src)env_embedded.c $(obj)../tools/envcrc $(obj)../tools/envcrc: $(MAKE) -C ../tools +$(obj)hush.o: CFLAGS += -mno-unaligned-access +$(obj)fdt_support.o: CFLAGS += -mno-unaligned-access + ######################################################################### # defines $(obj).depend target
common/cmd_dfu.c +1 -1
@@ -30,7 +30,7 @@static int do_dfu (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {const char *str_env; -char s[] ="dfu" ; +char *s ="dfu" ;char *env_bkp;int ret;
doc/README.arm-unaligned-accesses new file +110 -0
110 lines not on this page · raw message
fs/fat/Makefile +2 -0
@@ -39,6 +39,8 @@ all: $(LIB) $(AOBJS) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)file.o: CFLAGS += -mno-unaligned-access #########################################################################
fs/ubifs/Makefile +3 -0
@@ -42,6 +42,9 @@ all: $(LIB) $(AOBJS) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)super.o: CFLAGS += -mno-unaligned-access + ######################################################################### # defines $(obj).depend target
lib/Makefile +3 -0
@@ -83,6 +83,9 @@ OBJS := $(addprefix $(obj),$(COBJS)) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)bzlib.o: CFLAGS += -mno-unaligned-access + ######################################################################### # defines $(obj).depend target
Signature · 1 line
1.7.9.5
PATCH v2 1/1 ARM: prevent misaligned array inits
Dear Albert Aribaud,
Quoted 10 lines · Albert ARIBAUD
Under option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
Signed-off-by Albert ARIBAUD <[email protected]>---
V2: fix incorrect doc file name in dabort handler message
well, I can not see any change regarding the doc file ;)
Quoted 7 lines
arch/arm/cpu/arm926ejs/orion5x/cpu.c | 4 +- arch/arm/lib/interrupts.c | 2 +- board/ti/omap2420h4/sys_info.c | 28 ++++----- common/Makefile | 3 + common/cmd_dfu.c | 2 +- doc/README.arm-unaligned-accesses | 110 ++++++++++++++++++++++++++++++++++
--------------^^
Quoted 5 lines
fs/fat/Makefile | 2 + fs/ubifs/Makefile | 3 + lib/Makefile | 3 + 9 files changed, 139 insertions(+), 18 deletions(-) create mode 100644 doc/README.arm-unaligned-accesses
<snip>
arch/arm/lib/interrupts.c void do_prefetch_abort (struct pt_regs *pt_regs) · line 172
Quoted 10 lines
arch/arm/lib/interrupts.c +1
-1@@ -169,7 +169,7 @@ void do_prefetch_abort (struct pt_regs *pt_regs)void do_data_abort (struct pt_regs *pt_regs) { -printf ("data abort\n" ); +printf ("data abort\n\n MAYBE you should read doc/README.unaligned-accesses\n\n" );
--------------------------------------------------------------------^^
Quoted 3 lines
arch/arm/lib/interrupts.c +0
-0show_regs (pt_regs);bad_mode (); }
<snip>
doc/README.arm-unaligned-accesses line 5
Quoted 11 lines
doc/README.arm-unaligned-accesses new file +5
-0@@ -0,0 +1,110 @@ +If you are reading this because of a data abort: the following MIGHT +be relevant to your abort, if it was caused by an alignment violation. +In order to determine this, use the PC from the abort dump along with +an objdump -s -S of the u-boot ELF binary to locate the function where +the abort happened; then compare this function with the exemples below.
examples
doc/README.arm-unaligned-accesses line 18
Quoted 13 lines
doc/README.arm-unaligned-accesses new file +13
-0+If they match, then you've been hit with a compiler generated unaligned +access, and you should rewrite your code or add -mno-unaligned-access +to the command line of the offending file. + +* + +Since U-Boot runs on a variety of hardware, some only able to perform +unaligned accesses with a strong penalty, some unable to perform them +at all, the policy regarding unaligned accesses is to not perform any, +unless absolutely necessary because of hardware or standards. + +Also, on hardware which permits it, the core is configured to throw +data abort exceptions on unaligned accesses in order to catch these
----------------------------------------------^^
doc/README.arm-unaligned-accesses line 25
Quoted 7 lines
doc/README.arm-unaligned-accesses new file +7
-0+unallowed accesses as early as possible. + +Until version 4.7, the gcc default for performing unaligned accesses +(-mno-unaligned-access) is to emulate unaligned accesses using aligned +loads and stores plus shifts and masks. Emulated unaligned accesses +will not be caught by hardware. These accesses may be costly and may +be actually unnecessary. In order to catch these accesses and remove
-----^^
doc/README.arm-unaligned-accesses line 33
Quoted 8 lines
doc/README.arm-unaligned-accesses new file +8
-0+or optimize them, option -munaligned-access is explicitly set for all +versions of gcc which support it. + +From gcc 4.7 onward, the default for performing unaligned accesses +is to use unaligned native loads and stores (-munaligned-access), +because the cost of unaligned accesses has dropped. This should not +affect U-Boot's policy of controlling unaligned accesses, however the +compiler may generate uncontrolled unaligned on its own in at least
-----------------------------------------------^ access?
Quoted 33 lines
doc/README.arm-unaligned-accesses new file +33
-0+one known case: when declaring a local initialized char array, e.g. + +function foo() +{ + char buffer[] = "initial value"; +/* or */ + char buffer[] = { 'i', 'n', 'i', 't', 0 }; + ... +} + +Under -munaligned-accesses with optimizations on, this declaration +causes the compiler to generate native loads from the literal string +and native stores to the buffer, and the literal string alignment +cannot be controlled. If it is misaligned, then the core will throw +a data abort exception. + +Quite probably the same might happen for 16-bit array initializations +where the constant is aligned on a boundary which is a multiple of 2 +but not of 4: + +function foo() +{ + u16 buffer[] = { 1, 2, 3 }; + ... +} + +The long term solution to this issue is to add an option to gcc to +allow controlling the general alignment of data, including constant +initialization values. + +However this will only apply to the version of gcc which will have such +an option. For other versions, there are four workarounds: +
doc/README.arm-unaligned-accesses line 76
Quoted 10 lines
doc/README.arm-unaligned-accesses new file +10
-0+a) Enforce as a rule that array initializations as described above + are forbidden. This is generally not acceptable as they are valid, + and usual, C constructs. The only case where they could be rejected + is when they actually equate to a const char* declaration, i.e. the + array is initialized and never modified in the function's scope. + +b) Drop the requirement on unaligned accesses at least for ARMv7, + i.e. do not throw a data abort exception upon unaligned accesses. + But that will allow adding badly aligned code to U-Boot, only for + it to fail when re-used with another, more strict, target, possibly
-------------------------------------------------------^
Quoted 9 lines
doc/README.arm-unaligned-accesses new file +9
-0+ once the bad code is already in mainline. + +c) Relax the -munaligned-access rule globally. This will prevent native + unaligned accesses of course, but that will also hide any bug caused + by a bad unaligned access, making it much harder to diagnose it. It + is actually what already happens when building ARM targets with a + pre-4.7 gcc, and it may actually already hide some bugs yet unseen + until the target gets compiled with -munaligned-access. +
doc/README.arm-unaligned-accesses line 95
Quoted 10 lines
doc/README.arm-unaligned-accesses new file +10
-0+d) Relax the -munaligned-access rule only for for files susceptible to + the local initialized array issue. This minimizes the quantity of + code which can hide unwanted misaligned accesses. + +The option retained is d). + +Considering the rarity of actual occurrences (as of this writing, 5 +files out of 7840 in U-Boot, or .3%, contain an initialized local char +array which cannot actually be replaced with a const char*), detection +if the issue in patches should not be asked from contributors.
---8<---
Considering the rarity of actual occurrences, detection if the issue in patches should not be asked from contributors.
--->8---
I think there is something wrong wih this sentence ... albeit I can not definitely say what it is.
doc/README.arm-unaligned-accesses line 101
Quoted 6 lines
doc/README.arm-unaligned-accesses new file +6
-0+ +Detecting files susceptible to the issue can be automated through a +filter installed as a hook in .git which recognizes local char array +initializations. Automation should err on the false positive side, for +instance flagging non-local arrays as if they were local if they cannot +be told apart.
Isn't that a suggestion that should be asked to the list instead? I wonder why it is written down in this README document.
doc/README.arm-unaligned-accesses line 110
Quoted 9 lines
doc/README.arm-unaligned-accesses new file +9
-0+ +In any case, detection shall not prevent committing the patch, but +shall pre-populate the commit message with a note to the effect that +this patch contains an initialized local char or 16-bit array and thus +should be protected from the gcc 4.7 issue. + +Upon a positive detection, either option -mno-unaligned-access should +be applied (if not already) to the affected file(s), or if the array +is a pseudo const char*, it should be replaced by one.
Best regards
Andreas Bie?mann
PATCH v2 1/1 ARM: prevent misaligned array inits
Hi Andreas,
Quoted 10 lines · Andreas Bie?mann
Dear Albert Aribaud,
Quoted 7 lines · Albert ARIBAUD
Under option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
Quoted 5 lines
Quoted 3 lines
Signed-off-by Albert ARIBAUD <[email protected]>---
V2: fix incorrect doc file name in dabort handler messagewell, I can not see any change regarding the doc file ;)
Maybe you though there was a change in the doc file itself? V2 is about correcting the file *name* as printed out by the dabort handler.
Quoted 35 lines
Quoted 7 lines
arch/arm/cpu/arm926ejs/orion5x/cpu.c | 4 +- arch/arm/lib/interrupts.c | 2 +- board/ti/omap2420h4/sys_info.c | 28 ++++----- common/Makefile | 3 + common/cmd_dfu.c | 2 +- doc/README.arm-unaligned-accesses | 110 ++++++++++++++++++++++++++++++++++--------------^^
Quoted 5 lines
fs/fat/Makefile | 2 + fs/ubifs/Makefile | 3 + lib/Makefile | 3 + 9 files changed, 139 insertions(+), 18 deletions(-) create mode 100644 doc/README.arm-unaligned-accesses<snip>
arch/arm/lib/interrupts.c void do_prefetch_abort (struct pt_regs *pt_regs) · line 172
Quoted 10 lines
arch/arm/lib/interrupts.c +1
-1@@ -169,7 +169,7 @@ void do_prefetch_abort (struct pt_regs *pt_regs)void do_data_abort (struct pt_regs *pt_regs) { -printf ("data abort\n" ); +printf ("data abort\n\n MAYBE you should read doc/README.unaligned-accesses\n\n" );--------------------------------------------------------------------^^
Quoted 3 lines
arch/arm/lib/interrupts.c +0
-0show_regs (pt_regs);bad_mode (); }<snip>
Quoted 13 lines
doc/README.arm-unaligned-accesses line 5
Quoted 11 lines
doc/README.arm-unaligned-accesses new file +5
-0@@ -0,0 +1,110 @@ +If you are reading this because of a data abort: the following MIGHT +be relevant to your abort, if it was caused by an alignment violation. +In order to determine this, use the PC from the abort dump along with +an objdump -s -S of the u-boot ELF binary to locate the function where +the abort happened; then compare this function with the exemples below.examples
That's the French touch. :)
Will fix in V3.
Quoted 6 lines
Quoted 6 lines
doc/README.arm-unaligned-accesses new file +6
-0+If they match, then you've been hit with a compiler generated unaligned +access, and you should rewrite your code or add -mno-unaligned-access +to the command line of the offending file. + +* +
Quoted 8 lines
doc/README.arm-unaligned-accesses line 18
Quoted 7 lines
doc/README.arm-unaligned-accesses new file +7
-0+Since U-Boot runs on a variety of hardware, some only able to perform +unaligned accesses with a strong penalty, some unable to perform them +at all, the policy regarding unaligned accesses is to not perform any, +unless absolutely necessary because of hardware or standards. + +Also, on hardware which permits it, the core is configured to throw +data abort exceptions on unaligned accesses in order to catch these----------------------------------------------^^
Will remove all extra spaces in doc.
Quoted 9 lines
doc/README.arm-unaligned-accesses line 25
Quoted 7 lines
doc/README.arm-unaligned-accesses new file +7
-0+unallowed accesses as early as possible. + +Until version 4.7, the gcc default for performing unaligned accesses +(-mno-unaligned-access) is to emulate unaligned accesses using aligned +loads and stores plus shifts and masks. Emulated unaligned accesses +will not be caught by hardware. These accesses may be costly and may +be actually unnecessary. In order to catch these accesses and remove-----^^
Quoted 9 lines
doc/README.arm-unaligned-accesses line 33
Quoted 8 lines
doc/README.arm-unaligned-accesses new file +8
-0+or optimize them, option -munaligned-access is explicitly set for all +versions of gcc which support it. + +From gcc 4.7 onward, the default for performing unaligned accesses +is to use unaligned native loads and stores (-munaligned-access), +because the cost of unaligned accesses has dropped. This should not +affect U-Boot's policy of controlling unaligned accesses, however the +compiler may generate uncontrolled unaligned on its own in at least-----------------------------------------------^ access?
"AccessES", even. Will fix.
Quoted 70 lines
Quoted 33 lines
doc/README.arm-unaligned-accesses new file +33
-0+one known case: when declaring a local initialized char array, e.g. + +function foo() +{ + char buffer[] = "initial value"; +/* or */ + char buffer[] = { 'i', 'n', 'i', 't', 0 }; + ... +} + +Under -munaligned-accesses with optimizations on, this declaration +causes the compiler to generate native loads from the literal string +and native stores to the buffer, and the literal string alignment +cannot be controlled. If it is misaligned, then the core will throw +a data abort exception. + +Quite probably the same might happen for 16-bit array initializations +where the constant is aligned on a boundary which is a multiple of 2 +but not of 4: + +function foo() +{ + u16 buffer[] = { 1, 2, 3 }; + ... +} + +The long term solution to this issue is to add an option to gcc to +allow controlling the general alignment of data, including constant +initialization values. + +However this will only apply to the version of gcc which will have such +an option. For other versions, there are four workarounds: +doc/README.arm-unaligned-accesses line 76
Quoted 10 lines
doc/README.arm-unaligned-accesses new file +10
-0+a) Enforce as a rule that array initializations as described above + are forbidden. This is generally not acceptable as they are valid, + and usual, C constructs. The only case where they could be rejected + is when they actually equate to a const char* declaration, i.e. the + array is initialized and never modified in the function's scope. + +b) Drop the requirement on unaligned accesses at least for ARMv7, + i.e. do not throw a data abort exception upon unaligned accesses. + But that will allow adding badly aligned code to U-Boot, only for + it to fail when re-used with another, more strict, target, possibly-------------------------------------------------------^
Quoted 9 lines
doc/README.arm-unaligned-accesses new file +9
-0+ once the bad code is already in mainline. + +c) Relax the -munaligned-access rule globally. This will prevent native + unaligned accesses of course, but that will also hide any bug caused + by a bad unaligned access, making it much harder to diagnose it. It + is actually what already happens when building ARM targets with a + pre-4.7 gcc, and it may actually already hide some bugs yet unseen + until the target gets compiled with -munaligned-access. +doc/README.arm-unaligned-accesses line 95
Quoted 10 lines
doc/README.arm-unaligned-accesses new file +10
-0+d) Relax the -munaligned-access rule only for for files susceptible to + the local initialized array issue. This minimizes the quantity of + code which can hide unwanted misaligned accesses. + +The option retained is d). + +Considering the rarity of actual occurrences (as of this writing, 5 +files out of 7840 in U-Boot, or .3%, contain an initialized local char +array which cannot actually be replaced with a const char*), detection +if the issue in patches should not be asked from contributors.---8<---
Considering the rarity of actual occurrences, detection if the issue in patches should not be asked from contributors.
--->8---
Quoted 2 lines
I think there is something wrong wih this sentence ... albeit I can not definitely say what it is.
s/if/of/, but yes, the sentence could use some rewriting. "Considering that actual occurrences of the issue are rare, contributors should not be required to systematically try and detect the issue in their patches". Would that be ok?
Quoted 9 lines
doc/README.arm-unaligned-accesses line 101
Quoted 6 lines
doc/README.arm-unaligned-accesses new file +6
-0+ +Detecting files susceptible to the issue can be automated through a +filter installed as a hook in .git which recognizes local char array +initializations. Automation should err on the false positive side, for +instance flagging non-local arrays as if they were local if they cannot +be told apart.Isn't that a suggestion that should be asked to the list instead? I wonder why it is written down in this README document.
Not sure I understand what you mean about "ask[ing] the list instead".
As for writing it down, I did because it's better written down than forgotten, and at this point there is no proper way to auto install a git hook in a U-Boot developer's tree, at least none that I would feel safe pushing so close to a release. So even if I did provide a script, each developer would have to manually put the hook in place. Therefore, the doc just says how to automate detection.
Quoted 12 lines
doc/README.arm-unaligned-accesses line 110
Quoted 9 lines
doc/README.arm-unaligned-accesses new file +9
-0+ +In any case, detection shall not prevent committing the patch, but +shall pre-populate the commit message with a note to the effect that +this patch contains an initialized local char or 16-bit array and thus +should be protected from the gcc 4.7 issue. + +Upon a positive detection, either option -mno-unaligned-access should +be applied (if not already) to the affected file(s), or if the array +is a pseudo const char*, it should be replaced by one.Best regards
Quoted 1 line
Andreas Bie?mann
Thanks a lot for your feedback!
Amicalement,
Signature · 1 line
Albert.
PATCH v2 1/1 ARM: prevent misaligned array inits
Hi Albert,
Quoted 15 lines · Albert ARIBAUD
Hi Andreas,
Quoted 10 lines · Andreas Bie?mann
Dear Albert Aribaud,
Quoted 7 lines · Albert ARIBAUD
Under option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Signed-off-by Albert ARIBAUD <[email protected]>---
V2: fix incorrect doc file name in dabort handler messagewell, I can not see any change regarding the doc file ;)
Maybe you though there was a change in the doc file itself? V2 is about correcting the file *name* as printed out by the dabort handler.
Well, that was I understood by the V2 comment ...
but V1 has:
---8<---
- printf ("data abort\n");
+ printf ("data abort\n\n MAYBE you should read
doc/README.unaligned-access\n\n");
--->8---
and V2 has:
---8<---
- printf ("data abort\n");
+ printf ("data abort\n\n MAYBE you should read
doc/README.unaligned-accesses\n\n");
--->8---
However the filename is 'doc/README.arm-unaligned-accesses'
<snip>
Quoted 11 lines
Quoted 11 lines
doc/README.arm-unaligned-accesses line 95
Quoted 5 lines
doc/README.arm-unaligned-accesses new file +5
-0+ +Considering the rarity of actual occurrences (as of this writing, 5 +files out of 7840 in U-Boot, or .3%, contain an initialized local char +array which cannot actually be replaced with a const char*), detection +if the issue in patches should not be asked from contributors.---8<---
Considering the rarity of actual occurrences, detection if the issue in patches should not be asked from contributors.
--->8---
Quoted 7 lines
Quoted 2 lines
I think there is something wrong wih this sentence ... albeit I can not definitely say what it is.
s/if/of/, but yes, the sentence could use some rewriting. "Considering that actual occurrences of the issue are rare, contributors should not be required to systematically try and detect the issue in their patches". Would that be ok?
Sounds way better.
Quoted 11 lines
Quoted 10 lines
doc/README.arm-unaligned-accesses line 101
Quoted 7 lines
doc/README.arm-unaligned-accesses new file +6
-0+ +Detecting files susceptible to the issue can be automated through a +filter installed as a hook in .git which recognizes local char array +initializations. Automation should err on the false positive side, for +instance flagging non-local arrays as if they were local if they cannot +be told apart.Isn't that a suggestion that should be asked to the list instead? I wonder why it is written down in this README document.
Quoted 1 line
Not sure I understand what you mean about "ask[ing] the list instead".
I meant to discuss this on the list and just install the hook then (at least for the denx.de repositories).
Quoted 6 lines
As for writing it down, I did because it's better written down than forgotten, and at this point there is no proper way to auto install a git hook in a U-Boot developer's tree, at least none that I would feel safe pushing so close to a release. So even if I did provide a script, each developer would have to manually put the hook in place. Therefore, the doc just says how to automate detection.
But you are right, so forget my comment.
best regards
Andreas Bie?mann
PATCH v2 1/1 ARM: prevent misaligned array inits
Hi Andreas,
Quoted 43 lines · Andreas Bie?mann
Hi Albert,
Quoted 15 lines · Albert ARIBAUD
Hi Andreas,
Quoted 10 lines · Andreas Bie?mann
Dear Albert Aribaud,
Quoted 7 lines · Albert ARIBAUD
Under option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Signed-off-by Albert ARIBAUD <[email protected]>---
V2: fix incorrect doc file name in dabort handler messagewell, I can not see any change regarding the doc file ;)
Maybe you though there was a change in the doc file itself? V2 is about correcting the file *name* as printed out by the dabort handler.
Well, that was I understood by the V2 comment ...
but V1 has:
---8<---(quoted diff) +1
-1- printf ("data abort\n"); + printf ("data abort\n\n MAYBE you should readdoc/README.unaligned-access\n\n");
--->8---and V2 has:
---8<---(quoted diff) +1
-1- printf ("data abort\n"); + printf ("data abort\n\n MAYBE you should readdoc/README.unaligned-accesses\n\n");
--->8---
Quoted 1 line
However the filename is 'doc/README.arm-unaligned-accesses'
Argh!
Will fix in V3... For good. Thanks.
Quoted 16 lines
<snip>
Quoted 14 lines
Quoted 13 lines
doc/README.arm-unaligned-accesses line 95
Quoted 5 lines
doc/README.arm-unaligned-accesses new file +5
-0+ +Considering the rarity of actual occurrences (as of this writing, 5 +files out of 7840 in U-Boot, or .3%, contain an initialized local char +array which cannot actually be replaced with a const char*), detection +if the issue in patches should not be asked from contributors.---8<---
Considering the rarity of actual occurrences, detection if the issue in patches should not be asked from contributors.
--->8---I think there is something wrong wih this sentence ... albeit I can not definitely say what it is.
Quoted 6 lines
Quoted 4 lines
s/if/of/, but yes, the sentence could use some rewriting. "Considering that actual occurrences of the issue are rare, contributors should not be required to systematically try and detect the issue in their patches". Would that be ok?
Sounds way better.
Will put in V3.
Quoted 16 lines
Quoted 11 lines
Quoted 10 lines
doc/README.arm-unaligned-accesses line 101
Quoted 7 lines
doc/README.arm-unaligned-accesses new file +6
-0+ +Detecting files susceptible to the issue can be automated through a +filter installed as a hook in .git which recognizes local char array +initializations. Automation should err on the false positive side, for +instance flagging non-local arrays as if they were local if they cannot +be told apart.Isn't that a suggestion that should be asked to the list instead? I wonder why it is written down in this README document.
Quoted 1 line
Not sure I understand what you mean about "ask[ing] the list instead".
I meant to discuss this on the list and just install the hook then (at least for the denx.de repositories).
Quoted 8 lines
Quoted 6 lines
As for writing it down, I did because it's better written down than forgotten, and at this point there is no proper way to auto install a git hook in a U-Boot developer's tree, at least none that I would feel safe pushing so close to a release. So even if I did provide a script, each developer would have to manually put the hook in place. Therefore, the doc just says how to automate detection.
But you are right, so forget my comment.
Thanks.
Quoted 3 lines
best regards
Andreas Bie?mann
Amicalement,
Signature · 1 line
Albert.
PATCH v3 1/1 ARM: prevent misaligned array inits
In reply to Albert ARIBAUDUnder option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
---
V3: *really* fix incorrect doc file name in dabort handler message
clarifications and typo fixes in README.arm-unaligned-accesses
V2: fix incorrect doc file name in dabort handler message
arch/arm/cpu/arm926ejs/orion5x/cpu.c | 4 +- arch/arm/lib/interrupts.c | 2 +- board/ti/omap2420h4/sys_info.c | 28 ++++----- common/Makefile | 3 + common/cmd_dfu.c | 2 +- doc/README.arm-unaligned-accesses | 112 ++++++++++++++++++++++++++++++++++ fs/fat/Makefile | 2 + fs/ubifs/Makefile | 3 + lib/Makefile | 3 + 9 files changed, 141 insertions(+), 18 deletions(-) create mode 100644 doc/README.arm-unaligned-accesses
arch/arm/cpu/arm926ejs/orion5x/cpu.c +2 -2
@@ -194,8 +194,8 @@ u32 orion5x_device_rev(void)*/ int print_cpuinfo (void ) { -char dev_str[] ="0x0000" ; -char rev_str[] ="0x00" ; +char dev_str[7 ];/* room enough for 0x0000 plus null byte */ +char rev_str[5 ];/* room enough for 0x00 plus null byte */ char *dev_name =NULL ;char *rev_name =NULL ;
arch/arm/lib/interrupts.c +1 -1
@@ -169,7 +169,7 @@ void do_prefetch_abort (struct pt_regs *pt_regs)void do_data_abort (struct pt_regs *pt_regs) { -printf ("data abort\n" ); +printf ("data abort\n\n MAYBE you should read doc/README.arm-unaligned-accesses\n\n" );show_regs (pt_regs);bad_mode (); }
board/ti/omap2420h4/sys_info.c +14 -14
@@ -237,20 +237,20 @@ u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)*********************************************************************/ void display_board_info (u32 btype) { -char cpu_2420[] ="2420" ;/* cpu type */ -char cpu_2422[] ="2422" ; -char cpu_2423[] ="2423" ; -char db_men[] ="Menelaus" ;/* board type */ -char db_ip[] ="IP" ; -char mem_sdr[] ="mSDR" ;/* memory type */ -char mem_ddr[] ="mDDR" ; -char t_tst[] ="TST" ;/* security level */ -char t_emu[] ="EMU" ; -char t_hs[] ="HS" ; -char t_gp[] ="GP" ; -char unk[] ="?" ; - -char *cpu_s, *db_s, *mem_s, *sec_s; +static const char cpu_2420 [] ="2420" ;/* cpu type */ +static const char cpu_2422 [] ="2422" ; +static const char cpu_2423 [] ="2423" ; +static const char db_men [] ="Menelaus" ;/* board type */ +static const char db_ip [] ="IP" ; +static const char mem_sdr [] ="mSDR" ;/* memory type */ +static const char mem_ddr [] ="mDDR" ; +static const char t_tst [] ="TST" ;/* security level */ +static const char t_emu [] ="EMU" ; +static const char t_hs [] ="HS" ; +static const char t_gp [] ="GP" ; +static const char unk [] ="?" ; + +const char *cpu_s, *db_s, *mem_s, *sec_s;u32 cpu, rev, sec; rev =get_cpu_rev ();
common/Makefile +3 -0
@@ -232,6 +232,9 @@ $(obj)env_embedded.o: $(src)env_embedded.c $(obj)../tools/envcrc $(obj)../tools/envcrc: $(MAKE) -C ../tools +$(obj)hush.o: CFLAGS += -mno-unaligned-access +$(obj)fdt_support.o: CFLAGS += -mno-unaligned-access + ######################################################################### # defines $(obj).depend target
common/cmd_dfu.c +1 -1
@@ -30,7 +30,7 @@static int do_dfu (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {const char *str_env; -char s[] ="dfu" ; +char *s ="dfu" ;char *env_bkp;int ret;
doc/README.arm-unaligned-accesses new file +112 -0
112 lines not on this page · raw message
fs/fat/Makefile +2 -0
@@ -39,6 +39,8 @@ all: $(LIB) $(AOBJS) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)file.o: CFLAGS += -mno-unaligned-access #########################################################################
fs/ubifs/Makefile +3 -0
@@ -42,6 +42,9 @@ all: $(LIB) $(AOBJS) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)super.o: CFLAGS += -mno-unaligned-access + ######################################################################### # defines $(obj).depend target
lib/Makefile +3 -0
@@ -83,6 +83,9 @@ OBJS := $(addprefix $(obj),$(COBJS)) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)bzlib.o: CFLAGS += -mno-unaligned-access + ######################################################################### # defines $(obj).depend target
Signature · 1 line
1.7.9.5
PATCH v3 1/1 ARM: prevent misaligned array inits
Quoted 8 lines · Albert ARIBAUD
Under option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
Signed-off-by Albert ARIBAUD <[email protected]>
[snip]
common/Makefile $(obj)env_embedded.o: $(src)env_embedded.c $(obj)../tools/envcrc · line 236
Quoted 10 lines
common/Makefile +2
-0@@ -232,6 +232,9 @@ $(obj)env_embedded.o: $(src)env_embedded.c $(obj)../tools/envcrc $(obj)../tools/envcrc: $(MAKE) -C ../tools +$(obj)hush.o: CFLAGS += -mno-unaligned-access +$(obj)fdt_support.o: CFLAGS += -mno-unaligned-access
Forgot a '# SEE doc/...' here.
[snip]
common/Makefile $(obj)env_embedded.o: $(src)env_embedded.c $(obj)../tools/envcrc
Quoted 5 lines
common/Makefile +5
-0+If you are reading this because of a data abort: the following MIGHT +be relevant to your abort, if it was caused by an alignment violation. +In order to determine this, use the PC from the abort dump along with +an objdump -s -S of the u-boot ELF binary to locate the function where +the abort happened; then compare this function with the examples below.
You should also add something about how if you are able to reach the U-Boot prompt before the abort happens, if CONFIG_CMD_BDI is set the 'bdinfo' command will give you the relocation offset to apply to the PC.
Otherwise looks good. Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121008/babc6a27/attachment.pgp>
PATCH v4 1/1 ARM: prevent misaligned array inits
In reply to Albert ARIBAUDUnder option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
---
V4: added information on how to find relocation offset for pc
common/Makefile missed a comment re README.arm-unaligned-accesses
V3: *really* fix incorrect doc file name in dabort handler message
clarifications and typo fixes in README.arm-unaligned-accesses
V2: fix incorrect doc file name in dabort handler message
arch/arm/cpu/arm926ejs/orion5x/cpu.c | 4 +- arch/arm/lib/interrupts.c | 2 +- board/ti/omap2420h4/sys_info.c | 28 ++++---- common/Makefile | 4 ++ common/cmd_dfu.c | 2 +- doc/README.arm-unaligned-accesses | 121 ++++++++++++++++++++++++++++++++++ fs/fat/Makefile | 2 + fs/ubifs/Makefile | 3 + lib/Makefile | 3 + 9 files changed, 151 insertions(+), 18 deletions(-) create mode 100644 doc/README.arm-unaligned-accesses
arch/arm/cpu/arm926ejs/orion5x/cpu.c +2 -2
@@ -194,8 +194,8 @@ u32 orion5x_device_rev(void)*/ int print_cpuinfo (void ) { -char dev_str[] ="0x0000" ; -char rev_str[] ="0x00" ; +char dev_str[7 ];/* room enough for 0x0000 plus null byte */ +char rev_str[5 ];/* room enough for 0x00 plus null byte */ char *dev_name =NULL ;char *rev_name =NULL ;
arch/arm/lib/interrupts.c +1 -1
@@ -169,7 +169,7 @@ void do_prefetch_abort (struct pt_regs *pt_regs)void do_data_abort (struct pt_regs *pt_regs) { -printf ("data abort\n" ); +printf ("data abort\n\n MAYBE you should read doc/README.arm-unaligned-accesses\n\n" );show_regs (pt_regs);bad_mode (); }
board/ti/omap2420h4/sys_info.c +14 -14
@@ -237,20 +237,20 @@ u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)*********************************************************************/ void display_board_info (u32 btype) { -char cpu_2420[] ="2420" ;/* cpu type */ -char cpu_2422[] ="2422" ; -char cpu_2423[] ="2423" ; -char db_men[] ="Menelaus" ;/* board type */ -char db_ip[] ="IP" ; -char mem_sdr[] ="mSDR" ;/* memory type */ -char mem_ddr[] ="mDDR" ; -char t_tst[] ="TST" ;/* security level */ -char t_emu[] ="EMU" ; -char t_hs[] ="HS" ; -char t_gp[] ="GP" ; -char unk[] ="?" ; - -char *cpu_s, *db_s, *mem_s, *sec_s; +static const char cpu_2420 [] ="2420" ;/* cpu type */ +static const char cpu_2422 [] ="2422" ; +static const char cpu_2423 [] ="2423" ; +static const char db_men [] ="Menelaus" ;/* board type */ +static const char db_ip [] ="IP" ; +static const char mem_sdr [] ="mSDR" ;/* memory type */ +static const char mem_ddr [] ="mDDR" ; +static const char t_tst [] ="TST" ;/* security level */ +static const char t_emu [] ="EMU" ; +static const char t_hs [] ="HS" ; +static const char t_gp [] ="GP" ; +static const char unk [] ="?" ; + +const char *cpu_s, *db_s, *mem_s, *sec_s;u32 cpu, rev, sec; rev =get_cpu_rev ();
common/Makefile +4 -0
@@ -232,6 +232,10 @@ $(obj)env_embedded.o: $(src)env_embedded.c $(obj)../tools/envcrc $(obj)../tools/envcrc: $(MAKE) -C ../tools +# SEE README.arm-unaligned-accesses +$(obj)hush.o: CFLAGS += -mno-unaligned-access +$(obj)fdt_support.o: CFLAGS += -mno-unaligned-access + ######################################################################### # defines $(obj).depend target
common/cmd_dfu.c +1 -1
@@ -30,7 +30,7 @@static int do_dfu (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {const char *str_env; -char s[] ="dfu" ; +char *s ="dfu" ;char *env_bkp;int ret;
doc/README.arm-unaligned-accesses new file +121 -0
121 lines not on this page · raw message
fs/fat/Makefile +2 -0
@@ -39,6 +39,8 @@ all: $(LIB) $(AOBJS) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)file.o: CFLAGS += -mno-unaligned-access #########################################################################
fs/ubifs/Makefile +3 -0
@@ -42,6 +42,9 @@ all: $(LIB) $(AOBJS) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)super.o: CFLAGS += -mno-unaligned-access + ######################################################################### # defines $(obj).depend target
lib/Makefile +3 -0
@@ -83,6 +83,9 @@ OBJS := $(addprefix $(obj),$(COBJS)) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)bzlib.o: CFLAGS += -mno-unaligned-access + ######################################################################### # defines $(obj).depend target
Signature · 1 line
1.7.9.5
PATCH v4 1/1 ARM: prevent misaligned array inits
Quoted 8 lines · Albert ARIBAUD
Under option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
Signed-off-by Albert ARIBAUD <[email protected]>
We unfortunately have a problem here. This ends up passing -mno-unaligned-access globally, for all platforms. We need something like the following:
Ensure that we only pass -mno-unaligned-access to ARMv7 platforms (where we must ensure this flag is passed so no using call-cc-option).
Signed-off-by; Tom Rini <[email protected]>
arch/arm/cpu/armv7/config.mk +4 -0
@@ -34,6 +34,10 @@ PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARMV7) # ========================================================================= PF_RELFLAGS_SLB_AT := $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) PLATFORM_RELFLAGS += $(PF_RELFLAGS_SLB_AT) + +# SEE README.arm-unaligned-accesses +PLATFORM_NO_UNALIGNED := -mno-unaligned-access + ifneq ($(CONFIG_IMX_CONFIG),) ALL-y += $(obj)u-boot.imx endif
common/Makefile +2 -2
@@ -233,8 +233,8 @@ $(obj)../tools/envcrc: $(MAKE) -C ../tools # SEE README.arm-unaligned-accesses -$(obj)hush.o: CFLAGS += -mno-unaligned-access -$(obj)fdt_support.o: CFLAGS += -mno-unaligned-access +$(obj)hush.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) +$(obj)fdt_support.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) #########################################################################
fs/fat/Makefile +1 -1
@@ -40,7 +40,7 @@ $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) # SEE README.arm-unaligned-accesses -$(obj)file.o: CFLAGS += -mno-unaligned-access +$(obj)file.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) #########################################################################
fs/ubifs/Makefile +1 -1
@@ -43,7 +43,7 @@ $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) # SEE README.arm-unaligned-accesses -$(obj)super.o: CFLAGS += -mno-unaligned-access +$(obj)super.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) #########################################################################
lib/Makefile +1 -1
@@ -84,7 +84,7 @@ $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) # SEE README.arm-unaligned-accesses -$(obj)bzlib.o: CFLAGS += -mno-unaligned-access +$(obj)bzlib.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) #########################################################################
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121009/006c3151/attachment.pgp>
PATCH v4 1/1 ARM: prevent misaligned array inits
Hi Tom,
Quoted 9 lines · Tom Rini
Quoted 7 lines · Albert ARIBAUD
Under option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
Quoted 5 lines
Quoted 1 line
Signed-off-by Albert ARIBAUD <[email protected]>We unfortunately have a problem here. This ends up passing -mno-unaligned-access globally, for all platforms. We need something like the following:
General remark: I'd strongly suggest not to copy-paste in a list reply somtheing that looks suspiciously like a (new) patch. It leads to this kind of things: http://patchwork.ozlabs.org/patch/190403/ which may not be what you wanted.
Quoted 10 lines
Ensure that we only pass -mno-unaligned-access to ARMv7 platforms (where we must ensure this flag is passed so no using call-cc-option).
Signed-off-by; Tom Rini <[email protected]>
arch/arm/cpu/armv7/config.mk +0
-0
arch/arm/cpu/armv7/config.mk PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARMV7) · line 39
Quoted 6 lines
arch/arm/cpu/armv7/config.mk +3
-0@@ -34,6 +34,10 @@ PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARMV7) # ========================================================================= PF_RELFLAGS_SLB_AT := $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) PLATFORM_RELFLAGS += $(PF_RELFLAGS_SLB_AT) + +# SEE README.arm-unaligned-accesses +PLATFORM_NO_UNALIGNED := -mno-unaligned-access
I suspect that you meant
PLATFORM_NO_UNALIGNED := $(call cc-option,-mno-unaligned-access,)
?
Quoted 50 lines
arch/arm/cpu/armv7/config.mk +1
-0+ ifneq ($(CONFIG_IMX_CONFIG),) ALL-y += $(obj)u-boot.imx endifcommon/Makefile +2
-2@@ -233,8 +233,8 @@ $(obj)../tools/envcrc: $(MAKE) -C ../tools # SEE README.arm-unaligned-accesses -$(obj)hush.o: CFLAGS += -mno-unaligned-access -$(obj)fdt_support.o: CFLAGS += -mno-unaligned-access +$(obj)hush.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) +$(obj)fdt_support.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) #########################################################################fs/fat/Makefile +1
-1@@ -40,7 +40,7 @@ $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) # SEE README.arm-unaligned-accesses -$(obj)file.o: CFLAGS += -mno-unaligned-access +$(obj)file.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) #########################################################################fs/ubifs/Makefile +1
-1@@ -43,7 +43,7 @@ $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) # SEE README.arm-unaligned-accesses -$(obj)super.o: CFLAGS += -mno-unaligned-access +$(obj)super.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) #########################################################################lib/Makefile +0
-0
lib/Makefile $(LIB): $(obj).depend $(OBJS) · line 89
Quoted 7 lines
lib/Makefile +1
-1@@ -84,7 +84,7 @@ $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) # SEE README.arm-unaligned-accesses -$(obj)bzlib.o: CFLAGS += -mno-unaligned-access +$(obj)bzlib.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) #########################################################################
Will prepare V5 right away.
Amicalement,
Signature · 1 line
Albert.
PATCH v4 1/1 ARM: prevent misaligned array inits
Quoted 43 lines · Albert ARIBAUD
Hi Tom,
Quoted 9 lines · Tom Rini
Quoted 7 lines · Albert ARIBAUD
Under option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
Quoted 5 lines
Quoted 1 line
Signed-off-by Albert ARIBAUD <[email protected]>We unfortunately have a problem here. This ends up passing -mno-unaligned-access globally, for all platforms. We need something like the following:
General remark: I'd strongly suggest not to copy-paste in a list reply somtheing that looks suspiciously like a (new) patch. It leads to this kind of things: http://patchwork.ozlabs.org/patch/190403/ which may not be what you wanted.
Quoted 10 lines
Ensure that we only pass -mno-unaligned-access to ARMv7 platforms (where we must ensure this flag is passed so no using call-cc-option).
Signed-off-by; Tom Rini <[email protected]>
arch/arm/cpu/armv7/config.mk +0
-0arch/arm/cpu/armv7/config.mk PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARMV7) · line 39
Quoted 6 lines
arch/arm/cpu/armv7/config.mk +3
-0@@ -34,6 +34,10 @@ PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARMV7) # ========================================================================= PF_RELFLAGS_SLB_AT := $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) PLATFORM_RELFLAGS += $(PF_RELFLAGS_SLB_AT) + +# SEE README.arm-unaligned-accesses +PLATFORM_NO_UNALIGNED := -mno-unaligned-accessI suspect that you meant
Quoted 1 line
PLATFORM_NO_UNALIGNED:= $(call cc-option,-mno-unaligned-access,)
This could lead to silently not applying the flag when we want to apply the flag. Just like before, I think we need to force the option, until such time as we can do $(call cc-option,-mdont-unalign-strings-for-fun,-mno-unaligned-access).
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121009/70ef1432/attachment.pgp>
PATCH v5 1/1 ARM: prevent misaligned array inits
In reply to Albert ARIBAUDUnder option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
---
V5: -mno-unaligned-access was applied to all platforms. Make it apply
only to armv7.
Clarified README.arm-unaligned-accesses re how to fix issue. Included revert of 'release-only' workaround.
V4: added information on how to find relocation offset for pc
common/Makefile missed a comment re README.arm-unaligned-accesses
V3: *really* fix incorrect doc file name in dabort handler message
clarifications and typo fixes in README.arm-unaligned-accesses
V2: fix incorrect doc file name in dabort handler message
arch/arm/cpu/arm926ejs/orion5x/cpu.c | 4 +- arch/arm/cpu/armv7/config.mk | 6 +- arch/arm/lib/interrupts.c | 2 +- board/ti/omap2420h4/sys_info.c | 28 ++++---- common/Makefile | 4 ++ common/cmd_dfu.c | 2 +- doc/README.arm-unaligned-accesses | 122 ++++++++++++++++++++++++++++++++++ fs/fat/Makefile | 2 + fs/ubifs/Makefile | 3 + lib/Makefile | 3 + 10 files changed, 156 insertions(+), 20 deletions(-) create mode 100644 doc/README.arm-unaligned-accesses
arch/arm/cpu/arm926ejs/orion5x/cpu.c +2 -2
@@ -194,8 +194,8 @@ u32 orion5x_device_rev(void)*/ int print_cpuinfo (void ) { -char dev_str[] ="0x0000" ; -char rev_str[] ="0x00" ; +char dev_str[7 ];/* room enough for 0x0000 plus null byte */ +char rev_str[5 ];/* room enough for 0x00 plus null byte */ char *dev_name =NULL ;char *rev_name =NULL ;
arch/arm/cpu/armv7/config.mk +4 -2
@@ -26,8 +26,6 @@ PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float # supported by more tool-chains PF_CPPFLAGS_ARMV7 := $(call cc-option, -march=armv7-a, -march=armv5) PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARMV7) -PF_CPPFLAGS_NO_UNALIGNED := $(call cc-option, -mno-unaligned-access,) -PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_NO_UNALIGNED) # ========================================================================= #
@@ -36,6 +34,10 @@ PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_NO_UNALIGNED) # ========================================================================= PF_RELFLAGS_SLB_AT := $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) PLATFORM_RELFLAGS += $(PF_RELFLAGS_SLB_AT) + +# SEE README.arm-unaligned-accesses +PLATFORM_NO_UNALIGNED := $(call cc-option, -mno-unaligned-access,) + ifneq ($(CONFIG_IMX_CONFIG),) ALL-y += $(obj)u-boot.imx endif
arch/arm/lib/interrupts.c +1 -1
@@ -169,7 +169,7 @@ void do_prefetch_abort (struct pt_regs *pt_regs)void do_data_abort (struct pt_regs *pt_regs) { -printf ("data abort\n" ); +printf ("data abort\n\n MAYBE you should read doc/README.arm-unaligned-accesses\n\n" );show_regs (pt_regs);bad_mode (); }
board/ti/omap2420h4/sys_info.c +14 -14
@@ -237,20 +237,20 @@ u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)*********************************************************************/ void display_board_info (u32 btype) { -char cpu_2420[] ="2420" ;/* cpu type */ -char cpu_2422[] ="2422" ; -char cpu_2423[] ="2423" ; -char db_men[] ="Menelaus" ;/* board type */ -char db_ip[] ="IP" ; -char mem_sdr[] ="mSDR" ;/* memory type */ -char mem_ddr[] ="mDDR" ; -char t_tst[] ="TST" ;/* security level */ -char t_emu[] ="EMU" ; -char t_hs[] ="HS" ; -char t_gp[] ="GP" ; -char unk[] ="?" ; - -char *cpu_s, *db_s, *mem_s, *sec_s; +static const char cpu_2420 [] ="2420" ;/* cpu type */ +static const char cpu_2422 [] ="2422" ; +static const char cpu_2423 [] ="2423" ; +static const char db_men [] ="Menelaus" ;/* board type */ +static const char db_ip [] ="IP" ; +static const char mem_sdr [] ="mSDR" ;/* memory type */ +static const char mem_ddr [] ="mDDR" ; +static const char t_tst [] ="TST" ;/* security level */ +static const char t_emu [] ="EMU" ; +static const char t_hs [] ="HS" ; +static const char t_gp [] ="GP" ; +static const char unk [] ="?" ; + +const char *cpu_s, *db_s, *mem_s, *sec_s;u32 cpu, rev, sec; rev =get_cpu_rev ();
common/Makefile +4 -0
@@ -231,6 +231,10 @@ $(obj)env_embedded.o: $(src)env_embedded.c $(obj)../tools/envcrc $(obj)../tools/envcrc: $(MAKE) -C ../tools +# SEE README.arm-unaligned-accesses +$(obj)hush.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) +$(obj)fdt_support.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) + ######################################################################### # defines $(obj).depend target
common/cmd_dfu.c +1 -1
@@ -30,7 +30,7 @@static int do_dfu (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {const char *str_env; -char s[] ="dfu" ; +char *s ="dfu" ;char *env_bkp;int ret;
doc/README.arm-unaligned-accesses new file +122 -0
122 lines not on this page · raw message
fs/fat/Makefile +2 -0
@@ -39,6 +39,8 @@ all: $(LIB) $(AOBJS) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)file.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) #########################################################################
fs/ubifs/Makefile +3 -0
@@ -42,6 +42,9 @@ all: $(LIB) $(AOBJS) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)super.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) + ######################################################################### # defines $(obj).depend target
lib/Makefile +3 -0
@@ -83,6 +83,9 @@ OBJS := $(addprefix $(obj),$(COBJS)) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)bzlib.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) + ######################################################################### # defines $(obj).depend target
Signature · 1 line
1.7.9.5
PATCH 1/1 ARM: prevent misaligned array inits
Under option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
---
V6: Make sure that gcc does not silently drop -mno-unaligned-access
if it does not support it.
V5: -mno-unaligned-access was applied to all platforms. Make it apply
only to armv7.
Clarified README.arm-unaligned-accesses re how to fix issue. Included revert of 'release-only' workaround.
V4: added information on how to find relocation offset for pc
common/Makefile missed a comment re README.arm-unaligned-accesses
V3: *really* fix incorrect doc file name in dabort handler message
clarifications and typo fixes in README.arm-unaligned-accesses
V2: fix incorrect doc file name in dabort handler message
arch/arm/cpu/arm926ejs/orion5x/cpu.c | 4 +- arch/arm/cpu/armv7/config.mk | 6 +- arch/arm/lib/interrupts.c | 2 +- board/ti/omap2420h4/sys_info.c | 28 ++++---- common/Makefile | 4 ++ common/cmd_dfu.c | 2 +- doc/README.arm-unaligned-accesses | 122 ++++++++++++++++++++++++++++++++++ fs/fat/Makefile | 2 + fs/ubifs/Makefile | 3 + lib/Makefile | 3 + 10 files changed, 156 insertions(+), 20 deletions(-) create mode 100644 doc/README.arm-unaligned-accesses
arch/arm/cpu/arm926ejs/orion5x/cpu.c +2 -2
@@ -194,8 +194,8 @@ u32 orion5x_device_rev(void)*/ int print_cpuinfo (void ) { -char dev_str[] ="0x0000" ; -char rev_str[] ="0x00" ; +char dev_str[7 ];/* room enough for 0x0000 plus null byte */ +char rev_str[5 ];/* room enough for 0x00 plus null byte */ char *dev_name =NULL ;char *rev_name =NULL ;
arch/arm/cpu/armv7/config.mk +4 -2
@@ -26,8 +26,6 @@ PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float # supported by more tool-chains PF_CPPFLAGS_ARMV7 := $(call cc-option, -march=armv7-a, -march=armv5) PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARMV7) -PF_CPPFLAGS_NO_UNALIGNED := $(call cc-option, -mno-unaligned-access,) -PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_NO_UNALIGNED) # ========================================================================= #
@@ -36,6 +34,10 @@ PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_NO_UNALIGNED) # ========================================================================= PF_RELFLAGS_SLB_AT := $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) PLATFORM_RELFLAGS += $(PF_RELFLAGS_SLB_AT) + +# SEE README.arm-unaligned-accesses +PLATFORM_NO_UNALIGNED := -mno-unaligned-access + ifneq ($(CONFIG_IMX_CONFIG),) ALL-y += $(obj)u-boot.imx endif
arch/arm/lib/interrupts.c +1 -1
@@ -169,7 +169,7 @@ void do_prefetch_abort (struct pt_regs *pt_regs)void do_data_abort (struct pt_regs *pt_regs) { -printf ("data abort\n" ); +printf ("data abort\n\n MAYBE you should read doc/README.arm-unaligned-accesses\n\n" );show_regs (pt_regs);bad_mode (); }
board/ti/omap2420h4/sys_info.c +14 -14
@@ -237,20 +237,20 @@ u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)*********************************************************************/ void display_board_info (u32 btype) { -char cpu_2420[] ="2420" ;/* cpu type */ -char cpu_2422[] ="2422" ; -char cpu_2423[] ="2423" ; -char db_men[] ="Menelaus" ;/* board type */ -char db_ip[] ="IP" ; -char mem_sdr[] ="mSDR" ;/* memory type */ -char mem_ddr[] ="mDDR" ; -char t_tst[] ="TST" ;/* security level */ -char t_emu[] ="EMU" ; -char t_hs[] ="HS" ; -char t_gp[] ="GP" ; -char unk[] ="?" ; - -char *cpu_s, *db_s, *mem_s, *sec_s; +static const char cpu_2420 [] ="2420" ;/* cpu type */ +static const char cpu_2422 [] ="2422" ; +static const char cpu_2423 [] ="2423" ; +static const char db_men [] ="Menelaus" ;/* board type */ +static const char db_ip [] ="IP" ; +static const char mem_sdr [] ="mSDR" ;/* memory type */ +static const char mem_ddr [] ="mDDR" ; +static const char t_tst [] ="TST" ;/* security level */ +static const char t_emu [] ="EMU" ; +static const char t_hs [] ="HS" ; +static const char t_gp [] ="GP" ; +static const char unk [] ="?" ; + +const char *cpu_s, *db_s, *mem_s, *sec_s;u32 cpu, rev, sec; rev =get_cpu_rev ();
common/Makefile +4 -0
@@ -231,6 +231,10 @@ $(obj)env_embedded.o: $(src)env_embedded.c $(obj)../tools/envcrc $(obj)../tools/envcrc: $(MAKE) -C ../tools +# SEE README.arm-unaligned-accesses +$(obj)hush.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) +$(obj)fdt_support.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) + ######################################################################### # defines $(obj).depend target
common/cmd_dfu.c +1 -1
@@ -30,7 +30,7 @@static int do_dfu (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {const char *str_env; -char s[] ="dfu" ; +char *s ="dfu" ;char *env_bkp;int ret;
doc/README.arm-unaligned-accesses new file +122 -0
122 lines not on this page · raw message
fs/fat/Makefile +2 -0
@@ -39,6 +39,8 @@ all: $(LIB) $(AOBJS) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)file.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) #########################################################################
fs/ubifs/Makefile +3 -0
@@ -42,6 +42,9 @@ all: $(LIB) $(AOBJS) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)super.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) + ######################################################################### # defines $(obj).depend target
lib/Makefile +3 -0
@@ -83,6 +83,9 @@ OBJS := $(addprefix $(obj),$(COBJS)) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)bzlib.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) + ######################################################################### # defines $(obj).depend target
Signature · 1 line
1.7.9.5
PATCH 1/1 ARM: prevent misaligned array inits -- PLEASE DISREGARD.
This patch has been sent without a proper Vx indication.
Resending.
Amicalement,
Signature · 1 line
Albert.
PATCH RESEND v6 1/1 ARM: prevent misaligned array inits
In reply to Albert ARIBAUDUnder option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
---
V6: Make sure that gcc does not silently drop -mno-unaligned-access
if it does not support it.
V5: -mno-unaligned-access was applied to all platforms. Make it apply
only to armv7.
Clarified README.arm-unaligned-accesses re how to fix issue. Included revert of 'release-only' workaround.
V4: added information on how to find relocation offset for pc
common/Makefile missed a comment re README.arm-unaligned-accesses
V3: *really* fix incorrect doc file name in dabort handler message
clarifications and typo fixes in README.arm-unaligned-accesses
V2: fix incorrect doc file name in dabort handler message
arch/arm/cpu/arm926ejs/orion5x/cpu.c | 4 +- arch/arm/cpu/armv7/config.mk | 6 +- arch/arm/lib/interrupts.c | 2 +- board/ti/omap2420h4/sys_info.c | 28 ++++---- common/Makefile | 4 ++ common/cmd_dfu.c | 2 +- doc/README.arm-unaligned-accesses | 122 ++++++++++++++++++++++++++++++++++ fs/fat/Makefile | 2 + fs/ubifs/Makefile | 3 + lib/Makefile | 3 + 10 files changed, 156 insertions(+), 20 deletions(-) create mode 100644 doc/README.arm-unaligned-accesses
arch/arm/cpu/arm926ejs/orion5x/cpu.c +2 -2
@@ -194,8 +194,8 @@ u32 orion5x_device_rev(void)*/ int print_cpuinfo (void ) { -char dev_str[] ="0x0000" ; -char rev_str[] ="0x00" ; +char dev_str[7 ];/* room enough for 0x0000 plus null byte */ +char rev_str[5 ];/* room enough for 0x00 plus null byte */ char *dev_name =NULL ;char *rev_name =NULL ;
arch/arm/cpu/armv7/config.mk +4 -2
@@ -26,8 +26,6 @@ PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float # supported by more tool-chains PF_CPPFLAGS_ARMV7 := $(call cc-option, -march=armv7-a, -march=armv5) PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARMV7) -PF_CPPFLAGS_NO_UNALIGNED := $(call cc-option, -mno-unaligned-access,) -PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_NO_UNALIGNED) # ========================================================================= #
@@ -36,6 +34,10 @@ PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_NO_UNALIGNED) # ========================================================================= PF_RELFLAGS_SLB_AT := $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) PLATFORM_RELFLAGS += $(PF_RELFLAGS_SLB_AT) + +# SEE README.arm-unaligned-accesses +PLATFORM_NO_UNALIGNED := -mno-unaligned-access + ifneq ($(CONFIG_IMX_CONFIG),) ALL-y += $(obj)u-boot.imx endif
arch/arm/lib/interrupts.c +1 -1
@@ -169,7 +169,7 @@ void do_prefetch_abort (struct pt_regs *pt_regs)void do_data_abort (struct pt_regs *pt_regs) { -printf ("data abort\n" ); +printf ("data abort\n\n MAYBE you should read doc/README.arm-unaligned-accesses\n\n" );show_regs (pt_regs);bad_mode (); }
board/ti/omap2420h4/sys_info.c +14 -14
@@ -237,20 +237,20 @@ u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)*********************************************************************/ void display_board_info (u32 btype) { -char cpu_2420[] ="2420" ;/* cpu type */ -char cpu_2422[] ="2422" ; -char cpu_2423[] ="2423" ; -char db_men[] ="Menelaus" ;/* board type */ -char db_ip[] ="IP" ; -char mem_sdr[] ="mSDR" ;/* memory type */ -char mem_ddr[] ="mDDR" ; -char t_tst[] ="TST" ;/* security level */ -char t_emu[] ="EMU" ; -char t_hs[] ="HS" ; -char t_gp[] ="GP" ; -char unk[] ="?" ; - -char *cpu_s, *db_s, *mem_s, *sec_s; +static const char cpu_2420 [] ="2420" ;/* cpu type */ +static const char cpu_2422 [] ="2422" ; +static const char cpu_2423 [] ="2423" ; +static const char db_men [] ="Menelaus" ;/* board type */ +static const char db_ip [] ="IP" ; +static const char mem_sdr [] ="mSDR" ;/* memory type */ +static const char mem_ddr [] ="mDDR" ; +static const char t_tst [] ="TST" ;/* security level */ +static const char t_emu [] ="EMU" ; +static const char t_hs [] ="HS" ; +static const char t_gp [] ="GP" ; +static const char unk [] ="?" ; + +const char *cpu_s, *db_s, *mem_s, *sec_s;u32 cpu, rev, sec; rev =get_cpu_rev ();
common/Makefile +4 -0
@@ -231,6 +231,10 @@ $(obj)env_embedded.o: $(src)env_embedded.c $(obj)../tools/envcrc $(obj)../tools/envcrc: $(MAKE) -C ../tools +# SEE README.arm-unaligned-accesses +$(obj)hush.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) +$(obj)fdt_support.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) + ######################################################################### # defines $(obj).depend target
common/cmd_dfu.c +1 -1
@@ -30,7 +30,7 @@static int do_dfu (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {const char *str_env; -char s[] ="dfu" ; +char *s ="dfu" ;char *env_bkp;int ret;
doc/README.arm-unaligned-accesses new file +122 -0
122 lines not on this page · raw message
fs/fat/Makefile +2 -0
@@ -39,6 +39,8 @@ all: $(LIB) $(AOBJS) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)file.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) #########################################################################
fs/ubifs/Makefile +3 -0
@@ -42,6 +42,9 @@ all: $(LIB) $(AOBJS) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)super.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) + ######################################################################### # defines $(obj).depend target
lib/Makefile +3 -0
@@ -83,6 +83,9 @@ OBJS := $(addprefix $(obj),$(COBJS)) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) +# SEE README.arm-unaligned-accesses +$(obj)bzlib.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) + ######################################################################### # defines $(obj).depend target
Signature · 1 line
1.7.9.5
PATCH RESEND v6 1/1 ARM: prevent misaligned array inits
Quoted 9 lines · Albert ARIBAUD
Under option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
Signed-off-by Albert ARIBAUD <[email protected]>---
Tom,
As per our discussion, this patch should be placed in u-boot/next right above the 2012-10 release commit.
At this time, just after a git fech u-boot, I don't see the patch in next at all.
Do you want me to prepare an ad hoc branch with this patch then the current content of u-boot/next, above v2012.10-rc3, so that you just have to git reset --hard your next on it?
Amicalement,
Signature · 1 line
Albert.
PATCH RESEND v6 1/1 ARM: prevent misaligned array inits
Quoted 18 lines · Albert ARIBAUD
Quoted 9 lines · Albert ARIBAUD
Under option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
Signed-off-by Albert ARIBAUD <[email protected]>---
Tom,
As per our discussion, this patch should be placed in u-boot/next right above the 2012-10 release commit.
Quoted 8 lines
At this time, just after a git fech u-boot, I don't see the patch in next at all.
Do you want me to prepare an ad hoc branch with this patch then the current content of u-boot/next, above v2012.10-rc3, so that you just have to git reset --hard your next on it?
Amicalement,
As the questions about our usage of rebasing in 'next' have shown, it's not quite as cut and dry as I had hoped to rebase next at my whim (and long term, that's a good thing I think). My plan tomorrow (or today, depending on your local timezone) is to release v2012.10, apply this v6 patch and then bring in next to master, see that everything is still building and go from there.
Signature · 1 line
Tom
PATCH RESEND v6 1/1 ARM: prevent misaligned array inits
Hi Tom,
Quoted 27 lines · Tom Rini
Quoted 25 lines · Albert ARIBAUD
Quoted 9 lines · Albert ARIBAUD
Under option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
Signed-off-by Albert ARIBAUD <[email protected]>---
Tom,
As per our discussion, this patch should be placed in u-boot/next right above the 2012-10 release commit.
At this time, just after a git fech u-boot, I don't see the patch in next at all.
Do you want me to prepare an ad hoc branch with this patch then the current content of u-boot/next, above v2012.10-rc3, so that you just have to git reset --hard your next on it?
Quoted 8 lines
Quoted 1 line
Amicalement,
As the questions about our usage of rebasing in 'next' have shown, it's not quite as cut and dry as I had hoped to rebase next at my whim (and long term, that's a good thing I think). My plan tomorrow (or today, depending on your local timezone) is to release v2012.10, apply this v6 patch and then bring in next to master, see that everything is still building and go from there.
Fine with me, thanks!
P.S. Until this release, I'd worked under the assumption that next could be more freely rebased than master is. From now on, I will follow the same principle for next as for master, i.e. not rebase but merge (possibly ff) from other and only rollback if required and appropriate.
Amicalement,
Signature · 1 line
Albert.
PATCH RESEND v6 1/1 ARM: prevent misaligned array inits
In reply to Albert ARIBAUDQuoted 11 lines · Albert ARIBAUD
Under option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access.
Signed-off-by Albert ARIBAUD <[email protected]>---
V6: Make sure that gcc does not silently drop -mno-unaligned-access
if it does not support it.
OK, you were correct. We need to use cc-option since older compilers which were not causing issues don't support it either, making this workable. I will just fix this in-line rather than make you do a v7.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121015/2ce1ce8d/attachment.pgp>