From patchwork Thu Aug 1 23:45:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 2837424 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 AC6DB9F479 for ; Thu, 1 Aug 2013 23:56:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D7D720411 for ; Thu, 1 Aug 2013 23:56:31 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 42B34203F8 for ; Thu, 1 Aug 2013 23:56:30 +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 1V52jK-0006JX-0T; Thu, 01 Aug 2013 23:56:26 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V52jH-0000jO-SG; Thu, 01 Aug 2013 23:56:23 +0000 Received: from mail-yh0-f47.google.com ([209.85.213.47]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V52jE-0000hz-IJ for linux-arm-kernel@lists.infradead.org; Thu, 01 Aug 2013 23:56:21 +0000 Received: by mail-yh0-f47.google.com with SMTP id z20so5082yhz.34 for ; Thu, 01 Aug 2013 16:55:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=VZElUxLaFlYsSqjV7vngSlqZJQT3qGM7bBIX5/aTFJc=; b=X/cQYPYW8/DYHJbLVTTHz/AB4TBsJ/zdAT0SF7CW3tDah8mZdV5HYrUYuEkS6PiibP tYB/p8VQAyHCyZYx48H0TbGrncxImhW4JVNaqxtPOavQ8RbaA6Zl4Ay9PUTKSSsOo1ko N3cAr6QzkoLj/8jCeEtawcxBbdfGgBpDcASYmmS2bU4OL6zWhIf+E3bDwmZVI27CoH48 hYdkdtL9a5iByHJhjDW4EMJU5fCSBuNJPyLLN4oUT6/fYMQsv+/8CEpl8RgSq8dGPTLd aPP/w/rvmVYpgASIIoi/+o3LV7EsVfg707VZNzNty/ATvjWODSEX8kthROMzzvmmqnpv WjBw== X-Received: by 10.236.228.165 with SMTP id f35mr2519758yhq.152.1375400758465; Thu, 01 Aug 2013 16:45:58 -0700 (PDT) Received: from localhost.localdomain (pool-71-181-37-252.cncdnh.fast.myfairpoint.net. [71.181.37.252]) by mx.google.com with ESMTPSA id b48sm7874263yhc.8.2013.08.01.16.45.57 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 Aug 2013 16:45:58 -0700 (PDT) From: David Long To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/9] uprobes: allow ignoring of probe hits Date: Thu, 1 Aug 2013 19:45:46 -0400 Message-Id: <1375400753-3454-3-git-send-email-dave.long@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1375400753-3454-1-git-send-email-dave.long@linaro.org> References: <1375400753-3454-1-git-send-email-dave.long@linaro.org> X-Gm-Message-State: ALoCoQmIg3z3FogHLVhZgdlC1qyFK7sDMlIkwLKTy1i32NcmaRPceSaP9g3zzeLmOr96/QR18W3S X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130801_195620_662141_048C22A2 X-CRM114-Status: GOOD ( 13.61 ) X-Spam-Score: -2.6 (--) Cc: Rabin Vincent , "Jon Medhurst \(Tixy\)" , linux-kernel@vger.kernel.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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.7 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 From: Rabin Vincent Allow arches to decided to ignore a probe hit. ARM will use this to only call handlers if the conditions to execute a conditionally executed instruction are satisfied. Upleveled for v3.10-rc7. Signed-off-by: David A. Long --- include/linux/uprobes.h | 1 + kernel/events/uprobes.c | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h index 4e3b847..7a7c035 100644 --- a/include/linux/uprobes.h +++ b/include/linux/uprobes.h @@ -133,6 +133,7 @@ extern int arch_uprobe_post_xol(struct arch_uprobe *aup, struct pt_regs *regs); extern bool arch_uprobe_xol_was_trapped(struct task_struct *tsk); extern int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val, void *data); extern void arch_uprobe_abort_xol(struct arch_uprobe *aup, struct pt_regs *regs); +extern bool __weak arch_uprobe_ignore(struct arch_uprobe *aup, struct pt_regs *regs); #else /* !CONFIG_UPROBES */ struct uprobes_state { }; diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index f356974..2f3a4cb 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -1734,9 +1734,6 @@ static void handle_swbp(struct pt_regs *regs) return; } - /* change it in advance for ->handler() and restart */ - instruction_pointer_set(regs, bp_vaddr); - /* * TODO: move copy_insn/etc into _register and remove this hack. * After we hit the bp, _unregister + _register can install the @@ -1744,16 +1741,26 @@ static void handle_swbp(struct pt_regs *regs) */ smp_rmb(); /* pairs with wmb() in install_breakpoint() */ if (unlikely(!test_bit(UPROBE_COPY_INSN, &uprobe->flags))) - goto out; + goto restart; handler_chain(uprobe, regs); + + if (arch_uprobe_ignore(&uprobe->arch, regs)) + goto out; + if (can_skip_sstep(uprobe, regs)) goto out; if (!pre_ssout(uprobe, regs, bp_vaddr)) return; - /* can_skip_sstep() succeeded, or restart if can't singlestep */ +restart: + /* + * cannot singlestep; cannot skip instruction; + * re-execute the instruction. + */ + instruction_pointer_set(regs, bp_vaddr); + out: put_uprobe(uprobe); }