Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752196AbdLFNe6 (ORCPT ); Wed, 6 Dec 2017 08:34:58 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:35754 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751530AbdLFNez (ORCPT ); Wed, 6 Dec 2017 08:34:55 -0500 Date: Wed, 6 Dec 2017 13:34:51 +0000 From: Mark Rutland To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, catalin.marinas@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 Subject: Re: [PATCH v3 18/20] perf: arm_spe: Fail device probe when arm64_kernel_unmapped_at_el0() Message-ID: <20171206133450.7bcbyxnlyei3qgvl@lakrids.cambridge.arm.com> References: <1512563739-25239-1-git-send-email-will.deacon@arm.com> <1512563739-25239-19-git-send-email-will.deacon@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1512563739-25239-19-git-send-email-will.deacon@arm.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1480 Lines: 41 On Wed, Dec 06, 2017 at 12:35:37PM +0000, Will Deacon wrote: > 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 and potentially also when writing back kernel samples > unless an expensive drain operation is performed on exception return. > > For now, fail the SPE driver probe when arm64_kernel_unmapped_at_el0(). > > Signed-off-by: Will Deacon Reviewed-by: Mark Rutland Mark. > --- > drivers/perf/arm_spe_pmu.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c > index 8ce262fc2561..51b40aecb776 100644 > --- a/drivers/perf/arm_spe_pmu.c > +++ b/drivers/perf/arm_spe_pmu.c > @@ -1164,6 +1164,15 @@ static int arm_spe_pmu_device_dt_probe(struct platform_device *pdev) > struct arm_spe_pmu *spe_pmu; > struct device *dev = &pdev->dev; > > + /* > + * 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()) { > + dev_warn_once(dev, "profiling buffer inaccessible. Try passing \"kpti=off\" on the kernel command line\n"); > + return -EPERM; > + } > + > spe_pmu = devm_kzalloc(dev, sizeof(*spe_pmu), GFP_KERNEL); > if (!spe_pmu) { > dev_err(dev, "failed to allocate spe_pmu\n"); > -- > 2.1.4 >