All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@redhat.com>
To: Ingo Molnar <mingo@elte.hu>, lkml <linux-kernel@vger.kernel.org>
Cc: systemtap <systemtap@sources.redhat.com>,
	DLE <dle-develop@lists.sourceforge.net>,
	Masami Hiramatsu <mhiramat@redhat.com>,
	Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
	Ingo Molnar <mingo@elte.hu>
Subject: [BUGFIX PATCH -tip] x86: Fix fixmap page order in text_poke()
Date: Wed, 01 Jul 2009 17:02:46 -0400	[thread overview]
Message-ID: <20090701210246.22089.65697.stgit@localhost.localdomain> (raw)

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

             reply	other threads:[~2009-07-01 21:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-01 21:02 Masami Hiramatsu [this message]
2009-07-01 21:17 ` [BUGFIX PATCH -tip] x86: Fix fixmap page order in text_poke() 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:58   ` Masami Hiramatsu
2009-07-03  8:57   ` [tip:x86/urgent] " tip-bot for Mathieu Desnoyers
2009-07-03 12:44   ` tip-bot for Mathieu Desnoyers

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=20090701210246.22089.65697.stgit@localhost.localdomain \
    --to=mhiramat@redhat.com \
    --cc=dle-develop@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@polymtl.ca \
    --cc=mingo@elte.hu \
    --cc=systemtap@sources.redhat.com \
    /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.