All of lore.kernel.org
 help / color / mirror / Atom feed
From: catalin.marinas@arm.com (Catalin Marinas)
To: linux-arm-kernel@lists.infradead.org
Subject: Kernel related (?) user space crash at ARM11 MPCore
Date: Sun, 20 Sep 2009 23:02:12 +0100	[thread overview]
Message-ID: <4AB6A664.3010704@arm.com> (raw)
In-Reply-To: <20090920093139.GA1704@n2100.arm.linux.org.uk>

Russell King - ARM Linux wrote:
> On Sun, Sep 20, 2009 at 09:39:00AM +0100, Catalin Marinas wrote:
>> On Sat, 2009-09-19 at 23:40 +0100, Russell King - ARM Linux wrote:
>>> On Mon, Aug 17, 2009 at 06:25:16PM +0100, Catalin Marinas wrote:
>>>> Assuming that the dynamic linker does instruction modifications as well
>>>> and expects the mprotect(RX) to flush the caches, the patch below
>>>> appears to fix the problem (not intensively tested). Note that I don't
>>>> say this is the right fix but it may work around the problem until
>>>> further investigation into the dynamic linker.
>>> Having now re-read the start of the thread, and put all the pieces
>>> together, the problem is not to do with SMP per-se, or Icache
>>> problems.
 >>
>> It's the I-D cache coherency.
> 
> You may be right, but the current evidence does not support that.
> If what you say is true, then all current ARMv6 and ARMv7 non-SMP
> systems would be affected.  So far, the bug report is only against
> SMP systems, where the cache is always forced to write allocate mode.

It is quite unlikely, though not impossible, for the I-cache to have 
stale entries. That's mainly because by the time a page cache page is 
reused for a different file, the corresponding I-cache entries are long 
gone. You could try on a software model to limit the amount of RAM and 
increase the I-cache size (I think AEM supports pseudo-infinite caches).

Data (instruction opcodes) not reaching the RAM because of 
write-allocate D-cache is the main issue, but it would be better to 
cover the I-cache coherency to avoid hard to reproduce bugs on some 
hardware configurations.

>>> I'd like to request that someone who can prove that the program works
>>> on ARMv6/v7 hardware does the following test:
>>>
>>> 1. boot the system with cachepolicy=writealloc
>>> 2. re-test the program
 >>
>> I don't think this would work. All the non-SMP v6/v7 processors I'm
>> aware of only support read-allocate caches, even if you try to force
>> write-allocate. On the SMP ones (Cortex-A9, ARM11MPCore), write-allocate
>> is the default.
> 
> Are you sure - I thought some of them did support write allocate.

I'm not entirely sure but that's what I recall. Anyway, you can run a UP 
kernel on ARM11MPCore.

>> I also recall that the cachepolicy argument was only affecting the
>> kernel mapping rather than the user one. Is this still the case?
> 
> Since changing the ptebits stuff, it affects everything.

Great.

>>> I think what we need to do is to ensure that the copy_user_highpage
>>> function is writing back data to the backing RAM, so it is visible
>>> to the I-cache when COWs of executable pages occur.  However, while
>>> we can pass this the vma, the vm_flags can't currently be used to
>>> detect COW of temporarily non-executable pages - which is what we
>>> want to detect to avoid having to clean the cache on every page
>>> copy.
 >>
>> copy_user_highpage() would work if we can detect the VM_EXEC flag but in
>> this case, the linker does mprotect(RW) before writing to the page (BTW,
>> this function could be fixed as well for RWX pages).
> 
> "can't currently be used" - yes, I'm aware of this.  

Sorry, I missed that line (too early in the morning).

> We could arrange
> to remember that the region had executable permission, and use that as
> a trigger for additional handling in copy_user_highpage().

Can the current dirty mechanism used for UP kernels be extended to cover 
this? The copy_user_highpage() could mark the page as dirty and later 
flush_cache_range() called via mprotect() could check this bit, similar 
to update_mmu_cache(). This would work on Cortex-A9 (where cache 
operations are detected by the snoop unit) but not on ARM11MPCore, where 
we can do it non-lazily.

We have the mechanism in place already, we could call 
flush_dcache_page(to) in copy_user_highpage() (which makes sense since 
the kernel is writing to a page visible to the user). Ideally, 
change_protection() should call update_mmu_cache() as well.

