From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>
Subject: [PATCH/RFC 3/4] kprobes: use probe_kernel_write
Date: Tue, 02 Jun 2009 12:53:14 +0200 [thread overview]
Message-ID: <20090602110512.327768024@de.ibm.com> (raw)
In-Reply-To: 20090602105311.591592481@de.ibm.com
[-- Attachment #1: 202-kprobes-probe_kernel_write.diff --]
[-- Type: text/plain, Size: 1936 bytes --]
From: Heiko Carstens <heiko.carstens@de.ibm.com>
Use proble_kernel_write() to patch the kernel.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
arch/s390/kernel/kprobes.c | 31 ++-----------------------------
1 file changed, 2 insertions(+), 29 deletions(-)
diff -urpN linux-2.6/arch/s390/kernel/kprobes.c linux-2.6-patched/arch/s390/kernel/kprobes.c
--- linux-2.6/arch/s390/kernel/kprobes.c 2009-03-24 00:12:14.000000000 +0100
+++ linux-2.6-patched/arch/s390/kernel/kprobes.c 2009-06-02 10:40:05.000000000 +0200
@@ -25,9 +25,9 @@
#include <linux/preempt.h>
#include <linux/stop_machine.h>
#include <linux/kdebug.h>
+#include <linux/uaccess.h>
#include <asm/cacheflush.h>
#include <asm/sections.h>
-#include <asm/uaccess.h>
#include <linux/module.h>
DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
@@ -155,35 +155,8 @@ void __kprobes get_instruction_type(stru
static int __kprobes swap_instruction(void *aref)
{
struct ins_replace_args *args = aref;
- u32 *addr;
- u32 instr;
- int err = -EFAULT;
- /*
- * Text segment is read-only, hence we use stura to bypass dynamic
- * address translation to exchange the instruction. Since stura
- * always operates on four bytes, but we only want to exchange two
- * bytes do some calculations to get things right. In addition we
- * shall not cross any page boundaries (vmalloc area!) when writing
- * the new instruction.
- */
- addr = (u32 *)((unsigned long)args->ptr & -4UL);
- if ((unsigned long)args->ptr & 2)
- instr = ((*addr) & 0xffff0000) | args->new;
- else
- instr = ((*addr) & 0x0000ffff) | args->new << 16;
-
- asm volatile(
- " lra %1,0(%1)\n"
- "0: stura %2,%1\n"
- "1: la %0,0\n"
- "2:\n"
- EX_TABLE(0b,2b)
- : "+d" (err)
- : "a" (addr), "d" (instr)
- : "memory", "cc");
-
- return err;
+ return probe_kernel_write(args->ptr, &args->new, sizeof(args->new));
}
void __kprobes arch_arm_kprobe(struct kprobe *p)
--
next prev parent reply other threads:[~2009-06-02 11:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-02 10:53 [PATCH/RFC 0/4] Dynamic ftrace support for s390 Heiko Carstens
2009-06-02 10:53 ` [PATCH/RFC 1/4] maccess: add weak attribute to probe_kernel_write Heiko Carstens
2009-06-02 10:53 ` [PATCH/RFC 2/4] arch specific probe_kernel_write() implementation Heiko Carstens
2009-06-02 10:53 ` Heiko Carstens [this message]
2009-06-02 10:53 ` [PATCH/RFC 4/4] add dynamic ftrace support Heiko Carstens
2009-06-02 15:28 ` Steven Rostedt
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=20090602110512.327768024@de.ibm.com \
--to=heiko.carstens@de.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=schwidefsky@de.ibm.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.