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: 28417 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6BCC12036D for ; Tue, 15 Apr 2014 17:21:55 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id il7sf33409798vcb.1 for ; Tue, 15 Apr 2014 10:21:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:subject:references:in-reply-to:cc:precedence :list-id:list-unsubscribe:list-archive:list-post:list-help :list-subscribe:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=3fe/MNheXdTsVMtRMdOFV0n5M9VkAkOzQrN64U3njJg=; b=dihygSDMaAjlySGTQXM9u5EDbey1aNJSoZg8kTyWcw9qdKWKTUiHLgJN4ClJt0SWbX 6C3NIhMG9XSHfqXMD4/jpuYX45ADbt6L1ATEv75AgkfRR8nAGuBDw3is3ZMInAWYaj3G KpVuuDHKu8r5KoQbwhebbC+Gdu0sKmwXGrTv+s5kSJ4csyyB+6p7tcL5M09IUbLgCSBv +hIGFxTg16rrLgC3RvRFvVIri7iNeXigAOhvCj1m5dDiZjyFQWmcMJjsDbUIYu8H4Nal UAl1Q+ZdTgcsmUVq9ZVpDcmCMmbYCKAVW3AWGwdOP4yKXKmcniANkMu+eMrIpHY01s5n gjUA== X-Gm-Message-State: ALoCoQn9LUROg6aWx0rGvhhGMXbp0oDMcm/NeAwoihRVo4r7JqX4NlWTACopFXF3CQEmrKBHDYPl X-Received: by 10.58.22.70 with SMTP id b6mr1340244vef.13.1397582515181; Tue, 15 Apr 2014 10:21:55 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.179 with SMTP id q48ls258004qga.21.gmail; Tue, 15 Apr 2014 10:21:55 -0700 (PDT) X-Received: by 10.220.113.11 with SMTP id y11mr920195vcp.40.1397582515099; Tue, 15 Apr 2014 10:21:55 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id sq9si3514155vdc.179.2014.04.15.10.21.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Apr 2014 10:21:55 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id lh14so9330231vcb.6 for ; Tue, 15 Apr 2014 10:21:55 -0700 (PDT) X-Received: by 10.52.104.33 with SMTP id gb1mr761589vdb.45.1397582514998; Tue, 15 Apr 2014 10:21:54 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp248548vcb; Tue, 15 Apr 2014 10:21:54 -0700 (PDT) X-Received: by 10.224.65.194 with SMTP id k2mr4454968qai.59.1397582514419; Tue, 15 Apr 2014 10:21:54 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id d5si1952795qab.84.2014.04.15.10.21.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Apr 2014 10:21:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; 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-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 (/) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.192.48 listed in list.dnswl.org] 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+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: dave.long@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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; }