|
35 | 35 | #include "ia32.h"
|
36 | 36 |
|
37 | 37 | #define CPUID_CACHE_SIZE 6
|
38 |
| -#define CPUID_FEATURE_SET_SIZE 2 |
| 38 | +#define CPUID_FEATURE_SET_SIZE 3 |
39 | 39 | #define MAX_BASIC_CPUID 0x16
|
40 | 40 | #define MAX_EXTENDED_CPUID 0x80000008
|
41 | 41 |
|
@@ -95,7 +95,6 @@ static hax_cpuid_entry * find_cpuid_entry(hax_cpuid_entry *features,
|
95 | 95 | uint32_t index);
|
96 | 96 | static void dump_features(hax_cpuid_entry *features, uint32_t size);
|
97 | 97 |
|
98 |
| -static void get_guest_cache(cpuid_args_t *args, hax_cpuid_entry *entry); |
99 | 98 | static void adjust_0000_0001(cpuid_args_t *args);
|
100 | 99 | static void adjust_8000_0001(cpuid_args_t *args);
|
101 | 100 | static void execute_0000_0000(cpuid_args_t *args);
|
@@ -132,6 +131,7 @@ static const cpuid_manager_t kCpuidManager[] = {
|
132 | 131 | {0x00000001, 0, execute_0000_0001}, // Version Information and Features
|
133 | 132 | {0x00000002, 0, execute_0000_0002}, // Cache and TLB Information
|
134 | 133 | {0x00000007, 0, execute_0000_0007}, // Structured Extended Feature Flags
|
| 134 | + {0x00000007, 1, execute_0000_0007}, // Structured Extended Feature Flags |
135 | 135 | {0x0000000a, 0, execute_0000_000a}, // Architectural Performance Monitoring
|
136 | 136 | {0x00000015, 0, NULL}, // Time Stamp Counter and Nominal
|
137 | 137 | // Core Crystal Clock Information
|
@@ -173,6 +173,7 @@ static const cpuid_controller_t kCpuidController[] = {
|
173 | 173 | {0x00000001, 0, set_leaf_0000_0001},
|
174 | 174 | {0x00000002, 0, NULL},
|
175 | 175 | {0x00000007, 0, NULL},
|
| 176 | + {0x00000007, 1, NULL}, |
176 | 177 | {0x0000000a, 0, NULL},
|
177 | 178 | {0x00000015, 0, set_leaf_0000_0015},
|
178 | 179 | {0x00000016, 0, set_leaf_0000_0016},
|
@@ -270,6 +271,12 @@ void cpuid_init_supported_features(void)
|
270 | 271 | .edx = cache.data[1]
|
271 | 272 | };
|
272 | 273 | host_supported[1] = (hax_cpuid_entry){
|
| 274 | + .function = 0x07, |
| 275 | + .index = 0, |
| 276 | + .ebx = cache.data[3], |
| 277 | + .ecx = cache.data[2] |
| 278 | + }; |
| 279 | + host_supported[2] = (hax_cpuid_entry){ |
273 | 280 | .function = 0x80000001,
|
274 | 281 | .ecx = cache.data[4],
|
275 | 282 | .edx = cache.data[5]
|
@@ -320,6 +327,12 @@ void cpuid_init_supported_features(void)
|
320 | 327 | FEATURE(HTT)
|
321 | 328 | };
|
322 | 329 | hax_supported[1] = (hax_cpuid_entry){
|
| 330 | + .function = 0x07, |
| 331 | + .index = 0, |
| 332 | + .ebx = |
| 333 | + FEATURE(ERMS) |
| 334 | + }; |
| 335 | + hax_supported[2] = (hax_cpuid_entry){ |
323 | 336 | .function = 0x80000001,
|
324 | 337 | .edx =
|
325 | 338 | FEATURE(NX) |
|
@@ -667,22 +680,6 @@ static void dump_features(hax_cpuid_entry *features, uint32_t size)
|
667 | 680 | }
|
668 | 681 | }
|
669 | 682 |
|
670 |
| -static void get_guest_cache(cpuid_args_t *args, hax_cpuid_entry *entry) |
671 |
| -{ |
672 |
| - if (args == NULL) |
673 |
| - return; |
674 |
| - |
675 |
| - if (entry == NULL) { |
676 |
| - args->eax = args->ebx = args->ecx = args->edx = 0; |
677 |
| - return; |
678 |
| - } |
679 |
| - |
680 |
| - args->eax = entry->eax; |
681 |
| - args->ebx = entry->ebx; |
682 |
| - args->ecx = entry->ecx; |
683 |
| - args->edx = entry->edx; |
684 |
| -} |
685 |
| - |
686 | 683 | static void adjust_0000_0001(cpuid_args_t *args)
|
687 | 684 | {
|
688 | 685 | #define VIRT_FAMILY 0x06
|
@@ -764,7 +761,7 @@ static void adjust_8000_0001(cpuid_args_t *args)
|
764 | 761 | if (args == NULL)
|
765 | 762 | return;
|
766 | 763 |
|
767 |
| - hax_supported = &cache.hax_supported[1]; |
| 764 | + hax_supported = &cache.hax_supported[2]; |
768 | 765 |
|
769 | 766 | args->eax = args->ebx = 0;
|
770 | 767 | // Report only the features specified but turn off any features this
|
@@ -810,18 +807,18 @@ static void execute_0000_0007(cpuid_args_t *args)
|
810 | 807 | return;
|
811 | 808 |
|
812 | 809 | switch (args->ecx) {
|
813 |
| - case 0: { // Sub-leaf 0 |
814 |
| - // The maximum input value for supported leaf 7 sub-leaves |
815 |
| - // Bit 09: Supports Enhanced REP MOVSB/STOSB if 1 |
816 |
| - // TODO: Add sub-leaf in the CPUID manager so that the feature bits |
817 |
| - // can be specified in cache.hax_supported[] during CPUID |
818 |
| - // initialization. |
819 |
| - args->ebx = cache.data[3] & 0x00000200; |
| 810 | + case 0: { // Structured Extended Feature Flags Enumeration Leaf |
| 811 | + hax_cpuid_entry *host_supported, *hax_supported; |
| 812 | + |
| 813 | + host_supported = &cache.host_supported[1]; |
| 814 | + hax_supported = &cache.hax_supported[1]; |
| 815 | + |
| 816 | + args->ebx = host_supported->ebx & hax_supported->ebx; |
820 | 817 | args->eax = args->ecx = args->edx = 0;
|
821 | 818 | break;
|
822 | 819 | }
|
823 | 820 | case 1: { // Structured Extended Feature Enumeration Sub-leaf
|
824 |
| - get_guest_cache(args, NULL); |
| 821 | + args->eax = args->ebx = args->ecx = args->edx = 0; |
825 | 822 | break;
|
826 | 823 | }
|
827 | 824 | default: {
|
|
0 commit comments