* [U-Boot] [PATCH] fdt: remove unaligned access in fdt_fixup_ethernet()
@ 2013-05-28 4:01 Stephen Warren
2013-05-28 4:05 ` Michael Trimarchi
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Stephen Warren @ 2013-05-28 4:01 UTC (permalink / raw)
To: u-boot
Some ARM compilers may emit code that makes unaligned accesses when
faced with constructs such as:
char mac[16] = "ethaddr";
Replace this with a strcpy() call instead to avoid this. strcpy() is
used here, rather than replacing all usage of the mac variable with the
string itself, since the loop itself sprintf()s to the variable each
iteration, so strcpy() is doing basically the same thing.
Reported-by: Florian Meier
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
---
common/fdt_support.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 812acb4..89e7883 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -454,7 +454,7 @@ void fdt_fixup_ethernet(void *fdt)
{
int node, i, j;
char enet[16], *tmp, *end;
- char mac[16] = "ethaddr";
+ char mac[16];
const char *path;
unsigned char mac_addr[6];
@@ -463,6 +463,7 @@ void fdt_fixup_ethernet(void *fdt)
return;
i = 0;
+ strcpy(mac, "ethaddr");
while ((tmp = getenv(mac)) != NULL) {
sprintf(enet, "ethernet%d", i);
path = fdt_getprop(fdt, node, enet, NULL);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] fdt: remove unaligned access in fdt_fixup_ethernet()
2013-05-28 4:01 [U-Boot] [PATCH] fdt: remove unaligned access in fdt_fixup_ethernet() Stephen Warren
@ 2013-05-28 4:05 ` Michael Trimarchi
2013-05-28 4:16 ` Stephen Warren
2013-06-05 3:41 ` Stephen Warren
2013-06-07 18:19 ` [U-Boot] " Tom Rini
2 siblings, 1 reply; 6+ messages in thread
From: Michael Trimarchi @ 2013-05-28 4:05 UTC (permalink / raw)
To: u-boot
Hi
On May 28, 2013 6:02 AM, "Stephen Warren" <swarren@wwwdotorg.org> wrote:
>
> Some ARM compilers may emit code that makes unaligned accesses when
> faced with constructs such as:
>
> char mac[16] = "ethaddr";
>
Recently I have seen some of this emails. I understand the problem but is
it a compiler problem? Is it reported somewhere?
Michael
> Replace this with a strcpy() call instead to avoid this. strcpy() is
> used here, rather than replacing all usage of the mac variable with the
> string itself, since the loop itself sprintf()s to the variable each
> iteration, so strcpy() is doing basically the same thing.
>
> Reported-by: Florian Meier
> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
> ---
> common/fdt_support.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index 812acb4..89e7883 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
> @@ -454,7 +454,7 @@ void fdt_fixup_ethernet(void *fdt)
> {
> int node, i, j;
> char enet[16], *tmp, *end;
> - char mac[16] = "ethaddr";
> + char mac[16];
> const char *path;
> unsigned char mac_addr[6];
>
> @@ -463,6 +463,7 @@ void fdt_fixup_ethernet(void *fdt)
> return;
>
> i = 0;
> + strcpy(mac, "ethaddr");
> while ((tmp = getenv(mac)) != NULL) {
> sprintf(enet, "ethernet%d", i);
> path = fdt_getprop(fdt, node, enet, NULL);
> --
> 1.7.10.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] fdt: remove unaligned access in fdt_fixup_ethernet()
2013-05-28 4:05 ` Michael Trimarchi
@ 2013-05-28 4:16 ` Stephen Warren
0 siblings, 0 replies; 6+ messages in thread
From: Stephen Warren @ 2013-05-28 4:16 UTC (permalink / raw)
To: u-boot
On 05/27/2013 10:05 PM, Michael Trimarchi wrote:
> Hi
>
> On May 28, 2013 6:02 AM, "Stephen Warren" <swarren@wwwdotorg.org
> <mailto:swarren@wwwdotorg.org>> wrote:
>>
>> Some ARM compilers may emit code that makes unaligned accesses when
>> faced with constructs such as:
>>
>> char mac[16] = "ethaddr";
>>
>
> Recently I have seen some of this emails. I understand the problem but
> is it a compiler problem? Is it reported somewhere?
The situation is explained in doc/README.arm-unaligned-accesses.
IIUC, the basic synopsis is that before ARMv7, the HW could not perform
unaligned accesses, whereas ARMv7 and later can (with an enable bit in
HW). Newer gcc takes advantage of this fact when it knows it's compiling
for ARMv7 or later. However, in order to support pre-ARMv7, U-Boot has
disabled this feature even on ARMv7 HW at runtime, so it's obvious where
the code is making unaligned accesses, so U-Boot still works on
pre-ARMv7. However, where gcc "implicitly" emits unaligned accesses, we
have to fix them up, as in this patch.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] fdt: remove unaligned access in fdt_fixup_ethernet()
2013-05-28 4:01 [U-Boot] [PATCH] fdt: remove unaligned access in fdt_fixup_ethernet() Stephen Warren
2013-05-28 4:05 ` Michael Trimarchi
@ 2013-06-05 3:41 ` Stephen Warren
2013-06-07 18:19 ` [U-Boot] " Tom Rini
2 siblings, 0 replies; 6+ messages in thread
From: Stephen Warren @ 2013-06-05 3:41 UTC (permalink / raw)
To: u-boot
On 05/27/2013 10:01 PM, Stephen Warren wrote:
> Some ARM compilers may emit code that makes unaligned accesses when
> faced with constructs such as:
>
> char mac[16] = "ethaddr";
>
> Replace this with a strcpy() call instead to avoid this. strcpy() is
> used here, rather than replacing all usage of the mac variable with the
> string itself, since the loop itself sprintf()s to the variable each
> iteration, so strcpy() is doing basically the same thing.
Jerry, does this patch look good? This fixes a problem that prevents
U-Boot from booting a Linux kernel for some people. Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] fdt: remove unaligned access in fdt_fixup_ethernet()
2013-05-28 4:01 [U-Boot] [PATCH] fdt: remove unaligned access in fdt_fixup_ethernet() Stephen Warren
2013-05-28 4:05 ` Michael Trimarchi
2013-06-05 3:41 ` Stephen Warren
@ 2013-06-07 18:19 ` Tom Rini
2013-06-12 1:55 ` Jerry Van Baren
2 siblings, 1 reply; 6+ messages in thread
From: Tom Rini @ 2013-06-07 18:19 UTC (permalink / raw)
To: u-boot
On Mon, May 27, 2013 at 06:01:19PM -0000, Stephen Warren wrote:
> Some ARM compilers may emit code that makes unaligned accesses when
> faced with constructs such as:
>
> char mac[16] = "ethaddr";
>
> Replace this with a strcpy() call instead to avoid this. strcpy() is
> used here, rather than replacing all usage of the mac variable with the
> string itself, since the loop itself sprintf()s to the variable each
> iteration, so strcpy() is doing basically the same thing.
>
> Reported-by: Florian Meier
> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
Applied to u-boot/master, thanks!
--
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/20130607/22b9944e/attachment.pgp>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] fdt: remove unaligned access in fdt_fixup_ethernet()
2013-06-07 18:19 ` [U-Boot] " Tom Rini
@ 2013-06-12 1:55 ` Jerry Van Baren
0 siblings, 0 replies; 6+ messages in thread
From: Jerry Van Baren @ 2013-06-12 1:55 UTC (permalink / raw)
To: u-boot
Hi Stephen,
Sorry for not applying this in a timely manner. Thanks, Tom, for
covering for me.
gvb
On 06/07/2013 02:19 PM, Tom Rini wrote:
> On Mon, May 27, 2013 at 06:01:19PM -0000, Stephen Warren wrote:
>
>> Some ARM compilers may emit code that makes unaligned accesses when
>> faced with constructs such as:
>>
>> char mac[16] = "ethaddr";
>>
>> Replace this with a strcpy() call instead to avoid this. strcpy() is
>> used here, rather than replacing all usage of the mac variable with the
>> string itself, since the loop itself sprintf()s to the variable each
>> iteration, so strcpy() is doing basically the same thing.
>>
>> Reported-by: Florian Meier
>> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
>
> Applied to u-boot/master, thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-06-12 1:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-28 4:01 [U-Boot] [PATCH] fdt: remove unaligned access in fdt_fixup_ethernet() Stephen Warren
2013-05-28 4:05 ` Michael Trimarchi
2013-05-28 4:16 ` Stephen Warren
2013-06-05 3:41 ` Stephen Warren
2013-06-07 18:19 ` [U-Boot] " Tom Rini
2013-06-12 1:55 ` Jerry Van Baren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox