From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79857C433ED for ; Tue, 27 Apr 2021 13:57:52 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 26C0F61001 for ; Tue, 27 Apr 2021 13:57:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26C0F61001 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=z2OrBglOAoWxgKDHNvU3K2qzF8uEyUFsNCrmRxuJRRo=; b=Vu0dwcug9zFg2XwG4AI2NUCL0 yjmkF9/s6zLzMwuy8Nc603puFyoOtbfI9x73XmnYW0v3ijt8/tE6ZRsnzuEh2XTj8oYgt1dJAYlpS WdMbODNKelv95F4KkArDmKo1K1jylGplBqEmnZSp7gYTYRIlnHtunzY7j5wuxLOFqciS/u7qsaX1q 6qkMIsJPS++cc9sx5rnD1Olt2DWgi13FeTXGfsW0lkS5PDNKOVQry4/dji9D56XF0fVL0wGla3kxJ w49F+ADH8AaQg4mMuS8h7MCyPxqK/Aw13nBm7mbzCXdIumosbCCc4m93MEVBmYKbu/v5afO5P3vOH qxDdXQMSA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lbOBP-001j8D-2U; Tue, 27 Apr 2021 13:55:23 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbOBM-001j7P-EU for linux-arm-kernel@desiato.infradead.org; Tue, 27 Apr 2021 13:55:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=i9FaUSAJKG7DCzBagCMthNnEE3TI0nDwF40zpbJlsOo=; b=mXkvc+3L6Lmf6Kf0HCjTI+QG+C ySER79pFnIBPh0YmQUCt4XX69VS5++99JT9KJNSjYegcOY8vdb6e4lMhj3jt+ANLimOdnWa65TrtP 8cZKqdbD3LvEdK3P3UMaivEskHFwfRnTfmIOVRo9ozqrkceAxTIYf2iBaifLvL81uWNsgy9c/cstw fnlAeW0UuZToUOQ+p/SjsYptrgPE0YvQKco3ia7igzi5IJ3PD94xf9/0SgzTk81q6P+E9IGmfzlx7 TP7JYrKN0Z6UnnDhMW4gj8HTbhse2hhavmfbNfmJTuYjMfiFa8crMlftpfT9uWr3852hBCPv2LNzC /EDSgvWg==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lbOBJ-00GmAl-G7 for linux-arm-kernel@lists.infradead.org; Tue, 27 Apr 2021 13:55:19 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2D12AD6E; Tue, 27 Apr 2021 06:55:12 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.31.135]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 92B363F70D; Tue, 27 Apr 2021 06:55:09 -0700 (PDT) Date: Tue, 27 Apr 2021 14:55:06 +0100 From: Mark Rutland To: Rob Herring Cc: Will Deacon , Catalin Marinas , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim Subject: Re: [PATCH] arm64: perf: Ensure EL0 access is disabled at reset Message-ID: <20210427135506.GC37475@C02TD0UTHF1T.local> References: <20210427134852.1411642-1-robh@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210427134852.1411642-1-robh@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210427_065517_607619_E2211F3A X-CRM114-Status: GOOD ( 21.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Apr 27, 2021 at 08:48:52AM -0500, Rob Herring wrote: > The ER, SW, and EN bits in the PMUSERENR_EL0 register are UNKNOWN at > reset and the register is never initialized, so EL0 access could be > enabled by default on some implementations. Let's initialize > PMUSERENR_EL0 to a known state with EL0 access disabled. We reset PMUSERENR_EL0 via the reset_pmuserenr_el0 macro, called from __cpu_setup when a CPU is onlined and from cpu_do_resume() when a CPU returns from a context-destructive idle state. We do it there so that it's handled even if a kernel isn't built with perf support. AFAICT, that *should* do the right thing -- are you seeing UNKNOWN values, or was this found by inspection? Thanks, Mark. > > Signed-off-by: Rob Herring > --- > arch/arm64/kernel/perf_event.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c > index 4658fcf88c2b..c32778ae5117 100644 > --- a/arch/arm64/kernel/perf_event.c > +++ b/arch/arm64/kernel/perf_event.c > @@ -450,6 +450,11 @@ static inline void armv8pmu_pmcr_write(u32 val) > write_sysreg(val, pmcr_el0); > } > > +static void armv8pmu_clear_pmuserenr(void) > +{ > + write_sysreg(0, pmuserenr_el0); > +} > + > static inline int armv8pmu_has_overflowed(u32 pmovsr) > { > return pmovsr & ARMV8_PMU_OVERFLOWED_MASK; > @@ -933,6 +938,9 @@ static void armv8pmu_reset(void *info) > armv8pmu_disable_counter(U32_MAX); > armv8pmu_disable_intens(U32_MAX); > > + /* User access is unknown at reset. */ > + armv8pmu_clear_pmuserenr(); > + > /* Clear the counters we flip at guest entry/exit */ > kvm_clr_pmu_events(U32_MAX); > > -- > 2.27.0 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel