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: 21047 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f197.google.com (mail-ve0-f197.google.com [209.85.128.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B4EB820D84 for ; Tue, 15 Oct 2013 21:04:35 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id jw12sf3835079veb.8 for ; Tue, 15 Oct 2013 14:04:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=bbU4CMvT1CYPKI/8hpOTYm6nzblD83GAmIkR40Y/Uj4=; b=ekpW73/LJj06dXW4KTauh2jQkn0M6xwLdr+6mWQ/miqwL5auzfFcmZi8rce7C+eKur kChcSUmzhkPS8mYdCn8819XvdJ2f2V8xU8MyRMFlxU1XLmjQ1h0HasZYtD1etbw9T9WI q/BNgi5eP/WslC3ww+7QR9cDzHRnFhUh7+oyHEtRDT6GS1JrVw3jmfqKpmhMVx4iDmQB 6IXgsa2isLSYf87xQY3sYNQcbYY103zaNWGHG/NjOCQbuPtpaQDf1kuMzYhwZNVuPoUd yKqg7+IKKglKOMqRPnfTuQFvODFKNJ1Q3U0NoZAELVX692JWm7KIYi9eva8SvmQw/S3N U3sg== X-Received: by 10.236.52.7 with SMTP id d7mr35663521yhc.32.1381871075063; Tue, 15 Oct 2013 14:04:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.49.42 with SMTP id r10ls288101qen.86.gmail; Tue, 15 Oct 2013 14:04:35 -0700 (PDT) X-Received: by 10.52.228.137 with SMTP id si9mr1950142vdc.29.1381871074961; Tue, 15 Oct 2013 14:04:34 -0700 (PDT) Received: from mail-vb0-f45.google.com (mail-vb0-f45.google.com [209.85.212.45]) by mx.google.com with ESMTPS id ge8si4000484vec.67.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Oct 2013 14:04:34 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.45 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.45; Received: by mail-vb0-f45.google.com with SMTP id e15so5451263vbg.18 for ; Tue, 15 Oct 2013 14:04:34 -0700 (PDT) X-Gm-Message-State: ALoCoQnGSUgyteTw1plxtRwk9h9/AdsWYVbmIhdVac+7naSxbj+x+85kAt5i1pwc11a4bcg2K204 X-Received: by 10.52.37.69 with SMTP id w5mr1802876vdj.32.1381871074871; Tue, 15 Oct 2013 14:04:34 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp328408vcz; Tue, 15 Oct 2013 14:04:34 -0700 (PDT) X-Received: by 10.224.95.10 with SMTP id b10mr46565599qan.6.1381871074415; Tue, 15 Oct 2013 14:04:34 -0700 (PDT) Received: from mail-qa0-f44.google.com (mail-qa0-f44.google.com [209.85.216.44]) by mx.google.com with ESMTPS id ho2si33437721qeb.138.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Oct 2013 14:04:34 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.216.44 is neither permitted nor denied by best guess record for domain of dave.long@linaro.org) client-ip=209.85.216.44; Received: by mail-qa0-f44.google.com with SMTP id cm18so3864008qab.10 for ; Tue, 15 Oct 2013 14:04:34 -0700 (PDT) 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 Cc: Rabin Vincent , "Jon Medhurst (Tixy)" , Oleg Nesterov , Srikar Dronamraju , Ingo Molnar , linux-kernel@vger.kernel.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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: dave.long@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.45 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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); }