Patch "arm64: cpufeature: Extract capped perfmon fields" has been added to the 4.19-stable tree

gregkh at linuxfoundation.org gregkh at linuxfoundation.org
Thu Nov 30 05:42:29 PST 2023


This is a note to let you know that I've just added the patch titled

    arm64: cpufeature: Extract capped perfmon fields

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     arm64-cpufeature-extract-capped-perfmon-fields.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable at vger.kernel.org> know about it.


>From stable+bounces-2863-greg=kroah.com at vger.kernel.org Tue Nov 28 07:47:05 2023
From: Zenghui Yu <yuzenghui at huawei.com>
Date: Tue, 28 Nov 2023 15:46:32 +0800
Subject: arm64: cpufeature: Extract capped perfmon fields
To: <stable at vger.kernel.org>, <gregkh at linuxfoundation.org>, <sashal at kernel.org>
Cc: <linux-arm-kernel at lists.infradead.org>, <kvmarm at lists.linux.dev>, <andrew.murray at arm.com>, <mark.rutland at arm.com>, <suzuki.poulose at arm.com>, <wanghaibin.wang at huawei.com>, <will at kernel.org>, Zenghui Yu <yuzenghui at huawei.com>
Message-ID: <20231128074633.646-2-yuzenghui at huawei.com>

From: Andrew Murray <andrew.murray at arm.com>

commit 8e35aa642ee4dab01b16cc4b2df59d1936f3b3c2 upstream.

When emulating ID registers there is often a need to cap the version
bits of a feature such that the guest will not use features that the
host is not aware of. For example, when KVM mediates access to the PMU
by emulating register accesses.

Let's add a helper that extracts a performance monitors ID field and
caps the version to a given value.

Fields that identify the version of the Performance Monitors Extension
do not follow the standard ID scheme, and instead follow the scheme
described in ARM DDI 0487E.a page D13-2825 "Alternative ID scheme used
for the Performance Monitors Extension version". The value 0xF means an
IMPLEMENTATION DEFINED PMU is present, and values 0x0-OxE can be treated
the same as an unsigned field with 0x0 meaning no PMU is present.

Signed-off-by: Andrew Murray <andrew.murray at arm.com>
Reviewed-by: Suzuki K Poulose <suzuki.poulose at arm.com>
[Mark: rework to handle perfmon fields]
Signed-off-by: Mark Rutland <mark.rutland at arm.com>
Signed-off-by: Will Deacon <will at kernel.org>
Signed-off-by: Zenghui Yu <yuzenghui at huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
---
 arch/arm64/include/asm/cpufeature.h |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -422,6 +422,29 @@ cpuid_feature_extract_unsigned_field(u64
 	return cpuid_feature_extract_unsigned_field_width(features, field, 4);
 }
 
+/*
+ * Fields that identify the version of the Performance Monitors Extension do
+ * not follow the standard ID scheme. See ARM DDI 0487E.a page D13-2825,
+ * "Alternative ID scheme used for the Performance Monitors Extension version".
+ */
+static inline u64 __attribute_const__
+cpuid_feature_cap_perfmon_field(u64 features, int field, u64 cap)
+{
+	u64 val = cpuid_feature_extract_unsigned_field(features, field);
+	u64 mask = GENMASK_ULL(field + 3, field);
+
+	/* Treat IMPLEMENTATION DEFINED functionality as unimplemented */
+	if (val == 0xf)
+		val = 0;
+
+	if (val > cap) {
+		features &= ~mask;
+		features |= (cap << field) & mask;
+	}
+
+	return features;
+}
+
 static inline u64 arm64_ftr_mask(const struct arm64_ftr_bits *ftrp)
 {
 	return (u64)GENMASK(ftrp->shift + ftrp->width - 1, ftrp->shift);


Patches currently in stable-queue which might be from kroah.com at vger.kernel.org are

queue-4.19/arm64-cpufeature-extract-capped-perfmon-fields.patch
queue-4.19/kvm-arm64-limit-pmu-version-to-pmuv3-for-armv8.1.patch



More information about the linux-arm-kernel mailing list