Commit e737b32a3688d415c3b1f9d0a3fb2b941b1e758c

Authored by balrog
1 parent c5096daf

Core 2 Duo specification (Alexander Graf).

This patch adds a Core 2 Duo CPU to the available CPU types. The CPU
definition tries to resemble a real CPU as good as possible, whilst not
exposing features qemu does not implement.
The patch also includes some minor additions that Core 2 Duo CPUs have:

- New MSR: MSR_IA32_PERF_STATUS
- CPUID up to level 5 (cache info and mwait)

Signed-off-by: Alexander Graf <agraf@suse.de>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5317 c046a42c-6fe2-441c-8c8c-71466251a162
target-i386/cpu.h
@@ -242,6 +242,8 @@ @@ -242,6 +242,8 @@
242 #define MSR_MCG_STATUS 0x17a 242 #define MSR_MCG_STATUS 0x17a
243 #define MSR_MCG_CTL 0x17b 243 #define MSR_MCG_CTL 0x17b
244 244
  245 +#define MSR_IA32_PERF_STATUS 0x198
  246 +
245 #define MSR_PAT 0x277 247 #define MSR_PAT 0x277
246 248
247 #define MSR_EFER 0xc0000080 249 #define MSR_EFER 0xc0000080
@@ -341,6 +343,9 @@ @@ -341,6 +343,9 @@
341 #define CPUID_VENDOR_AMD_2 0x69746e65 /* "enti" */ 343 #define CPUID_VENDOR_AMD_2 0x69746e65 /* "enti" */
342 #define CPUID_VENDOR_AMD_3 0x444d4163 /* "cAMD" */ 344 #define CPUID_VENDOR_AMD_3 0x444d4163 /* "cAMD" */
343 345
  346 +#define CPUID_MWAIT_IBE (1 << 1) /* Interrupts can exit capability */
  347 +#define CPUID_MWAIT_EMX (0 << 1) /* enumeration supported */
  348 +
344 #define EXCP00_DIVZ 0 349 #define EXCP00_DIVZ 0
345 #define EXCP01_SSTP 1 350 #define EXCP01_SSTP 1
346 #define EXCP02_NMI 2 351 #define EXCP02_NMI 2
target-i386/helper.c
@@ -165,6 +165,24 @@ static x86_def_t x86_defs[] = { @@ -165,6 +165,24 @@ static x86_def_t x86_defs[] = {
165 .xlevel = 0x8000000A, 165 .xlevel = 0x8000000A,
166 .model_id = "QEMU Virtual CPU version " QEMU_VERSION, 166 .model_id = "QEMU Virtual CPU version " QEMU_VERSION,
167 }, 167 },
  168 + {
  169 + .name = "core2duo",
  170 + /* original is on level 10 */
  171 + .level = 5,
  172 + .family = 6,
  173 + .model = 15,
  174 + .stepping = 11,
  175 + /* the original CPU does have many more features that are
  176 + * not implemented yet */
  177 + .features = PPRO_FEATURES |
  178 + CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA |
  179 + CPUID_PSE36,
  180 + .ext_features = CPUID_EXT_SSE3 | CPUID_EXT_MONITOR,
  181 + .ext2_features = (PPRO_FEATURES & 0x0183F3FF) |
  182 + CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX,
  183 + .xlevel = 0x8000000A,
  184 + .model_id = "Intel(R) Core(TM)2 Duo CPU T7700 @ 2.40GHz",
  185 + },
168 #endif 186 #endif
169 { 187 {
170 .name = "qemu32", 188 .name = "qemu32",
target-i386/op_helper.c
@@ -1919,6 +1919,43 @@ void helper_cpuid(void) @@ -1919,6 +1919,43 @@ void helper_cpuid(void)
1919 ECX = 0; 1919 ECX = 0;
1920 EDX = 0x2c307d; 1920 EDX = 0x2c307d;
1921 break; 1921 break;
  1922 + case 4:
  1923 + /* cache info: needed for Core compatibility */
  1924 + switch (ECX) {
  1925 + case 0: /* L1 dcache info */
  1926 + EAX = 0x0000121;
  1927 + EBX = 0x1c0003f;
  1928 + ECX = 0x000003f;
  1929 + EDX = 0x0000001;
  1930 + break;
  1931 + case 1: /* L1 icache info */
  1932 + EAX = 0x0000122;
  1933 + EBX = 0x1c0003f;
  1934 + ECX = 0x000003f;
  1935 + EDX = 0x0000001;
  1936 + break;
  1937 + case 2: /* L2 cache info */
  1938 + EAX = 0x0000143;
  1939 + EBX = 0x3c0003f;
  1940 + ECX = 0x0000fff;
  1941 + EDX = 0x0000001;
  1942 + break;
  1943 + default: /* end of info */
  1944 + EAX = 0;
  1945 + EBX = 0;
  1946 + ECX = 0;
  1947 + EDX = 0;
  1948 + break;
  1949 + }
  1950 +
  1951 + break;
  1952 + case 5:
  1953 + /* mwait info: needed for Core compatibility */
  1954 + EAX = 0; /* Smallest monitor-line size in bytes */
  1955 + EBX = 0; /* Largest monitor-line size in bytes */
  1956 + ECX = CPUID_MWAIT_EMX | CPUID_MWAIT_IBE;
  1957 + EDX = 0;
  1958 + break;
1922 case 0x80000000: 1959 case 0x80000000:
1923 EAX = env->cpuid_xlevel; 1960 EAX = env->cpuid_xlevel;
1924 EBX = env->cpuid_vendor1; 1961 EBX = env->cpuid_vendor1;
@@ -3089,6 +3126,12 @@ void helper_wrmsr(void) @@ -3089,6 +3126,12 @@ void helper_wrmsr(void)
3089 case MSR_VM_HSAVE_PA: 3126 case MSR_VM_HSAVE_PA:
3090 env->vm_hsave = val; 3127 env->vm_hsave = val;
3091 break; 3128 break;
  3129 + case MSR_IA32_PERF_STATUS:
  3130 + /* tsc_increment_by_tick */
  3131 + val = 1000ULL;
  3132 + /* CPU multiplier */
  3133 + val |= (((uint64_t)4ULL) << 40);
  3134 + break;
3092 #ifdef TARGET_X86_64 3135 #ifdef TARGET_X86_64
3093 case MSR_LSTAR: 3136 case MSR_LSTAR:
3094 env->lstar = val; 3137 env->lstar = val;