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: 4435801 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 D9536BEEAA for ; Fri, 27 Jun 2014 15:00:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0F29620320 for ; Fri, 27 Jun 2014 15:00:59 +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 37EB220379 for ; Fri, 27 Jun 2014 15:00:58 +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 1X0XcF-00053B-HB; Fri, 27 Jun 2014 14:59:03 +0000 Received: from mail-we0-f181.google.com ([74.125.82.181]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X0Xbj-0004iD-JX for linux-arm-kernel@lists.infradead.org; Fri, 27 Jun 2014 14:58:32 +0000 Received: by mail-we0-f181.google.com with SMTP id q59so5336919wes.26 for ; Fri, 27 Jun 2014 07:58:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WMZeT4831E1daoiq+uXuhSLUmyYwlBPA9pxDLEc1DmU=; b=MuIpnMn1jwqBvNFMqWXnCusJRopweNq57ShEq+7soHeUxHF95otlCMMxl6lMGYzXEi EOs6UP3QbO1Qbge/GnudNE3i3uLdcc4FBCiYaimkGoI2QWGp8IxR4i+TIwHzqDuMMxCS cJg80Jky5fQFYqOqk/7X92ZghWZVYMrLAzzoXfcYi8W/d/27Xo1xxk5la2LuclmsFtNs d+EY8kKkKWnIVHQbdy2m3P2RT/bms9lELbYy7gSTqohlW5aPQjmtCHE0ReR6N97/q+Kt MtKHI8XcZ9Ue56nAGkH2WKilXcpJHv9mQVTiBwKtVYq3qpN9oy9JM0rcl2RqaCZcNC3g 2ZzQ== X-Gm-Message-State: ALoCoQkJKyhXWJvP8yvVjHptbhWyjxfS49iFiFEzZOO0egwf+Th5HWj7yM4k5zioee1g4wwYF2+G 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140627_075831_832809_DF07C6E5 X-CRM114-Status: GOOD ( 11.71 ) X-Spam-Score: -0.7 (/) Cc: Jean Pihet X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_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 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);