From patchwork Tue Apr 15 17:19:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 3994331 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 D329B9F2CC for ; Tue, 15 Apr 2014 17:22:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0E5EA20200 for ; Tue, 15 Apr 2014 17:22:58 +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 14BE4201DE for ; Tue, 15 Apr 2014 17:22:57 +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 1Wa71W-0007Co-8j; Tue, 15 Apr 2014 17:19:54 +0000 Received: from mail-qg0-f48.google.com ([209.85.192.48]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wa71U-0007AJ-A7 for linux-arm-kernel@lists.infradead.org; Tue, 15 Apr 2014 17:19:52 +0000 Received: by mail-qg0-f48.google.com with SMTP id i50so2285124qgf.35 for ; Tue, 15 Apr 2014 10:19:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=M4h527UmZK3XjAR8l76qOytn3+0jnhmCnrhWE3CkCps=; b=I7KaMekcHsQO5F2xKnBve/B52JDNrTWA/qxTChqdr/q8IqVrouJTABGTw4j2Sb6K9m oJCv4xSmlbWZN3xD+5qJQxhi0CMPvkv59sf8bRRJh02fiTCvCppxiQBSN0A2PJX2y7TU KB4uIaIPMLzz/cUOf6NU3308mIDEKzEhjv1fVmFXduxAJh9Hg1Q0x/p3J+v+4zZfC08J U1HYtNa+c083SL5kBOIErpQIDHIUdMTlO1k7oWGdgkCt1dtfsQfXyGPmhN7e8fUKyMfA qgPgT9Ckd6A3Ln3zJ0nYcgxVLBN9pONAnKb8TW9beX9AFt/RYcbciK59K/Tc7vlrmKXk HMVA== X-Gm-Message-State: ALoCoQlCkU8uX1gIDKQPeIadflbLnjAbntAhCsZy6FbAaEQIxnfNwf9YzGmHon7bSM017Yh3CRIx X-Received: by 10.140.92.110 with SMTP id a101mr4327259qge.34.1397582369326; Tue, 15 Apr 2014 10:19:29 -0700 (PDT) Received: from [10.1.10.24] (c-76-24-48-141.hsd1.nh.comcast.net. [76.24.48.141]) by mx.google.com with ESMTPSA id y9sm38461042qai.13.2014.04.15.10.19.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Apr 2014 10:19:28 -0700 (PDT) Message-ID: <534D6A1F.70102@linaro.org> Date: Tue, 15 Apr 2014 13:19:27 -0400 From: David Long User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: Oleg Nesterov Subject: Re: [RFC PATCH] uprobes: copy to user-space xol page with proper cache flushing References: <5347655B.3080307@linaro.org> <20140411.003636.272212797007496394.davem@davemloft.net> <20140411145625.GA27493@redhat.com> <20140411152207.GA28188@redhat.com> <20140411153041.GQ16119@n2100.arm.linux.org.uk> <20140411172456.GA20506@redhat.com> <20140414185916.GA30672@redhat.com> <20140415154637.GA3560@redhat.com> In-Reply-To: <20140415154637.GA3560@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140415_101952_419888_5167C2DD X-CRM114-Status: GOOD ( 15.97 ) X-Spam-Score: 0.0 (/) Cc: Jon Medhurst , "linaro-kernel@lists.linaro.org" , Russell King - ARM Linux , Ananth N Mavinakayanahalli , Victor Kamensky , Peter Zijlstra , Taras Kondratiuk , David Miller , rabin@rab.in, Linus Torvalds , 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=-2.6 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/15/14 11:46, Oleg Nesterov wrote: > > But. Please do not add copy_to_user_page() into copy_to_page() (as your patch > did). This is certainly not what uprobe_write_opcode() wants, we do not want > or need "flush" in this case. The same for __create_xol_area(). > It looked me like a call to a new __copy_to_user_page(current->mm, ...) in xol_get_insn_slot() would be in line with David Miller's suggestion and would cure the problem on ARM (and hopefuly be more philosophically correct for all architectures): Opinions? It's possible this approach isn't good enough. Cache operations and VM are not my strong suit. -dl diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 04709b6..b418626 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -1287,6 +1287,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) @@ -1297,13 +1298,11 @@ static unsigned long xol_get_insn_slot(struct uprobe *uprobe) return 0; /* 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); + kaddr = kmap_atomic(area->page); + __copy_to_user_page(current->mm, area->page, xol_vaddr, + kaddr + (xol_vaddr & ~PAGE_MASK), + &uprobe->arch.ixol, sizeof(uprobe->arch.ixol), true); + kunmap_atomic(kaddr); return xol_vaddr; }