1 Index: kvm-86/cpu-defs.h
2 ===================================================================
3 --- kvm-86.orig/cpu-defs.h 2009-09-24 14:19:14.000000000 +0200
4 +++ kvm-86/cpu-defs.h 2009-09-24 14:47:00.000000000 +0200
6 int cpu_index; /* CPU index (informative) */ \
7 uint32_t host_tid; /* host thread ID */ \
8 int numa_node; /* NUMA node this cpu is belonging to */ \
9 + int nr_cores; /* number of cores within this CPU package */ \
10 + int nr_threads;/* number of threads within this CPU */ \
11 int running; /* Nonzero if cpu is currently running(usermode). */ \
14 Index: kvm-86/target-i386/helper.c
15 ===================================================================
16 --- kvm-86.orig/target-i386/helper.c 2009-09-24 14:19:14.000000000 +0200
17 +++ kvm-86/target-i386/helper.c 2009-09-24 14:50:18.000000000 +0200
24 .vendor1 = CPUID_VENDOR_AMD_1,
25 .vendor2 = CPUID_VENDOR_AMD_2,
26 .vendor3 = CPUID_VENDOR_AMD_3,
36 @@ -1638,6 +1638,12 @@
37 *ebx = (env->cpuid_apic_id << 24) | 8 << 8; /* CLFLUSH size in quad words, Linux wants it. */
38 *ecx = env->cpuid_ext_features;
39 *edx = env->cpuid_features;
41 + if (env->nr_cores * env->nr_threads > 1) {
42 + *ebx |= (env->nr_cores * env->nr_threads) << 16;
43 + *edx |= 1 << 28; /* HTT bit */
48 /* cache info: needed for Pentium Pro compatibility */
49 @@ -1648,21 +1654,29 @@
52 /* cache info: needed for Core compatibility */
53 + if (env->nr_cores > 1) {
54 + *eax = (env->nr_cores - 1) << 26;
59 case 0: /* L1 dcache info */
66 case 1: /* L1 icache info */
73 case 2: /* L2 cache info */
76 + if (env->nr_threads > 1) {
77 + *eax |= (env->nr_threads - 1) << 14;
82 @@ -1715,6 +1729,16 @@
83 *ecx = env->cpuid_ext3_features;
84 *edx = env->cpuid_ext2_features;
86 + if (env->nr_cores * env->nr_threads > 1) {
87 + uint32_t teax, tebx, tecx, tedx;
88 + cpu_x86_cpuid(env, 0, 0, &teax, &tebx, &tecx, &tedx);
89 + if ( tebx == CPUID_VENDOR_AMD_1 &&
90 + tedx == CPUID_VENDOR_AMD_2 &&
91 + tecx == CPUID_VENDOR_AMD_3) {
92 + *ecx |= 1 << 1; /* CmpLegacy bit */
97 uint32_t h_eax, h_edx;
103 + if (env->nr_cores * env->nr_threads > 1) {
104 + *ecx |= (env->nr_cores * env->nr_threads) - 1;
108 *eax = 0x00000001; /* SVM Revision */
110 ===================================================================
111 --- kvm-86.orig/vl.c 2009-09-24 14:30:14.000000000 +0200
112 +++ kvm-86/vl.c 2009-09-24 14:47:00.000000000 +0200
114 const char *assigned_devices[MAX_DEV_ASSIGN_CMDLINE];
115 int assigned_devices_index;
118 +int smp_threads = 1;
119 int fairsched_id = 0;
120 const char *vnc_display;
121 int acpi_enabled = 1;
122 @@ -2499,6 +2501,52 @@
126 +static void smp_parse(const char *optarg)
128 + int smp, sockets = 0, threads = 0, cores = 0;
132 + smp = strtoul(optarg, &endptr, 10);
133 + if (endptr != optarg) {
134 + if (*endptr == ',') {
138 + if (get_param_value(option, 128, "sockets", endptr) != 0)
139 + sockets = strtoull(option, NULL, 10);
140 + if (get_param_value(option, 128, "cores", endptr) != 0)
141 + cores = strtoull(option, NULL, 10);
142 + if (get_param_value(option, 128, "threads", endptr) != 0)
143 + threads = strtoull(option, NULL, 10);
145 + /* compute missing values, prefer sockets over cores over threads */
146 + if (smp == 0 || sockets == 0) {
147 + sockets = sockets > 0 ? sockets : 1;
148 + cores = cores > 0 ? cores : 1;
149 + threads = threads > 0 ? threads : 1;
151 + smp = cores * threads * sockets;
153 + sockets = smp / (cores * threads);
157 + threads = threads > 0 ? threads : 1;
158 + cores = smp / (sockets * threads);
160 + if (sockets == 0) {
161 + sockets = smp / (cores * threads);
163 + threads = smp / (cores * sockets);
168 + smp_cores = cores > 0 ? cores : 1;
169 + smp_threads = threads > 0 ? threads : 1;
172 /***********************************************************/
175 @@ -3727,6 +3775,8 @@
179 + env->nr_cores = smp_cores;
180 + env->nr_threads = smp_threads;
184 @@ -4060,6 +4110,8 @@
188 + env->nr_cores = smp_cores;
189 + env->nr_threads = smp_threads;
192 void qemu_notify_event(void)
193 @@ -5560,7 +5612,7 @@
196 case QEMU_OPTION_smp:
197 - smp_cpus = atoi(optarg);
200 fprintf(stderr, "Invalid number of CPUs\n");