linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] printk: correctly align __log_buf
@ 2012-05-10 22:14 Stephen Warren
  2012-05-10 22:39 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Warren @ 2012-05-10 22:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Kay Sievers, linux-kernel, linux-next, Stephen Warren

From: Stephen Warren <swarren@nvidia.com>

__log_buf must be aligned, because a 64-bit value is written directly
to it as part of struct log. Alignment of the log entries is typically
handled by log_store(), but this only triggers for subsequent entries,
not the very first (or wrapped) entries.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 kernel/printk.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/kernel/printk.c b/kernel/printk.c
index 7b43295..7e82fb7 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -227,8 +227,13 @@ static u32 clear_idx;
 #define LOG_LINE_MAX 1024
 
 /* record buffer */
+#if !defined(CONFIG_64BIT) || defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
+#define LOG_ALIGN 4
+#else
+#define LOG_ALIGN 8
+#endif
 #define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)
-static char __log_buf[__LOG_BUF_LEN];
+static char __log_buf[__LOG_BUF_LEN] __aligned(LOG_ALIGN);
 static char *log_buf = __log_buf;
 static u32 log_buf_len = __LOG_BUF_LEN;
 
@@ -279,12 +284,6 @@ static u32 log_next(u32 idx)
 	return idx + msg->len;
 }
 
-#if !defined(CONFIG_64BIT) || defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
-#define LOG_ALIGN 4
-#else
-#define LOG_ALIGN 8
-#endif
-
 /* insert record into the buffer, discard old ones, update heads */
 static void log_store(int facility, int level,
 		      const char *dict, u16 dict_len,
-- 
1.7.0.4

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

* Re: [PATCH] printk: correctly align __log_buf
  2012-05-10 22:14 [PATCH] printk: correctly align __log_buf Stephen Warren
@ 2012-05-10 22:39 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2012-05-10 22:39 UTC (permalink / raw)
  To: Stephen Warren; +Cc: Kay Sievers, linux-kernel, linux-next, Stephen Warren

On Thu, May 10, 2012 at 04:14:33PM -0600, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> __log_buf must be aligned, because a 64-bit value is written directly
> to it as part of struct log. Alignment of the log entries is typically
> handled by log_store(), but this only triggers for subsequent entries,
> not the very first (or wrapped) entries.

Thanks for tracking this down and fixing it, much appreciated.  I've
applied your patch now.

greg k-h

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

end of thread, other threads:[~2012-05-10 22:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-10 22:14 [PATCH] printk: correctly align __log_buf Stephen Warren
2012-05-10 22:39 ` Greg Kroah-Hartman

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).