From patchwork Thu Nov 30 16:39:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 120228 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp16461qgn; Thu, 30 Nov 2017 08:42:38 -0800 (PST) X-Google-Smtp-Source: AGs4zMYKr88vIjG1ZycQ66PNf5ZTDlB91On5b03tQkYM6QtDOFvJBNHXvxdi4Y+9fJqpglaH6XUb X-Received: by 10.99.120.195 with SMTP id t186mr2969083pgc.62.1512060158144; Thu, 30 Nov 2017 08:42:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060158; cv=none; d=google.com; s=arc-20160816; b=uG0R0NTJLlqpDVcObbx0uYnm6BBJYVx4Ok06mA2dt3Gyhda6MCuvP8oKRI/su76JzS hTBGLwE+8y8Hw6wuuZjg4pjC07As7yndkYdVtAq8CELjM2JLpM6QwU9fKYkn4McD8ueL oLTy0GHPxP6mrTMg8f4g7erC6vswEnrvyT+XtmqGADFK5fcMaOoZUrQtqFAHMtEE8Qxd jfw1DH2UYS/mzXk0z9M2hOjqQVTvV5l+PmaCaNhh5V8rJSaNy7nbU5NI8FIaDK5DUSb2 2pimJC6jcL2Olo5nLFyBMiXjo2BP+us7PCftiHgcJGyE77yuj5dEF5EZjPAl9WyOSNl1 opCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=sWLRcRShKWR4TB3jKdyMc0sCk28ScWZ5UxqSh2LbkYI=; b=HjEExsy6lOsAfvQC4OlIrec2Vz8yIBPZs3lebZIb1AwlhYpKGbVKaTY+2T08jcFrY/ yefypPh3V7M2pSch6FkzXHRBzVSqbPyo11wRmyd799b9Bt+IzNQEZLnXsKdTbrfa24bu 6ZjRRINdfXxMxRQ1FB1RkO/sL6nwu4NsVFFTDiDvfcy/pSGKBVaYZVks1+tuIryqzVnz gbsu/sJyg+52Lc83EFIiVUq93F62cst8aDWfKsTVlnmQzOx22/xyeHkQmmpuy8yijTuc 9BDGYLn0W53UvZp5qgvR3YvdXsoF3pTNLB8uT0+3hiCq1+IVA6/ALyygsn2sq3QHJj5w 5b5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1si3492329pfj.303.2017.11.30.08.42.37; Thu, 30 Nov 2017 08:42:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753326AbdK3Qkd (ORCPT + 28 others); Thu, 30 Nov 2017 11:40:33 -0500 Received: from foss.arm.com ([217.140.101.70]:57586 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753382AbdK3Qjr (ORCPT ); Thu, 30 Nov 2017 11:39:47 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 492251B33; Thu, 30 Nov 2017 08:39:46 -0800 (PST) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1A6083F5B3; Thu, 30 Nov 2017 08:39:46 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 8ED121AE3BC8; Thu, 30 Nov 2017 16:39:48 +0000 (GMT) From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, ard.biesheuvel@linaro.org, sboyd@codeaurora.org, dave.hansen@linux.intel.com, keescook@chromium.org, msalter@redhat.com, labbott@redhat.com, tglx@linutronix.de, Will Deacon Subject: [PATCH v2 18/18] perf: arm_spe: Disallow userspace profiling when arm_kernel_unmapped_at_el0() Date: Thu, 30 Nov 2017 16:39:46 +0000 Message-Id: <1512059986-21325-19-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1512059986-21325-1-git-send-email-will.deacon@arm.com> References: <1512059986-21325-1-git-send-email-will.deacon@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When running with the kernel unmapped whilst at EL0, the virtually-addressed SPE buffer is also unmapped, which can lead to buffer faults if userspace profiling is enabled. This patch prohibits SPE profiling of userspace when arm_kernel_unmapped_at_el0(). Signed-off-by: Will Deacon --- drivers/perf/arm_spe_pmu.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.1.4 diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index 8ce262fc2561..c028db8973a4 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -675,6 +675,13 @@ static int arm_spe_pmu_event_init(struct perf_event *event) return -EOPNOTSUPP; /* + * If kernelspace is unmapped when running at EL0, then the SPE + * buffer will fault and prematurely terminate the AUX session. + */ + if (arm64_kernel_unmapped_at_el0() && !attr->exclude_user) + dev_warn_once(&spe_pmu->pdev->dev, "unable to write to profiling buffer from EL0. Try passing \"kaiser=off\" on the kernel command line"); + + /* * Feedback-directed frequency throttling doesn't work when we * have a buffer of samples. We'd need to manually count the * samples in the buffer when it fills up and adjust the event