From patchwork Fri Jun 27 14:57:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Pihet X-Patchwork-Id: 32624 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0A676207CA for ; Fri, 27 Jun 2014 14:58:47 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id lx4sf29679246iec.8 for ; Fri, 27 Jun 2014 07:58:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=ATkkhHkbikisVL/biXkqcQJu1ZvtS1YK44JxBrOh7wE=; b=iOVk6omUHfPAPTV2g1KN7P6zbTtrZbdEkl5ice7Iq+YRzr4/zIXolZTEO7v45/mBh5 koYaZvkNORIpidw97GUvMlP0ywzzPHos+oWbAdl2Cy/504oOCQcqFWZ+fYe5l1ihNCRM a0SHdz0s382jiUsf+Yqnwx69HDQO7xB3FmM/k3s3oOktNpX+TXPXg8X7ce6MGhjH3W2B 80FvFtNJdzTaEPD9nhv+MkbxZnxg6u8IYDqvTTZQmc5Il5oETvNMwU79SmEeX1Dgbpqp KeLN+G4WNbec/BaGXHx6xP2alI0R3xdmSFGV8pQe+QbTIT/zDfecr0yxsQ1Ybg3NFDfB L3yg== X-Gm-Message-State: ALoCoQnBoS0SyQnOct/lB00mGJcBlowC6hBEPDpfc/0tXpVZr8O+hnF7cgiGq5asIQuTpeiqP/7F X-Received: by 10.42.36.10 with SMTP id s10mr11112432icd.5.1403881127560; Fri, 27 Jun 2014 07:58:47 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.41.244 with SMTP id z107ls710831qgz.43.gmail; Fri, 27 Jun 2014 07:58:47 -0700 (PDT) X-Received: by 10.52.171.68 with SMTP id as4mr560983vdc.91.1403881127417; Fri, 27 Jun 2014 07:58:47 -0700 (PDT) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id m2si6510734vek.107.2014.06.27.07.58.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Jun 2014 07:58:47 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.180 as permitted sender) client-ip=209.85.128.180; Received: by mail-ve0-f180.google.com with SMTP id jw12so5434339veb.11 for ; Fri, 27 Jun 2014 07:58:47 -0700 (PDT) X-Received: by 10.58.219.194 with SMTP id pq2mr684736vec.71.1403881127210; Fri, 27 Jun 2014 07:58:47 -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.221.37.5 with SMTP id tc5csp113500vcb; Fri, 27 Jun 2014 07:58:46 -0700 (PDT) X-Received: by 10.66.102.39 with SMTP id fl7mr31287304pab.43.1403881126485; Fri, 27 Jun 2014 07:58:46 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bv1si14251270pbc.101.2014.06.27.07.58.45; Fri, 27 Jun 2014 07:58:45 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754101AbaF0O6g (ORCPT + 27 others); Fri, 27 Jun 2014 10:58:36 -0400 Received: from mail-wg0-f48.google.com ([74.125.82.48]:42040 "EHLO mail-wg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753939AbaF0O6J (ORCPT ); Fri, 27 Jun 2014 10:58:09 -0400 Received: by mail-wg0-f48.google.com with SMTP id n12so5146865wgh.19 for ; Fri, 27 Jun 2014 07:58:08 -0700 (PDT) X-Received: by 10.194.189.50 with SMTP id gf18mr26584795wjc.13.1403881087930; Fri, 27 Jun 2014 07:58:07 -0700 (PDT) Received: from localhost.localdomain (216.193-240-81.adsl-dyn.isp.belgacom.be. [81.240.193.216]) by mx.google.com with ESMTPSA id 19sm21920749wjz.3.2014.06.27.07.58.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jun 2014 07:58:07 -0700 (PDT) From: Jean Pihet To: Will Deacon , linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, Sneha Priya , linux-kernel@vger.kernel.org, Jiri Olsa , Arnaldo Carvalho de Melo Cc: Jean Pihet Subject: [PATCH 2/3] ARM: perf: disable the pagefault handler when reading from user space Date: Fri, 27 Jun 2014 16:57:46 +0200 Message-Id: <1403881067-22690-3-git-send-email-jean.pihet@linaro.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1403881067-22690-1-git-send-email-jean.pihet@linaro.org> References: <1403881067-22690-1-git-send-email-jean.pihet@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: jean.pihet@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.180 as permitted sender) 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , As done on other architectures (ARM64, x86, Sparc etc.). This prevents a deadlock on down_read in do_page_fault when unwinding using fp and triggering on kernel tracepoints: INFO: task stress:2116 blocked for more than 120 seconds. Not tainted 3.15.0-rc4-00364-g3401dfb-dirty #43 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. stress D c04b41e8 0 2116 2115 0x00000000 [] (__schedule) from [] (schedule+0x40/0x90) [] (schedule) from [] (__down_read+0xc4/0xfc) [] (__down_read) from [] (down_read+0x18/0x1c) [] (down_read) from [] (do_page_fault+0xac/0x420) [] (do_page_fault) from [] (do_DataAbort+0x44/0xa8) [] (do_DataAbort) from [] (__dabt_svc+0x38/0x60) Exception stack(0xecbc3af8 to 0xecbc3b40) 3ae0: ecbc3b74 b6d72ff4 3b00: ffffffec 00000000 b6d72ff4 ec0fc000 00000000 ec0fc000 0000007e 00000000 3b20: ecbc2000 ecbc3bac 00000014 ecbc3b44 c0019e78 c021ef44 00000013 ffffffff [] (__dabt_svc) from [] (__copy_from_user+0xa4/0x3a0) Signed-off-by: Jean Pihet Cc: Will Deacon --- arch/arm/kernel/perf_event.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c index 6493c4c..f5aeca2 100644 --- a/arch/arm/kernel/perf_event.c +++ b/arch/arm/kernel/perf_event.c @@ -560,11 +560,16 @@ user_backtrace(struct frame_tail __user *tail, struct perf_callchain_entry *entry) { struct frame_tail buftail; + unsigned long err; - /* Also check accessibility of one struct frame_tail beyond */ if (!access_ok(VERIFY_READ, tail, sizeof(buftail))) return NULL; - if (__copy_from_user_inatomic(&buftail, tail, sizeof(buftail))) + + pagefault_disable(); + err = __copy_from_user_inatomic(&buftail, tail, sizeof(buftail)); + pagefault_enable(); + + if (err) return NULL; perf_callchain_store(entry, buftail.lr);