From: Peter Rosin <peda@axentia.se>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: "'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>,
"'linux-arm-kernel@lists.infradead.org'"
<linux-arm-kernel@lists.infradead.org>,
"nico@fluxnic.net" <nico@fluxnic.net>,
Will Deacon <will.deacon@arm.com>
Subject: RE: Domain faults when CONFIG_CPU_SW_DOMAIN_PAN is enabled
Date: Thu, 3 Dec 2015 21:37:51 +0000 [thread overview]
Message-ID: <45b615420548463ebd1d582bc5da2eff@EMAIL.axentia.se> (raw)
In-Reply-To: <20151203172708.GT8644@n2100.arm.linux.org.uk>
Russell King wrote:
> On Thu, Dec 03, 2015 at 04:41:18PM +0000, Russell King - ARM Linux wrote:
> > On Thu, Dec 03, 2015 at 04:12:06PM +0000, Peter Rosin wrote:
> > > * uaccess_with_memcpy.c:__copy_to_user() has a mode in which it copies
> > > "non-atomically" (if faulthandler_disabled() returns 0). If a fault
> > > happens during __copy_to_user, what prevents some other thread from
> > > clobbering DACR?
> >
> > See the second point above. Moreover, if we sleep in down_read(),
> > then __switch_to() reads the current DACR value and saves it in the
> > thread information, and will restore that value when resuming the
> > thread - even if the thread has been migrated to a different CPU.
>
> I thought this was correct, but it isn't - that's what my original solution
> did, but I think when Will reviewed it, we decided it wasn't necessary -
> and it isn't necessary for every single case with the exception of this
> one. This is exactly what's going wrong: the down_read() in these paths
> calls into the scheduler, which switches away. When we come back, the
> DACR value is reset by the other thread to 0x51.
>
> There's a few ways to solve this:
>
> 1. Make the thread switching code save and restore the DACR register as
> it would do for domains. This imposes an overhead on every single
> context switch whether or not we happen to be in this _single_
> troublesome code. (Patch attached - as there's several, I'm attaching
> them.)
>
> 2. Add additional code to the uaccess-with-memcpy stuff to reset the
> DACR value prior to using memcpy() or memset(). (Patch attached.)
I took both patches for a quick spin (a dozen boots and one hour uptime
after that for each patch) and no incidents. I have not gathered data,
but the crash on boot feels like it's quite a bit above 50% when there
is a problem so this feels good (I used 5 clean reboots when I bisected
and that worked).
Reported-by: Peter Rosin <peda@axentia.se>
Tested-by: Peter Rosin <peda@axentia.se>
(and please don't forget to cc stable)
> 3. Make uaccess-with-memcpy depend on !CPU_SW_DOMAINS_PAN (suggested by
> Will)
>
> 4. Delete the uaccess-with-memcpy code (also suggested by Will.)
>
> I think the best thing I can do is say... "Discuss amongst yourselves" :)
I have no personal preference on what should be done, I only had
copy_to_user_memcpy enabled since that was what Atmel fed me.
Cheers,
Peter
next prev parent reply other threads:[~2015-12-03 21:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-03 8:33 Peter Rosin
2015-12-03 11:00 ` Russell King - ARM Linux
2015-12-03 11:38 ` Peter Rosin
2015-12-03 11:51 ` Russell King - ARM Linux
2015-12-03 12:08 ` Peter Rosin
2015-12-03 13:37 ` Russell King - ARM Linux
2015-12-03 16:12 ` Peter Rosin
2015-12-03 16:41 ` Russell King - ARM Linux
2015-12-03 17:27 ` Russell King - ARM Linux
2015-12-03 18:28 ` Nicolas Pitre
2015-12-05 13:41 ` Russell King - ARM Linux
2015-12-03 21:37 ` Peter Rosin [this message]
2015-12-10 0:22 ` Russell King - ARM Linux
2015-12-10 15:29 ` Peter Rosin
2015-12-10 16:20 ` Russell King - ARM Linux
2015-12-10 18:32 ` Peter Rosin
2015-12-30 16:51 ` Peter Rosin
2015-12-30 16:57 ` Peter Rosin
-- strict thread matches above, loose matches on Subject: below --
2015-12-03 7:43 Peter Rosin
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=45b615420548463ebd1d582bc5da2eff@EMAIL.axentia.se \
--to=peda@axentia.se \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=nico@fluxnic.net \
--cc=will.deacon@arm.com \
/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
all inboxes | Powered by JetHome®