From patchwork Wed Oct 19 08:22:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4539 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp204049wrs; Wed, 19 Oct 2022 01:44:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5whUVs3cfLpKAPSN26Yt3nOkVGshRyrwx9QE6xR2GbxtJOYnRZ7xZJlJvym5IT5yPh45zD X-Received: by 2002:a05:6a00:1145:b0:52b:78c:fa26 with SMTP id b5-20020a056a00114500b0052b078cfa26mr7342135pfm.27.1666169092415; Wed, 19 Oct 2022 01:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666169092; cv=none; d=google.com; s=arc-20160816; b=SxI7sI0PcRFKY6opPsq7bUTwPaTYuGNJmJe6xzHHZgdcAVJamwCWogHoTq83lLLHmc ZN3xZNKLQWmZVJhVof3eQ8weK3SDfzABPOapQMPXrhBZ+yAMPEtOpRWcMu4iqSP3u7Zj ZIaRqK/Xq8pjo2mMgRusV2EEMYgmridFFUCXgk0wFu0OQqbfYCN/DwwTbD8yyPNCMxaG TKiis0iPo0Ps/hz8EH/ngp0tY0SKY8Xr/g3QDwVB1HD/AL4NcB3y378BElazuvtUREKL Uj712qPDqU4Q26K8OPefiMbxMJtE5BvC2IYSYX1oS/83pIJPwGjaUiYdJsBSuXsZYdRa 8trA== 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=E2ZdVVJRfoEsYsWUfZZAO6YyE2qPJxRAf6engqdE5b8=; b=nRlYZhDlJEL6KYjYjYcRorvZ0E7lm09BcG224GZmlCRDE+F/rFwmh0eh2RLHePAN17 SvfIK4FJAqOnuRs4KEdCzUVhSGgXA1wOa/vfJAl06d0x9I219qG1R7TdcYADDGcMTTbK DHrFhSmm205HuCfLsbvklr9W2kwhViXhqeGnL2KKM4mAGuIVarQEteWkmVkgTkv8RkzW qozm+rW1NHao0kOL5UjZScQLsj4NSzhS3PIFDYpYdSAkc9Y7Si1p5IYvlCbV1svIUYyB DysEfQzPRgLEkPTGuiZIvUSESEjxQqjHN/gWk+sPPaeie7cnYVj1Qprmw6KRtqd20o68 fvLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QJCsbt6+; 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 26-20020a63185a000000b0043949ac7067si18162716pgy.200.2022.10.19.01.44.39; Wed, 19 Oct 2022 01:44:52 -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=QJCsbt6+; 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 S231317AbiJSIn5 (ORCPT + 99 others); Wed, 19 Oct 2022 04:43:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230137AbiJSIm7 (ORCPT ); Wed, 19 Oct 2022 04:42:59 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D75A57B78A; Wed, 19 Oct 2022 01:40:08 -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 sin.source.kernel.org (Postfix) with ESMTPS id 76085CE20F0; Wed, 19 Oct 2022 08:40:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B56DC433D7; Wed, 19 Oct 2022 08:39:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168799; bh=TZQmwUKjFwQPzZOwmCSzDveGHxx/GcI5wz6rikE8fwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QJCsbt6+3OilC9R3C7CDNUbdslBBG9tANbqpu3yUfXpVDYaNwipjrHE1ddy9uW7SF 8fuVDZPJ4oQPKkgslS/Kh5rAMDj7TUYvZK0eROaYbNuziVJ4qxEbLWd20S1UsS217j QbDG28tJdHcCrbhfUE+8CLWtw8NQ8TfdAWxJF+a8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Conor Dooley , Palmer Dabbelt Subject: [PATCH 6.0 057/862] RISC-V: Re-enable counter access from userspace Date: Wed, 19 Oct 2022 10:22:24 +0200 Message-Id: <20221019083252.507436677@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747104922318144523?= X-GMAIL-MSGID: =?utf-8?q?1747104922318144523?= 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 @@ -645,8 +645,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);