From: Catalin Marinas <catalin.marinas@arm.com>
To: Mark Rutland <mark.rutland@arm.com>
Cc: "Leizhen (ThunderTown)" <thunder.leizhen@huawei.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Tianhong Ding <dingtianhong@huawei.com>,
Will Deacon <will.deacon@arm.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Russell King <linux@armlinux.org.uk>,
Xinwei Hu <huxinwei@huawei.com>, Zefan Li <lizefan@huawei.com>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Hanjun Guo <guohanjun@huawei.com>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 1/1] arm64: fix flush_cache_range
Date: Wed, 25 May 2016 16:22:55 +0100 [thread overview]
Message-ID: <20160525152255.GH5996@e104818-lin.cambridge.arm.com> (raw)
In-Reply-To: <20160524151235.GA11605@leverpostej>
On Tue, May 24, 2016 at 04:12:35PM +0100, Mark Rutland wrote:
> On Tue, May 24, 2016 at 08:19:05PM +0800, Leizhen (ThunderTown) wrote:
> > On 2016/5/24 19:37, Mark Rutland wrote:
> > > On Tue, May 24, 2016 at 07:16:37PM +0800, Zhen Lei wrote:
> > >> When we ran mprotect04(a test case in LTP) infinitely, it would always
> > >> failed after a few seconds. The case can be described briefly that: copy
> > >> a empty function from code area into a new memory area(created by mmap),
> > >> then call mprotect to change the protection to PROT_EXEC. The syscall
> > >> sys_mprotect will finally invoke flush_cache_range, but this function
> > >> currently only invalid icache, the operation of flush dcache is missed.
[...]
> Jumping back to the problem at hand:
>
> It looks like we inherited this from ARM, which has done this for all
> executable mappings since commit 6060e8df517847bf ("ARM: I-cache: flush
> executable mappings in flush_cache_range()"). The commit message refers
> to a4db94d, which doesn't seem to exist, and I assume is
> 115b22474eb1905d ("ARM: 5794/1: Flush the D-cache during
> copy_user_highpage()") which happened to get rebased at some point.
>
> That all implies that the icache maintenance is only intended to ensure
> that CoW does not result in unexpected incoherency. Which in turn
> implies that flipping permissions with mprotect is not expected to
> synchronise the D and I caches.
Looking through the arm32 history:
2.6.33:
115b22474eb1 ("ARM: 5794/1: Flush the D-cache during copy_user_highpage()")
6060e8df5178 ("ARM: I-cache: flush executable mappings in flush_cache_range()")
These both take care of the CoW issue with executable pages.
2.6.37:
6012191aa9c6 ("ARM: 6380/1: Introduce __sync_icache_dcache() for VIPT caches")
The above is a fix for SMP systems where update_mmu_cache() happens
after the PTE was actually written, so slight chance of race with
another CPU. We generalised it to all ARMv6+ systems (so VIPT caches).
3.1:
c7e89b16eb90 ("ARM: 6995/2: mm: remove unnecessary cache flush on v6 copypage")
That's when we realised that the CoW problem no longer exists for
non-aliasing VIPT caches. However, the I-cache counterpart 6060e8df5178
has not been reverted.
So I think that for arm64 and arm32 with non-aliasing VIPT,
flush_cache_range() can safely be a no-op.
--
Catalin
next prev parent reply other threads:[~2016-05-25 15:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-24 11:16 Zhen Lei
2016-05-24 11:37 ` Mark Rutland
2016-05-24 12:19 ` Leizhen (ThunderTown)
2016-05-24 13:02 ` Catalin Marinas
2016-05-25 1:20 ` Leizhen (ThunderTown)
2016-05-25 3:36 ` Leizhen (ThunderTown)
2016-05-25 10:50 ` Catalin Marinas
2016-05-26 3:40 ` Leizhen (ThunderTown)
2016-05-26 11:46 ` Leizhen (ThunderTown)
2016-05-26 12:04 ` Russell King - ARM Linux
2016-05-26 16:36 ` Catalin Marinas
2016-05-24 15:12 ` Mark Rutland
2016-05-25 15:22 ` Catalin Marinas [this message]
2016-05-25 17:27 ` Russell King - ARM Linux
2016-05-26 16:44 ` Catalin Marinas
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=20160525152255.GH5996@e104818-lin.cambridge.arm.com \
--to=catalin.marinas@arm.com \
--cc=benh@kernel.crashing.org \
--cc=dingtianhong@huawei.com \
--cc=guohanjun@huawei.com \
--cc=huxinwei@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lizefan@huawei.com \
--cc=mark.rutland@arm.com \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
--cc=thunder.leizhen@huawei.com \
--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®