linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: srinivas.kandagatla@linaro.org (Srinivas Kandagatla)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] regmap: Add range check in _regmap_raw_read()
Date: Tue, 24 Feb 2015 09:12:43 +0000	[thread overview]
Message-ID: <54EC408B.60209@linaro.org> (raw)
In-Reply-To: <20150224085524.GC6236@finisterre.sirena.org.uk>



On 24/02/15 08:55, Mark Brown wrote:
> On Thu, Feb 19, 2015 at 01:02:03PM +0000, Srinivas Kandagatla wrote:
>
>> The culprit was in my test code, which I eventually fixed. However I would
>> have expected regmap to do some out of bound check before it tries to access
>> the register space.
>
>> If I try to do an out of bound access via regmap_read()/write() it throws up
>> an error, which is not the same with regmap_bulk_read/write() apis.
>
>> I was lucky that I got a page fault as the register range was just at page
>> boundary, but in cases where the range is not at page boundary, Its highly
>> likely that it could silently corrupt other memory location( specially in
>> write cases).
>
> The risk of page faults mostly only applies to memory mapped register
> maps - most register maps are on other buses where things are a bit less
> clear, we do often have writes to undocumented registers which aren't

Yes, my test was on memory mapped registers.

> included in the readability checks (indeed it's rare for anything to
> actually give us writability information for the write side).  As
> covered in earlier messages a part of this is a performance tradeoff,
> it's potentially expensive for us to do the checks on bulk I/O but for
> single register access it's much cheaper relative to the operation as a
> whole.

I totally agree with you on the performance overhead of checking every 
read/write, But on the other hand adding a single range check is better 
than no check with less/nil performance overhead.

>
> It's particularly interesting for MMIO actually as these devices are by
> far the most performance intensive, we don't have all the costs of the
> bus to mask what regmap is doing.
>

  reply	other threads:[~2015-02-24  9:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-19  8:39 [PATCH 0/2] regmap: fix range checks in _regmap_raw_read/write() Srinivas Kandagatla
2015-02-19  8:40 ` [PATCH 1/2] regmap: Add range check in _regmap_raw_read() Srinivas Kandagatla
2015-02-19 10:27   ` Mark Brown
2015-02-19 11:04     ` Srinivas Kandagatla
2015-02-19 12:21       ` Mark Brown
2015-02-19 13:02         ` Srinivas Kandagatla
2015-02-24  8:55           ` Mark Brown
2015-02-24  9:12             ` Srinivas Kandagatla [this message]
2015-02-19  8:40 ` [PATCH 2/2] regmap: Add range check in _regmap_raw_write() Srinivas Kandagatla
2015-02-19 10:31   ` Mark Brown
2015-02-19 11:11     ` Srinivas Kandagatla
2015-02-19 11:55       ` Mark Brown

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=54EC408B.60209@linaro.org \
    --to=srinivas.kandagatla@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).