From nobody Tue Mar 4 22:14:00 2025 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2992B22576E for ; Tue, 14 Jan 2025 22:58:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736895515; cv=none; b=P9ahqYbjU4PWNkAom4+9KtTcZkq8nyb/ME2V/RYSwTUshKP2/sZVPRjBy9g+Ua+s7Fn9fpvm3DfQ00sBs2/lQ6H5ru3MQc17H81/9EdMWTwilmvoKO7Zb2jn2vmDw2deIs5DaxkkX0EFvamT63ftgHCzTfyHSESBNCVK8gAKVok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736895515; c=relaxed/simple; bh=6cvdh9C7OPpZKWwBlCCCuIR/XmKs0464rb7Zln508uw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iDV969lMFUx7eEcDKmohZlhvciYts34I/N4dtDrk8HtJGOADMsgLTuHQ4R56uZ15B3n4Iv/2uKHpjRr7oiXbS+kVxdzbpHFIl5KeNMoGUo7lr85dfWMOQEeLe7HatSxidxVStSVnVbKt5aZMeqCjRbX4NeV22Mf0MLRrvJBXI00= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=ByoSjsS+; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="ByoSjsS+" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-21636268e43so142411985ad.2 for ; Tue, 14 Jan 2025 14:58:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1736895513; x=1737500313; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=nWIGDLFCubHBSCVyRujLDRmHtXnqwdBi6tbEZKWPh8g=; b=ByoSjsS+rJagZici9xtLzFoM1xDW5uEXH4ApT63qf79CvC7hNj/rsKJzdVum+fTHm1 F7RLgwVD+7ra2Ty3u+WEHKhsFtLdbkQTRVQDnuA++slaDQVTzULiBpnjMflhdKpJc+eC Gj2xSkhEjXLu/dkHzYbV6RoAfVt01Q/AJZL4ANQbXYzZuQSi8AYAes8BtSoZX0GoW0T/ weZKWWAkiHMBKFkSD8riT9gGg6CgsPQLebb3wwQV4/1ep/zJfGZa0S2oFYuq1zwPdtWQ TS6FWgaXMqSJ3TpJkbSQq3CiPw5ipK4PoNdjiaW/1ZeyQsIWvIYJoIcjcZOCpOBGDLWa MN8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736895513; x=1737500313; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nWIGDLFCubHBSCVyRujLDRmHtXnqwdBi6tbEZKWPh8g=; b=MwB7gRBqhQ16diCnLC62oCltTueGXsZ7d8k98PcPUQCgyBP9QgA2OhYtlPEiFkwzX1 yAuo7do+jRbGaInhKwNRyM0OODP2bh7dnkFpIjSFyqBJ+zN3N+F/L2KESF0sfNnjgGUs kl+GHiTbQ/S6DxXsg9MI+OMhO7ItEBidk8zTmstDlZrMIgdp8Bws+pZi+apmYJJOGIUy FGZmSDHujaUlWPEL50C4AptRL0F8K8B9GTx4SxULBDRe+MkCh/enqtEC8xlSSWvlFKAW xUsTqAZHkQFz0MK7B+9EH1lqW3oXAc5dOTYsgFCHb9t8Y0qOP72APjjWUPayYImDfoGz Dipg== X-Forwarded-Encrypted: i=1; AJvYcCUa6NxEeSmnYhuN0CHsxQ+eApZe9Eib8zRhEMaZhrOqL2Rti7Suf6Gm6gy2ELX4peZVBuCCLLrEHIQiS7A=@vger.kernel.org X-Gm-Message-State: AOJu0Yykn5lG2XkWCJ1MnafcaKz5wFbkqssOsdxJas/M5B09M9300Kth oLbwOK80fSU3GPy7C2LsPU0Xjfm1e82lmzQejO0AJX7ENgYreAUrVmylHui4guM= X-Gm-Gg: ASbGnctqSrTigxN4af/vtU2bYbeIKyrIa8RGvVRnnQ2/BML7ZQ3AE6QshTXl8UWcn0b VqYZWI2I04dFhSM3Q8mn9iEuLThf4XY2wSdAODz2JM1YZ+X12Uq6av8+VhDoYgLTceaAB+ARSa4 H9s1Is2RgQECAnCGhsY6ZE2RWEBCMqfeK/vtRKg3GACVSEkt18urVFiR9Xj11hX6JJcU199Hr0O rwTyPObD0LetpzFoORU1I60ADh6sWzD15qfXwZgniQE1btXTwcGLU6AjH9hej3DyU7Mtw== X-Google-Smtp-Source: AGHT+IEA456GfI5+8oEuqGE6qvT+i61hsuXVFO4kFDRLI54KTxTxc0Qi5q2Wl0+CmS3HjZwnXXbB9Q== X-Received: by 2002:a17:902:dac6:b0:216:4a8a:2665 with SMTP id d9443c01a7336-21a84012a17mr412337025ad.50.1736895513466; Tue, 14 Jan 2025 14:58:33 -0800 (PST) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21a9f10df7asm71746105ad.47.2025.01.14.14.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 14:58:33 -0800 (PST) From: Atish Patra Date: Tue, 14 Jan 2025 14:57:34 -0800 Subject: [PATCH v2 09/21] RISC-V: Add Smcntrpmf extension parsing Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250114-counter_delegation-v2-9-8ba74cdb851b@rivosinc.com> References: <20250114-counter_delegation-v2-0-8ba74cdb851b@rivosinc.com> In-Reply-To: <20250114-counter_delegation-v2-0-8ba74cdb851b@rivosinc.com> To: Paul Walmsley , Palmer Dabbelt , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Anup Patel , Atish Patra , Will Deacon , Mark Rutland , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , weilin.wang@intel.com Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Conor Dooley , devicetree@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, Atish Patra X-Mailer: b4 0.15-dev-13183 Smcntrpmf extension allows M-mode to enable privilege mode filtering for cycle/instret counters. However, the cyclecfg/instretcfg CSRs are only available only in Ssccfg only Smcntrpmf is present. That's why, kernel needs to detect presence of Smcntrpmf extension and enable privilege mode filtering for cycle/instret counters. Signed-off-by: Atish Patra --- arch/riscv/include/asm/hwcap.h | 1 + arch/riscv/kernel/cpufeature.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index 2f5ef1dee7ac..42b34e2f80e8 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -104,6 +104,7 @@ #define RISCV_ISA_EXT_SMCSRIND 95 #define RISCV_ISA_EXT_SSCCFG 96 #define RISCV_ISA_EXT_SMCDELEG 97 +#define RISCV_ISA_EXT_SMCNTRPMF 98 =20 #define RISCV_ISA_EXT_XLINUXENVCFG 127 =20 diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index b584aa2d5bc3..ec068c9130e5 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -394,6 +394,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] =3D { __RISCV_ISA_EXT_DATA(smmpm, RISCV_ISA_EXT_SMMPM), __RISCV_ISA_EXT_SUPERSET(smnpm, RISCV_ISA_EXT_SMNPM, riscv_xlinuxenvcfg_e= xts), __RISCV_ISA_EXT_DATA(smstateen, RISCV_ISA_EXT_SMSTATEEN), + __RISCV_ISA_EXT_DATA(smcntrpmf, RISCV_ISA_EXT_SMCNTRPMF), __RISCV_ISA_EXT_DATA(smcsrind, RISCV_ISA_EXT_SMCSRIND), __RISCV_ISA_EXT_DATA(ssaia, RISCV_ISA_EXT_SSAIA), __RISCV_ISA_EXT_DATA(sscsrind, RISCV_ISA_EXT_SSCSRIND), --=20 2.34.1