Commit ef7681389f1d5bd4bba9b66504df8a0b768b27b1

Authored by Andre Przywara
Committed by Anthony Liguori
1 parent 09695a4a

allow CPUID vendor override

KVM-enabled QEMU will always report the vendor ID of the physical CPU it is
running on. Allow to override this if explicitly requested on the
command line. It will not suffice to name a CPU type (like -cpu phenom),
but you have to explicitly set the vendor: -cpu phenom,vendor=AuthenticAMD

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
target-i386/cpu.h
... ... @@ -655,6 +655,7 @@ typedef struct CPUX86State {
655 655 uint32_t cpuid_ext2_features;
656 656 uint32_t cpuid_ext3_features;
657 657 uint32_t cpuid_apic_id;
  658 + int cpuid_vendor_override;
658 659  
659 660 /* MTRRs */
660 661 uint64_t mtrr_fixed[11];
... ...
target-i386/helper.c
... ... @@ -116,6 +116,7 @@ typedef struct x86_def_t {
116 116 uint32_t features, ext_features, ext2_features, ext3_features;
117 117 uint32_t xlevel;
118 118 char model_id[48];
  119 + int vendor_override;
119 120 } x86_def_t;
120 121  
121 122 #define I486_FEATURES (CPUID_FP87 | CPUID_VME | CPUID_PSE)
... ... @@ -376,6 +377,7 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
376 377 x86_cpu_def->vendor2 |= ((uint8_t)val[i + 4]) << (8 * i);
377 378 x86_cpu_def->vendor3 |= ((uint8_t)val[i + 8]) << (8 * i);
378 379 }
  380 + x86_cpu_def->vendor_override = 1;
379 381 } else if (!strcmp(featurestr, "model_id")) {
380 382 pstrcpy(x86_cpu_def->model_id, sizeof(x86_cpu_def->model_id),
381 383 val);
... ... @@ -428,6 +430,7 @@ static int cpu_x86_register (CPUX86State *env, const char *cpu_model)
428 430 env->cpuid_vendor2 = CPUID_VENDOR_INTEL_2;
429 431 env->cpuid_vendor3 = CPUID_VENDOR_INTEL_3;
430 432 }
  433 + env->cpuid_vendor_override = def->vendor_override;
431 434 env->cpuid_level = def->level;
432 435 if (def->family > 0x0f)
433 436 env->cpuid_version = 0xf00 | ((def->family - 0x0f) << 20);
... ... @@ -1506,7 +1509,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
1506 1509 * isn't supported in compatibility mode on Intel. so advertise the
1507 1510 * actuall cpu, and say goodbye to migration between different vendors
1508 1511 * is you use compatibility mode. */
1509   - if (kvm_enabled())
  1512 + if (kvm_enabled() && !env->cpuid_vendor_override)
1510 1513 host_cpuid(0, 0, NULL, ebx, ecx, edx);
1511 1514 break;
1512 1515 case 1:
... ...