From 6fbabb4bce8e111e98eaa6fe2b5a3efdf442cd54 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 5 Mar 2018 12:40:31 -0500 Subject: [PATCH] i386: Add FEAT_8000_0008_EBX CPUID feature word Add the new feature word and the "ibpb" feature flag. Based on a patch by Paolo Bonzini. Backports commit 1ade973f5202404e772aae7b1acd331270d246dc from qemu --- qemu/target/i386/cpu.c | 43 +++++++++++++++++++++++++++++++++++++++++- qemu/target/i386/cpu.h | 3 +++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/qemu/target/i386/cpu.c b/qemu/target/i386/cpu.c index fd247c44..52785e1b 100644 --- a/qemu/target/i386/cpu.c +++ b/qemu/target/i386/cpu.c @@ -399,6 +399,24 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = { TCG_APM_FEATURES, CPUID_APM_INVTSC, }, + // FEAT_8000_0008_EBX + { + { + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + "ibpb", NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + }, + 0x80000008, + false,0, + R_EBX, + 0, + 0, + }, // FEAT_C000_0001_EDX { { @@ -946,6 +964,8 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_ABM | CPUID_EXT3_SSE4A, // FEAT_8000_0007_EDX 0, + // FEAT_8000_0008_EBX + 0, // FEAT_C000_0001_EDX 0, // FEAT_KVM @@ -1292,6 +1312,8 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_LAHF_LM, // FEAT_8000_0007_EDX 0, + // FEAT_8000_0008_EBX + 0, // FEAT_C000_0001_EDX 0, // FEAT_KVM @@ -1342,6 +1364,8 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_LAHF_LM, // FEAT_8000_0007_EDX 0, + // FEAT_8000_0008_EBX + 0, // FEAT_C000_0001_EDX 0, // FEAT_KVM @@ -1393,6 +1417,8 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_LAHF_LM, // FEAT_8000_0007_EDX 0, + // FEAT_8000_0008_EBX + 0, // FEAT_C000_0001_EDX 0, // FEAT_KVM @@ -1446,6 +1472,8 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM, // FEAT_8000_0007_EDX 0, + // FEAT_8000_0008_EBX + 0, // FEAT_C000_0001_EDX 0, // FEAT_KVM @@ -1500,6 +1528,8 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM, // FEAT_8000_0007_EDX 0, + // FEAT_8000_0008_EBX + 0, // FEAT_C000_0001_EDX 0, // FEAT_KVM @@ -1555,6 +1585,8 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH, // FEAT_8000_0007_EDX 0, + // FEAT_8000_0008_EBX + 0, // FEAT_C000_0001_EDX 0, // FEAT_KVM @@ -1610,6 +1642,8 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH, // FEAT_8000_0007_EDX 0, + // FEAT_8000_0008_EBX + 0, // FEAT_C000_0001_EDX 0, // FEAT_KVM @@ -1665,6 +1699,8 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH, // FEAT_8000_0007_EDX 0, + // FEAT_8000_0008_EBX + 0, // FEAT_C000_0001_EDX 0, // FEAT_KVM @@ -1732,6 +1768,8 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH, // FEAT_8000_0007_EDX 0, + // FEAT_8000_0008_EBX + 0, // FEAT_C000_0001_EDX 0, // FEAT_KVM @@ -1944,6 +1982,8 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM, // FEAT_8000_0007_EDX 0, + // FEAT_8000_0008_EBX + 0, // FEAT_C000_0001_EDX 0, // FEAT_KVM @@ -2905,7 +2945,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, } else { *eax = cpu->phys_bits; } - *ebx = 0; + *ebx = env->features[FEAT_8000_0008_EBX]; *ecx = 0; *edx = 0; if (cs->nr_cores * cs->nr_threads > 1) { @@ -3306,6 +3346,7 @@ static void x86_cpu_expand_features(struct uc_struct *uc, X86CPU *cpu, Error **e x86_cpu_adjust_feat_level(cpu, FEAT_8000_0001_EDX); x86_cpu_adjust_feat_level(cpu, FEAT_8000_0001_ECX); x86_cpu_adjust_feat_level(cpu, FEAT_8000_0007_EDX); + x86_cpu_adjust_feat_level(cpu, FEAT_8000_0008_EBX); x86_cpu_adjust_feat_level(cpu, FEAT_C000_0001_EDX); x86_cpu_adjust_feat_level(cpu, FEAT_SVM); x86_cpu_adjust_feat_level(cpu, FEAT_XSAVE); diff --git a/qemu/target/i386/cpu.h b/qemu/target/i386/cpu.h index 880678fe..3dbf1cf7 100644 --- a/qemu/target/i386/cpu.h +++ b/qemu/target/i386/cpu.h @@ -452,6 +452,7 @@ typedef enum FeatureWord { FEAT_8000_0001_EDX, /* CPUID[8000_0001].EDX */ FEAT_8000_0001_ECX, /* CPUID[8000_0001].ECX */ FEAT_8000_0007_EDX, /* CPUID[8000_0007].EDX */ + 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_HYPERV_EAX, /* CPUID[4000_0003].EAX */ @@ -642,6 +643,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 CPUID_8000_0008_EBX_IBPB (1U << 12) /* Indirect Branch Prediction Barrier */ + #define CPUID_XSAVE_XSAVEOPT (1U << 0) #define CPUID_XSAVE_XSAVEC (1U << 1) #define CPUID_XSAVE_XGETBV1 (1U << 2)