From patchwork Thu Aug 1 23:45:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 2837409 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 BC5119F47C for ; Thu, 1 Aug 2013 23:47:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7F5DB20258 for ; Thu, 1 Aug 2013 23:47:20 +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 0E1E2203DA for ; Thu, 1 Aug 2013 23:47:19 +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 1V52a7-00038O-Fv; Thu, 01 Aug 2013 23:46:55 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V52Zv-0000Va-Dq; Thu, 01 Aug 2013 23:46:43 +0000 Received: from mail-yh0-f52.google.com ([209.85.213.52]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V52ZY-0000Qk-Cl for linux-arm-kernel@lists.infradead.org; Thu, 01 Aug 2013 23:46:21 +0000 Received: by mail-yh0-f52.google.com with SMTP id f11so2602yha.11 for ; Thu, 01 Aug 2013 16:45: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=8kAkgG9x0cBlIxIV7fl5/7Y3yL20gxFw4XdUceXVWRg=; b=O0fhA4oGE2STvQZJSY/xsy1JIw3QBA9YRq53NN4a1aQ/3JjuGG2cJoHAofP4DF9d4O ioXtVjBbZJMHzNJuTNKHyevjTw62aaXDfkHiNbhbWHhivn5GJ5pagPeZrQF2K02hHV7l z6UY0/6aQVWFBITRc0ean7BRlXZkXxrsvbHKV2QCw3z6Xo9d7E3819Mm4NWVEDysSvZh FhDtAkrFxXlcw53umI6q3slOEd4dev+r/AxUz7T2bF1zg0nnI24MAYX2f6ED8Fl2iJXx R8/PgDHmZT5xJ/YzBUFiSBJeI15P1FvEO90DYYmUe3CC8QChYOdGNsmE95tK8grNFR+p 9bLQ== X-Received: by 10.236.90.143 with SMTP id e15mr2500800yhf.185.1375400759399; Thu, 01 Aug 2013 16:45:59 -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.58 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 Aug 2013 16:45:59 -0700 (PDT) From: David Long To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/9] uprobes: allow arch access to xol slot Date: Thu, 1 Aug 2013 19:45:47 -0400 Message-Id: <1375400753-3454-4-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: ALoCoQnJyj0uIAnv4Qmz8wwU1fevEpZaeSPOkvrbi7vgCXXXWkzcb+NzTHZTcw1z3/cjclvx+466 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130801_194620_518745_B9D22F30 X-CRM114-Status: GOOD ( 13.94 ) 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 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 7a7c035..f6287f0 100644 --- a/include/linux/uprobes.h +++ b/include/linux/uprobes.h @@ -134,6 +134,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 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 2f3a4cb..64471bd 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.