From nobody Thu Apr 9 21:52:49 2026 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 A89AC3CB2EC for ; Thu, 5 Mar 2026 16:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772728131; cv=none; b=twe7EcXnemQAP6uX9yeGUmP7I688Qbow89nmjSGLpzm8hIjnF/qJKwZk+RTZx/Bj2f7NWB4SsIQayEJDu4ZzawWnQv/hhaB1oqwZ0Dj7qTWNpsu6qBFDxqIHd+iAOoOZHoh6JIa4yqqhVl5w07d8al4pSgicl5UWvxIHY4OF8DA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772728131; c=relaxed/simple; bh=suVlOkK2FxaMrVmsSWeDXx31yW5F+MdOw/3w+mpbd44=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=L4TkgOFfTTeqc+HpnoBYCqP410HGDjXXsrvuOK26SFrlA3perfisJMGPNRr8Qth2uIukg2OUl+KLsOTtzHj3gzcNpeeiNxp3DlrnkPTrHiHkB+r7Q3PfitOICDnnLRd3Hx/yhJPHi7yalMfwW8UysZoIC77RECI3i6Mn25Z9Tvs= 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=epz1j30v; arc=none smtp.client-ip=209.85.221.52 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="epz1j30v" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-439b790af67so2854247f8f.0 for ; Thu, 05 Mar 2026 08:28:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772728128; x=1773332928; 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=b/8Q0uO9fn7N2aNObdrJAfX+BnNEdYRQNZ6cnN9zLhE=; b=epz1j30vedCEsttEsm4d2OBncjoiS0LYTY6RdwSakYZ+KIwO597Bgzu2oHRE4njRtj oTuy7aE0K9wYaSI9zcqpndAakUPWm0NXFPFDd8ciJRq+MmWGAQd1SoJsN651JC/SX/ip vW5qfbBmluj2CyfK4UsQb8PGp7mXyfFrDcfLkzzmp9HuWy0j3WH6KkVhxN5lUxGV0VIE 0DmJjhl8IkafpyzMC5BCY4VC/0lqpmIhdwwOHGSHYkT2iWGZZO9d54+AoOao0MgAyxE+ Rbs+mXVUh+Zgan5IEWqqlsVZrxKdqGTtqVpR5bRDLlE46/sLNFaW/8g5m/ygTsADYn9Z vaTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772728128; x=1773332928; 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=b/8Q0uO9fn7N2aNObdrJAfX+BnNEdYRQNZ6cnN9zLhE=; b=AZ3YS+bGyezi27NU5btk203A2UNuXnjG5PlqFROJVUXc1xPoRH5IZD7jaTBipw7gNM tfhzIatNt9AWg+fecyLICSWBeVn9vDKGUllu++zYudCePDY3Cad9J2oymTxJ8xAreTpD /xR3x6dmQR4wDR5J5VMGiN8MKU6mezCgcjoZgxBxaP35XBBHTLoHWGdmRWniaRp4G3zE rn8NsMoLsRZtJhuG8l8SbdfpdVzy6bl61y50yLa1qKSeYNMzlLnFyVWwffFghGwCr+J+ aKc58zUuxdkqjhRlqIFWw027ZBeeCK1Mr0rcgRC+gBLa7eOGaWQX17FAvp+c+fpbP30r EMlw== X-Forwarded-Encrypted: i=1; AJvYcCVKHkCdzr/mgaXk+Lch69EIK4gr2c23E3zCxz48st/REJFNeqlS/Eqedu2j6vk6sWqR/u7EBAwu7X8pNdI=@vger.kernel.org X-Gm-Message-State: AOJu0YwBWwEHqJN19qo02Gm9QYe373UMrZzCubMdkw3Y8pjGY/rkkbFY UJByfC+3hGp6/YOz/d99k9poSoZ2OXT29pbmPtBz2tXgf+VYJ3DOvWkHlwWFF/3LiJ8= X-Gm-Gg: ATEYQzzuVMqNvpoD5OLnTz123PcHntoTxdOTAS+dFkzXR7q0KdLkT/89lLW6WkF0zAh txtCOwlbe+8tHG5L6WKRWUlbZLXCFu4Y7APxqD503LouDDwDj/k9Y31L4rWgDCIL1BottwnBBh2 fCisLkgEf85ajds5RLuSUuMhHcC6L9QzRwy3mk5MWnCkijHddjdAneEJ1bSE23YCN8/VVMzk+K2 IY0y0htEH5xMMD71L8BntVv0BL8rDd9/6j2b4u9jCalxYE9DRu2xxitOM20JDCMa6rFXR+ndqna gCekfA+sloJHbrqeY9SQpvkW3Jak+3KUX73sSzXRiqINhOP5On5GBYKnjswlkgme6atrKTv7+zJ ioZ/b68Pn7WZCpoNeNdgD9wMC7KSGVxbeQWQGT7WJuSHlfutzV3ANcbWuhhUUhY2q8Ltpo7OGe+ 0JyO32gAoA9nueRY8yOb+cCGd1Dc0UoLFd X-Received: by 2002:a05:6000:1849:b0:439:ccd7:cdcc with SMTP id ffacd0b85a97d-439cfd65a3amr5335384f8f.18.1772728127425; Thu, 05 Mar 2026 08:28:47 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2026 08:28:47 -0800 (PST) From: James Clark Date: Thu, 05 Mar 2026 16:28:17 +0000 Subject: [PATCH v2 1/3] KVM: arm64: Read PMUVer as unsigned 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-1-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 ID_AA64DFR0_EL1.PMUVer is an unsigned field, so this skips initialization of host_data_ptr(nr_event_counters) for PMUv3 for Armv8.8 onwards as they appear as negative values. Fix it by reading it as unsigned. Now ID_AA64DFR0_EL1_PMUVer_IMP_DEF needs to be special cased, so use pmuv3_implemented() which already does it. Fixes: 2417218f2f23 ("KVM: arm64: Get rid of __kvm_get_mdcr_el2() and relat= ed warts") Signed-off-by: James Clark Reviewed-by: Colton Lewis Reviewed-by: Marc Zyngier --- arch/arm64/kvm/debug.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c index 3ad6b7c6e4ba..f4d7b12045e8 100644 --- a/arch/arm64/kvm/debug.c +++ b/arch/arm64/kvm/debug.c @@ -10,6 +10,7 @@ #include #include =20 +#include #include #include #include @@ -75,8 +76,10 @@ static void kvm_arm_setup_mdcr_el2(struct kvm_vcpu *vcpu) void kvm_init_host_debug_data(void) { u64 dfr0 =3D read_sysreg(id_aa64dfr0_el1); + unsigned int pmuver =3D cpuid_feature_extract_unsigned_field(dfr0, + ID_AA64DFR0_EL1_PMUVer_SHIFT); =20 - if (cpuid_feature_extract_signed_field(dfr0, ID_AA64DFR0_EL1_PMUVer_SHIFT= ) > 0) + if (pmuv3_implemented(pmuver)) *host_data_ptr(nr_event_counters) =3D FIELD_GET(ARMV8_PMU_PMCR_N, read_sysreg(pmcr_el0)); =20 --=20 2.34.1 From nobody Thu Apr 9 21:52:49 2026 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 3878A3CE488 for ; Thu, 5 Mar 2026 16:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772728131; cv=none; b=pdtRzzGCi1e0JZn98ldnPAR4UtGCmHtp7vz5UmI+iqXez+EtE/Pq1KPnMNYagNancVdIE9Jf0fWXDFpmgR943t1mHcJAvGeG7Lp2GvQ3LJCAV4wwqWmdmsuTL8zP6819FjyBynbKGM50k/VDJJKiM+gJg406ywj0UGpJTun7dLs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772728131; c=relaxed/simple; bh=eGMJHqDbmqpHeKVNhq5RasWcU0PN40UYs50dG3pEfSY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iSpH45kG+bbb8qkphnQRbjp26F0Y9YtYIB84t1tVSBPTQy3zNxHTzh0rheA4jKxepGo4O777WySGPDcj40IPV0BErY/x0HPNNBgJTzBV2PouJUXRIT6vm70ep7Bv6szu2XIomXSddvU58rV5HNXtDtk/KNSe5IOqpCuP4y8UA8A= 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=Ep/wRTYi; arc=none smtp.client-ip=209.85.221.50 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="Ep/wRTYi" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-439c56e822eso2525710f8f.2 for ; Thu, 05 Mar 2026 08:28:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772728128; x=1773332928; 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=956LHPVlfL1rOP3wzpXMeMW0aPaZLWqWprb6Mq5DKY0=; b=Ep/wRTYi9/JLzt+R2PCtBD7YR/3Fa6bEn1htRCZg/fIm15CyBtIcQHx9aMSi3rL3+T svlzFFHZEe4sr1I+Wgn9fhcClp8FctS1aYRG5RD9NbYnQ9mfH3SwDtpn+ypyxD/kRr26 zKifTTmEPovCmsVW4z9L2e2mlsUU+3/EcmGRFUIvQg+olu4w83RFEj3/Y/WMbe+syOs0 51Zw05qAjISqQpkmUa9QiMZOCFqgppKYribMiXzcYKGssUOdwtlM75tn5DhB3qXBhQKq yIZbGyyRpaty69C+Q298ja7oZ3lyhQgOALXRKlU9UCqb6f6WfLcQX9wuPAGei2sHiTC8 d5sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772728128; x=1773332928; 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=956LHPVlfL1rOP3wzpXMeMW0aPaZLWqWprb6Mq5DKY0=; b=Xd7cMTetZgqK4tiD46/4GBvFA3Oo/4ZEJ7x7BRiyDBqde+1JqjJ6ilyv4xFTNWPbbt lx+xWwC67FdxDE547k3NBDAQxV5hvRlYmZvyBJQ0VsFREDPBbwXXD2g4r+tt167RntBm 9Qwv52cT3/iWnEjFKBjpu2XRqFYOAyvomDI1AHIgbJDf5HvQP4xXx+WCekXVMDwtBTLf x2DbW/TWO5EGYQP6H6WMby33SudugWFP+d/19RqzJ+NVxld4cS56SmUn0CktDqY3LHc4 8yT6ZBeNSoSnxRT5BvMkmlQbR9z/CZ3PfkLZvH9xF10itx6/vPazHDN4jLy+hAH/c7zv hmMg== X-Forwarded-Encrypted: i=1; AJvYcCU62q+gYnv5Q5pTp7l+hr4XZFiP9lmBnUKKO5nwgf8N1z7Dun59YtdgG3z/jMXVIVx21gah4OMyUj+LwKs=@vger.kernel.org X-Gm-Message-State: AOJu0Yw19BQ1e7pXB5szLXELd/ErPCcpYk7LQs5Ysb3ZwpLGNDpYpQdZ rWqsZLRneof2k8ilnSuH902/xqY5RltOa0W5gwnQzkD2xl6fyPYlfE2ZrwDvhd1J/S0= X-Gm-Gg: ATEYQzwzmdFCexmY3qT3tuklNqbTsxh35+a82S4trxO57GU1BZPYHZ/tWxXlTPpHtPq IAj1qFeKi6+rUqgZ+O56FFM1dbx0slhkzQ4DdWDMWe+/HBTvA/r1/eYbP7CTxG0NRQ8pGwc2lH0 91beMyGg40B+/MHzNsdCrYfXtt5CEnoPL7eSDrkGkrd736e4WY2MjWln/DwjFoEmYnpabjHrrSa 1lP/v+IbM3MTQ7jDhNpKKcgHJEuEnph30+NMYe8A0ujVjdPxkFNuda0gkohHIJLVCPfL/NhfB9/ la5amqh7XQXYZZvDh80jDdFPDfkHHOY3iiF86KYq4zsl2vsOZsltgtE1GKCgacMKQ5fiBfDPqfR ZWqlCFh0wFmxbqXG7bmClLHEJPH3xYfMKa42vpQrOT+4p9kUEJftFGf7XUYL0scrbxn5RusDKoH lV2NSidB06SHG10y2ZUVVEToaf8tE/CIa/ X-Received: by 2002:a05:6000:2881:b0:439:b9bd:51f with SMTP id ffacd0b85a97d-439d721cfc2mr748137f8f.25.1772728128375; Thu, 05 Mar 2026 08:28:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2026 08:28:48 -0800 (PST) From: James Clark Date: Thu, 05 Mar 2026 16:28:18 +0000 Subject: [PATCH v2 2/3] arm64: cpufeature: Make PMUVer and PerfMon unsigned 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-2-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 On the host, this change doesn't make a difference because the fields are defined as FTR_EXACT. However, KVM allows userspace to set these fields for a guest and overrides the type to be FTR_LOWER_SAFE. And while KVM used to do an unsigned comparison to validate that the new value is lower than what the hardware provides, since the linked commit it uses the generic sanitization framework which does a signed comparison. Fix it by defining these fields as unsigned. In theory, without this fix, userspace could set a higher PMU version than the hardware supports by providing any value with the top bit set. Fixes: c118cead07a7 ("KVM: arm64: Use generic sanitisation for ID_(AA64)DFR= 0_EL1") Signed-off-by: James Clark Reviewed-by: Colton Lewis Reviewed-by: Marc Zyngier --- arch/arm64/kernel/cpufeature.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index c31f8e17732a..07abdfd40756 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -565,7 +565,7 @@ static const struct arm64_ftr_bits ftr_id_aa64dfr0[] = =3D { * We can instantiate multiple PMU instances with different levels * of support. */ - S_ARM64_FTR_BITS(FTR_HIDDEN, FTR_NONSTRICT, FTR_EXACT, ID_AA64DFR0_EL1_PM= UVer_SHIFT, 4, 0), + ARM64_FTR_BITS(FTR_HIDDEN, FTR_NONSTRICT, FTR_EXACT, ID_AA64DFR0_EL1_PMUV= er_SHIFT, 4, 0), ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_EXACT, ID_AA64DFR0_EL1_DebugVe= r_SHIFT, 4, 0x6), ARM64_FTR_END, }; @@ -709,7 +709,7 @@ static const struct arm64_ftr_bits ftr_id_pfr2[] =3D { =20 static const struct arm64_ftr_bits ftr_id_dfr0[] =3D { /* [31:28] TraceFilt */ - S_ARM64_FTR_BITS(FTR_HIDDEN, FTR_NONSTRICT, FTR_EXACT, ID_DFR0_EL1_PerfMo= n_SHIFT, 4, 0), + ARM64_FTR_BITS(FTR_HIDDEN, FTR_NONSTRICT, FTR_EXACT, ID_DFR0_EL1_PerfMon_= SHIFT, 4, 0), ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_DFR0_EL1_MProfD= bg_SHIFT, 4, 0), ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_DFR0_EL1_MMapTr= c_SHIFT, 4, 0), ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_DFR0_EL1_CopTrc= _SHIFT, 4, 0), --=20 2.34.1 From nobody Thu Apr 9 21:52:49 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 Reviewed-by: Colton Lewis Reviewed-by: Marc Zyngier --- 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