From patchwork Sat Oct 22 07:18:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7171 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1088493wrr; Sat, 22 Oct 2022 00:40:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Eki3tdalBjDnXW2f9bdjGkP9zD5DfPSRw2KxJ3re56tbzsYYpBV8/npIxitZidlz9JCbp X-Received: by 2002:a63:1e47:0:b0:43c:261f:f773 with SMTP id p7-20020a631e47000000b0043c261ff773mr19749440pgm.1.1666424413026; Sat, 22 Oct 2022 00:40:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424413; cv=none; d=google.com; s=arc-20160816; b=Ejt7/cb3flsVD5FuCacDnlZNKuYTYaNruYtKKI7FsHAc+E7TnKxtS0/peDWGA9AztZ QwMjv/tz6tUUIGvVIM7y8/tNzWB29TC30dp16hTaftkIP9V+VnJ9pYwYNQXJeYtgxSHd g2hDxGw2XN3HWaCw0W66aNBH2Q7W0An94L2cBtXo6FHN0HRQmLdkJ0zXT+9TTt4ro/PB 6iWN/89y8LfFS605yfZdvJ7PJr85+k3c816dX+w0YiPeLEgTvxQgd7jrI89ZEfUdl+ON cdqwrv318N6Sy1km6QMc7OzWDZN2hzOvkIpdyBniQgnd4pUPLvLSPTNV7OsyJj15961t qefQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yZyt8OX2aLUrybbW6T6vV8l8c2Wacsh1wbEFam1YI2g=; b=VACFphJOnYG6ZaVVm2sdN0OmVc4Ze41nsSlSHIrPvn0c/uwTfZB+jwqURUXjXEcKCi UItFs+PICNmEUBNbtJ7CTOjq3Numb70ZGy1xismkGMJbWWVs8aXDarXzpvpDzGWnj1xx g8kwjr6DjLrR5uB3thINHahyp2Lkv9WR6w/OwUrvrcm6FL6+yI8RvTwG8FRUx+Ccm3Pj CGCznP/KGFSCs9HOoq1UmnZ4X/ASOSgq0N0vBLxAPiOoMZVRuXEX1KGNpY+wlf1aMh7q sdLxFhBHSdqNfNsElz2Td5ZHNthHkrIgoAmSfDMJZkNDIkpYSlj9Gxl+W2J1vNL1mULX nnOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AaKUhQWO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 206-20020a6306d7000000b00460dd0eed0csi29266255pgg.176.2022.10.22.00.40.00; Sat, 22 Oct 2022 00:40:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AaKUhQWO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230495AbiJVHjn (ORCPT + 99 others); Sat, 22 Oct 2022 03:39:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230477AbiJVHjD (ORCPT ); Sat, 22 Oct 2022 03:39:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E8222A4387; Sat, 22 Oct 2022 00:36:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 21F3FB82D9F; Sat, 22 Oct 2022 07:36:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83146C433D7; Sat, 22 Oct 2022 07:36:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424176; bh=mGRauISegIPrTXzdB7pt9upnSHpoEpaDkcfpDRK+yts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AaKUhQWOqjkb0Q7QLosuaicV8YBBULk/KR/XIqXpHWy72dU4MIX1ME/LMuIV8KWmB ktM5c6yXiziWTnaVUbgqrHUQ0K8z0+mIsndJbEyq+GZ2BNYmCbGm/o8sZkCKjrpzuT bgsIWmAi/6D2ybZxK3JJBCfIUf2QV8yQV6Rupfao= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Conor Dooley , Palmer Dabbelt Subject: [PATCH 5.19 051/717] RISC-V: Re-enable counter access from userspace Date: Sat, 22 Oct 2022 09:18:50 +0200 Message-Id: <20221022072424.147975123@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747372645313869751?= X-GMAIL-MSGID: =?utf-8?q?1747372645313869751?= From: Palmer Dabbelt commit 5a5294fbe0200d1327f0e089135dad77b45aa2ee upstream. These counters were part of the ISA when we froze the uABI, removing them breaks userspace. Link: https://lore.kernel.org/all/YxEhC%2FmDW1lFt36J@aurel32.net/ Fixes: e9991434596f ("RISC-V: Add perf platform driver based on SBI PMU extension") Tested-by: Conor Dooley Reviewed-by: Conor Dooley Link: https://lore.kernel.org/r/20220928131807.30386-1-palmer@rivosinc.com Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt Signed-off-by: Greg Kroah-Hartman --- drivers/perf/riscv_pmu_sbi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/perf/riscv_pmu_sbi.c +++ b/drivers/perf/riscv_pmu_sbi.c @@ -639,8 +639,11 @@ static int pmu_sbi_starting_cpu(unsigned struct riscv_pmu *pmu = hlist_entry_safe(node, struct riscv_pmu, node); struct cpu_hw_events *cpu_hw_evt = this_cpu_ptr(pmu->hw_events); - /* Enable the access for TIME csr only from the user mode now */ - csr_write(CSR_SCOUNTEREN, 0x2); + /* + * Enable the access for CYCLE, TIME, and INSTRET CSRs from userspace, + * as is necessary to maintain uABI compatibility. + */ + csr_write(CSR_SCOUNTEREN, 0x7); /* Stop all the counters so that they can be enabled from perf */ pmu_sbi_stop_all(pmu);