From f0701e6dd529d1a95d9fcf306b351b51bff07dc1 Mon Sep 17 00:00:00 2001 From: Wanpeng Li Date: Sat, 17 Mar 2018 19:07:13 -0400 Subject: [PATCH] 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 --- qemu/target/i386/cpu.c | 64 +++++++++++++++++++++++++++++++++++++++++- qemu/target/i386/cpu.h | 3 ++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/qemu/target/i386/cpu.c b/qemu/target/i386/cpu.c index 4a62ef8c..f812f80a 100644 --- a/qemu/target/i386/cpu.c +++ b/qemu/target/i386/cpu.c @@ -435,7 +435,8 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = { TCG_EXT4_FEATURES, }, // FEAT_KVM - {{NULL}, + { + {NULL}, /* Unicorn: commented out { "kvmclock", "kvm-nopiodelay", "kvm-mmu", "kvmclock", @@ -452,6 +453,25 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = { R_EAX, 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 { { @@ -970,6 +990,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -1346,6 +1368,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -1395,6 +1419,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -1447,6 +1473,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -1499,6 +1527,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -1552,6 +1582,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -1605,6 +1637,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -1660,6 +1694,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -1715,6 +1751,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -1771,6 +1809,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -1827,6 +1867,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -1884,6 +1926,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -1941,6 +1985,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -1998,6 +2044,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -2055,6 +2103,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -2112,6 +2162,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -2176,6 +2228,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -2245,6 +2299,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -2312,6 +2368,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -2526,6 +2584,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX @@ -2589,6 +2649,8 @@ static X86CPUDefinition builtin_x86_defs[] = { 0, // FEAT_KVM 0, + // FEAT_KVM_HINTS + 0, // FEAT_HYPERV_EAX 0, // FEAT_HYPERV_EBX diff --git a/qemu/target/i386/cpu.h b/qemu/target/i386/cpu.h index f2321f04..c4a5c747 100644 --- a/qemu/target/i386/cpu.h +++ b/qemu/target/i386/cpu.h @@ -452,6 +452,7 @@ typedef enum FeatureWord { FEAT_8000_0008_EBX, /* CPUID[8000_0008].EBX */ FEAT_C000_0001_EDX, /* CPUID[C000_0001].EDX */ 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_EBX, /* CPUID[4000_0003].EBX */ FEAT_HYPERV_EDX, /* CPUID[4000_0003].EDX */ @@ -646,6 +647,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_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_XSAVE_XSAVEOPT (1U << 0)