From: oleg@redhat.com (Oleg Nesterov)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH] uprobes: copy to user-space xol page with proper cache flushing
Date: Tue, 15 Apr 2014 17:46:37 +0200 [thread overview]
Message-ID: <20140415154637.GA3560@redhat.com> (raw)
In-Reply-To: <CAA3XUr3BGA55JF_cgH=cqbo1wAK0773P1fvnG9dBjLU2KzBdKA@mail.gmail.com>
On 04/14, Victor Kamensky wrote:
>
> On 14 April 2014 11:59, Oleg Nesterov <oleg@redhat.com> wrote:
> > On 04/11, Linus Torvalds wrote:
> >>
> >> So I really think we should just have a fixed
> >> "flush_icache_page(page,vaddr)" function.
> >> ...
> >> Then the uprobe case can just do
> >>
> >> copy_to_page()
> >> flush_dcache_page()
> >> flush_icache_page()
> >
> >
> > And I obviously like this idea because (iiuc) it more or less matches
> > flush_icache_page_xxx() I tried to suggest.
>
> Would not page granularity to be too expensive? Note you need to do that on
> each probe hit and you flushing whole data and instruction page every time.
> IMHO it will work correctly when you flush just few dcache/icache lines that
> correspond to xol slot that got modified. Note copy_to_user_page takes
> len that describes size of area that has to be flushed. Given that we are
> flushing xol area page at this case; and nothing except one xol slot is
> any interest for current task, and if CPU can flush one dcache and icache
> page as quickly as it can flush range, my remark may not matter.
We can add "vaddr, len" to the argument list.
> I personally would prefer if we could have function like copy_to_user_page
> but without requirement to pass vma to it.
I won't argue, but you need to convince maintainers.
And to remind, we need something simple/nonintrusive for arm right now.
Again, I won't argue if we turn copy_to_page() + flush_dcache_page() into
__weak arch_uprobe_copy_ixol(), and add the necessary hacks into arm's
implementatiion. This is up to you and Russel.
But. Please do not add copy_to_user_page() into copy_to_page() (as your patch
did). This is certainly not what uprobe_write_opcode() wants, we do not want
or need "flush" in this case. The same for __create_xol_area().
Note also that currently copy_to_user_page() is always called under mmap_sem.
I do not know if arm actually needs ->mmap_sem, but if you propose it as a
generic solution we should probably take this lock.
Also. Even if we have copy_to_user_page_no_vma() or change copy_to_user_page()
to accept vma => NULL, I am not sure this will work fine on arm when the probed
application unmaps xol_area and mmaps something else at the same vaddr. I mean,
in this case we do not care if the application crashes, but please verify that
something really bad can't happen.
Let me repeat just in case, I know nothing about arm/. I can't even understand
how, say, flush_pfn_alias() works, and how it should work if 2 threads call it
at the same time with the same vaddr (or CACHE_COLOUR(vaddr)).
Oleg.
next prev parent reply other threads:[~2014-04-15 15:46 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-09 5:58 [PATCH v2] ARM: uprobes need icache flush after xol write Victor Kamensky
2014-04-09 5:58 ` Victor Kamensky
2014-04-09 18:23 ` David Long
2014-04-09 18:45 ` Oleg Nesterov
2014-04-09 19:13 ` Victor Kamensky
2014-04-09 19:19 ` Russell King - ARM Linux
2014-04-11 3:42 ` [RFC PATCH] uprobes: copy to user-space xol page with proper cache flushing David Long
2014-04-11 3:45 ` David Long
2014-04-11 4:36 ` David Miller
2014-04-11 14:26 ` Victor Kamensky
2014-04-11 14:35 ` Oleg Nesterov
2014-04-11 14:55 ` Victor Kamensky
2014-04-11 14:56 ` Oleg Nesterov
2014-04-11 15:22 ` Oleg Nesterov
2014-04-11 15:30 ` Russell King - ARM Linux
2014-04-11 17:24 ` Oleg Nesterov
2014-04-11 17:38 ` Oleg Nesterov
2014-04-11 18:00 ` David Miller
2014-04-11 18:25 ` Oleg Nesterov
2014-04-11 17:50 ` Linus Torvalds
2014-04-11 18:02 ` David Miller
2014-04-11 18:11 ` Linus Torvalds
2014-04-11 18:19 ` David Miller
2014-04-11 18:24 ` Linus Torvalds
2014-04-11 18:58 ` David Miller
2014-04-11 19:24 ` Linus Torvalds
2014-04-11 18:13 ` Victor Kamensky
2014-04-11 18:36 ` Oleg Nesterov
2014-04-14 18:59 ` Oleg Nesterov
2014-04-14 20:05 ` Victor Kamensky
2014-04-14 21:40 ` Victor Kamensky
2014-04-15 16:26 ` Oleg Nesterov
2014-04-15 15:46 ` Oleg Nesterov [this message]
2014-04-15 16:46 ` Victor Kamensky
2014-04-15 17:19 ` David Long
2014-04-15 17:38 ` David Miller
2014-04-15 17:49 ` Oleg Nesterov
2014-04-15 17:50 ` David Miller
2014-04-15 18:07 ` Oleg Nesterov
2014-04-15 18:27 ` David Miller
2014-04-15 18:46 ` Oleg Nesterov
2014-04-15 17:43 ` Oleg Nesterov
2014-04-15 17:46 ` David Miller
2014-04-15 18:03 ` Oleg Nesterov
2014-04-15 18:30 ` David Miller
2014-04-15 18:47 ` Russell King - ARM Linux
2014-04-15 18:53 ` David Miller
2014-04-15 18:50 ` David Miller
2014-04-15 19:29 ` Russell King - ARM Linux
2014-04-15 19:51 ` David Miller
2014-04-15 19:39 ` David Long
2014-04-15 19:53 ` David Miller
2014-04-16 1:42 ` Victor Kamensky
2014-04-16 2:22 ` David Miller
2014-04-16 2:24 ` David Miller
2014-04-16 3:06 ` Victor Kamensky
2014-04-16 3:17 ` David Miller
2014-04-11 17:43 ` David Miller
2014-04-11 15:32 ` Peter Zijlstra
2014-04-11 16:00 ` Russell King - ARM Linux
2014-04-11 18:39 ` Peter Zijlstra
2014-04-11 15:37 ` Victor Kamensky
2014-04-11 16:22 ` Oleg Nesterov
2014-04-11 15:42 ` Linus Torvalds
2014-04-11 13:08 ` Oleg Nesterov
2014-04-23 10:45 ` 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=20140415154637.GA3560@redhat.com \
--to=oleg@redhat.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 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).