summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@amd.com>2009-06-25 15:12:03 +0200
committerAvi Kivity <avi@redhat.com>2009-07-01 12:47:14 +0300
commitd448f409f1de409483d681fcd68d789402c3070b (patch)
treec146032143fc86161a764ebfbf67290f81998966 /qemu-kvm-x86.c
parentDisable msix save/load if msix is not supported (diff)
downloadqemu-kvm-d448f409f1de409483d681fcd68d789402c3070b.tar.gz
qemu-kvm-d448f409f1de409483d681fcd68d789402c3070b.tar.bz2
qemu-kvm-d448f409f1de409483d681fcd68d789402c3070b.zip
Fix KVMs GET_SUPPORTED_CPUID feature usage
If we want to trim the user provided CPUID bits for KVM to be not greater than that of the host, we should a) not remove the bits _after_ we sent them to the kernel and b) not do the bitmangling on the original values while sending a copy This fixes the masking of features that are not present on the host and helps to use -cpu host. Signed-off-by: Andre Przywara <andre.przywara@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'qemu-kvm-x86.c')
-rw-r--r--qemu-kvm-x86.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 1eb147e4a..a5c72e918 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -1191,7 +1191,6 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
qemu_kvm_load_lapic(cenv);
- copy = *cenv;
#ifdef KVM_CPUID_SIGNATURE
/* Paravirtualization CPUIDs */
@@ -1210,6 +1209,17 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
pv_ent->eax = get_para_features(kvm_context);
#endif
+ kvm_trim_features(&cenv->cpuid_features,
+ kvm_arch_get_supported_cpuid(cenv, 1, R_EDX));
+ kvm_trim_features(&cenv->cpuid_ext_features,
+ kvm_arch_get_supported_cpuid(cenv, 1, R_ECX));
+ kvm_trim_features(&cenv->cpuid_ext2_features,
+ kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_EDX));
+ kvm_trim_features(&cenv->cpuid_ext3_features,
+ kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_ECX));
+
+ copy = *cenv;
+
copy.regs[R_EAX] = 0;
qemu_kvm_cpuid_on_env(&copy);
limit = copy.regs[R_EAX];
@@ -1244,15 +1254,6 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
kvm_setup_cpuid2(cenv->kvm_cpu_state.vcpu_ctx, cpuid_nent, cpuid_ent);
- kvm_trim_features(&cenv->cpuid_features,
- kvm_arch_get_supported_cpuid(cenv, 1, R_EDX));
- kvm_trim_features(&cenv->cpuid_ext_features,
- kvm_arch_get_supported_cpuid(cenv, 1, R_ECX));
- kvm_trim_features(&cenv->cpuid_ext2_features,
- kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_EDX));
- kvm_trim_features(&cenv->cpuid_ext3_features,
- kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_ECX));
-
return 0;
}