public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>,
	hpa@linux.intel.com, akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org,
	"Luis R. Rodriguez" <mcgrof@suse.com>,
	Andrew Lunn <andrew@lunn.ch>, Michal Hocko <mhocko@suse.cz>,
	Petr Mladek <pmladek@suse.cz>, Joe Perches <joe@perches.com>,
	Arun KS <arunks.linux@gmail.com>,
	Kees Cook <keescook@chromium.org>,
	Davidlohr Bueso <davidlohr@hp.com>,
	Chris Metcalf <cmetcalf@tilera.com>
Subject: Re: [RFT 1/2] printk: make dynamic kernel ring buffer alignemnt explicit
Date: Wed, 18 Jun 2014 09:56:03 -0600	[thread overview]
Message-ID: <53A1B693.2000609@wwwdotorg.org> (raw)
In-Reply-To: <1403090065-13879-1-git-send-email-mcgrof@do-not-panic.com>

On 06/18/2014 05:14 AM, Luis R. Rodriguez wrote:
> From: "Luis R. Rodriguez" <mcgrof@suse.com>
> 
> We have to consider alignment for the ring buffer both for the
> default static size, and then also for when an dynamic allocation
> is made when the log_buf_len=n kernel parameter is passed to set
> the size specifically to a size larger than the default size set
> by the architecture through CONFIG_LOG_BUF_SHIFT.
> 
> The default static kernel ring buffer can be aligned properly if
> architectures set CONFIG_LOG_BUF_SHIFT properly, we provide ranges
> for the size though so even if CONFIG_LOG_BUF_SHIFT has a sensible
> aligned value it can be reduced to a non aligned value. Commit
> 6ebb017de9 by Andrew ensures the static buffer is always aligned
> and the decision of alignment is done by the compiler by using
> __alignof__(struct log) (curious what value caused the crash?).

IIRC the issue was that __log_buf's type is char[] so without the
__aligned it could have any alignment at all, e.g. 1 or 2. However,
struct printk_log is stored in the buffer rather than just char*, and so
if __log_buf isn't aligned to the required alignment for that structure,
that can caused unaligned accesses to fields in the structure, which
isn't supported on ARM in at least some cases.

As such, I think the change to setup_log_buf() in this patch makes sense
(although I suppose in practice memblock_virt_alloc() probably has some
minimum internal alignment that dwards LOG_ALIGN, but that's an
implementation detail we shouldn't rely on).

  parent reply	other threads:[~2014-06-18 15:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-18 11:14 [RFT 1/2] printk: make dynamic kernel ring buffer alignemnt explicit Luis R. Rodriguez
2014-06-18 11:14 ` [RFT 2/2] printk: allow increasing the ring buffer depending on the number of CPUs Luis R. Rodriguez
2014-06-18 15:42   ` Petr Mládek
2014-06-18 20:43     ` Luis R. Rodriguez
2014-06-18 18:11   ` Davidlohr Bueso
2014-06-18 18:14     ` Davidlohr Bueso
2014-06-18 19:21     ` Luis R. Rodriguez
2014-06-18 15:40 ` [RFT 1/2] printk: make dynamic kernel ring buffer alignemnt explicit Petr Mládek
2014-06-18 15:56 ` Stephen Warren [this message]
2014-06-18 19:33   ` Luis R. Rodriguez
2014-06-18 19:46     ` Stephen Warren
2014-06-18 20:03       ` Luis R. Rodriguez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53A1B693.2000609@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --cc=akpm@linux-foundation.org \
    --cc=andrew@lunn.ch \
    --cc=arunks.linux@gmail.com \
    --cc=cmetcalf@tilera.com \
    --cc=davidlohr@hp.com \
    --cc=hpa@linux.intel.com \
    --cc=joe@perches.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@do-not-panic.com \
    --cc=mcgrof@suse.com \
    --cc=mhocko@suse.cz \
    --cc=pmladek@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox