public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [BUGFIX PATCH -tip] x86: Fix fixmap page order in text_poke()
@ 2009-07-01 20:59 Masami Hiramatsu
  2009-07-01 21:17 ` Mathieu Desnoyers
  2009-07-01 21:37 ` [BUGFIX PATCH] x86: Fix fixmap page order for FIX_TEXT_POKE0,1 Mathieu Desnoyers
  0 siblings, 2 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2009-07-01 20:59 UTC (permalink / raw)
  To: Ingo Molnar, lkml
  Cc: systemtap, DLE, Masami Hiramatsu, Mathieu Desnoyers, Ingo Molnar

Since the fixmap pages are assigned higher address to lower, text_poke()
has to use it with inverted order (FIX_TEXT_POKE1 to FIX_TEXT_POKE0).

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Ingo Molnar <mingo@elte.hu>
---

 arch/x86/kernel/alternative.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index f576587..4d8b40b 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -527,14 +527,18 @@ void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
 	}
 	BUG_ON(!pages[0]);
 	local_irq_save(flags);
-	set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
+	/*
+	 * Since the fixmaps are assinged from higher address to lower,
+	 * we use FIX_TEXT_POKE1 first, and FIX_TEXT_POKE0 second.
+	 */
+	set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[0]));
 	if (pages[1])
-		set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
-	vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
+		set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[1]));
+	vaddr = (char *)fix_to_virt(FIX_TEXT_POKE1);
 	memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
-	clear_fixmap(FIX_TEXT_POKE0);
+	clear_fixmap(FIX_TEXT_POKE1);
 	if (pages[1])
-		clear_fixmap(FIX_TEXT_POKE1);
+		clear_fixmap(FIX_TEXT_POKE0);
 	local_flush_tlb();
 	sync_core();
 	/* Could also do a CLFLUSH here to speed up CPU recovery; but


-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

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

end of thread, other threads:[~2009-07-01 21:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-01 20:59 [BUGFIX PATCH -tip] x86: Fix fixmap page order in text_poke() Masami Hiramatsu
2009-07-01 21:17 ` Mathieu Desnoyers
2009-07-01 21:37 ` [BUGFIX PATCH] x86: Fix fixmap page order for FIX_TEXT_POKE0,1 Mathieu Desnoyers
2009-07-01 21:56   ` Masami Hiramatsu

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 read-only IMAP folder(s) and NNTP newsgroup(s).