1515//!
1616//! - [Zircon implementation](https://fuchsia.googlesource.com/zircon/+/master/kernel/arch/arm64/feature.cpp)
1717//! - [Linux documentation](https://www.kernel.org/doc/Documentation/arm64/cpu-feature-registers.txt)
18+ //! - [ARM documentation](https://developer.arm.com/documentation/ddi0601/2022-12/AArch64-Registers?lang=en)
1819
1920use crate :: detect:: { cache, Feature } ;
2021use core:: arch:: asm;
@@ -43,6 +44,16 @@ pub(crate) fn detect_features() -> cache::Initializer {
4344 ) ;
4445 }
4546
47+ // ID_AA64MMFR2_EL1 - AArch64 Memory Model Feature Register 2
48+ let aa64mmfr2: u64 ;
49+ unsafe {
50+ asm ! (
51+ "mrs {}, ID_AA64MMFR2_EL1" ,
52+ out( reg) aa64mmfr2,
53+ options( pure, nomem, preserves_flags, nostack)
54+ ) ;
55+ }
56+
4657 // ID_AA64PFR0_EL1 - Processor Feature Register 0
4758 let aa64pfr0: u64 ;
4859 unsafe {
@@ -53,12 +64,13 @@ pub(crate) fn detect_features() -> cache::Initializer {
5364 ) ;
5465 }
5566
56- parse_system_registers ( aa64isar0, aa64isar1, Some ( aa64pfr0) )
67+ parse_system_registers ( aa64isar0, aa64isar1, aa64mmfr2 , Some ( aa64pfr0) )
5768}
5869
5970pub ( crate ) fn parse_system_registers (
6071 aa64isar0 : u64 ,
6172 aa64isar1 : u64 ,
73+ aa64mmfr2 : u64 ,
6274 aa64pfr0 : Option < u64 > ,
6375) -> cache:: Initializer {
6476 let mut value = cache:: Initializer :: default ( ) ;
@@ -72,7 +84,7 @@ pub(crate) fn parse_system_registers(
7284 // ID_AA64ISAR0_EL1 - Instruction Set Attribute Register 0
7385 enable_feature ( Feature :: pmull, bits_shift ( aa64isar0, 7 , 4 ) >= 2 ) ;
7486 enable_feature ( Feature :: tme, bits_shift ( aa64isar0, 27 , 24 ) == 1 ) ;
75- enable_feature ( Feature :: lse, bits_shift ( aa64isar0, 23 , 20 ) >= 1 ) ;
87+ enable_feature ( Feature :: lse, bits_shift ( aa64isar0, 23 , 20 ) >= 2 ) ;
7688 enable_feature ( Feature :: crc, bits_shift ( aa64isar0, 19 , 16 ) >= 1 ) ;
7789
7890 // ID_AA64PFR0_EL1 - Processor Feature Register 0
@@ -99,13 +111,16 @@ pub(crate) fn parse_system_registers(
99111 enable_feature ( Feature :: sve, asimd && bits_shift ( aa64pfr0, 35 , 32 ) >= 1 ) ;
100112 }
101113
102- // ID_AA64PFR0_EL1 - Processor Feature Register 0
114+ // ID_AA64ISAR1_EL1 - Instruction Set Attribute Register 1
103115 // Check for either APA or API field
104116 enable_feature ( Feature :: paca, bits_shift ( aa64isar1, 11 , 4 ) >= 1 ) ;
105117 enable_feature ( Feature :: rcpc, bits_shift ( aa64isar1, 23 , 20 ) >= 1 ) ;
106118 // Check for either GPA or GPI field
107119 enable_feature ( Feature :: pacg, bits_shift ( aa64isar1, 31 , 24 ) >= 1 ) ;
108120
121+ // ID_AA64MMFR2_EL1 - AArch64 Memory Model Feature Register 2
122+ enable_feature ( Feature :: lse2, bits_shift ( aa64mmfr2, 35 , 32 ) >= 1 ) ;
123+
109124 value
110125}
111126
0 commit comments