From nobody Thu Apr 9 23:26:47 2026 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 030793D1CDF for ; Thu, 5 Mar 2026 16:28:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772728132; cv=none; b=oLmUvr12MQO4v+Ctam10bcdCaD+0S5mmnlH2ZUDlQ4osJWOUWX8S24fLy3eqHH5wQSMLv2FjnkQi3bRdFSz+TBgCTzbAkbYY767uu0JtOSmuNeLAxvD4ScdcMPct3ULuDQwA/xWoPjvhRqzl6aLkp8U5mGZOL69Che80cXgzwTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772728132; c=relaxed/simple; bh=jRbuMwpJsJoLSg/pi0zzkkbxx1hvVOZC7VqjzxcTG6M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P6W8bwiVuvF8be7XQsNujM5idJSTJcWAP9Bwx1OravaibZpN6+eQyjhW5JdKAXzCRj9fAn8sX94evwvYfgVZO/32BBz7UOF3gH7Eg4p8yuUINkjiHrg4GsT0M+lkt++zu2IjKDLPIcQSFPL46DaULHhDCaq/rkwTa2oGq/5X/NE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=S9JqFgUX; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="S9JqFgUX" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-439aa2f8ebaso3421121f8f.2 for ; Thu, 05 Mar 2026 08:28:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772728129; x=1773332929; 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=11VRqYRJ5Pqc2nNG60kzy1sCOR7Z8KyAMmnGQpaAEQI=; b=S9JqFgUXaxDdenOIb46wgs6D6Er3sOsVRZ/ofNU3SfGa+OccJ1A4zOMVeWhXmdC8qT eV7nqm7ik5ZCnZmFdKgBXsE96k4IJp+6hhZHsPm1SZ+TuVPevvHZKUbFZHeRTHVTcWWA w4GQwA3XG2Rj8GAn0JCaY5ji+eCFi2LxtpRWwN71BXUsA5+FBiQrquKAj8FFp7wr98fj NH4r+Y32XxrihuuVnQ5NNFZuk31CpTXoTDQGjtIYM4XbS5+coaoxWQQcW4RMLaIXRy6v fubysT1Umv2a3xDN8AS+aEQl6g7j5WmMk+wKtJhjyPAc4V4y8RwUiAH3o0QVTLuQmyIL rFgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772728129; x=1773332929; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=11VRqYRJ5Pqc2nNG60kzy1sCOR7Z8KyAMmnGQpaAEQI=; b=I09wDQbjTQuVDQFz8oA/FNrOB+f9PKcOCfsdPbNh1aql03fmT8P5VB9JgjQq+vEMAU SxCobWpRiLGaPWs0LH5ht3MEDIOFgQGb220DGMtvtPcB1QVk+cvuvZQF83h8xFiDRmn3 a5qnylWq2r+BSAp7lJhXorW/Fo1TGI06yWdEIPhkiSRKR7vy201z9ELLC5L+R1Qj39+/ VZVWem4Y7IqiCtG4ehreiSFkN4nddPqnyoFJdbOk7r7Y4jUdYUyET1AkSOg/2ijcSgrc BXL29kRDmbXbWS8C4aiFO3Jh35JCoS/OeIX2G0+B5jYyESIrS1omgQHLDF3TAnylvnpN Keqw== X-Forwarded-Encrypted: i=1; AJvYcCWpFXOEsxMFKnzWprwlbuO7rOVMacCfBpEQ/KLgV2BZmCHes9MbLaD2ahPcY+Ev8VLoNZ360qYTb+LAg6k=@vger.kernel.org X-Gm-Message-State: AOJu0YwM9/hafG/UfYUJECqWxyGSi7ulplHG/2BPM+cfE4LLRD4H3I7r KfTapJkx3VTa06Wa3ZljIVaqVmOvTqhBtDZQju0mTyY5Swoqdtmv7KR45d7qVDquUJk= X-Gm-Gg: ATEYQzwipepXSaeaGSrgLllBiNZMn0TpZGSRXNyrqFlAZsniYEe7vI5pSL6PEhdpTGE 9+3fJ3z0H4Ca+dijeBxdt+Zm84wHClh4lzkn4leaht6CoDw1bmiZgxz0SLFmaHIsP9KstNkdeAf NzmaP0uGZ5lgSNQRTUb4qwxVGPX+YhScK3NwkS9dSOybvlSKMwx7xDCHudpi8nhGUlodlep5Erq ZJ5d9yaACf08xkdVo7Pz+8YbiDqV1Pqh2NVYTlxOIFjl8HgM1o11iumtvw8FTPvckzBxpRsbOK7 pmmNEvAG0sWyLhtzsPd1Tg050oTbe1b7zlK3kqlI9DnPm+nagjZekgpuDCfR/Q8B1zZjgBcz042 iFnqMSf7bTJsZ0DuNorTYX6Z76cHJ2jRXNZkBZ9GkjbRAoTEGMjfMiUizzM3OEjj8yH9iW83oq6 xDqLxHknKA4lHiyXhe3EhNXDoYYoPvNvSd X-Received: by 2002:a05:6000:2401:b0:439:c1ca:82be with SMTP id ffacd0b85a97d-439c7fffe76mr12612831f8f.28.1772728129352; Thu, 05 Mar 2026 08:28:49 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439c2f8c0e7sm19596034f8f.29.2026.03.05.08.28.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2026 08:28:49 -0800 (PST) From: James Clark Date: Thu, 05 Mar 2026 16:28:19 +0000 Subject: [PATCH v2 3/3] arm64: cpufeature: Use pmuv3_implemented() function 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: <20260305-james-kvm-pmuver-sign-v2-3-ee80a125af9b@linaro.org> References: <20260305-james-kvm-pmuver-sign-v2-0-ee80a125af9b@linaro.org> In-Reply-To: <20260305-james-kvm-pmuver-sign-v2-0-ee80a125af9b@linaro.org> To: Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Colton Lewis , Alexandru Elisei Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Other places that are doing this version comparison are already using pmuv3_implemented(), so might as well use it here too for consistency. Signed-off-by: James Clark --- arch/arm/include/asm/arm_pmuv3.h | 7 +++++++ arch/arm64/kernel/cpufeature.c | 12 ++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/arch/arm/include/asm/arm_pmuv3.h b/arch/arm/include/asm/arm_pm= uv3.h index 2ec0e5e83fc9..ecfede0c0348 100644 --- a/arch/arm/include/asm/arm_pmuv3.h +++ b/arch/arm/include/asm/arm_pmuv3.h @@ -238,6 +238,13 @@ static inline void kvm_vcpu_pmu_resync_el0(void) {} =20 static inline bool pmuv3_implemented(int pmuver) { + /* + * PMUVer follows the standard ID scheme for an unsigned field with the + * exception of 0xF (IMP_DEF) which is treated specially and implies + * FEAT_PMUv3 is not implemented. + * + * See DDI0487L.a D24.1.3.2 for more details. + */ return !(pmuver =3D=3D ARMV8_PMU_DFR_VER_IMP_DEF || pmuver =3D=3D ARMV8_PMU_DFR_VER_NI); } diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 07abdfd40756..cc9783b26443 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -77,6 +77,7 @@ #include #include =20 +#include #include #include #include @@ -1927,19 +1928,10 @@ static bool has_pmuv3(const struct arm64_cpu_capabi= lities *entry, int scope) u64 dfr0 =3D read_sanitised_ftr_reg(SYS_ID_AA64DFR0_EL1); unsigned int pmuver; =20 - /* - * PMUVer follows the standard ID scheme for an unsigned field with the - * exception of 0xF (IMP_DEF) which is treated specially and implies - * FEAT_PMUv3 is not implemented. - * - * See DDI0487L.a D24.1.3.2 for more details. - */ pmuver =3D cpuid_feature_extract_unsigned_field(dfr0, ID_AA64DFR0_EL1_PMUVer_SHIFT); - if (pmuver =3D=3D ID_AA64DFR0_EL1_PMUVer_IMP_DEF) - return false; =20 - return pmuver >=3D ID_AA64DFR0_EL1_PMUVer_IMP; + return pmuv3_implemented(pmuver); } #endif =20 --=20 2.34.1