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: Unify kpropes MAX_INSN_SIZE definition
Date: Fri, 14 Dec 2007 14:10:32 -0800 [thread overview]
Message-ID: <1197670232.898.63.camel@brick> (raw)
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
arch/x86/kernel/kprobes_32.c | 8 ++++----
include/asm-x86/kprobes.h | 5 +----
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/arch/x86/kernel/kprobes_32.c b/arch/x86/kernel/kprobes_32.c
index b47381e..615f24a 100644
--- a/arch/x86/kernel/kprobes_32.c
+++ b/arch/x86/kernel/kprobes_32.c
@@ -101,13 +101,13 @@ static __always_inline int can_boost(kprobe_opcode_t *opcodes)
kprobe_opcode_t opcode;
kprobe_opcode_t *orig_opcodes = opcodes;
retry:
- if (opcodes - orig_opcodes > MAX_INSN_SIZE - 1)
+ if (opcodes - orig_opcodes > MAX_INSN_SIZE)
return 0;
opcode = *(opcodes++);
/* 2nd-byte opcode */
if (opcode == 0x0f) {
- if (opcodes - orig_opcodes > MAX_INSN_SIZE - 1)
+ if (opcodes - orig_opcodes > MAX_INSN_SIZE)
return 0;
return test_bit(*opcodes, twobyte_is_boostable);
}
@@ -164,7 +164,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
if (!p->ainsn.insn)
return -ENOMEM;
- memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
+ 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;
@@ -539,7 +539,7 @@ static void __kprobes resume_execution(struct kprobe *p,
if (p->ainsn.boostable == 0) {
if ((regs->ip > copy_eip) &&
- (regs->ip - copy_eip) + 5 < MAX_INSN_SIZE) {
+ (regs->ip - copy_eip) + 5 < (MAX_INSN_SIZE + 1)) {
/*
* These instructions can be executed directly if it
* jumps back to correct address.
diff --git a/include/asm-x86/kprobes.h b/include/asm-x86/kprobes.h
index 87b9d1b..e348ed6 100644
--- a/include/asm-x86/kprobes.h
+++ b/include/asm-x86/kprobes.h
@@ -35,12 +35,9 @@ struct kprobe;
struct pt_regs;
typedef u8 kprobe_opcode_t;
-#ifdef CONFIG_X86_32
+
# define RELATIVEJUMP_INSTRUCTION 0xe9
-# define MAX_INSN_SIZE 16
-#else
# define MAX_INSN_SIZE 15
-#endif
#define BREAKPOINT_INSTRUCTION 0xcc
#define MAX_STACK_SIZE 64
--
1.5.4.rc0.1083.gf568
reply other threads:[~2007-12-14 22:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1197670232.898.63.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox