Patch "arm64: cpufeature: Force HWCAP to be based on the sysreg visible to user-space" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

    arm64: cpufeature: Force HWCAP to be based on the sysreg visible to user-space

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-force-hwcap-to-be-based-on-the-sysr.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@xxxxxxxxxxxxxxx> know about it.



commit 1a11a0d0c9dbdc78d08f8a8a92979220ff81e6a2
Author: James Morse <james.morse@xxxxxxx>
Date:   Fri Aug 9 11:43:44 2024 +0100

    arm64: cpufeature: Force HWCAP to be based on the sysreg visible to user-space
    
    [ Upstream commit 237405ebef580a7352a52129b2465c117145eafa ]
    
    arm64 advertises hardware features to user-space via HWCAPs, and by
    emulating access to the CPUs id registers. The cpufeature code has a
    sanitised system-wide view of an id register, and a sanitised user-space
    view of an id register, where some features use their 'safe' value
    instead of the hardware value.
    
    It is currently possible for a HWCAP to be advertised where the user-space
    view of the id register does not show the feature as supported.
    Erratum workaround need to remove both the HWCAP, and the feature from
    the user-space view of the id register. This involves duplicating the
    code, and spreading it over cpufeature.c and cpu_errata.c.
    
    Make the HWCAP code use the user-space view of id registers. This ensures
    the values never diverge, and allows erratum workaround to remove HWCAP
    by modifying the user-space view of the id register.
    
    Signed-off-by: James Morse <james.morse@xxxxxxx>
    Reviewed-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
    Link: https://lore.kernel.org/r/20220909165938.3931307-2-james.morse@xxxxxxx
    Signed-off-by: Catalin Marinas <catalin.marinas@xxxxxxx>
    [ Mark: fixup lack of 'width' parameter, whitespace conflict ]
    Signed-off-by: Mark Rutland <mark.rutland@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 3f6a2187d0911..094a74b2efa79 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -827,17 +827,39 @@ feature_matches(u64 reg, const struct arm64_cpu_capabilities *entry)
 	return val >= entry->min_field_value;
 }
 
-static bool
-has_cpuid_feature(const struct arm64_cpu_capabilities *entry, int scope)
+static u64
+read_scoped_sysreg(const struct arm64_cpu_capabilities *entry, int scope)
 {
-	u64 val;
-
 	WARN_ON(scope == SCOPE_LOCAL_CPU && preemptible());
 	if (scope == SCOPE_SYSTEM)
-		val = read_sanitised_ftr_reg(entry->sys_reg);
+		return read_sanitised_ftr_reg(entry->sys_reg);
 	else
-		val = __read_sysreg_by_encoding(entry->sys_reg);
+		return __read_sysreg_by_encoding(entry->sys_reg);
+}
+
+static bool
+has_user_cpuid_feature(const struct arm64_cpu_capabilities *entry, int scope)
+{
+	int mask;
+	struct arm64_ftr_reg *regp;
+	u64 val = read_scoped_sysreg(entry, scope);
+
+	regp = get_arm64_ftr_reg(entry->sys_reg);
+	if (!regp)
+		return false;
+
+	mask = cpuid_feature_extract_unsigned_field(regp->user_mask,
+						    entry->field_pos);
+	if (!mask)
+		return false;
+
+	return feature_matches(val, entry);
+}
 
+static bool
+has_cpuid_feature(const struct arm64_cpu_capabilities *entry, int scope)
+{
+	u64 val = read_scoped_sysreg(entry, scope);
 	return feature_matches(val, entry);
 }
 
@@ -1375,9 +1397,8 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
 	{},
 };
 
-
 #define HWCAP_CPUID_MATCH(reg, field, s, min_value)		\
-		.matches = has_cpuid_feature,			\
+		.matches = has_user_cpuid_feature,		\
 		.sys_reg = reg,					\
 		.field_pos = field,				\
 		.sign = s,					\




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux