All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ARM: uprobes need icache flush after xol write
@ 2014-04-09  5:58 Victor Kamensky
  2014-04-09  5:58 ` Victor Kamensky
  0 siblings, 1 reply; 66+ messages in thread
From: Victor Kamensky @ 2014-04-09  5:58 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Guys,

This second version of patch to flush icache and dcache after
uprobes xol write to make written instruction available in icache.
Please see [1] for initial discussion.

This patch follows Russell's suggestion, and function that does
cache flush after xol slot instruction write is shared/reused
with similar one implemented already for ptrace code.

In order to reuse common implementation but to avoid vma use
by xol_get_insn_slot I split flush_ptrace_access into two
functions. Where first part retrieves all required conditions
from vma and places them into flags variable and then calls 
second function which is common code.

Also I had to change xol_get_insn_slot function to map page
into kernel explicitly within function without use of 
copy_to_page helper because ARM cache flush code need both
kernel address through which instruction write happens and
virtual address of user-land process where instruction will
end up. I hope this call back is universal enough so other
CPU could implement their cache invalidation/sync after
uprobes xol instruction write logic based on provided
parameters.

I've tested it on Arndale board with my SystemTap test case
that had cache problem before. Disassemble of 
flush_uprobe_xol_access in case of Arndale shows that compiler
does good job and optimizes out all flags check effectively
leaving on this cpu call to flush_icache_alias or call to
v7_coherent_user_range (__cpuc_coherent_kern_range).

Also tested basic user-level debugging.

Wondering on what ARM boards/cpus could we test cache_is_vivt()
and cache_is_vipt_aliasing cases ...

Just to summarize, please note on [1] there were couple other
suggestions:

   Oleg suggested to use flush_icache_user_range but Russell
argument was that meaning of the function is lost and on ARM
it is not implemented in such way that it could address the
issue anyway. Please see [2] for details. Note it would has
vma problem use or not, that should be hacked.

   Dave Martin suggested to use flush_icache_range, which is
effectively better way to call 
__cpuc_coherent_[kern|user]_range(s,e), that was originally 
suggested. But Russell explained that it won't be enough in
case of user-land process pages and variety of cache types have
to be covered. Note for kernel pages it would be OK and it is
used in multiple places like kprobes, modules, etc.

Thanks,
Victor

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-April/245595.html
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-April/245427.html

[2] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-April/245605.html

Victor Kamensky (1):
  ARM: uprobes need icache flush after xol write

 arch/arm/include/asm/cacheflush.h |  2 ++
 arch/arm/kernel/uprobes.c         |  6 ++++++
 arch/arm/mm/flush.c               | 41 +++++++++++++++++++++++++++++++++------
 include/linux/uprobes.h           |  3 +++
 kernel/events/uprobes.c           | 33 +++++++++++++++++++++++++------
 5 files changed, 73 insertions(+), 12 deletions(-)

-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 66+ messages in thread

end of thread, other threads:[~2014-04-23 10:45 UTC | newest]

Thread overview: 66+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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.