pc: Use PC_COMPAT_* for CPUID feature compatibility

Now we can use compat_props to keep CPUID feature compatibility, using
the boolean QOM properties for CPUID feature flags.

This simplifies the compatibility code, and reduces duplication between
pc_piix.c and pc_q35.c.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Eduardo Habkost 2015-08-07 16:55:42 -03:00 committed by Michael S. Tsirkin
parent e33d22fab3
commit 27add38141
3 changed files with 112 additions and 46 deletions

View File

@ -319,24 +319,6 @@ static void pc_compat_2_2(MachineState *machine)
{
pc_compat_2_3(machine);
rsdp_in_ram = false;
x86_cpu_compat_set_features("kvm64", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("kvm32", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Conroe", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Penryn", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Nehalem", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Westmere", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("SandyBridge", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Haswell", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Broadwell", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Opteron_G1", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Opteron_G2", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Opteron_G3", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Opteron_G4", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Opteron_G5", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, 0, CPUID_EXT_F16C);
x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, 0, CPUID_EXT_RDRAND);
x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, 0, CPUID_EXT_F16C);
x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, 0, CPUID_EXT_RDRAND);
machine->suppress_vmdesc = true;
}
@ -346,8 +328,6 @@ static void pc_compat_2_1(MachineState *machine)
pc_compat_2_2(machine);
smbios_uuid_encoded = false;
x86_cpu_compat_set_features("coreduo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
x86_cpu_compat_set_features("core2duo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
pcms->enforce_aligned_dimm = false;
}
@ -402,8 +382,6 @@ static void pc_compat_1_5(MachineState *machine)
static void pc_compat_1_4(MachineState *machine)
{
pc_compat_1_5(machine);
x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
}
static void pc_compat_1_3(MachineState *machine)

View File

@ -302,24 +302,6 @@ static void pc_compat_2_2(MachineState *machine)
{
pc_compat_2_3(machine);
rsdp_in_ram = false;
x86_cpu_compat_set_features("kvm64", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("kvm32", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Conroe", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Penryn", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Nehalem", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Westmere", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("SandyBridge", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Haswell", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Broadwell", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Opteron_G1", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Opteron_G2", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Opteron_G3", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Opteron_G4", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Opteron_G5", FEAT_1_EDX, 0, CPUID_VME);
x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, 0, CPUID_EXT_F16C);
x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, 0, CPUID_EXT_RDRAND);
x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, 0, CPUID_EXT_F16C);
x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, 0, CPUID_EXT_RDRAND);
machine->suppress_vmdesc = true;
}
@ -330,8 +312,6 @@ static void pc_compat_2_1(MachineState *machine)
pc_compat_2_2(machine);
pcms->enforce_aligned_dimm = false;
smbios_uuid_encoded = false;
x86_cpu_compat_set_features("coreduo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
x86_cpu_compat_set_features("core2duo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
}
@ -367,8 +347,6 @@ static void pc_compat_1_5(MachineState *machine)
static void pc_compat_1_4(MachineState *machine)
{
pc_compat_1_5(machine);
x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
}
#define DEFINE_Q35_MACHINE(suffix, name, compatfn, optionfn) \

View File

@ -374,11 +374,111 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
#define PC_COMPAT_2_2 \
PC_COMPAT_2_3 \
HW_COMPAT_2_2
HW_COMPAT_2_2 \
{\
.driver = "kvm64" "-" TYPE_X86_CPU,\
.property = "vme",\
.value = "off",\
},\
{\
.driver = "kvm32" "-" TYPE_X86_CPU,\
.property = "vme",\
.value = "off",\
},\
{\
.driver = "Conroe" "-" TYPE_X86_CPU,\
.property = "vme",\
.value = "off",\
},\
{\
.driver = "Penryn" "-" TYPE_X86_CPU,\
.property = "vme",\
.value = "off",\
},\
{\
.driver = "Nehalem" "-" TYPE_X86_CPU,\
.property = "vme",\
.value = "off",\
},\
{\
.driver = "Westmere" "-" TYPE_X86_CPU,\
.property = "vme",\
.value = "off",\
},\
{\
.driver = "SandyBridge" "-" TYPE_X86_CPU,\
.property = "vme",\
.value = "off",\
},\
{\
.driver = "Haswell" "-" TYPE_X86_CPU,\
.property = "vme",\
.value = "off",\
},\
{\
.driver = "Broadwell" "-" TYPE_X86_CPU,\
.property = "vme",\
.value = "off",\
},\
{\
.driver = "Opteron_G1" "-" TYPE_X86_CPU,\
.property = "vme",\
.value = "off",\
},\
{\
.driver = "Opteron_G2" "-" TYPE_X86_CPU,\
.property = "vme",\
.value = "off",\
},\
{\
.driver = "Opteron_G3" "-" TYPE_X86_CPU,\
.property = "vme",\
.value = "off",\
},\
{\
.driver = "Opteron_G4" "-" TYPE_X86_CPU,\
.property = "vme",\
.value = "off",\
},\
{\
.driver = "Opteron_G5" "-" TYPE_X86_CPU,\
.property = "vme",\
.value = "off",\
},\
{\
.driver = "Haswell" "-" TYPE_X86_CPU,\
.property = "f16c",\
.value = "off",\
},\
{\
.driver = "Haswell" "-" TYPE_X86_CPU,\
.property = "rdrand",\
.value = "off",\
},\
{\
.driver = "Broadwell" "-" TYPE_X86_CPU,\
.property = "f16c",\
.value = "off",\
},\
{\
.driver = "Broadwell" "-" TYPE_X86_CPU,\
.property = "rdrand",\
.value = "off",\
},
#define PC_COMPAT_2_1 \
PC_COMPAT_2_2 \
HW_COMPAT_2_1
HW_COMPAT_2_1 \
{\
.driver = "coreduo" "-" TYPE_X86_CPU,\
.property = "vmx",\
.value = "on",\
},\
{\
.driver = "core2duo" "-" TYPE_X86_CPU,\
.property = "vmx",\
.value = "on",\
},
#define PC_COMPAT_2_0 \
PC_COMPAT_2_1 \
@ -589,6 +689,16 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
.driver = "486-" TYPE_X86_CPU,\
.property = "model",\
.value = stringify(0),\
},\
{\
.driver = "n270" "-" TYPE_X86_CPU,\
.property = "movbe",\
.value = "off",\
},\
{\
.driver = "Westmere" "-" TYPE_X86_CPU,\
.property = "pclmulqdq",\
.value = "off",\
},
static inline void pc_common_machine_options(MachineClass *m)