From: Michael.McTernan.2001@cs.bris.ac.uk (Michael McTernan)
To: linux-arm-kernel@lists.infradead.org
Subject: mm: get_user_pages_fast()
Date: Wed, 06 Nov 2013 22:31:22 +0000 [thread overview]
Message-ID: <527AC33A.5080103@cs.bris.ac.uk> (raw)
In-Reply-To: <20131106195725.GD16735@n2100.arm.linux.org.uk>
On 11/06/2013 07:57 PM, Russell King - ARM Linux wrote:
> Please expose the memory in a saner way rather than re-using /dev/mem.
> /dev/mem is all well and good, but it has side effects with the way it
> maps memory. Having your own driver gives you control over that. It's
> also better practice because it avoids a whole load of security issues.
Sure - that's where I'm heading now. The security isn't an issue for
this application, though I accept it's good practice.
>>> Placing futexes in IO memory is not supported, period.
>>
>> Except the _PRIVATE futex calls do work fine in IO memory since they
>> don't walk the process page tables to determine the 'key' from the
>> address.
...
> Sorry, I should have said mutexes. The point here is that userspace
> pthreads can ldrex/strex on that memory before issuing any futex calls.
Mutexes do access the memory, yes.
There is still inconsistency in futex behaviour, with _PRIVATE calls
working for IO memory, non-private not. This isn't ARM specific though.
>>> You can't map random bits of /dev/mem and expect
>>> this stuff to work.
>>
>> Nothing I am mapping is random.
>
> As far as I'm concerned, it's random areas of system memory - random in
> the sense that it's not well defined what it is and what attributes it
> should have in the page tables for things like memory type etc. I
> somehow doubt that you've thought about this at all, you just decided
> that opening /dev/mem is a solution to your problem.
I didn't want to bore the list with gory details, but I didn't earlier
state that I added a /dev/shmem and defined memory regions and types for
the areas, with the required attributes for sharability and caching - so
it isn't really random, though I see how it sounds like that from my
original post. /dev/shmem is a close cousin of /dev/mem, and has picked
up the VM_PFNMAP and VM_IO flags which cause me inconvenience.
>>> (b) means that the load/store exclusives, which userspace mutexes will
>>> use on ARMv6+, will not work correctly.
>>> (they're not supported to strongly ordered memory by the architecture.)
>>
>> I don't see this stated in the ARM Architecture Reference Manual.
>> Instead I see it saying that it is implementation dependent whether
>> LDREX and STREX work on strongly ordered memory (section A3.4.5).
>
> Here's the latest wording:
>
> It is IMPLEMENTATION DEFINED whether LDREX and STREX operations can be
> performed to a memory region with the Device or Strongly-ordered memory
> attribute. Unless the implementation documentation explicitly states
> that LDREX and STREX operations to a memory region with the Device or
> Strongly-ordered attribute are permitted, the effect of such operations
> is UNPREDICTABLE.
>
> In other words, it is only supported where it is explicitly documented
> that it works on these memory types; otherwise it must be assumed that
> they do not work...
What you've quoted is not the same as your first statement that "they're
not supported to strongly ordered memory by the architecture." It's
implementation defined, which means it is a possibility.
> So, what happens if Linux crashes having taken a pthread mutex in this
> region, and your application then comes along and tries to regain that
> lock?
Well there's a whole restart procedure needed to pick up state from the
memory area and get back to sensible operation. Re-initialising
pthread_mutexes and some other counters and indices is all part of that
- for a simple enough FIFO type interface it's not that difficult to
cover potentially corrupt state variables, though getting good testing
coverage is hard. Fuzzing the restart state helps a lot, though the key
is to keep the state space as small as possible.
Kind Regards,
Mike
prev parent reply other threads:[~2013-11-06 22:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-05 22:43 mm: get_user_pages_fast() Michael McTernan
2013-11-06 10:19 ` Will Deacon
2013-11-06 10:54 ` Russell King - ARM Linux
2013-11-06 11:07 ` Will Deacon
2013-11-06 19:38 ` Michael McTernan
2013-11-06 19:57 ` Russell King - ARM Linux
2013-11-06 22:31 ` Michael McTernan [this message]
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=527AC33A.5080103@cs.bris.ac.uk \
--to=michael.mcternan.2001@cs.bris.ac.uk \
--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