From patchwork Wed Apr 16 20:24:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 4004001 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 7887DBFF02 for ; Wed, 16 Apr 2014 20:26:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9FEF32034A for ; Wed, 16 Apr 2014 20:26:48 +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 A005820306 for ; Wed, 16 Apr 2014 20:26:47 +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 1WaWO0-0006Hm-1d; Wed, 16 Apr 2014 20:24:48 +0000 Received: from mail-qc0-f172.google.com ([209.85.216.172]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WaWNv-00054n-8n for linux-arm-kernel@lists.infradead.org; Wed, 16 Apr 2014 20:24:45 +0000 Received: by mail-qc0-f172.google.com with SMTP id i8so12354566qcq.17 for ; Wed, 16 Apr 2014 13:24:20 -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=KSYr1IpMmAHRw/C07dQILZTzlAt51vOLiwsYe8Z2heE=; b=RaSSnTw4u2AXlOJJT4b70innN50GDiwnd1+dforZNjxe4nAQe1DWI8Iek7VL7dOm8V fg7yr6EVYxn0jXU+bQYK5nENSlis31nB0FLTR7zgeAX9xu8S4UBVjk1eftFNQhfCq9BM G1QRo69A7SOuIjjsgT9kwtQ87wyDAXxKa18gZAhTzgPI7bHFhKkUin1e/5A6JY2yxUoA 2cRHaZyqbi4E87c7SS4/N7glxbERHRnqJH2BSTvVVBTP8lbVQVsBk0+93w+3gJzuyv15 A+jYQOvDc/jIWwR1Y5Iokc7+iZywRsz5FmDUqq7mW/oxvVhkflhI5vE3lTIFZ6yG4tGH zD7g== X-Gm-Message-State: ALoCoQkYTbP3BMwNY2ZrCAXUGTh0AC+j9VdkEjNV8nOwC2dHPlWOVXt1odxSoQQ5yX+qWqJLtQum X-Received: by 10.224.38.209 with SMTP id c17mr7800296qae.11.1397679860621; Wed, 16 Apr 2014 13:24:20 -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 w14sm26368556qaw.11.2014.04.16.13.24.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Apr 2014 13:24:20 -0700 (PDT) Message-ID: <534EE6F2.3050005@linaro.org> Date: Wed, 16 Apr 2014 16:24:18 -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: David Miller , oleg@redhat.com Subject: Re: [RFC PATCH v4] ARM: uprobes xol write directly to userspace References: <20140416164310.GA15739@redhat.com> <20140416.133831.364304583096073299.davem@davemloft.net> <20140416191825.GA22246@redhat.com> <20140416.153734.675854782374654510.davem@davemloft.net> In-Reply-To: <20140416.153734.675854782374654510.davem@davemloft.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140416_132443_394032_2B657B04 X-CRM114-Status: GOOD ( 16.54 ) X-Spam-Score: -0.7 (/) Cc: tixy@linaro.org, linaro-kernel@lists.linaro.org, ananth@in.ibm.com, victor.kamensky@linaro.org, peterz@infradead.org, taras.kondratiuk@linaro.org, rabin@rab.in, rmk@arm.linux.org.uk, torvalds@linux-foundation.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.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/16/14 15:37, David Miller wrote: > From: Oleg Nesterov > Date: Wed, 16 Apr 2014 21:18:25 +0200 > >> The last question... area->page = alloc_page(GFP_HIGHUSER), and I am >> not sure that arch/arm/mm/highmem.c:kmap_atomic() can't break the >> aliasing, __fix_to_virt() in this case will use the same (per-cpu) idx. >> >> Looks like, __kunmap_atomic()->__cpuc_flush_dcache_area() should take >> care, but could you please ack/nack my understanding? > > Good point, it might therefore make sense to use a low-mem page. > The following test code seems to have the same problems with stale user icache. It works if I put the dcache flush back in. Am I missing something? -dl diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 04709b6..10ad973 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -34,6 +34,7 @@ #include /* user_enable_single_step */ #include /* notifier mechanism */ #include "../../mm/internal.h" /* munlock_vma_page */ +#include #include #include @@ -1141,7 +1142,7 @@ static int xol_add_vma(struct mm_struct *mm, struct xol_area *area) if (!area->vaddr) { /* Try to map as high as possible, this is only a hint. */ area->vaddr = get_unmapped_area(NULL, TASK_SIZE - PAGE_SIZE, - PAGE_SIZE, 0, 0); + PAGE_SIZE, page_to_pfn(area->page), MAP_SHARED); if (area->vaddr & ~PAGE_MASK) { ret = area->vaddr; goto fail; @@ -1175,7 +1176,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr) if (!area->bitmap) goto free_area; - area->page = alloc_page(GFP_HIGHUSER); + area->page = alloc_page(GFP_USER); if (!area->page) goto free_bitmap; @@ -1299,11 +1300,8 @@ static unsigned long xol_get_insn_slot(struct uprobe *uprobe) /* 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); +/* Temporary hard-core icache flush for testing */ + __flush_icache_all(); return xol_vaddr; }