From: Harvey Harrison <harvey.harrison@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
LKML <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH] x86: Use helper in kprobes{32|64}.c
Date: Fri, 14 Dec 2007 16:55:07 -0800 [thread overview]
Message-ID: <1197680107.898.81.camel@brick> (raw)
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
arch/x86/kernel/kprobes_32.c | 18 +++++++++++-------
arch/x86/kernel/kprobes_64.c | 14 ++++++++++++--
2 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/arch/x86/kernel/kprobes_32.c b/arch/x86/kernel/kprobes_32.c
index 2a8acd6..878b0c4 100644
--- a/arch/x86/kernel/kprobes_32.c
+++ b/arch/x86/kernel/kprobes_32.c
@@ -239,13 +239,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
if (!p->ainsn.insn)
return -ENOMEM;
- memcpy(p->ainsn.insn, p->addr, (MAX_INSN_SIZE + 1) * sizeof(kprobe_opcode_t));
- p->opcode = *p->addr;
- if (can_boost(p->addr)) {
- p->ainsn.boostable = 0;
- } else {
- p->ainsn.boostable = -1;
- }
+ arch_copy_kprobe(p);
return 0;
}
@@ -303,6 +297,15 @@ static s32 __kprobes *is_riprel(u8 *insn)
static void __kprobes arch_copy_kprobe(struct kprobe *p)
{
+#ifdef CONFIG_X86_32
+ memcpy(p->ainsn.insn, p->addr, (MAX_INSN_SIZE + 1) * sizeof(kprobe_opcode_t));
+ p->opcode = *p->addr;
+ if (can_boost(p->addr)) {
+ p->ainsn.boostable = 0;
+ } else {
+ p->ainsn.boostable = -1;
+ }
+#else
s32 *ripdisp;
memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE);
ripdisp = is_riprel(p->ainsn.insn);
@@ -325,6 +328,7 @@ static void __kprobes arch_copy_kprobe(struct kprobe *p)
*ripdisp = disp;
}
p->opcode = *p->addr;
+#endif
}
void __kprobes arch_arm_kprobe(struct kprobe *p)
diff --git a/arch/x86/kernel/kprobes_64.c b/arch/x86/kernel/kprobes_64.c
index 5f02e75..b437f7a 100644
--- a/arch/x86/kernel/kprobes_64.c
+++ b/arch/x86/kernel/kprobes_64.c
@@ -245,9 +245,9 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
{
/* insn: must be on special executable page on x86_32|64. */
p->ainsn.insn = get_insn_slot();
- if (!p->ainsn.insn) {
+ if (!p->ainsn.insn)
return -ENOMEM;
- }
+
arch_copy_kprobe(p);
return 0;
}
@@ -306,6 +306,15 @@ static s32 __kprobes *is_riprel(u8 *insn)
static void __kprobes arch_copy_kprobe(struct kprobe *p)
{
+#ifdef CONFIG_X86_32
+ memcpy(p->ainsn.insn, p->addr, (MAX_INSN_SIZE + 1) * sizeof(kprobe_opcode_t));
+ p->opcode = *p->addr;
+ if (can_boost(p->addr)) {
+ p->ainsn.boostable = 0;
+ } else {
+ p->ainsn.boostable = -1;
+ }
+#else
s32 *ripdisp;
memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE);
ripdisp = is_riprel(p->ainsn.insn);
@@ -328,6 +337,7 @@ static void __kprobes arch_copy_kprobe(struct kprobe *p)
*ripdisp = disp;
}
p->opcode = *p->addr;
+#endif
}
void __kprobes arch_arm_kprobe(struct kprobe *p)
--
1.5.4.rc0.1083.gf568
next reply other threads:[~2007-12-15 0:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-15 0:55 Harvey Harrison [this message]
2007-12-15 7:36 ` [PATCH] x86: Use helper in kprobes{32|64}.c Ingo Molnar
2007-12-15 7:40 ` Harvey Harrison
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=1197680107.898.81.camel@brick \
--to=harvey.harrison@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/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.