@@ -159,9 +159,10 @@ fn test_bit(x: usize, bit: u32) -> bool {
159159/// [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf
160160/// [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf
161161fn detect_features ( ) -> usize {
162- let extended_features_ebx;
163- let proc_info_ecx;
164- let proc_info_edx;
162+ let extended_features_ebx: u32 ;
163+ let proc_info_ecx: u32 ;
164+ let proc_info_edx: u32 ;
165+ let extended_proc_info_ecx: u32 ;
165166
166167 unsafe {
167168 /// To obtain all feature flags we need two CPUID queries:
@@ -181,8 +182,20 @@ fn detect_features() -> usize {
181182 : "={ebx}" ( extended_features_ebx)
182183 : "{eax}" ( 0x0000_0007_u32 ) , "{ecx}" ( 0 as u32 )
183184 : : ) ;
185+
186+ /// 3. EAX=80000001h: Queries "Extended Processor Info and
187+ /// Feature Bits"
188+ asm ! ( "cpuid"
189+ : "={ecx}" ( extended_proc_info_ecx)
190+ : "{eax}" ( 0x8000_0001_u32 ) , "{ecx}" ( 0 as u32 )
191+ : : ) ;
184192 }
185193
194+ let extended_features_ebx = extended_features_ebx as usize ;
195+ let proc_info_ecx = proc_info_ecx as usize ;
196+ let proc_info_edx = proc_info_edx as usize ;
197+ let extended_proc_info_ecx = extended_proc_info_ecx as usize ;
198+
186199 let mut value: usize = 0 ;
187200
188201 if test_bit ( extended_features_ebx, 3 ) {
@@ -195,9 +208,6 @@ fn detect_features() -> usize {
195208 if test_bit ( proc_info_ecx, 0 ) {
196209 value = set_bit ( value, __Feature:: sse3 as u32 ) ;
197210 }
198- if test_bit ( proc_info_ecx, 5 ) {
199- value = set_bit ( value, __Feature:: abm as u32 ) ;
200- }
201211 if test_bit ( proc_info_ecx, 9 ) {
202212 value = set_bit ( value, __Feature:: ssse3 as u32 ) ;
203213 }
@@ -254,7 +264,11 @@ fn detect_features() -> usize {
254264 }
255265 }
256266
257- if test_bit ( proc_info_ecx, 21 ) && is_amd ( ) {
267+ if test_bit ( extended_proc_info_ecx, 5 ) {
268+ value = set_bit ( value, __Feature:: abm as u32 ) ;
269+ }
270+
271+ if test_bit ( extended_proc_info_ecx, 21 ) && is_amd ( ) {
258272 value = set_bit ( value, __Feature:: tbm as u32 ) ;
259273 }
260274
0 commit comments