From patchwork Tue Oct 15 21:04:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 3048461 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 2D12B9F2B7 for ; Tue, 15 Oct 2013 21:06:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0E6C1201FA for ; Tue, 15 Oct 2013 21:06:18 +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 A3C1C20237 for ; Tue, 15 Oct 2013 21:06:16 +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 1VWBoC-0002kq-KH; Tue, 15 Oct 2013 21:05:40 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VWBo0-0005xH-9d; Tue, 15 Oct 2013 21:05:28 +0000 Received: from mail-qa0-f46.google.com ([209.85.216.46]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VWBnT-0005rR-9n for linux-arm-kernel@lists.infradead.org; Tue, 15 Oct 2013 21:04:57 +0000 Received: by mail-qa0-f46.google.com with SMTP id j15so3814774qaq.5 for ; Tue, 15 Oct 2013 14:04:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bbU4CMvT1CYPKI/8hpOTYm6nzblD83GAmIkR40Y/Uj4=; b=b4uGO51jzrfXRlqjoTM1EkdXR+w1T/MnDsLpOGMCXblBHQTY6QlqIyMau6Rg9ol71O yUHEG1SGii9581SpcWqRHzRpHsLbpJNRXNqLvDSAc60xh5COxOLk8JuSX8U5GHP3Cu/9 tm6xCsXqGJAySD4I8k2lCogxy8pcaG7fxoKXaD77AgUY/JpE7bpVB3rBaf+OlCV/hydn sIvx4zQcoBJpNnHs+NPF0CoOqXpc/2lUSxS+Qt+IgxHyfF89C5bW4udhkTwt4ugl+eKM kk2BF9QN4JjjSjE9na0unzL+ZtkqYJ4ySSX1K/s2A8cOE9ZpKA4IqSbpGlHRyA/9Itpr 22mA== X-Gm-Message-State: ALoCoQkD79vO94VVpGi0M87bq1K/iboTlntiIh3aqnCi0FvBiW3DIzZ/+pkGr4eRWr3ntmRFPA/V X-Received: by 10.49.5.231 with SMTP id v7mr36710820qev.58.1381871074200; Tue, 15 Oct 2013 14:04:34 -0700 (PDT) Received: from localhost.localdomain (pool-72-71-243-183.cncdnh.fast00.myfairpoint.net. [72.71.243.183]) by mx.google.com with ESMTPSA id i4sm159645128qan.0.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Oct 2013 14:04:33 -0700 (PDT) From: David Long To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 02/13] uprobes: allow ignoring of probe hits Date: Tue, 15 Oct 2013 17:04:17 -0400 Message-Id: <1381871068-27660-3-git-send-email-dave.long@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1381871068-27660-1-git-send-email-dave.long@linaro.org> References: <1381871068-27660-1-git-send-email-dave.long@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131015_170455_432166_420B0F4F X-CRM114-Status: GOOD ( 13.82 ) X-Spam-Score: -2.6 (--) Cc: "Jon Medhurst \(Tixy\)" , Srikar Dronamraju , Oleg Nesterov , linux-kernel@vger.kernel.org, Rabin Vincent , Ingo Molnar 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=-4.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: "David A. Long" 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.12-rc4. 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 9fd60c5..80116c9 100644 --- a/include/linux/uprobes.h +++ b/include/linux/uprobes.h @@ -133,6 +133,7 @@ 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 unsigned long arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, 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 ad8e1bd..3955172 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -1732,9 +1732,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 @@ -1742,16 +1739,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); }