-- 
Catalin

  parent reply	other threads:[~2009-09-20 22:02 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4A7AEEB6.5060903@googlemail.com>
     [not found] ` <1250184014.14019.40.camel@pc1117.cambridge.arm.com>
     [not found]   ` <1250501311.9858.24.camel@pc1117.cambridge.arm.com>
     [not found]     ` <20090817140422.GA10764@n2100.arm.linux.org.uk>
2009-08-29 12:27       ` Kernel related (?) user space crash at ARM11 MPCore Catalin Marinas
2009-08-31  8:30         ` Catalin Marinas
2009-09-07 15:29           ` Catalin Marinas
2009-09-07 15:56             ` Dirk Behme
2009-09-07 16:43               ` Catalin Marinas
2009-09-07 17:31             ` Mikael Pettersson
2009-09-07 21:40               ` Catalin Marinas
2009-09-03 11:58         ` Dirk Behme
     [not found]       ` <1250529916.11185.80.camel@pc1117.cambridge.arm.com>
     [not found]         ` <20090919224022.GA738@n2100.arm.linux.org.uk>
     [not found]           ` <1253435940.498.15.camel@pc1117.cambridge.arm.com>
2009-09-20  9:31             ` Russell King - ARM Linux
2009-09-20 19:02               ` Russell King - ARM Linux
2009-09-20 22:46                 ` Catalin Marinas
2009-09-21  8:31                   ` Jamie Lokier
2009-09-21  8:41                     ` Russell King - ARM Linux
2009-09-21  9:41                       ` Jamie Lokier
2009-09-21 10:08                         ` Catalin Marinas
2009-09-21  8:49                     ` Catalin Marinas
2009-09-21  8:54                       ` Russell King - ARM Linux
2009-09-21  9:44                         ` Catalin Marinas
2009-09-21 10:07                           ` Russell King - ARM Linux
2009-09-21 10:42                             ` Catalin Marinas
2009-09-21 20:10                             ` Jamie Lokier
2009-09-21 21:26                               ` Russell King - ARM Linux
2009-09-21 22:14                                 ` Catalin Marinas
2009-09-21 22:25                                 ` Jamie Lokier
2009-09-22  8:43                                   ` Catalin Marinas
2009-09-21 21:58                               ` Catalin Marinas
2009-09-21 22:12                                 ` Jamie Lokier
2009-09-21 22:31                                   ` Russell King - ARM Linux
2009-09-21 22:34                                   ` Catalin Marinas
2009-09-21 21:38                             ` Russell King - ARM Linux
2009-09-21 22:28                               ` Catalin Marinas
2009-09-21 22:37                                 ` Jamie Lokier
2009-09-21 22:33                               ` Jamie Lokier
2009-09-22  9:21                                 ` Catalin Marinas
2009-09-22 10:19                               ` Catalin Marinas
2009-09-22 17:17                                 ` Catalin Marinas
2009-09-23  6:03                                   ` Dirk Behme
2009-09-23  9:13                                     ` Catalin Marinas
2009-09-23 10:38                                       ` Catalin Marinas
2009-09-23 12:12                                         ` Mikael Pettersson
2009-09-23 12:42                                           ` Russell King - ARM Linux
2009-09-23 12:51                                             ` Catalin Marinas
2009-09-23 12:55                                               ` Catalin Marinas
2009-10-15 14:57                             ` Russell King - ARM Linux
2009-10-15 15:20                               ` Catalin Marinas
2009-10-15 15:28                                 ` Russell King - ARM Linux
2009-10-15 15:56                                   ` Catalin Marinas
2009-10-20 11:39                                     ` Catalin Marinas
2009-10-25 13:39                                       ` Russell King - ARM Linux
2009-10-26 18:40                                         ` Catalin Marinas
2009-10-25 14:48                                       ` Russell King - ARM Linux
2009-10-26 18:45                                         ` Catalin Marinas
2009-10-26 19:17                                           ` Russell King - ARM Linux
2009-10-15 15:48                                 ` Dirk Behme
2009-10-15 15:53                                   ` Catalin Marinas
2009-10-25 13:04                                 ` Russell King - ARM Linux
2009-10-26 18:18                                   ` Catalin Marinas
2009-09-20 22:02               ` Catalin Marinas [this message]
2009-09-22  5:44                 ` Shilimkar, Santosh
2009-09-22  9:01                   ` Catalin Marinas
2009-09-22  9:34                     ` Shilimkar, Santosh
     [not found] ` <1249981883.27150.14.camel@pc1117.cambridge.arm.com>
     [not found]   ` <4A818CBC.8040000@googlemail.com>
     [not found]     ` <1250006770.30628.1.camel@pc1117.cambridge.arm.com>
     [not found]       ` <4A819C54.3080606@googlemail.com>
     [not found]         ` <1250009043.30628.9.camel@pc1117.cambridge.arm.com>
     [not found]           ` <87ab25vazg.fsf@brigitte.kvy.fi>
     [not found]             ` <1250080338.20332.32.camel@pc1117.cambridge.arm.com>
     [not found]               ` <87k518yc8a.fsf@brigitte.kvy.fi>
2009-09-11  9:21                 ` smsc911x.c driver and SMP (was Re: Kernel related (?) user space crash at ARM11 MPCore) Catalin Marinas
2009-09-11 12:55                   ` Bill Gatliff
2009-09-11 13:00                     ` Catalin Marinas
2009-09-11 15:20                       ` Bill Gatliff
2009-09-11 16:06                         ` Catalin Marinas
2009-10-06  6:12                           ` smsc911x.c driver and SMP Antti P Miettinen
2010-08-31  0:07                             ` Shinya Kuribayashi
2010-08-31  6:22                               ` Antti P Miettinen
2010-08-31  9:10                                 ` Shinya Kuribayashi
2010-08-31  8:33                               ` Catalin Marinas
2010-08-31  8:42                                 ` Shinya Kuribayashi

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=4AB6A664.3010704@arm.com \
    --to=catalin.marinas@arm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.