From patchwork Tue Oct 15 21:04:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 3048511 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A899DBF924 for ; Tue, 15 Oct 2013 21:06:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D3D2D20425 for ; Tue, 15 Oct 2013 21:06:57 +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 D3A0E20421 for ; Tue, 15 Oct 2013 21:06:56 +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 1VWBoX-0002xb-H3; Tue, 15 Oct 2013 21:06:01 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VWBoE-0005z6-Lf; Tue, 15 Oct 2013 21:05:42 +0000 Received: from mail-qe0-f47.google.com ([209.85.128.47]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VWBnV-0005rS-4S for linux-arm-kernel@lists.infradead.org; Tue, 15 Oct 2013 21:04:57 +0000 Received: by mail-qe0-f47.google.com with SMTP id b4so6707530qen.34 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=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2ysZNH+icOAiv7xhtqj9ePdRfe8FET942uW/xh+7KRQ=; b=QPfPv60TJb0YJppJogMEfu/ovt/tTf5nZHMekMLHRwVMFPjpCWrMBwa+LsoxKR9xnH xe3R4/MdBRcjB52Lxg4cWjwAOHueDYrALL1FLa5QQdz4fAHbC861UouNhsLpk/MOg+Hk HUDdDAUBoLAX0B6LxFsL0jJjtGXlc8C1jRI4uYHsdNBGGE4n4pdRmBaNyvailz12opRl aySlXidXaydB+yCRX/iBV7H/ZYi83tZRjCk13JUcyequWWhu49BGdWReEvMAtz1OspHt TJCZ3lLm2uKNLW3RYFR5q6Hw5bKHbAQTSI2rWt17/5tCyrWoeUPxH0GF/DVTdnzZHW4W 9rAA== X-Gm-Message-State: ALoCoQkwgW8N0k+gHvwqtDoqbBtqUN8V5MOuRkNEjSCtIRNvFzCoBMt6x44kOgfXM6pNDqv7sakM X-Received: by 10.229.192.65 with SMTP id dp1mr48637020qcb.19.1381871075681; Tue, 15 Oct 2013 14:04:35 -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:35 -0700 (PDT) From: David Long To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 03/13] uprobes: allow arch access to xol slot Date: Tue, 15 Oct 2013 17:04:18 -0400 Message-Id: <1381871068-27660-4-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_170457_223292_6755815D X-CRM114-Status: GOOD ( 14.48 ) 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 customize how the instruction is filled into the xol slot. ARM will use this to insert an undefined instruction after the real instruction in order to simulate a single step of the instruction without hardware support. Signed-off-by: Rabin Vincent Signed-off-by: David A. Long --- include/linux/uprobes.h | 1 + kernel/events/uprobes.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h index 80116c9..2556ab6 100644 --- a/include/linux/uprobes.h +++ b/include/linux/uprobes.h @@ -134,6 +134,7 @@ extern int arch_uprobe_exception_notify(struct notifier_block *self, unsigned l 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); +extern void __weak arch_uprobe_xol_copy(struct arch_uprobe *auprobe, void *vaddr); #else /* !CONFIG_UPROBES */ struct uprobes_state { }; diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 3955172..22d0121 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -1238,6 +1238,11 @@ static unsigned long xol_take_insn_slot(struct xol_area *area) return slot_addr; } +void __weak arch_uprobe_xol_copy(struct arch_uprobe *auprobe, void *vaddr) +{ + memcpy(vaddr, auprobe->insn, MAX_UINSN_BYTES); +} + /* * xol_get_insn_slot - allocate a slot for xol. * Returns the allocated slot address or 0. @@ -1246,6 +1251,7 @@ static unsigned long xol_get_insn_slot(struct uprobe *uprobe) { struct xol_area *area; unsigned long xol_vaddr; + void *kaddr; area = get_xol_area(); if (!area) @@ -1256,7 +1262,9 @@ static unsigned long xol_get_insn_slot(struct uprobe *uprobe) return 0; /* Initialize the slot */ - copy_to_page(area->page, xol_vaddr, uprobe->arch.insn, MAX_UINSN_BYTES); + kaddr = kmap_atomic(area->page); + arch_uprobe_xol_copy(&uprobe->arch, kaddr + (xol_vaddr & ~PAGE_MASK)); + kunmap_atomic(kaddr); /* * We probably need flush_icache_user_range() but it needs vma. * This should work on supported architectures too.