From patchwork Wed Aug 27 05:08:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 4786191 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0826DC0338 for ; Wed, 27 Aug 2014 05:23:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0739D2014A for ; Wed, 27 Aug 2014 05:23:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (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 D14082010B for ; Wed, 27 Aug 2014 05:23:44 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XMVfZ-0007Cg-A8; Wed, 27 Aug 2014 05:21:17 +0000 Received: from szxga01-in.huawei.com ([119.145.14.64]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XMVfW-00078E-4q for linux-arm-kernel@lists.infradead.org; Wed, 27 Aug 2014 05:21:15 +0000 Received: from 172.24.2.119 (EHLO lggeml407-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CAW02638; Wed, 27 Aug 2014 13:20:15 +0800 (CST) Received: from kernel-host.huawei (10.107.197.247) by lggeml407-hub.china.huawei.com (10.72.61.85) with Microsoft SMTP Server id 14.3.158.1; Wed, 27 Aug 2014 13:20:02 +0800 From: Wang Nan To: "David A. Long" , Russell King , Jon Medhurst , Taras Kondratiuk , Ben Dooks Subject: [PATCH] ARM: probes: return directly when emulate not set Date: Wed, 27 Aug 2014 13:08:29 +0800 Message-ID: <1409116109-67330-1-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.4 MIME-Version: 1.0 X-Originating-IP: [10.107.197.247] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140826_222114_711090_2D78D8F8 X-CRM114-Status: UNSURE ( 8.10 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.7 (/) Cc: Wang Nan , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, peifeiyue@huawei.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 When kprobe decoding instruction, original code calls instruction specific decoder if emulate is set to false. However, instructions with DECODE_TYPE_EMULATE are in fact don't have their decoder. What in the action table are in fact handlers. For example: /* LDRD (immediate) cccc 000x x1x0 xxxx xxxx xxxx 1101 xxxx */ /* STRD (immediate) cccc 000x x1x0 xxxx xxxx xxxx 1111 xxxx */ DECODE_EMULATEX (0x0e5000d0, 0x004000d0, PROBES_LDRSTRD, REGS(NOPCWB, NOPCX, 0, 0, 0)), and const union decode_action kprobes_arm_actions[NUM_PROBES_ARM_ACTIONS] = { ... [PROBES_LDRSTRD] = {.handler = emulate_ldrdstrd}, ... In this situation, original code calls 'emulate_ldrdstrd' as a decoder, which is obviously incorrect. This patch makes it returns INSN_GOOD directly when 'emulate' is not true. Signed-off-by: Wang Nan Cc: "David A. Long" Cc: Russell King Cc: Jon Medhurst Cc: Taras Kondratiuk Cc: Ben Dooks --- arch/arm/kernel/probes.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/kernel/probes.c b/arch/arm/kernel/probes.c index a8ab540..1c77b8d 100644 --- a/arch/arm/kernel/probes.c +++ b/arch/arm/kernel/probes.c @@ -436,8 +436,7 @@ probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi, struct decode_emulate *d = (struct decode_emulate *)h; if (!emulate) - return actions[d->handler.action].decoder(insn, - asi, h); + return INSN_GOOD; asi->insn_handler = actions[d->handler.action].handler; set_emulated_insn(insn, asi, thumb);