|
23 | 23 |
|
24 | 24 | #include <mach-o/dyld.h> |
25 | 25 |
|
| 26 | +static int |
| 27 | +get_cpuid_count (unsigned int leaf, |
| 28 | + unsigned int subleaf, |
| 29 | + unsigned int *eax, unsigned int *ebx, |
| 30 | + unsigned int *ecx, unsigned int *edx) |
| 31 | +{ |
| 32 | + __cpuid_count(leaf, subleaf, *eax, *ebx, *ecx, *edx); |
| 33 | + return 1; |
| 34 | +} |
| 35 | + |
26 | 36 | static bool |
27 | 37 | is_avx(int instlen, uint64_t rip) |
28 | 38 | { |
@@ -144,8 +154,8 @@ main_loop(int return_on_sigret) |
144 | 154 | uint64_t xcr0; |
145 | 155 | vmm_read_register(HV_X86_XCR0, &xcr0); |
146 | 156 | if ((xcr0 & XCR0_AVX_STATE) == 0) { |
147 | | - uint64_t eax; |
148 | | - asm ("cpuid" : "=a" (eax) : "a" (0x0d), "c" (0)); |
| 157 | + unsigned int eax, ebx, ecx, edx; |
| 158 | + get_cpuid_count(0x0d, 0x0, &eax, &ebx, &ecx, &edx); |
149 | 159 | if (eax & XCR0_AVX_STATE) { |
150 | 160 | vmm_write_register(HV_X86_XCR0, xcr0 | XCR0_AVX_STATE); |
151 | 161 | continue; |
@@ -330,8 +340,8 @@ init_regs() |
330 | 340 | { |
331 | 341 | /* set up cpu regs */ |
332 | 342 | vmm_write_register(HV_X86_RFLAGS, 0x2); |
333 | | - uint64_t eax; |
334 | | - asm ("cpuid" : "=a" (eax) : "a" (0x0d), "c" (0)); |
| 343 | + unsigned int eax, ebx, ecx, edx; |
| 344 | + get_cpuid_count(0x0d, 0x0, &eax, &ebx, &ecx, &edx); |
335 | 345 | if (eax & XCR0_SSE_STATE) { |
336 | 346 | uint64_t xcr0; |
337 | 347 | vmm_read_register(HV_X86_XCR0, &xcr0); |
|
0 commit comments