target-i386: add KVM_HINTS_DEDICATED performance hint

Add KVM_HINTS_DEDICATED performance hint, guest checks this feature bit
to determine if they run on dedicated vCPUs, allowing optimizations such
as usage of qspinlocks.

Backports commit be7773268d98176489483a315d3e2323cb0615b9 from qemu
This commit is contained in:
Wanpeng Li 2018-03-15 15:56:41 -04:00 committed by Lioncash
parent fc30b3d5cf
commit de4b198371
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
2 changed files with 67 additions and 1 deletions

View file

@ -435,7 +435,8 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
TCG_EXT4_FEATURES, TCG_EXT4_FEATURES,
}, },
// FEAT_KVM // FEAT_KVM
{{NULL}, {
{NULL},
/* Unicorn: commented out /* Unicorn: commented out
{ {
"kvmclock", "kvm-nopiodelay", "kvm-mmu", "kvmclock", "kvmclock", "kvm-nopiodelay", "kvm-mmu", "kvmclock",
@ -452,6 +453,26 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
R_EAX, R_EAX,
TCG_KVM_FEATURES,*/ TCG_KVM_FEATURES,*/
}, },
// FEAT_KVM_HINTS
{
{NULL},
/* Unicorn: commented out
{
"kvm-hint-dedicated", NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
},
KVM_CPUID_FEATURES,
false, 0,
R_EDX,
TCG_KVM_FEATURES,
*/
},
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
{ {
{ {
@ -970,6 +991,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -1346,6 +1369,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -1395,6 +1420,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -1447,6 +1474,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -1499,6 +1528,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -1552,6 +1583,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -1605,6 +1638,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -1660,6 +1695,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -1715,6 +1752,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -1771,6 +1810,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -1827,6 +1868,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -1884,6 +1927,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -1941,6 +1986,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -1998,6 +2045,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -2055,6 +2104,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -2112,6 +2163,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -2176,6 +2229,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -2245,6 +2300,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -2312,6 +2369,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -2526,6 +2585,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX
@ -2589,6 +2650,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
0, 0,
// FEAT_KVM // FEAT_KVM
0, 0,
// FEAT_KVM_HINTS
0,
// FEAT_HYPERV_EAX // FEAT_HYPERV_EAX
0, 0,
// FEAT_HYPERV_EBX // FEAT_HYPERV_EBX

View file

@ -451,6 +451,7 @@ typedef enum FeatureWord {
FEAT_8000_0008_EBX, /* CPUID[8000_0008].EBX */ FEAT_8000_0008_EBX, /* CPUID[8000_0008].EBX */
FEAT_C000_0001_EDX, /* CPUID[C000_0001].EDX */ FEAT_C000_0001_EDX, /* CPUID[C000_0001].EDX */
FEAT_KVM, /* CPUID[4000_0001].EAX (KVM_CPUID_FEATURES) */ FEAT_KVM, /* CPUID[4000_0001].EAX (KVM_CPUID_FEATURES) */
FEAT_KVM_HINTS, /* CPUID[4000_0001].EDX */
FEAT_HYPERV_EAX, /* CPUID[4000_0003].EAX */ FEAT_HYPERV_EAX, /* CPUID[4000_0003].EAX */
FEAT_HYPERV_EBX, /* CPUID[4000_0003].EBX */ FEAT_HYPERV_EBX, /* CPUID[4000_0003].EBX */
FEAT_HYPERV_EDX, /* CPUID[4000_0003].EDX */ FEAT_HYPERV_EDX, /* CPUID[4000_0003].EDX */
@ -645,6 +646,8 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
#define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3) /* AVX512 Multiply Accumulation Single Precision */ #define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3) /* AVX512 Multiply Accumulation Single Precision */
#define CPUID_7_0_EDX_SPEC_CTRL (1U << 26) /* Speculation Control */ #define CPUID_7_0_EDX_SPEC_CTRL (1U << 26) /* Speculation Control */
#define KVM_HINTS_DEDICATED (1U << 0)
#define CPUID_8000_0008_EBX_IBPB (1U << 12) /* Indirect Branch Prediction Barrier */ #define CPUID_8000_0008_EBX_IBPB (1U << 12) /* Indirect Branch Prediction Barrier */
#define CPUID_XSAVE_XSAVEOPT (1U << 0) #define CPUID_XSAVE_XSAVEOPT (1U << 0)