linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] printk: Fix alignment of buf causing crash on ARM EABI
@ 2012-06-05  6:52 Andrew Lunn
  2012-06-05  6:59 ` Greg KH
  2012-06-05 16:03 ` Stephen Warren
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Lunn @ 2012-06-05  6:52 UTC (permalink / raw)
  To: linux-arm-kernel

Commit 7ff9554bb578ba02166071d2d487b7fc7d860d62, printk: convert
byte-buffer to variable-length record buffer, causes systems using
EABI to crash very early in the boot cycle. The first entry in struct
log is a u64, which for EABI must be 8 byte aligned.

Make use of __alignof__() so the compiler to decide the alignment, but
allow it to be overridden using CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS,
for systems which can perform unaligned access and want to save
a few bytes of space.

Tested on Orion5x and Kirkwood.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 kernel/printk.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/printk.c b/kernel/printk.c
index 32462d2..f205c25 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -227,10 +227,10 @@ static u32 clear_idx;
 #define LOG_LINE_MAX 1024
 
 /* record buffer */
-#if !defined(CONFIG_64BIT) || defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
+#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
 #define LOG_ALIGN 4
 #else
-#define LOG_ALIGN 8
+#define LOG_ALIGN __alignof__(struct log)
 #endif
 #define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)
 static char __log_buf[__LOG_BUF_LEN] __aligned(LOG_ALIGN);
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] printk: Fix alignment of buf causing crash on ARM EABI
  2012-06-05  6:52 [PATCH] printk: Fix alignment of buf causing crash on ARM EABI Andrew Lunn
@ 2012-06-05  6:59 ` Greg KH
  2012-06-05 14:20   ` Kay Sievers
  2012-06-05 16:03 ` Stephen Warren
  1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2012-06-05  6:59 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jun 05, 2012 at 08:52:34AM +0200, Andrew Lunn wrote:
> Commit 7ff9554bb578ba02166071d2d487b7fc7d860d62, printk: convert
> byte-buffer to variable-length record buffer, causes systems using
> EABI to crash very early in the boot cycle. The first entry in struct
> log is a u64, which for EABI must be 8 byte aligned.
> 
> Make use of __alignof__() so the compiler to decide the alignment, but
> allow it to be overridden using CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS,
> for systems which can perform unaligned access and want to save
> a few bytes of space.
> 
> Tested on Orion5x and Kirkwood.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
>  kernel/printk.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Thanks, I think I have a patch in my to-apply queue that fixes this in a
bit different way.  I'll dig that up and compare them in the next few
days as I work my way through my pending patch queue.

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] printk: Fix alignment of buf causing crash on ARM EABI
  2012-06-05  6:59 ` Greg KH
@ 2012-06-05 14:20   ` Kay Sievers
  0 siblings, 0 replies; 4+ messages in thread
From: Kay Sievers @ 2012-06-05 14:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jun 5, 2012 at 8:59 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Tue, Jun 05, 2012 at 08:52:34AM +0200, Andrew Lunn wrote:
>> Commit 7ff9554bb578ba02166071d2d487b7fc7d860d62, printk: convert
>> byte-buffer to variable-length record buffer, causes systems using
>> EABI to crash very early in the boot cycle. The first entry in struct
>> log is a u64, which for EABI must be 8 byte aligned.
>>
>> Make use of __alignof__() so the compiler to decide the alignment, but
>> allow it to be overridden using CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS,
>> for systems which can perform unaligned access and want to save
>> a few bytes of space.
>>
>> Tested on Orion5x and Kirkwood.
>>
>> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
>> ---
>> ?kernel/printk.c | ? ?4 ++--
>> ?1 file changed, 2 insertions(+), 2 deletions(-)
>
> Thanks, I think I have a patch in my to-apply queue that fixes this in a
> bit different way. ?I'll dig that up and compare them in the next few
> days as I work my way through my pending patch queue.

This patch looks good to me.

Thanks,
Kay

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] printk: Fix alignment of buf causing crash on ARM EABI
  2012-06-05  6:52 [PATCH] printk: Fix alignment of buf causing crash on ARM EABI Andrew Lunn
  2012-06-05  6:59 ` Greg KH
@ 2012-06-05 16:03 ` Stephen Warren
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Warren @ 2012-06-05 16:03 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/05/2012 12:52 AM, Andrew Lunn wrote:
> Commit 7ff9554bb578ba02166071d2d487b7fc7d860d62, printk: convert
> byte-buffer to variable-length record buffer, causes systems using
> EABI to crash very early in the boot cycle. The first entry in struct
> log is a u64, which for EABI must be 8 byte aligned.
> 
> Make use of __alignof__() so the compiler to decide the alignment, but
> allow it to be overridden using CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS,
> for systems which can perform unaligned access and want to save
> a few bytes of space.
> 
> Tested on Orion5x and Kirkwood.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Tested-by: Stephen Warren <swarren@wwwdotorg.org>
Acked-by: Stephen Warren <swarren@wwwdotorg.org>

Indeed, using alignof is a good idea.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-06-05 16:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-05  6:52 [PATCH] printk: Fix alignment of buf causing crash on ARM EABI Andrew Lunn
2012-06-05  6:59 ` Greg KH
2012-06-05 14:20   ` Kay Sievers
2012-06-05 16:03 ` Stephen Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).