target-i386: parse cpu_model string into set of stringified properties

cpu_model string does represent features in following format:
 ([+-]feat)|(feat=foo)|(feat)
which makes it impossible directly use property infrastructure
to set features on CPU.
This patch introduces parser that splits CPU name from cpu_model and
converts legacy features string into canonized set of strings that
is compatible with property manipulation infrastructure.

PS:
  * later it could be used as a hook to convert legacy command line
    features to global properties. Then marked as deprecated and
    removed with -cpu option in the future.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: use properties to set/unset user specified features on CPU

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
target-i386: move init of "hypervisor" feature into CPU initializer from cpudef

"hypervisor" CPU feature is unconditionally enabled/overridden even if it's cleared
in cpudef. Moving it inside CPU initializer from cpudef will help to
split cpu_x86_find_by_name() into default init and user settable properties.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: move default init of cpuid_kvm_features bitmap into CPU initializer from cpudef

Moving it inside CPU initializer from cpudef will help to split
cpu_x86_find_by_name() into default init and user settable properties.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
target-i386: cleanup cpu_x86_find_by_name(), only fill x86_def_t in it

Do in cpu_x86_find_by_name() only what name implies. i.e. leave only
cpudef search and copy/fill passed in x86_def_t structure.

and move out of it cpu_model parsing and CPU initializing into
cpu_x86_register(). Plus add hints to where blocks should go when
cpu_x86_register() is disbanded.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
target-i386: Add missing kvm bits.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
target-i386: Add Hypervisor level.

Also known as Paravirtualization level or maximim cpuid function present in this leaf.
This is just the EAX value for 0x40000000.

QEMU knows this is KVM_CPUID_SIGNATURE (0x40000000).

This is based on:

Microsoft Hypervisor CPUID Leaves:
  http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx

Linux kernel change starts with:
  http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
  http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html

VMware documention on CPUIDs (Mechanisms to determine if software is
running in a VMware virtual machine):
  http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

QEMU has the value HYPERV_CPUID_MIN defined.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
target-i386: Add cpu object access routines for Hypervisor level.

These are modeled after x86_cpuid_get_xlevel and x86_cpuid_set_xlevel.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
target-i386: Add x86_set_hyperv.

This is used to set the cpu object's hypervisor level to the default for Microsoft's Hypervisor.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
target-i386: Use Hypervisor level in -machine pc,accel=kvm.

Also known as Paravirtualization level.

This change is based on:

Microsoft Hypervisor CPUID Leaves:
  http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx

Linux kernel change starts with:
  http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
  http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html

VMware documention on CPUIDs (Mechanisms to determine if software is
running in a VMware virtual machine):
  http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

QEMU knows this is KVM_CPUID_SIGNATURE (0x40000000).

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
target-i386: Use Hypervisor level in -machine pc,accel=tcg.

Also known as Paravirtualization level.

This change is based on:

Microsoft Hypervisor CPUID Leaves:
  http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx

Linux kernel change starts with:
  http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
  http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html

VMware documention on CPUIDs (Mechanisms to determine if software is
running in a VMware virtual machine):
  http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

QEMU knows this as KVM_CPUID_SIGNATURE (0x40000000) in kvm on linux.

This does not provide vendor support in tcg yet.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
target-i386: Add Hypervisor vendor.

Also known as Paravirtualization vendor.
This is EBX, ECX, EDX data for 0x40000000.

QEMU knows this is KVM_CPUID_SIGNATURE (0x40000000).

This is based on:

Microsoft Hypervisor CPUID Leaves:
  http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx

Linux kernel change starts with:
  http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
  http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html

VMware documention on CPUIDs (Mechanisms to determine if software is
running in a VMware virtual machine):
  http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
target-i386: Add cpu object access routines for Hypervisor vendor.

These are modeled after x86_cpuid_set_vendor and x86_cpuid_get_vendor.
Since kvm's vendor is shorter, the test for correct size is removed and zero padding is added.

Set Microsoft's Vendor now that we can.  Value defined in:
  http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx
And matches want is in target-i386/kvm.c

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
target-i386: Use Hypervisor vendor in -machine pc,accel=kvm.

Also known as Paravirtualization vendor.

This change is based on:

Microsoft Hypervisor CPUID Leaves:
  http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx

Linux kernel change starts with:
  http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
  http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html

VMware documention on CPUIDs (Mechanisms to determine if software is
running in a VMware virtual machine):
  http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
target-i386: Use Hypervisor vendor in -machine pc,accel=tcg.

Also known as Paravirtualization vendor.

This change is based on:

Microsoft Hypervisor CPUID Leaves:
  http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx

Linux kernel change starts with:
  http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
  http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html
This is where the 0 is the same as 0x40000001 is defined.

VMware documention on CPUIDs (Mechanisms to determine if software is
running in a VMware virtual machine):
  http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
target-i386: Add some known names to Hypervisor vendor.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
target-i386: Add optional Hypervisor leaf extra.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
target-i386: Add cpu object access routines for Hypervisor leaf extra.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
target-i386: Add setting of Hypervisor leaf extra for known vmare4.

This was taken from:
  http://article.gmane.org/gmane.comp.emulators.kvm.devel/22643

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
target-i386: Use Hypervisor leaf extra in -machine pc,accel=kvm.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>