From patchwork Fri Apr 11 15:22:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Nesterov X-Patchwork-Id: 3970101 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 700E6BFF02 for ; Fri, 11 Apr 2014 15:26:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ADBC420783 for ; Fri, 11 Apr 2014 15:26:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (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 A2775201DC for ; Fri, 11 Apr 2014 15:26:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WYdIF-0000iP-8z; Fri, 11 Apr 2014 15:23:03 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WYdIC-0000ce-Sp for linux-arm-kernel@lists.infradead.org; Fri, 11 Apr 2014 15:23:01 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3BFLxaB029587 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Apr 2014 11:21:59 -0400 Received: from tranklukator.brq.redhat.com (dhcp-1-104.brq.redhat.com [10.34.1.104]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id s3BFLtoC004803; Fri, 11 Apr 2014 11:21:56 -0400 Received: by tranklukator.brq.redhat.com (nbSMTP-1.00) for uid 500 oleg@redhat.com; Fri, 11 Apr 2014 17:22:11 +0200 (CEST) Date: Fri, 11 Apr 2014 17:22:07 +0200 From: Oleg Nesterov To: David Miller , Linus Torvalds , Peter Zijlstra Subject: Re: [RFC PATCH] uprobes: copy to user-space xol page with proper cache flushing Message-ID: <20140411152207.GA28188@redhat.com> References: <20140409184507.GA1058@redhat.com> <5347655B.3080307@linaro.org> <20140411.003636.272212797007496394.davem@davemloft.net> <20140411145625.GA27493@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140411145625.GA27493@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140411_082301_028227_B3476967 X-CRM114-Status: GOOD ( 12.96 ) X-Spam-Score: -5.4 (-----) Cc: tixy@linaro.org, linaro-kernel@lists.linaro.org, linux@arm.linux.org.uk, ananth@in.ibm.com, victor.kamensky@linaro.org, taras.kondratiuk@linaro.org, rabin@rab.in, dave.long@linaro.org, Dave.Martin@arm.com, 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=-2.3 required=5.0 tests=BAYES_00,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 On 04/11, Oleg Nesterov wrote: > > Can't we do _something_ > like below? If not, I'd propose the patch below. I can be easily wrong, but it seems that arch/arm can reimplement arch_uprobe_flush_xol_icache() and do flush_ptrace_access()-like code. It needs kaddr, but this is not a problem. Btw. From arch/arm/include/asm/cacheflush.h #define flush_icache_user_range(vma,page,addr,len) \ flush_dcache_page(page) but it has no users? And I am just curious, why arm's copy_to_user_page() disables premption before memcpy? Oleg. --- x/kernel/events/uprobes.c +++ x/kernel/events/uprobes.c @@ -1274,6 +1274,17 @@ static unsigned long xol_take_insn_slot( return slot_addr; } +void __weak arch_uprobe_flush_xol_icache(struct page *page, + unsigned long vaddr, int len) +{ + /* + * We need copy_to_user_page/flush_icache_user_range but this + * needs vma. If this doesn't work on your arch, reimplement. + */ + flush_dcache_page(area->page); + +} + /* * xol_get_insn_slot - allocate a slot for xol. * Returns the allocated slot address or 0. @@ -1294,11 +1305,8 @@ static unsigned long xol_get_insn_slot(s /* Initialize the slot */ 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. - */ - flush_dcache_page(area->page); + arch_uprobe_flush_xol_icache(area->page, xol_vaddr, + sizeof(uprobe->arch.ixol)); return xol_vaddr; }