From patchwork Fri Nov 29 18:00:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 3259241 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A516E9F384 for ; Fri, 29 Nov 2013 18:00:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5736C200DE for ; Fri, 29 Nov 2013 18:00:50 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 14B7C20115 for ; Fri, 29 Nov 2013 18:00:49 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VmSMt-0001ml-T8; Fri, 29 Nov 2013 18:00:44 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VmSMr-0007ur-GJ; Fri, 29 Nov 2013 18:00:41 +0000 Received: from mail-ea0-f176.google.com ([209.85.215.176]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VmSMo-0007uX-Pd for linux-arm-kernel@lists.infradead.org; Fri, 29 Nov 2013 18:00:39 +0000 Received: by mail-ea0-f176.google.com with SMTP id h14so6888230eaj.7 for ; Fri, 29 Nov 2013 10:00:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=b4YIaQwhC0o+0I0SNF2F696AHgao6pDOJ1qHlyr2Mpw=; b=cA50CdgX23r1CWhKmztM/3AsgVel+/Lj0G7gtyJA6nMfYIzwrLGFMQ7YhNKCvEZlYw zS/RGFQMSTL3EprI4+5qRFYiHDfMyN7EMJGx6GZAK7X6FjqjQ2+mg7i1qYJ5rLiv6AV7 /ubB0H/q9kLs4CecY6fer6yLVad/WdjUHcMBlIIuYaL1biy8NfgTzIkgmP17woDlAjz2 nyGipfEjH+yFbN5KTvtmuXKoFCa9QqWUidH7/+grHpsgwu3P+PGM926u0uqZa2PbUFAL t8/IFrxFFhXqlRNTz7JydhKsM+eMKFZKy5kiWmPnSw7Oyb0Zgj8/oDqivvku+bLAO/HY sS2g== X-Gm-Message-State: ALoCoQmk2JJdKtVvFWV1kvKQPj8HrAmzsYBLQYYmiyvTXgihuUXVJVxBv1jYOmOjhRTNe3584LpY X-Received: by 10.14.104.201 with SMTP id i49mr3061403eeg.78.1385748016537; Fri, 29 Nov 2013 10:00:16 -0800 (PST) Received: from [172.22.109.229] ([195.238.93.36]) by mx.google.com with ESMTPSA id e3sm5986089eeg.11.2013.11.29.10.00.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Nov 2013 10:00:16 -0800 (PST) Message-ID: <5298D62E.2000208@linaro.org> Date: Fri, 29 Nov 2013 20:00:14 +0200 From: Taras Kondratiuk User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: Ben Dooks Subject: Re: [RFC] kprobes/kprobes-test fixes, .inst updates References: <1383935832-20865-1-git-send-email-ben.dooks@codethink.co.uk> In-Reply-To: <1383935832-20865-1-git-send-email-ben.dooks@codethink.co.uk> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131129_130038_975728_67BFD476 X-CRM114-Status: GOOD ( 18.80 ) X-Spam-Score: -2.6 (--) Cc: Dave Martin , linux-arm-kernel@lists.infradead.org, victor.kamensky@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 11/08/2013 08:37 PM, Ben Dooks wrote: > This is a series to fix kprobes and kprobes-test, as well as tidy > up the use of data instructions to output code and > a missed bug in traps. > > I have not had time to test these, or push to the new git server we > are using. I will try and sort this out on monday. > > This is an initial review series and I would appreicate testing. kprobes-thumb.c fixes are missed in this series. Patch is below. I've tested the series with all my comments addressed, Dave's patch instead of 9/9 and with the patch below. Kprobes-test passed for all combinations ARM/Thumb LE/BE. From: Taras Kondratiuk Date: Fri, 29 Nov 2013 19:15:53 +0200 Subject: [PATCH] ARM: kprobes-thumb: fix instruction fetch order with If we are running BE8, the data and instruction endianness do not match, so use to correctly translate memory accesses into ARM instructions. Signed-off-by: Taras Kondratiuk --- arch/arm/kernel/kprobes-thumb.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/arch/arm/kernel/kprobes-thumb.c b/arch/arm/kernel/kprobes-thumb.c index 6123daf..b82e798 100644 --- a/arch/arm/kernel/kprobes-thumb.c +++ b/arch/arm/kernel/kprobes-thumb.c @@ -163,9 +163,9 @@ t32_decode_ldmstm(kprobe_opcode_t insn, struct arch_specific_insn *asi) enum kprobe_insn ret = kprobe_decode_ldmstm(insn, asi); /* Fixup modified instruction to have halfwords in correct order...*/ - insn = asi->insn[0]; - ((u16 *)asi->insn)[0] = insn >> 16; - ((u16 *)asi->insn)[1] = insn & 0xffff; + insn = __mem_to_opcode_arm(asi->insn[0]); + ((u16 *)asi->insn)[0] = __opcode_to_mem_thumb16(insn >> 16); + ((u16 *)asi->insn)[1] = __opcode_to_mem_thumb16(insn & 0xffff); return ret; } @@ -1153,7 +1153,7 @@ t16_decode_hiregs(kprobe_opcode_t insn, struct arch_specific_insn *asi) { insn &= ~0x00ff; insn |= 0x001; /* Set Rdn = R1 and Rm = R0 */ - ((u16 *)asi->insn)[0] = insn; + ((u16 *)asi->insn)[0] = __opcode_to_mem_thumb16(insn); asi->insn_handler = t16_emulate_hiregs; return INSN_GOOD; } @@ -1182,8 +1182,10 @@ t16_decode_push(kprobe_opcode_t insn, struct arch_specific_insn *asi) * and call it with R9=SP and LR in the register list represented * by R8. */ - ((u16 *)asi->insn)[0] = 0xe929; /* 1st half STMDB R9!,{} */ - ((u16 *)asi->insn)[1] = insn & 0x1ff; /* 2nd half (register list) */ + /* 1st half STMDB R9!,{} */ + ((u16 *)asi->insn)[0] = __opcode_to_mem_thumb16(0xe929); + /* 2nd half (register list) */ + ((u16 *)asi->insn)[1] = __opcode_to_mem_thumb16(insn & 0x1ff); asi->insn_handler = t16_emulate_push; return INSN_GOOD; } @@ -1232,8 +1234,10 @@ t16_decode_pop(kprobe_opcode_t insn, struct arch_specific_insn *asi) * and call it with R9=SP and PC in the register list represented * by R8. */ - ((u16 *)asi->insn)[0] = 0xe8b9; /* 1st half LDMIA R9!,{} */ - ((u16 *)asi->insn)[1] = insn & 0x1ff; /* 2nd half (register list) */ + /* 1st half LDMIA R9!,{} */ + ((u16 *)asi->insn)[0] = __opcode_to_mem_thumb16(0xe8b9); + /* 2nd half (register list) */ + ((u16 *)asi->insn)[1] = __opcode_to_mem_thumb16(insn & 0x1ff); asi->insn_handler = insn & 0x100 ? t16_emulate_pop_pc : t16_emulate_pop_nopc; return INSN_GOOD;