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: 10085303 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C20DB60234 for ; Thu, 30 Nov 2017 16:47:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B79D22A204 for ; Thu, 30 Nov 2017 16:47:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACA8E2A218; Thu, 30 Nov 2017 16:47:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 355DD2A204 for ; Thu, 30 Nov 2017 16:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=HPi8DNoMtby21yq8M8Z47YNu83/WgPhUNfj4tRPaAXE=; b=NkUfRceMr4umo8ofZil/WGf7Y3 0W1e1xmD9vOZ1dkQJlmA9s9wbSg9uD7ne3MQYJ8LcMDyKGuNgHjS8yXT3IDsZ83XNxAGLI5/qSDPv G1L/2+J3oQCJfeGlyqGNnPZ627TqxPVxj0PQeVebckPbpMtdZXITepfxEUW7JI7RURqjgc1+6I8b+ hzHz4J4m5Y4+FG/pfCWAqj31x96UAJWibPZqgVw+7tt3o254XU1ZzN8BksrxwZrwqll+fiHnnUN3j CKn1Zvxb9x6425pwFIM0TjcL1l9+JNx+6HxlfRm/xpDtK/D908fyeNAPBQpZt+BswMTY/44YVQ/Pl YDUBLzZw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eKRzt-0006Ai-7F; Thu, 30 Nov 2017 16:47:37 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eKRtN-00085t-SM for linux-arm-kernel@bombadil.infradead.org; Thu, 30 Nov 2017 16:40:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=sWLRcRShKWR4TB3jKdyMc0sCk28ScWZ5UxqSh2LbkYI=; b=gctwHsqGa5IjXXIYLl4nK9hj9 Qo026s+nHnisrkFbYq0eGR8xu3M5cx0vmQJpDJgix8To+iKhFJNMh4GTB+KZRxYN2tdyVJ5CLQiQt lmvv7bRSWaRMLF78nVNLTY08zM6STLL4HFJxtfL70caGcy0bwRvacP5owSN5wpLXeooFR6zbf3jvu W4aSHzeV857f+CvRWndGCRqC9JMPjwGm23ce9X8XG4Q7BUoQcreFeh1dQ5amRtU6IvtI2+BbZPIkH yv0F2BLEWzk+bMhZHLIY5Y5ks6bBgkLDC/RjFIH9lor/BMblSA9R9fyfUqgsUQOthEpLUw7UKaCuG y3NPNGR8w==; Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by merlin.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eKRtL-0002HX-5D for linux-arm-kernel@lists.infradead.org; Thu, 30 Nov 2017 16:40:51 +0000 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 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> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, keescook@chromium.org, ard.biesheuvel@linaro.org, catalin.marinas@arm.com, dave.hansen@linux.intel.com, sboyd@codeaurora.org, linux-kernel@vger.kernel.org, Will Deacon , msalter@redhat.com, tglx@linutronix.de, labbott@redhat.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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