Skip to contentSkip to conversation

Disaligned buffer in print_buffer

PATCH New Stefano Babic 4 participants 10 messages Aug 19, 2010 – Aug 28, 2010 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Disaligned buffer in print_buffer

As linebuf is accessed with 32-bit pointers, its address must be 32 bit aligned to avoid misaligned access.

---
 lib/display_options.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/display_options.c +1 -1
index 20319e6..30374f9 100644
@@ -101,7 +101,7 @@ void print_size(unsigned long long size, const char *s)
 #define DEFAULT_LINE_LENGTH_BYTES (16)
 int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen)
 {
-	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1];
+	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1] __attribute__((__aligned__(4)));
 	uint32_t *uip = (void*)linebuf;
 	uint16_t *usp = (void*)linebuf;
 	uint8_t *ucp = (void*)linebuf;
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH 1/1 Disaligned buffer in print_buffer

Quoted 3 lines · On Thursday, August 19, 2010 07:01:58 Stefano Babic wrote:
(quoted diff) +1 -1
-	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1];
+	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1]

__attribute__((__aligned__(4)));

i'd rather we go with Albert Aribaud's change (posted 14 Aug 2010)
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100819/7b2489a6/attachment.pgp

#2 lore raw

PATCH 1/1 Disaligned buffer in print_buffer

Quoted 7 lines · Mike Frysinger
Quoted 3 lines · On Thursday, August 19, 2010 07:01:58 Stefano Babic wrote:
(quoted diff) +1 -1
-	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1];
+	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1]

__attribute__((__aligned__(4)));

i'd rather we go with Albert Aribaud's change (posted 14 Aug 2010) -mike

Ok, I have missed someone else went in the same trouble ! Wolfgang, could you apply Albert's patch to the mainline ? As I see in the discussion, the patch proposed is accepted because _attribute__((__aligned__())) is everywhere used in u-boot.

Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#3 lore raw

PATCH 1/1 Disaligned buffer in print_buffer

Le 19/08/2010 18:33, Stefano Babic a ?crit :

Quoted 5 lines

As I see in the
discussion, the patch proposed is accepted because _attribute__((__aligned__())) is everywhere used in u-boot.

Stefano

'Acceptable' is my bet... Not yet 'accepted' though. :)

Amicalement,

Signature · 1 line
Albert.
#4 lore raw

PATCH 1/1 Disaligned buffer in print_buffer

In reply to Stefano Babic
Quoted 13 lines · Stefano Babic

As linebuf is accessed with 32-bit pointers, its address must be 32 bit aligned to avoid misaligned access.

---
 lib/display_options.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/display_options.c +0 -0
index 20319e6..30374f9 100644

lib/display_options.c void print_size(unsigned long long size, const char *s) · line 107

Quoted 8 lines
lib/display_options.c +1 -1
@@ -101,7 +101,7 @@ void print_size(unsigned long long size, const char *s)
 #define DEFAULT_LINE_LENGTH_BYTES (16)
 int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen)
 {
-	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1];
+	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1] __attribute__((__aligned__(4)));
 	uint32_t *uip = (void*)linebuf;
 	uint16_t *usp = (void*)linebuf;
 	uint8_t *ucp = (void*)linebuf;

Why not just declare it as

	uint_32t linebuf[MAX_LINE_LENGTH_BYTES/4+1];

?

Best Regards,
Reinhard

#5 lore raw

PATCH 1/1 Disaligned buffer in print_buffer

Quoted 14 lines · On Friday, August 27, 2010 05:41:08 Reinhard Meyer wrote:
Quoted 13 lines · Stefano Babic
lib/display_options.c +1 -1
@@ -101,7 +101,7 @@ void print_size(unsigned long long size, const char
 *s)
 
 #define DEFAULT_LINE_LENGTH_BYTES (16)
 int print_buffer (ulong addr, void* data, uint width, uint count, uint
 linelen) {
 
-	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1];
+	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1]

__attribute__((__aligned__(4)));

Quoted 7 lines

lib/display_options.c void print_size(unsigned long long size, const char *s) · line 107

Quoted 3 lines
lib/display_options.c +0 -0
 	uint32_t *uip = (void*)linebuf;
 	uint16_t *usp = (void*)linebuf;
 	uint8_t *ucp = (void*)linebuf;

Why not just declare it as

	uint_32t linebuf[MAX_LINE_LENGTH_BYTES/4+1];

?

i guess that'd be another way of doing it
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100827/70be83e1/attachment.pgp

#6 lore raw

PATCH 1/1 Disaligned buffer in print_buffer

In reply to Reinhard Meyer

Reinhard Meyer wrote:

Hi Reinhard,

Quoted 3 lines

Why not just declare it as

	uint_32t linebuf[MAX_LINE_LENGTH_BYTES/4+1];

?

Yes, we do not need any special compiler attribute. I forward to Albert, he sent previously an analog patch to solve this issue.

Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#7 lore raw

PATCH 1/1 Disaligned buffer in print_buffer

Quoted 4 lines · Stefano Babic

Reinhard Meyer wrote:

Hi Reinhard,

Quoted 9 lines
Quoted 3 lines

Why not just declare it as

	uint_32t linebuf[MAX_LINE_LENGTH_BYTES/4+1];

?

Yes, we do not need any special compiler attribute. I forward to Albert, he sent previously an analog patch to solve this issue.

Stefano

If you need a patch for this, I have made the change here this morning. I can format and email one instantly.

Reinhard

#8 lore raw

PATCH 1/1 Disaligned buffer in print_buffer

Le 27/08/2010 21:06, Reinhard Meyer a ?crit :

Quoted 12 lines · Stefano Babic
Quoted 11 lines

Reinhard Meyer wrote:

Hi Reinhard,

Quoted 3 lines

Why not just declare it as
uint_32t linebuf[MAX_LINE_LENGTH_BYTES/4+1];
?

Yes, we do not need any special compiler attribute. I forward to Albert, he sent previously an analog patch to solve this issue.

Quoted 6 lines
Quoted 2 lines

Stefano

If you need a patch for this, I have made the change here this morning. I can format and email one instantly.

Reinhard

I say go ahead!

Amicalement,

Signature · 1 line
Albert.
#9 lore raw

PATCH 1/1 Disaligned buffer in print_buffer

Dear Albert ARIBAUD,

Quoted 6 lines
Quoted 4 lines

If you need a patch for this, I have made the change here this morning. I can format and email one instantly.

Reinhard

I say go ahead!

Its there, right after the message. It has a different title, because I made it before I found the tread about the issue :)

Reinhard