Received: by 10.223.185.116 with SMTP id b49csp100350wrg; Thu, 15 Feb 2018 17:29:17 -0800 (PST) X-Google-Smtp-Source: AH8x227KBZG0Ine3pQvHW8H2sI5KhUwDW93sA+4DhLhz3wQU5GTHe6PVQM/3HEwQlFs5mWWnn7WA X-Received: by 10.98.11.194 with SMTP id 63mr455450pfl.172.1518744556999; Thu, 15 Feb 2018 17:29:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518744556; cv=none; d=google.com; s=arc-20160816; b=vYqHCOfgISYK/Ukzm0Os3cEZIC9e8ec90Y40bUDK3pwQX49PDDivjiqNDLAICZhFl8 xNXwnrthLiJI94dNsyIbUF1FFC1BrcUnjtHoyNTqqWAV5uAngY6Qu4YXA2bhjCOSVw+i IDqTEINfNVSol2GMQPyvvPyCvsgCKiDC3MmW++PDeZCnDLervoMsHnSsxKcoIZyqQHCB bWJtj1Og0sdx1QhIac7TbYS86GBMN8lzvI4FwYKOolktuHHb0ih48tlyQLtmN67C9MPG 5+GocwuenB98mntL/wjBM8X4XCorq3iJXPVfIyPDt56g1HZvQFZ+yqjHeMdR71vG1YUz AMFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=yCjEHzlI0Ds7zuQv0aTlwwXbx46DKcdqUk6OS2cE4uQ=; b=z0o60HrMb8hkXqWDHxZJjgnBpKBZL4b+6PUoaHubipAYG7ZUBCZYX+OlFkvtqO7qEQ FJV+t1upAbavox/QWjeHzjwogSw5GfKEYSHKd9ifTyAwMPY7vqJ6cgsagAf62WBM3/Z1 o4UDxxdM6uTnyZmCt4uN6Ineds+XaREAc/ZU02UgNbEYl9GtFM75taOy5VN+kLx6Eqli HATlZSKwYrbHgRt9K9gzwrvCRZw5ARsfz7hFQIfNKKW5nMbBs74Qm9t0h9iJwxcw2oiw hbp5OcI0gkDft3K7kuB05WEsOHdc+ldnAIvl9CSoCY9y8fZgGX9zxNH7vYOvtv3kqARU ECVQ== 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 w12-v6si1202907plp.288.2018.02.15.17.29.02; Thu, 15 Feb 2018 17:29:16 -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 S1424087AbeBOPmB (ORCPT + 99 others); Thu, 15 Feb 2018 10:42:01 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:33032 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424005AbeBOPl7 (ORCPT ); Thu, 15 Feb 2018 10:41:59 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E2C39F69; Thu, 15 Feb 2018 15:41:57 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Laura Abbott , Shanker Donthineni , Will Deacon Subject: [PATCH 4.15 048/202] [Variant 3/Meltdown] perf: arm_spe: Fail device probe when arm64_kernel_unmapped_at_el0() Date: Thu, 15 Feb 2018 16:15:48 +0100 Message-Id: <20180215151715.725606175@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Will Deacon Commit 7a4a0c1555b8 upstream. 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(). Reviewed-by: Mark Rutland Tested-by: Laura Abbott Tested-by: Shanker Donthineni Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- drivers/perf/arm_spe_pmu.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- 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(s 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");