From: Oleg Nesterov <oleg@redhat.com>
To: Ingo Molnar <mingo@elte.hu>,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
Anton Arapov <aarapov@redhat.com>,
David Long <dave.long@linaro.org>,
Denys Vlasenko <dvlasenk@redhat.com>,
"Frank Ch. Eigler" <fche@redhat.com>,
Jim Keniston <jkenisto@us.ibm.com>,
Jonathan Lebon <jlebon@redhat.com>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH v3 12/15] uprobes/x86: Emulate nop's using ops->emulate()
Date: Sun, 13 Apr 2014 19:46:03 +0200 [thread overview]
Message-ID: <20140413174603.GA11888@redhat.com> (raw)
In-Reply-To: <20140413174508.GA11811@redhat.com>
Finally we can kill the ugly (and very limited) code in __skip_sstep().
Just change branch_setup_xol_ops() to treat "nop" as jmp to the next insn.
Thanks to lib/insn.c, it is clever enough. OPCODE1() == 0x90 includes
"(rep;)+ nop;" at least, and (afaics) much more.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Jim Keniston <jkenisto@us.ibm.com>
---
arch/x86/kernel/uprobes.c | 20 +-------------------
1 files changed, 1 insertions(+), 19 deletions(-)
diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
index b1d129d..e228d95 100644
--- a/arch/x86/kernel/uprobes.c
+++ b/arch/x86/kernel/uprobes.c
@@ -478,6 +478,7 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)
switch (OPCODE1(insn)) {
case 0xeb: /* jmp 8 */
case 0xe9: /* jmp 32 */
+ case 0x90: /* prefix* + nop; same as jmp with .offs = 0 */
break;
default:
return -ENOSYS;
@@ -710,29 +711,10 @@ void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
regs->flags &= ~X86_EFLAGS_TF;
}
-/*
- * Skip these instructions as per the currently known x86 ISA.
- * rep=0x66*; nop=0x90
- */
static bool __skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs)
{
- int i;
-
if (auprobe->ops->emulate)
return auprobe->ops->emulate(auprobe, regs);
-
- /* TODO: move this code into ->emulate() hook */
- for (i = 0; i < MAX_UINSN_BYTES; i++) {
- if (auprobe->insn[i] == 0x66)
- continue;
-
- if (auprobe->insn[i] == 0x90) {
- regs->ip += i + 1;
- return true;
- }
-
- break;
- }
return false;
}
--
1.5.5.1
next prev parent reply other threads:[~2014-04-13 17:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-13 17:45 [PATCH v3 00/15] uprobes/x86: fix the handling of relative jmp's/call's Oleg Nesterov
2014-04-13 17:45 ` [PATCH v3 01/15] uprobes: Kill UPROBE_SKIP_SSTEP and can_skip_sstep() Oleg Nesterov
2014-04-13 17:45 ` [PATCH v3 02/15] uprobes/x86: Fold prepare_fixups() into arch_uprobe_analyze_insn() Oleg Nesterov
2014-04-13 17:45 ` [PATCH v3 03/15] uprobes/x86: Kill the "ia32_compat" check in handle_riprel_insn(), remove "mm" arg Oleg Nesterov
2014-04-13 17:45 ` [PATCH v3 04/15] uprobes/x86: Gather "riprel" functions together Oleg Nesterov
2014-04-13 17:45 ` [PATCH v3 05/15] uprobes/x86: move the UPROBE_FIX_{RIP,IP,CALL} code at the end of pre/post hooks Oleg Nesterov
2014-04-13 17:45 ` [PATCH v3 06/15] uprobes/x86: Introduce uprobe_xol_ops and arch_uprobe->ops Oleg Nesterov
2014-04-13 17:45 ` [PATCH v3 07/15] uprobes/x86: Conditionalize the usage of handle_riprel_insn() Oleg Nesterov
2014-04-13 17:45 ` [PATCH v3 08/15] uprobes/x86: Send SIGILL if arch_uprobe_post_xol() fails Oleg Nesterov
2014-04-13 17:45 ` [PATCH v3 09/15] uprobes/x86: Teach arch_uprobe_post_xol() to restart if possible Oleg Nesterov
2014-04-13 17:45 ` [PATCH v3 10/15] uprobes/x86: Introduce sizeof_long(), cleanup adjust_ret_addr() and arch_uretprobe_hijack_return_addr() Oleg Nesterov
2014-04-13 17:46 ` [PATCH v3 11/15] uprobes/x86: Emulate unconditional relative jmp's Oleg Nesterov
2014-04-13 17:46 ` Oleg Nesterov [this message]
2014-04-13 17:46 ` [PATCH v3 13/15] uprobes/x86: Emulate relative call's Oleg Nesterov
2014-04-13 17:46 ` [PATCH v3 14/15] uprobes/x86: Emulate relative conditional "short" jmp's Oleg Nesterov
2014-04-13 17:46 ` [PATCH v3 15/15] uprobes/x86: Emulate relative conditional "near" jmp's Oleg Nesterov
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=20140413174603.GA11888@redhat.com \
--to=oleg@redhat.com \
--cc=aarapov@redhat.com \
--cc=ananth@in.ibm.com \
--cc=dave.long@linaro.org \
--cc=dvlasenk@redhat.com \
--cc=fche@redhat.com \
--cc=jkenisto@us.ibm.com \
--cc=jlebon@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@elte.hu \
--cc=srikar@linux.vnet.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox