From patchwork Tue Apr 8 15:27:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Nesterov X-Patchwork-Id: 3949641 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 6334ABFF02 for ; Tue, 8 Apr 2014 15:37:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 69644203B8 for ; Tue, 8 Apr 2014 15:37:03 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6E1EB203B7 for ; Tue, 8 Apr 2014 15:37:02 +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 1WXY2W-00037j-Fm; Tue, 08 Apr 2014 15:34:21 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WXY2F-0006Zi-2A; Tue, 08 Apr 2014 15:34:03 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WXXwS-0005VV-Vb for linux-arm-kernel@lists.infradead.org; Tue, 08 Apr 2014 15:28:07 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s38FRMOj009768 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 8 Apr 2014 11:27:23 -0400 Received: from tranklukator.brq.redhat.com (dhcp-1-104.brq.redhat.com [10.34.1.104]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id s38FRKFj014829; Tue, 8 Apr 2014 11:27:21 -0400 Received: by tranklukator.brq.redhat.com (nbSMTP-1.00) for uid 500 oleg@redhat.com; Tue, 8 Apr 2014 17:27:38 +0200 (CEST) Date: Tue, 8 Apr 2014 17:27:35 +0200 From: Oleg Nesterov To: Russell King - ARM Linux Subject: Re: [RFC PATCH] ARM: uprobes need icache flush after xol write Message-ID: <20140408152735.GA30076@redhat.com> References: <1396926260-7705-1-git-send-email-victor.kamensky@linaro.org> <1396926260-7705-2-git-send-email-victor.kamensky@linaro.org> <20140408082444.GA3598@e103592.cambridge.arm.com> <20140408114619.GE16119@n2100.arm.linux.org.uk> <5343F42D.5090205@linaro.org> <20140408133039.GH16119@n2100.arm.linux.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140408133039.GH16119@n2100.arm.linux.org.uk> User-Agent: Mutt/1.5.18 (2008-05-17) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140408_112805_524210_436C65A0 X-CRM114-Status: GOOD ( 21.60 ) X-Spam-Score: -7.2 (-------) Cc: tixy@linaro.org, linaro-kernel@lists.linaro.org, ananth@in.ibm.com, Victor Kamensky , David Long , Dave Martin , linux-arm-kernel@lists.infradead.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: , 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.5 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 Sorry, I din't read the whole thread yet... On 04/08, Russell King - ARM Linux wrote: > On Tue, Apr 08, 2014 at 09:05:49AM -0400, David Long wrote: > > Unfortunately copy_to_user_page() also needs a pointer to a vma struct > > so, while it presumably provides the model to follow, it can't simply be > > dropped in. > > Well, isn't this code doing the same thing as ptrace? It seems to want > to modify a page in userspace of another process to change instructions > that are going to be executed. That's what ptrace does, and ptrace > already copes with all the issues there. Yes, but it does get_user_pages(&vma) and thus it knows vma. > Given that we've already solved that problem, wouldn't it be a good idea > if the tracing code would stop trying to reinvent broken solutions to > problems we have already solved? But uprobes can't do this. Of course, I am not saying this is impossible, but it would be nice to avoid mmap_sem/find_vma/etc. Almost nobody (iirc only sparc?) actually uses this "vma" arguments. And at least the supported architectures do not (at least this is what I think after the quick grep). Perhaps we can rolerate the hack below? Oleg. --- x/kernel/events/uprobes.c +++ x/kernel/events/uprobes.c @@ -1295,10 +1295,10 @@ static unsigned long xol_get_insn_slot(s copy_to_page(area->page, xol_vaddr, &uprobe->arch.ixol, sizeof(uprobe->arch.ixol)); /* - * We probably need flush_icache_user_range() but it needs vma. - * This should work on supported architectures too. + * The architectures we currently support do not really use vma. */ - flush_dcache_page(area->page); + flush_icache_user_range(NULL /* vma */, area->page, + xol_vaddr, sizeof(uprobe->arch.ixol)); return xol_vaddr; }