diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2017-07-27 10:15:11 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2017-07-27 10:15:11 +0100 |
commit | 2dca6d9e7eb4fb25f1e41024ca20515b38bc8635 (patch) | |
tree | fe13769930b945430cf0e9b96b664eaa38cbad4b | |
parent | 522fd24ca030c27c591dafedd65c1dfd51e40450 (diff) | |
parent | bd1820227ecc0c77cc2aeba7c7c25b2d0a72ff3c (diff) |
Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging
x86 bug fix for -rc1
Fix for a bug in "-cpu max" that breaks libvirt usage of
query-cpu-model-expansion.
# gpg: Signature made Wed 26 Jul 2017 19:35:28 BST
# gpg: using RSA key 0x2807936F984DC5A6
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>"
# Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6
* remotes/ehabkost/tags/x86-pull-request:
target/i386: Don't use x86_cpu_load_def() on "max" CPU model
target/i386: Define CPUID_MODEL_ID_SZ macro
target/i386: Use host_vendor_fms() in max_x86_cpu_initfn()
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | target/i386/cpu.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 89f5fb7a3f..ddc45abd70 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1585,6 +1585,17 @@ static bool lmce_supported(void) return !!(mce_cap & MCG_LMCE_P); } +#define CPUID_MODEL_ID_SZ 48 + +/** + * cpu_x86_fill_model_id: + * Get CPUID model ID string from host CPU. + * + * @str should have at least CPUID_MODEL_ID_SZ bytes + * + * The function does NOT add a null terminator to the string + * automatically. + */ static int cpu_x86_fill_model_id(char *str) { uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0; @@ -1633,20 +1644,21 @@ static void max_x86_cpu_initfn(Object *obj) cpu->max_features = true; if (kvm_enabled()) { - X86CPUDefinition host_cpudef = { }; - uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0; - - host_cpuid(0x0, 0, &eax, &ebx, &ecx, &edx); - x86_cpu_vendor_words2str(host_cpudef.vendor, ebx, edx, ecx); + char vendor[CPUID_VENDOR_SZ + 1] = { 0 }; + char model_id[CPUID_MODEL_ID_SZ + 1] = { 0 }; + int family, model, stepping; - host_cpuid(0x1, 0, &eax, &ebx, &ecx, &edx); - host_cpudef.family = ((eax >> 8) & 0x0F) + ((eax >> 20) & 0xFF); - host_cpudef.model = ((eax >> 4) & 0x0F) | ((eax & 0xF0000) >> 12); - host_cpudef.stepping = eax & 0x0F; + host_vendor_fms(vendor, &family, &model, &stepping); - cpu_x86_fill_model_id(host_cpudef.model_id); + cpu_x86_fill_model_id(model_id); - x86_cpu_load_def(cpu, &host_cpudef, &error_abort); + object_property_set_str(OBJECT(cpu), vendor, "vendor", &error_abort); + object_property_set_int(OBJECT(cpu), family, "family", &error_abort); + object_property_set_int(OBJECT(cpu), model, "model", &error_abort); + object_property_set_int(OBJECT(cpu), stepping, "stepping", + &error_abort); + object_property_set_str(OBJECT(cpu), model_id, "model-id", + &error_abort); env->cpuid_min_level = kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX); |