From patchwork Wed Oct 22 11:32:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 39276 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3D18220341 for ; Wed, 22 Oct 2014 11:36:20 +0000 (UTC) Received: by mail-wg0-f70.google.com with SMTP id a1sf1958223wgh.1 for ; Wed, 22 Oct 2014 04:36:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=ROwAU8O/BldxFOHnRuRD6EGYOVXVSPWie0BYZOxeF3A=; b=b9uxyHKDO4kOu0fXFNU5UeCRkwjqBPJrDYLcAOTUlhD9LUCxSqtS4FuUW3cGCiMeVM eEuldf4VbHwGl3WFVSvEUSPtJjQz1AHNHNs4d7+zzZk4qTTFZ440iDS0KL+yz9SnOetr Ze60NgnNtKGXwUVmLxtFHbOwn87upJWvXNyBE08ryGg2Rcx+ge1A6Uo0pVwe9k/UE0r+ 6hrJMjG0k3Z+c/xykcydg2xOd5Sc7m9XiaBQSY4BXoIN6ME+2C1dpcUavK5ESW0ixOIy QeC2YhTMZ9MxTqHETcQzlzAmCWZvXaLe+Q1Oqy1hEL0Ey44uE27ocR104ZkhYTIsjgvt SLvg== X-Gm-Message-State: ALoCoQl0XYfRLSDorZXVIphi3dftCqSCfLgUEWjqAm7lprnEkn7JBTsXwC6+1TxxuBb2x9pqdaVf X-Received: by 10.180.101.136 with SMTP id fg8mr396287wib.3.1413977779450; Wed, 22 Oct 2014 04:36:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.74 with SMTP id w10ls195328laj.99.gmail; Wed, 22 Oct 2014 04:36:19 -0700 (PDT) X-Received: by 10.112.63.70 with SMTP id e6mr2375500lbs.93.1413977779237; Wed, 22 Oct 2014 04:36:19 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id bc10si23012802lab.15.2014.10.22.04.36.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Oct 2014 04:36:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by mail-lb0-f176.google.com with SMTP id p9so2594251lbv.7 for ; Wed, 22 Oct 2014 04:36:19 -0700 (PDT) X-Received: by 10.112.97.135 with SMTP id ea7mr41395392lbb.46.1413977779088; Wed, 22 Oct 2014 04:36:19 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp53616lbz; Wed, 22 Oct 2014 04:36:12 -0700 (PDT) X-Received: by 10.66.218.42 with SMTP id pd10mr978186pac.151.1413977771670; Wed, 22 Oct 2014 04:36:11 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3si13921151pas.194.2014.10.22.04.36.11 for ; Wed, 22 Oct 2014 04:36:11 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933348AbaJVLfs (ORCPT + 27 others); Wed, 22 Oct 2014 07:35:48 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:25507 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932934AbaJVLeF (ORCPT ); Wed, 22 Oct 2014 07:34:05 -0400 Received: from 172.24.2.119 (EHLO lggeml425-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CBC48758; Wed, 22 Oct 2014 19:33:48 +0800 (CST) Received: from kernel-host.huawei (10.107.197.247) by lggeml425-hub.china.huawei.com (10.72.61.35) with Microsoft SMTP Server id 14.3.158.1; Wed, 22 Oct 2014 19:33:37 +0800 From: Wang Nan To: , , , , , , Ben Dooks , Christoph Lameter , Rabin Vincent , "David S. Miller" CC: , , "Li Zefan" Subject: [PATCH v6 3/7] ARM: kprobes: introduces checker Date: Wed, 22 Oct 2014 19:32:01 +0800 Message-ID: <1413977525-51480-4-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1413977525-51480-1-git-send-email-wangnan0@huawei.com> References: <1413977525-51480-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.197.247] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: wangnan0@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch introdces a 'checker' field to decode_action, and calls checkers when instruction decoding. This allows further analysis for specific instructions. Signed-off-by: Wang Nan --- arch/arm/kernel/probes.c | 10 ++++++++++ arch/arm/kernel/probes.h | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/arm/kernel/probes.c b/arch/arm/kernel/probes.c index ec030b8..6164b4d 100644 --- a/arch/arm/kernel/probes.c +++ b/arch/arm/kernel/probes.c @@ -393,6 +393,7 @@ probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi, const struct decode_header *h = (struct decode_header *)table; const struct decode_header *next; bool matched = false; + probes_opcode_t origin_insn = insn; if (emulate) insn = prepare_emulated_insn(insn, asi, thumb); @@ -423,17 +424,26 @@ probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi, case DECODE_TYPE_CUSTOM: { struct decode_custom *d = (struct decode_custom *)h; + probes_check_t *checker = actions[d->decoder.action].checker; + if (checker && (checker(origin_insn, asi, h) == INSN_REJECTED)) + return INSN_REJECTED; return actions[d->decoder.action].decoder(insn, asi, h); } case DECODE_TYPE_SIMULATE: { struct decode_simulate *d = (struct decode_simulate *)h; + probes_check_t *checker = actions[d->handler.action].checker; + if (checker && (checker(origin_insn, asi, h) == INSN_REJECTED)) + return INSN_REJECTED; asi->insn_handler = actions[d->handler.action].handler; return INSN_GOOD_NO_SLOT; } case DECODE_TYPE_EMULATE: { struct decode_emulate *d = (struct decode_emulate *)h; + probes_check_t *checker = actions[d->handler.action].checker; + if (checker && (checker(origin_insn, asi, h) == INSN_REJECTED)) + return INSN_REJECTED; if (!emulate) return actions[d->handler.action].decoder(insn, diff --git a/arch/arm/kernel/probes.h b/arch/arm/kernel/probes.h index 739c2a2..c56dd3d 100644 --- a/arch/arm/kernel/probes.h +++ b/arch/arm/kernel/probes.h @@ -309,9 +309,15 @@ typedef enum probes_insn (probes_custom_decode_t)(probes_opcode_t, struct arch_probes_insn *, const struct decode_header *); +typedef enum probes_insn (probes_check_t)(probes_opcode_t, + struct arch_probes_insn *, + const struct decode_header *); struct decode_action { - probes_insn_handler_t *handler; - probes_custom_decode_t *decoder; + probes_check_t *checker; + union { + probes_insn_handler_t *handler; + probes_custom_decode_t *decoder; + }; }; #define DECODE_END \