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=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 BEBEFC433B4 for ; Tue, 27 Apr 2021 13:51:14 +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 379D5613DA for ; Tue, 27 Apr 2021 13:51:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 379D5613DA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Geys3IoWDwYwq6MJNajd/EYaJKyGQia8fmKdagh++2A=; b=HONWk9JfhvasD26b2AxyGPJ8f+ D5fblneIhcoGCeXssHYm4wmE2Epp+YwaMi3IYARz5DW7iPT/kEVk0B/q20iIXYKPzzOGqbi3FGzSO 7kEw2XSSp/w9e+G2AB1E8PeDLTnF2rGkNfFqx8E1Y2UM0o4mcUtFUTsObiByZnqPopqeBrEyDfBp/ o6paQImdxf7yFLqTu5zFPv1GryRfqkG3wHLf6UxcujNA7ek7YhZURx5jdc1OaQIrgEPKAoQRp/14n am2kSCeb2roWvdBUt/bI6gEym6LTLwdYtxDnMCSYeUtqO4ne1aShepcC4BqXgH7bpyRTk7BY0TJ4Q eqqFTMSg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lbO5Q-001iFx-Mh; Tue, 27 Apr 2021 13:49:12 +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 1lbO5K-001iFi-KZ for linux-arm-kernel@desiato.infradead.org; Tue, 27 Apr 2021 13:49:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=rascPb9+iTk18v3l72lt8dJj1SNq+fKe6BYOPqMWaBA=; b=q1WEl6Sr6TqoTGszYjPMj9BTU/ fnDjkQfmUM73+5gChBXUb5+lRANN8LxUfFlBOBtjRxQSmrBQQgHvIa/QwWQIA6qV2Ho4GrkhJeFfq BcscVC48v/ye1J8aV0vyZJCbzIYkQpJNnYGwVYW2clnhPI9fyFjbC3N2hLe725PbEZoIQjTikqGzm gU2bAXBbjiYwXRgpxX1Bp/oP2xASFF+sjAJCp4URdw01rP+r3P5QxqaBT/wHyEfQ57pHYp3k7fl03 fE0MGnx0SHoFnAIpqFozlQOO/jOxyLoclB2wTMk5sPNWh9Dk4kkgKR+aXQS53htYRHLVvBYJ7qcCc lydkKbog==; Received: from mail-oi1-f169.google.com ([209.85.167.169]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbO5I-00GlsE-8O for linux-arm-kernel@lists.infradead.org; Tue, 27 Apr 2021 13:49:05 +0000 Received: by mail-oi1-f169.google.com with SMTP id i26so4433144oii.3 for ; Tue, 27 Apr 2021 06:48:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rascPb9+iTk18v3l72lt8dJj1SNq+fKe6BYOPqMWaBA=; b=FGJheHJ58YEK9biNuItkd9m0/S7WlCDcBAl4rmaMTm924jV3Yx1bupQYxwbnjVNgoU RKrSPhAHQVHb8YcoSwXdt4P1mYBqA38+pQsu8z3Qif1haDoBY5u9B9LB9LscE/pGO4a5 2/tl5/uYO5YNSWHrcM0COcMhTJWqqINJxhT9hDrEUK5VlnqR6+mPDXyQ0h+j/qXxKMof mm33pYh/MfgolkCeAJfcaOThN9RFclvIz6DVWShtFhox6pVyqlnqbanV3zfsp/5gOgE3 GXxKTqy/JcRDUDaaAn6xog23SpHTckMS+1iCzV9pH7vHaT8ERVxUAqZi5b+M4rIGiIwb kKHQ== X-Gm-Message-State: AOAM531d7d20p3OTZzw68pd95OpzmL54dddJ+xD6OKI1yrK2x5UKcOR6 mcH+gqGKcSryYRAS9R/OU1LTUzBdKg== X-Google-Smtp-Source: ABdhPJwITZZ2Rb/bFBACjX8TM0OViMLryidYFlnVJGIv6SEgqSK5z0Wrue+zXy2UHLPG0lxG0N6w5A== X-Received: by 2002:a54:4f91:: with SMTP id g17mr16737612oiy.15.1619531333895; Tue, 27 Apr 2021 06:48:53 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id e22sm496194oii.58.2021.04.27.06.48.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 06:48:53 -0700 (PDT) From: Rob Herring To: Will Deacon , Catalin Marinas Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim Subject: [PATCH] arm64: perf: Ensure EL0 access is disabled at reset Date: Tue, 27 Apr 2021 08:48:52 -0500 Message-Id: <20210427134852.1411642-1-robh@kernel.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210427_064904_319860_2C4EACBC X-CRM114-Status: GOOD ( 12.03 ) 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 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. 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