From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Nick Piggin <npiggin@suse.de>, akpm <akpm@linux-foundation.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@elte.hu>
Subject: [PATCH] x86: text_poke might sleep
Date: Fri, 13 Feb 2009 09:27:05 -0500 [thread overview]
Message-ID: <20090213142705.GC31922@Krystal> (raw)
In-Reply-To: <1234529407.6519.28.camel@twins>
* Peter Zijlstra (peterz@infradead.org) wrote:
> Now text_poke() uses local_irq_save/restore(), which conveys that it can
> be called with IRQs disabled, which is exactly what happens in the trace
> above, however we just established that vmap/vunmap() are not irq-safe.
>
> Anybody got an idea on how to fix this?
Add might_sleep(), comments and use local_irq_disable/enable in text_poke so
people are really aware that it uses vmap, which sleeps.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
CC: Ingo Molnar <mingo@elte.hu>
CC: Peter Zijlstra <peterz@infradead.org>
CC: Nick Piggin <npiggin@suse.de>
CC: akpm <akpm@linux-foundation.org>
---
arch/x86/kernel/alternative.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Index: linux-2.6-lttng/arch/x86/kernel/alternative.c
===================================================================
--- linux-2.6-lttng.orig/arch/x86/kernel/alternative.c 2009-02-13 09:02:20.000000000 -0500
+++ linux-2.6-lttng/arch/x86/kernel/alternative.c 2009-02-13 09:05:05.000000000 -0500
@@ -494,16 +494,16 @@ void *text_poke_early(void *addr, const
* Only atomic text poke/set should be allowed when not doing early patching.
* It means the size must be writable atomically and the address must be aligned
* in a way that permits an atomic write. It also makes sure we fit on a single
- * page.
+ * page. Should be called with preemption enabled.
*/
void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
{
- unsigned long flags;
char *vaddr;
int nr_pages = 2;
struct page *pages[2];
int i;
+ might_sleep();
if (!core_kernel_text((unsigned long)addr)) {
pages[0] = vmalloc_to_page(addr);
pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
@@ -517,9 +517,9 @@ void *__kprobes text_poke(void *addr, co
nr_pages = 1;
vaddr = vmap(pages, nr_pages, VM_MAP, PAGE_KERNEL);
BUG_ON(!vaddr);
- local_irq_save(flags);
+ local_irq_disable();
memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
- local_irq_restore(flags);
+ local_irq_enable();
vunmap(vaddr);
sync_core();
/* Could also do a CLFLUSH here to speed up CPU recovery; but
--
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
prev parent reply other threads:[~2009-02-13 14:27 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-13 12:50 irq-disabled vs vmap vs text_poke Peter Zijlstra
2009-02-13 12:55 ` Nick Piggin
2009-02-13 13:02 ` Peter Zijlstra
2009-02-13 13:04 ` Ingo Molnar
2009-02-13 14:25 ` Mathieu Desnoyers
2009-02-13 14:33 ` Peter Zijlstra
2009-02-13 14:43 ` Mathieu Desnoyers
2009-02-13 18:05 ` Ingo Molnar
2009-02-13 13:05 ` Peter Zijlstra
2009-02-13 13:09 ` Nick Piggin
2009-02-13 14:18 ` Mathieu Desnoyers
2009-02-13 14:28 ` Peter Zijlstra
2009-02-13 16:32 ` Masami Hiramatsu
2009-02-13 16:38 ` Peter Zijlstra
2009-02-13 16:55 ` Mathieu Desnoyers
2009-02-13 18:14 ` Masami Hiramatsu
2009-02-13 18:57 ` Mathieu Desnoyers
2009-02-13 21:41 ` Masami Hiramatsu
2009-02-16 15:04 ` Masami Hiramatsu
2009-02-16 15:31 ` Nick Piggin
2009-02-16 17:24 ` Mathieu Desnoyers
2009-02-17 2:00 ` Masami Hiramatsu
2009-02-17 3:03 ` Nick Piggin
2009-02-17 8:31 ` Peter Zijlstra
2009-02-17 17:13 ` Masami Hiramatsu
2009-02-17 16:48 ` Masami Hiramatsu
2009-02-17 17:02 ` Steven Rostedt
2009-02-17 17:18 ` Mathieu Desnoyers
2009-02-17 17:24 ` Steven Rostedt
2009-02-17 17:28 ` Mathieu Desnoyers
2009-02-17 17:48 ` Steven Rostedt
2009-02-13 14:27 ` Mathieu Desnoyers [this message]
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=20090213142705.GC31922@Krystal \
--to=mathieu.desnoyers@polymtl.ca \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=npiggin@suse.de \
--cc=peterz@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