From patchwork Sun Oct 14 19:23:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rabin Vincent X-Patchwork-Id: 1591651 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 70DA440135 for ; Sun, 14 Oct 2012 19:27:14 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TNToH-0006Pt-3I; Sun, 14 Oct 2012 19:25:13 +0000 Received: from mail-la0-f49.google.com ([209.85.215.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TNTmv-0005vx-7Y for linux-arm-kernel@lists.infradead.org; Sun, 14 Oct 2012 19:23:50 +0000 Received: by mail-la0-f49.google.com with SMTP id z14so2909020lag.36 for ; Sun, 14 Oct 2012 12:23:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=ZrFM8y9nk2SwmAaTgs9+gxn+VttDgzUljVZID4wgKxI=; b=L5HXpZcB8tP87EfZrWb1KpcgTxzYpdW80uN/U93xN7nPVP0VNWgmi4ujEiBDrSAKUT LkBlgbvjKtVKqYte11vw4JUrwhKSVgbheq+6R2liz78Mo/u9Ry/xp6lGGLINTIlq4bue eCjwZoZZnB4CS1DoJIAn+bvdWg63sDxOIwi2t4LBwz+xDbWURk0MXW5kc6+BBJIg+m0Y O4dXtPjV6WPgx0/Sa/XwVL3SmgyjteAWDv67GW28Uz2xq8iw/HIjLuTSqp89HH3Qlppv IsfdT7c5a+NXqz/gl9Xou7zSprnK4smpu0/v/2R/z3Oi7HClq0Ai0hY8akznY+gK/pRH F/pw== Received: by 10.152.148.8 with SMTP id to8mr8397353lab.2.1350242628822; Sun, 14 Oct 2012 12:23:48 -0700 (PDT) Received: from localhost.localdomain (c83-254-195-218.bredband.comhem.se. [83.254.195.218]) by mx.google.com with ESMTPS id ef4sm556036lbb.13.2012.10.14.12.23.47 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 14 Oct 2012 12:23:48 -0700 (PDT) From: Rabin Vincent To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 7/9] uprobes: add arch write opcode hook Date: Sun, 14 Oct 2012 21:23:11 +0200 Message-Id: <1350242593-17761-7-git-send-email-rabin@rab.in> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1350242593-17761-1-git-send-email-rabin@rab.in> References: <1350242593-17761-1-git-send-email-rabin@rab.in> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.215.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (rabin.vincent[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Peter Zijlstra , Rabin Vincent , Srikar Dronamraju , oleg@redhat.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Allow arches to write the opcode with a custom function. ARM needs to customize the swbp instruction depending on the condition code of the instruction it replaces. Signed-off-by: Rabin Vincent --- include/linux/uprobes.h | 3 +++ kernel/events/uprobes.c | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h index c3dc5de..35b9490 100644 --- a/include/linux/uprobes.h +++ b/include/linux/uprobes.h @@ -131,6 +131,9 @@ 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); extern void __weak arch_uprobe_xol_copy(struct arch_uprobe *auprobe, void *vaddr); extern int __weak arch_uprobes_init(void); +extern void __weak arch_uprobe_write_opcode(struct arch_uprobe *auprobe, + void *vaddr, + uprobe_opcode_t opcode); #else /* !CONFIG_UPROBES */ struct uprobes_state { }; diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 8c52f93..95ea618 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -203,6 +203,12 @@ bool __weak is_swbp_insn(uprobe_opcode_t *insn) * have fixed length instructions. */ +void __weak arch_uprobe_write_opcode(struct arch_uprobe *auprobe, void *vaddr, + uprobe_opcode_t opcode) +{ + memcpy(vaddr, &opcode, UPROBE_SWBP_INSN_SIZE); +} + /* * write_opcode - write the opcode at a given virtual address. * @auprobe: arch breakpointing information. @@ -242,7 +248,7 @@ retry: vaddr_new = kmap_atomic(new_page); memcpy(vaddr_new, vaddr_old, PAGE_SIZE); - memcpy(vaddr_new + (vaddr & ~PAGE_MASK), &opcode, UPROBE_SWBP_INSN_SIZE); + arch_uprobe_write_opcode(auprobe, vaddr_new + (vaddr & ~PAGE_MASK), opcode); kunmap_atomic(vaddr_new); kunmap_atomic(vaddr_old);