@@ -159,9 +159,10 @@ fn test_bit(x: usize, bit: u32) -> bool {
159
159
/// [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
160
160
/// [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf
161
161
fn 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 ;
165
166
166
167
unsafe {
167
168
/// To obtain all feature flags we need two CPUID queries:
@@ -181,8 +182,20 @@ fn detect_features() -> usize {
181
182
: "={ebx}" ( extended_features_ebx)
182
183
: "{eax}" ( 0x0000_0007_u32 ) , "{ecx}" ( 0 as u32 )
183
184
: : ) ;
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
+ : : ) ;
184
192
}
185
193
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
+
186
199
let mut value: usize = 0 ;
187
200
188
201
if test_bit ( extended_features_ebx, 3 ) {
@@ -195,9 +208,6 @@ fn detect_features() -> usize {
195
208
if test_bit ( proc_info_ecx, 0 ) {
196
209
value = set_bit ( value, __Feature:: sse3 as u32 ) ;
197
210
}
198
- if test_bit ( proc_info_ecx, 5 ) {
199
- value = set_bit ( value, __Feature:: abm as u32 ) ;
200
- }
201
211
if test_bit ( proc_info_ecx, 9 ) {
202
212
value = set_bit ( value, __Feature:: ssse3 as u32 ) ;
203
213
}
@@ -254,7 +264,11 @@ fn detect_features() -> usize {
254
264
}
255
265
}
256
266
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 ( ) {
258
272
value = set_bit ( value, __Feature:: tbm as u32 ) ;
259
273
}
260
274
0 commit comments