Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754639AbaDFURc (ORCPT ); Sun, 6 Apr 2014 16:17:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16892 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754568AbaDFUQh (ORCPT ); Sun, 6 Apr 2014 16:16:37 -0400 Date: Sun, 6 Apr 2014 22:16:36 +0200 From: Oleg Nesterov To: Ingo Molnar , Srikar Dronamraju Cc: Ananth N Mavinakayanahalli , Anton Arapov , David Long , Denys Vlasenko , "Frank Ch. Eigler" , Jim Keniston , Jonathan Lebon , Masami Hiramatsu , linux-kernel@vger.kernel.org Subject: [RFC PATCH 6/6] uprobes/x86: Emulate rip-relative conditional "near" jmp's Message-ID: <20140406201636.GA521@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140406201524.GA32694@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It seems that 16bit conditional jmp is just 0x0f + short_jump_opcode_incremented by 0x10. But I'll try to cleanup this patch... Signed-off-by: Oleg Nesterov --- arch/x86/kernel/uprobes.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index 797b8a4..8f92cbf 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -564,6 +564,19 @@ static int ttt_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn) if (WARN_ON_ONCE(!insn_complete(insn))) return -ENOEXEC; +#define CASE(op_y, op_n, cond) \ + case 0x ## op_y: case 0x ## op_n: + + if (insn->opcode.nbytes == 2 && opc1 == 0x0f) { + opc1 = OPCODE2(insn) - 0x10; + + switch (opc1) { + X86_COND_OPCODES + default: + return -ENOSYS; + } + } + switch (opc1) { case 0xeb: /* jmp 8 */ case 0xe9: /* jmp 32 */ @@ -573,10 +586,7 @@ static int ttt_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn) case 0xe8: /* call relative */ ttt_clear_displacement(auprobe, insn); /* fall through */ - #define CASE(op_y, op_n, cond) \ - case 0x ## op_y: case 0x ## op_n: X86_COND_OPCODES - #undef CASE auprobe->ttt.opc1 = opc1; break; @@ -584,6 +594,8 @@ static int ttt_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn) return -ENOSYS; } +#undef CASE + auprobe->ttt.ilen = insn->length; auprobe->ttt.disp = insn->moffset1.value; /* so far we assume that it fits into ->moffset1 */ -- 1.5.5.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/