Skip to contentSkip to conversation

target/arm: Correct condition of aa64_atomics feature function

PATCH In review Peter Maydell 2 participants 2 messages Aug 19, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/arm: Correct condition of aa64_atomics feature function

The ARMv8.1-Atomics feature (renamed FEAT_LSE in more modern versions of the Arm ARM) has always ben indicated by ID_AA64ISAR0.ATOMIC being 0b0010 or greater; 0b0001 is a reserved unused value.

We were incorrectly checking for != 0; this had no harmful effects because all the CPUs set their value for this field to either 0 (for not having the feature) or 2 (if they do have it), but it's better to match what the architecture specifies here.

---
I think it makes more sense to fix the condition first and rename the feature second, though there's not much difference in it. I'm happy to fix up the trivial conflict in target-arm.next.

 target/arm/cpu-features.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/cpu-features.h +1 -1
index 5876162428a..a4d00a001d3 100644
@@ -408,7 +408,7 @@ static inline bool isar_feature_aa64_crc32(const ARMISARegisters *id)
 
 static inline bool isar_feature_aa64_atomics(const ARMISARegisters *id)
 {
-    return FIELD_EX64_IDREG(id, ID_AA64ISAR0, ATOMIC) != 0;
+    return FIELD_EX64_IDREG(id, ID_AA64ISAR0, ATOMIC) >= 2;
 }
 
 static inline bool isar_feature_aa64_rdm(const ARMISARegisters *id)
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Peter Maydell

The ARMv8.1-Atomics feature (renamed FEAT_LSE in more modern versions of the Arm ARM) has always ben indicated by ID_AA64ISAR0.ATOMIC being 0b0010 or greater; 0b0001 is a reserved unused value.

We were incorrectly checking for != 0; this had no harmful effects because all the CPUs set their value for this field to either 0 (for not having the feature) or 2 (if they do have it), but it's better to match what the architecture specifies here.

---
I think it makes more sense to fix the condition first and rename the feature second, though there's not much difference in it. I'm happy to fix up the trivial conflict in target-arm.next.

  target/arm/cpu-features.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/cpu-features.h +0 -0
index 5876162428a..a4d00a001d3 100644

target/arm/cpu-features.h static inline bool isar_feature_aa64_crc32(const ARMISARegisters *id) · line 414

Quoted 8 lines
target/arm/cpu-features.h +1 -1
@@ -408,7 +408,7 @@ static inline bool isar_feature_aa64_crc32(const ARMISARegisters *id)
 
  static inline bool isar_feature_aa64_atomics(const ARMISARegisters *id)
  {
-    return FIELD_EX64_IDREG(id, ID_AA64ISAR0, ATOMIC) != 0;
+    return FIELD_EX64_IDREG(id, ID_AA64ISAR0, ATOMIC) >= 2;
  }
 
  static inline bool isar_feature_aa64_rdm(const ARMISARegisters *id)

r~