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: Fri, 11 Apr 2014 19:24:56 +0200 [thread overview]
Message-ID: <20140411172456.GA20506@redhat.com> (raw)
In-Reply-To: <20140411153041.GQ16119@n2100.arm.linux.org.uk>
On 04/11, Russell King - ARM Linux wrote:
>
> On Fri, Apr 11, 2014 at 05:22:07PM +0200, Oleg Nesterov wrote:
>
> I wonder whether you've read this yet:
>
> http://lkml.iu.edu//hypermail/linux/kernel/1404.1/00725.html
it seems that the only result of this discussion is "stop trying to
reinvent" you already quoted. Thanks.
> where I proposed removing flush_icache_user_range() since it's not used
> on a great many architectures.
Or at least it and its usage can be cleanuped somehow...
> > And I am just curious, why arm's copy_to_user_page() disables premption
> > before memcpy?
>
> flush_ptrace_access() needs to run on the CPU which ended up with the
> dirty cache line(s) to cope with those which do not have hardware
> broadcasting of cache maintanence operations.
Aha, thanks.
But you know, perhaps I'll ask you another stupid question later. Because
it still seems to me that we can do something better/cheaper in uprobe case.
Nevermind.
> This is why the hacks that you're doing are just that - they're hacks
> and are all broken in some way.
OK.
> I fail to see what your problem is with keeping the vma around,
We can't pin vm_area_struct.
> Let's not go inventing a whole new interface
> solving the same problem.
OK. How about the patch below?
Oleg.
---
index 2adbc97..9d45a4a 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1274,6 +1274,33 @@ static unsigned long xol_take_insn_slot(struct xol_area *area)
return slot_addr;
}
+static void arch_uprobe_copy_ixol(struct xol_area *area, unsigned long vaddr,
+ struct arch_uprobe *auprobe)
+{
+#ifndef ARCH_UPROBE_XXX
+ copy_to_page(area->page, vaddr, &auprobe->ixol, sizeof(&auprobe->ixol));
+ /*
+ * We probably need flush_icache_user_range() but it needs vma.
+ * If this doesn't work define ARCH_UPROBE_XXX.
+ */
+ flush_dcache_page(area->page);
+#else
+ struct mm_struct *mm = current->mm;
+ struct vm_area_struct *vma;
+
+ down_read(&mm->mmap_sem);
+ vma = find_exact_vma(mm, area->vaddr, area->vaddr + PAGE_SIZE);
+ if (vma) {
+ void *kaddr = kmap_atomic(area->page);
+ copy_to_user_page(vma, area->page,
+ vaddr, kaddr + (vaddr & ~PAGE_MASK),
+ &auprobe->ixol, sizeof(&auprobe->ixol));
+ kunmap_atomic(kaddr);
+ }
+ up_read(&mm->mmap_sem);
+#endif
+}
+
/*
* xol_get_insn_slot - allocate a slot for xol.
* Returns the allocated slot address or 0.
@@ -1291,15 +1318,7 @@ static unsigned long xol_get_insn_slot(struct uprobe *uprobe)
if (unlikely(!xol_vaddr))
return 0;
- /* Initialize the slot */
- copy_to_page(area->page, xol_vaddr,
- &uprobe->arch.ixol, sizeof(uprobe->arch.ixol));
- /*
- * We probably need flush_icache_user_range() but it needs vma.
- * This should work on supported architectures too.
- */
- flush_dcache_page(area->page);
-
+ arch_uprobe_copy_ixol(area, xol_vaddr, &uprobe->arch);
return xol_vaddr;
}
next prev parent reply other threads:[~2014-04-11 17:24 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 [this message]
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
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=20140411172456.GA20506@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 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.