cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-target-i386-cpu-add-new-CPU-models-for-indirect-bran.patch

5d360b
From 4f2a39dd988cfae0210dfa7a84be00617ba17bef Mon Sep 17 00:00:00 2001
5d360b
From: Eduardo Habkost <ehabkost@redhat.com>
5d360b
Date: Wed, 13 Dec 2017 15:43:41 -0200
5d360b
Subject: [PATCH 3/3] target-i386: cpu: add new CPU models for indirect branch
5d360b
 predictor restrictions
5d360b
5d360b
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
5d360b
Message-id: <20171213174341.20684-4-ehabkost@redhat.com>
5d360b
Patchwork-id: n/a
5d360b
O-Subject: [CONFIDENTIAL][RHEL-7.5 qemu-kvm PATCH v2 3/3] target-i386: cpu: add
5d360b
 new CPU models for indirect branch predictor restrictions
5d360b
Bugzilla: CVE-2017-5715
5d360b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
5d360b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
5d360b
Changes v1 -> v2:
5d360b
* Copied the original CPU models from the same source file, just adding
5d360b
  SPEC_CTRL and updating level/xlevel/model_id/stepping, to keep compatibility
5d360b
  code exactly the same.
5d360b
* Update compat_props so we can be sure the same compat rules will apply to the
5d360b
  original CPU models and to the *-IBRS ones
5d360b
5d360b
To ensure the New CPU models won't introduce any unexpected
5d360b
changes except for the spec-ctrl feature (even if people are
5d360b
running older machine-types), copy all compat_props entries for
5d360b
existing CPU models to their *-IBRS versions.
5d360b
5d360b
The only entries that are not being copied are the ones touching
5d360b
"(min-)level" and "(min-)xlevel" because it's an expected result
5d360b
of the CPU model change (otherwise the spec-ctrl feature would
5d360b
remain unavailable to the guest).
5d360b
5d360b
The entries that had to be copied can be found using:
5d360b
  $ git grep -E 'Nehalem|Westmere|SandyBridge|IvyBridge|Haswell-noTSX|Haswell|Broadwell-noTSX|Broadwell|Skylake-Client|Skylake-Server|EPYC'
5d360b
5d360b
Note that the upstream-only PC_COMPAT_* macros are not being
5d360b
touched as they are not used by the RHEL machine-types.
5d360b
---
5d360b
 hw/i386/pc_piix.c |  17 +++
5d360b
 hw/i386/pc_q35.c  |   1 +
5d360b
 target-i386/cpu.c | 328 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
5d360b
 target-i386/cpu.h |   3 +
5d360b
 4 files changed, 349 insertions(+)
5d360b
5d360b
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
5d360b
index b043124..c53a6d4 100644
5d360b
--- a/hw/i386/pc_piix.c
5d360b
+++ b/hw/i386/pc_piix.c
5d360b
@@ -753,7 +753,9 @@ static void pc_compat_rhel700(QEMUMachineInitArgs *args)
5d360b
     x86_cpu_compat_set_features("Conroe", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
5d360b
     x86_cpu_compat_set_features("Penryn", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
5d360b
     x86_cpu_compat_set_features("Nehalem", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
5d360b
+    x86_cpu_compat_set_features("Nehalem-IBRS", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
5d360b
     x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
5d360b
+    x86_cpu_compat_set_features("Westmere-IBRS", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
5d360b
     /* SandyBridge and Haswell already have x2apic enabled */
5d360b
     x86_cpu_compat_set_features("Opteron_G1", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
5d360b
     x86_cpu_compat_set_features("Opteron_G2", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
5d360b
@@ -928,18 +930,31 @@ static void pc_compat_rhel660(QEMUMachineInitArgs *args)
5d360b
     x86_cpu_compat_set_features("Conroe", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
5d360b
     x86_cpu_compat_set_features("Penryn", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
5d360b
     x86_cpu_compat_set_features("Nehalem", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
5d360b
+    x86_cpu_compat_set_features("Nehalem-IBRS", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
5d360b
     x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
5d360b
+    x86_cpu_compat_set_features("Westmere-IBRS", FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
5d360b
     x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
5d360b
+    x86_cpu_compat_set_features("Westmere-IBRS", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
5d360b
     x86_cpu_compat_set_features("Westmere", FEAT_8000_0001_EDX,
5d360b
              CPUID_EXT2_FXSR | CPUID_EXT2_MMX | CPUID_EXT2_PAT |
5d360b
              CPUID_EXT2_CMOV | CPUID_EXT2_PGE | CPUID_EXT2_APIC |
5d360b
              CPUID_EXT2_CX8 | CPUID_EXT2_MCE | CPUID_EXT2_PAE | CPUID_EXT2_MSR |
5d360b
              CPUID_EXT2_TSC | CPUID_EXT2_PSE | CPUID_EXT2_DE | CPUID_EXT2_FPU,
5d360b
              0);
5d360b
+    x86_cpu_compat_set_features("Westmere-IBRS", FEAT_8000_0001_EDX,
5d360b
+             CPUID_EXT2_FXSR | CPUID_EXT2_MMX | CPUID_EXT2_PAT |
5d360b
+             CPUID_EXT2_CMOV | CPUID_EXT2_PGE | CPUID_EXT2_APIC |
5d360b
+             CPUID_EXT2_CX8 | CPUID_EXT2_MCE | CPUID_EXT2_PAE | CPUID_EXT2_MSR |
5d360b
+             CPUID_EXT2_TSC | CPUID_EXT2_PSE | CPUID_EXT2_DE | CPUID_EXT2_FPU,
5d360b
+             0);
5d360b
     x86_cpu_compat_set_features("Broadwell", FEAT_8000_0001_EDX,
5d360b
                                 0, CPUID_EXT2_RDTSCP);
5d360b
+    x86_cpu_compat_set_features("Broadwell-IBRS", FEAT_8000_0001_EDX,
5d360b
+                                0, CPUID_EXT2_RDTSCP);
5d360b
     x86_cpu_compat_set_features("Broadwell", FEAT_7_0_EBX,
5d360b
                                 0, CPUID_7_0_EBX_SMAP);
5d360b
+    x86_cpu_compat_set_features("Broadwell-IBRS", FEAT_7_0_EBX,
5d360b
+                                0, CPUID_7_0_EBX_SMAP);
5d360b
 
5d360b
     /* RHEL-6 kernel never supported exposing RDTSCP */
5d360b
     x86_cpu_compat_set_features(NULL, FEAT_8000_0001_EDX, 0, CPUID_EXT2_RDTSCP);
5d360b
@@ -1122,6 +1137,8 @@ static void pc_compat_rhel630(QEMUMachineInitArgs *args)
5d360b
     enable_compat_apic_id_mode();
5d360b
     x86_cpu_compat_set_features("SandyBridge", FEAT_1_ECX,
5d360b
                                 0, CPUID_EXT_TSC_DEADLINE_TIMER);
5d360b
+    x86_cpu_compat_set_features("SandyBridge-IBRS", FEAT_1_ECX,
5d360b
+                                0, CPUID_EXT_TSC_DEADLINE_TIMER);
5d360b
 }
5d360b
 
5d360b
 static void pc_init_rhel630(QEMUMachineInitArgs *args)
5d360b
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
5d360b
index 850a25a..e6043df 100644
5d360b
--- a/hw/i386/pc_q35.c
5d360b
+++ b/hw/i386/pc_q35.c
5d360b
@@ -228,6 +228,7 @@ static void pc_q35_init_1_4(QEMUMachineInitArgs *args)
5d360b
 {
5d360b
     x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
5d360b
     x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
5d360b
+    x86_cpu_compat_set_features("Westmere-IBRS", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
5d360b
     pc_q35_init_1_5(args);
5d360b
 }
5d360b
 
5d360b
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
5d360b
index 335689b..08b43f5 100644
5d360b
--- a/target-i386/cpu.c
5d360b
+++ b/target-i386/cpu.c
5d360b
@@ -884,6 +884,31 @@ static x86_def_t builtin_x86_defs[] = {
5d360b
         .model_id = "Intel Core i7 9xx (Nehalem Class Core i7)",
5d360b
     },
5d360b
     {
5d360b
+        .name = "Nehalem-IBRS",
5d360b
+        .level = 11,
5d360b
+        .vendor = CPUID_VENDOR_INTEL,
5d360b
+        .family = 6,
5d360b
+        .model = 26,
5d360b
+        .stepping = 3,
5d360b
+        .features[FEAT_1_EDX] =
5d360b
+            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
5d360b
+             CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
5d360b
+             CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
5d360b
+             CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
5d360b
+             CPUID_DE | CPUID_FP87,
5d360b
+        .features[FEAT_1_ECX] =
5d360b
+            CPUID_EXT_POPCNT | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 |
5d360b
+             CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | CPUID_EXT_SSE3,
5d360b
+        .features[FEAT_7_0_EDX] =
5d360b
+            CPUID_7_0_EDX_SPEC_CTRL,
5d360b
+        .features[FEAT_8000_0001_EDX] =
5d360b
+            CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX,
5d360b
+        .features[FEAT_8000_0001_ECX] =
5d360b
+            CPUID_EXT3_LAHF_LM,
5d360b
+        .xlevel = 0x80000008,
5d360b
+        .model_id = "Intel Core i7 9xx (Nehalem Core i7, IBRS update)",
5d360b
+    },
5d360b
+    {
5d360b
         .name = "Westmere",
5d360b
         .level = 11,
5d360b
         .vendor = CPUID_VENDOR_INTEL,
5d360b
@@ -908,6 +933,32 @@ static x86_def_t builtin_x86_defs[] = {
5d360b
         .model_id = "Westmere E56xx/L56xx/X56xx (Nehalem-C)",
5d360b
     },
5d360b
     {
5d360b
+        .name = "Westmere-IBRS",
5d360b
+        .level = 11,
5d360b
+        .vendor = CPUID_VENDOR_INTEL,
5d360b
+        .family = 6,
5d360b
+        .model = 44,
5d360b
+        .stepping = 1,
5d360b
+        .features[FEAT_1_EDX] =
5d360b
+            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
5d360b
+             CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
5d360b
+             CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
5d360b
+             CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
5d360b
+             CPUID_DE | CPUID_FP87,
5d360b
+        .features[FEAT_1_ECX] =
5d360b
+            CPUID_EXT_AES | CPUID_EXT_POPCNT | CPUID_EXT_SSE42 |
5d360b
+             CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 |
5d360b
+             CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3,
5d360b
+        .features[FEAT_8000_0001_EDX] =
5d360b
+            CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX,
5d360b
+        .features[FEAT_8000_0001_ECX] =
5d360b
+            CPUID_EXT3_LAHF_LM,
5d360b
+	.features[FEAT_7_0_EDX] =
5d360b
+	    CPUID_7_0_EDX_SPEC_CTRL,
5d360b
+        .xlevel = 0x80000008,
5d360b
+        .model_id = "Westmere E56xx/L56xx/X56xx (IBRS update)",
5d360b
+    },
5d360b
+    {
5d360b
         .name = "SandyBridge",
5d360b
         .level = 0xd,
5d360b
         .vendor = CPUID_VENDOR_INTEL,
5d360b
@@ -937,6 +988,37 @@ static x86_def_t builtin_x86_defs[] = {
5d360b
         .model_id = "Intel Xeon E312xx (Sandy Bridge)",
5d360b
     },
5d360b
     {
5d360b
+        .name = "SandyBridge-IBRS",
5d360b
+        .level = 0xd,
5d360b
+        .vendor = CPUID_VENDOR_INTEL,
5d360b
+        .family = 6,
5d360b
+        .model = 42,
5d360b
+        .stepping = 1,
5d360b
+        .features[FEAT_1_EDX] =
5d360b
+            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
5d360b
+             CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
5d360b
+             CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
5d360b
+             CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
5d360b
+             CPUID_DE | CPUID_FP87,
5d360b
+        .features[FEAT_1_ECX] =
5d360b
+            CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES |
5d360b
+             CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_POPCNT |
5d360b
+             CPUID_EXT_X2APIC | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 |
5d360b
+             CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | CPUID_EXT_PCLMULQDQ |
5d360b
+             CPUID_EXT_SSE3,
5d360b
+        .features[FEAT_8000_0001_EDX] =
5d360b
+            CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX |
5d360b
+             CPUID_EXT2_SYSCALL,
5d360b
+        .features[FEAT_8000_0001_ECX] =
5d360b
+            CPUID_EXT3_LAHF_LM,
5d360b
+	.features[FEAT_7_0_EDX] =
5d360b
+	    CPUID_7_0_EDX_SPEC_CTRL,
5d360b
+        .features[FEAT_XSAVE] =
5d360b
+            CPUID_XSAVE_XSAVEOPT,
5d360b
+        .xlevel = 0x80000008,
5d360b
+        .model_id = "Intel Xeon E312xx (Sandy Bridge, IBRS update)",
5d360b
+    },
5d360b
+    {
5d360b
         .name = "IvyBridge",
5d360b
         .level = 0xd,
5d360b
         .vendor = CPUID_VENDOR_INTEL,
5d360b
@@ -969,6 +1051,40 @@ static x86_def_t builtin_x86_defs[] = {
5d360b
         .model_id = "Intel Xeon E3-12xx v2 (Ivy Bridge)",
5d360b
     },
5d360b
     {
5d360b
+        .name = "IvyBridge-IBRS",
5d360b
+        .level = 0xd,
5d360b
+        .vendor = CPUID_VENDOR_INTEL,
5d360b
+        .family = 6,
5d360b
+        .model = 58,
5d360b
+        .stepping = 9,
5d360b
+        .features[FEAT_1_EDX] =
5d360b
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
5d360b
+            CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
5d360b
+            CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
5d360b
+            CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
5d360b
+            CPUID_DE | CPUID_FP87,
5d360b
+        .features[FEAT_1_ECX] =
5d360b
+            CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES |
5d360b
+            CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_POPCNT |
5d360b
+            CPUID_EXT_X2APIC | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 |
5d360b
+            CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | CPUID_EXT_PCLMULQDQ |
5d360b
+            CPUID_EXT_SSE3 | CPUID_EXT_F16C | CPUID_EXT_RDRAND,
5d360b
+        .features[FEAT_7_0_EBX] =
5d360b
+            CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_SMEP |
5d360b
+            CPUID_7_0_EBX_ERMS,
5d360b
+        .features[FEAT_8000_0001_EDX] =
5d360b
+            CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX |
5d360b
+            CPUID_EXT2_SYSCALL,
5d360b
+        .features[FEAT_8000_0001_ECX] =
5d360b
+            CPUID_EXT3_LAHF_LM,
5d360b
+	.features[FEAT_7_0_EDX] =
5d360b
+	    CPUID_7_0_EDX_SPEC_CTRL,
5d360b
+        .features[FEAT_XSAVE] =
5d360b
+            CPUID_XSAVE_XSAVEOPT,
5d360b
+        .xlevel = 0x80000008,
5d360b
+        .model_id = "Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)",
5d360b
+    },
5d360b
+    {
5d360b
         .name = "Haswell",
5d360b
         .level = 0xd,
5d360b
         .vendor = CPUID_VENDOR_INTEL,
5d360b
@@ -1004,6 +1120,43 @@ static x86_def_t builtin_x86_defs[] = {
5d360b
         .model_id = "Intel Core Processor (Haswell)",
5d360b
     },
5d360b
     {
5d360b
+        .name = "Haswell-IBRS",
5d360b
+        .level = 0xd,
5d360b
+        .vendor = CPUID_VENDOR_INTEL,
5d360b
+        .family = 6,
5d360b
+        .model = 60,
5d360b
+        .stepping = 4,
5d360b
+        .features[FEAT_1_EDX] =
5d360b
+            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
5d360b
+             CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
5d360b
+             CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
5d360b
+             CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
5d360b
+             CPUID_DE | CPUID_FP87,
5d360b
+        .features[FEAT_1_ECX] =
5d360b
+            CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES |
5d360b
+             CPUID_EXT_POPCNT | CPUID_EXT_X2APIC | CPUID_EXT_SSE42 |
5d360b
+             CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 |
5d360b
+             CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3 |
5d360b
+             CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_FMA | CPUID_EXT_MOVBE |
5d360b
+             CPUID_EXT_PCID,
5d360b
+        .features[FEAT_8000_0001_EDX] =
5d360b
+            CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX |
5d360b
+             CPUID_EXT2_SYSCALL,
5d360b
+        .features[FEAT_8000_0001_ECX] =
5d360b
+            CPUID_EXT3_LAHF_LM,
5d360b
+	.features[FEAT_7_0_EDX] =
5d360b
+	    CPUID_7_0_EDX_SPEC_CTRL,
5d360b
+        .features[FEAT_7_0_EBX] =
5d360b
+            CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 |
5d360b
+            CPUID_7_0_EBX_HLE | CPUID_7_0_EBX_AVX2 | CPUID_7_0_EBX_SMEP |
5d360b
+            CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCID |
5d360b
+            CPUID_7_0_EBX_RTM,
5d360b
+        .features[FEAT_XSAVE] =
5d360b
+            CPUID_XSAVE_XSAVEOPT,
5d360b
+        .xlevel = 0x80000008,
5d360b
+        .model_id = "Intel Core Processor (Haswell, IBRS)",
5d360b
+    },
5d360b
+    {
5d360b
         .name = "Broadwell",
5d360b
         .level = 0xd,
5d360b
         .vendor = CPUID_VENDOR_INTEL,
5d360b
@@ -1040,6 +1193,44 @@ static x86_def_t builtin_x86_defs[] = {
5d360b
         .model_id = "Intel Core Processor (Broadwell)",
5d360b
     },
5d360b
     {
5d360b
+        .name = "Broadwell-IBRS",
5d360b
+        .level = 0xd,
5d360b
+        .vendor = CPUID_VENDOR_INTEL,
5d360b
+        .family = 6,
5d360b
+        .model = 61,
5d360b
+        .stepping = 2,
5d360b
+        .features[FEAT_1_EDX] =
5d360b
+            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
5d360b
+            CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
5d360b
+            CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
5d360b
+            CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
5d360b
+            CPUID_DE | CPUID_FP87,
5d360b
+        .features[FEAT_1_ECX] =
5d360b
+            CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES |
5d360b
+            CPUID_EXT_POPCNT | CPUID_EXT_X2APIC | CPUID_EXT_SSE42 |
5d360b
+            CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 |
5d360b
+            CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3 |
5d360b
+            CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_FMA | CPUID_EXT_MOVBE |
5d360b
+            CPUID_EXT_PCID,
5d360b
+        .features[FEAT_8000_0001_EDX] =
5d360b
+            CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX |
5d360b
+            CPUID_EXT2_SYSCALL,
5d360b
+        .features[FEAT_8000_0001_ECX] =
5d360b
+            CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH,
5d360b
+	.features[FEAT_7_0_EDX] =
5d360b
+	    CPUID_7_0_EDX_SPEC_CTRL,
5d360b
+        .features[FEAT_7_0_EBX] =
5d360b
+            CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 |
5d360b
+            CPUID_7_0_EBX_HLE | CPUID_7_0_EBX_AVX2 | CPUID_7_0_EBX_SMEP |
5d360b
+            CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCID |
5d360b
+            CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_RDSEED | CPUID_7_0_EBX_ADX |
5d360b
+            CPUID_7_0_EBX_SMAP,
5d360b
+        .features[FEAT_XSAVE] =
5d360b
+            CPUID_XSAVE_XSAVEOPT,
5d360b
+        .xlevel = 0x80000008,
5d360b
+        .model_id = "Intel Core Processor (Broadwell, IBRS)",
5d360b
+    },
5d360b
+    {
5d360b
         .name = "Skylake-Client",
5d360b
         .level = 0xd,
5d360b
         .vendor = CPUID_VENDOR_INTEL,
5d360b
@@ -1083,6 +1274,51 @@ static x86_def_t builtin_x86_defs[] = {
5d360b
         .model_id = "Intel Core Processor (Skylake)",
5d360b
     },
5d360b
     {
5d360b
+        .name = "Skylake-Client-IBRS",
5d360b
+        .level = 0xd,
5d360b
+        .vendor = CPUID_VENDOR_INTEL,
5d360b
+        .family = 6,
5d360b
+        .model = 94,
5d360b
+        .stepping = 3,
5d360b
+        .features[FEAT_1_EDX] =
5d360b
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
5d360b
+            CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
5d360b
+            CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
5d360b
+            CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
5d360b
+            CPUID_DE | CPUID_FP87,
5d360b
+        .features[FEAT_1_ECX] =
5d360b
+            CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES |
5d360b
+            CPUID_EXT_POPCNT | CPUID_EXT_X2APIC | CPUID_EXT_SSE42 |
5d360b
+            CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 |
5d360b
+            CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3 |
5d360b
+            CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_FMA | CPUID_EXT_MOVBE |
5d360b
+            CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND,
5d360b
+        .features[FEAT_8000_0001_EDX] =
5d360b
+            CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX |
5d360b
+            CPUID_EXT2_SYSCALL,
5d360b
+        .features[FEAT_8000_0001_ECX] =
5d360b
+            CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH,
5d360b
+	.features[FEAT_7_0_EDX] =
5d360b
+	    CPUID_7_0_EDX_SPEC_CTRL,
5d360b
+        .features[FEAT_7_0_EBX] =
5d360b
+            CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 |
5d360b
+            CPUID_7_0_EBX_HLE | CPUID_7_0_EBX_AVX2 | CPUID_7_0_EBX_SMEP |
5d360b
+            CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCID |
5d360b
+            CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_RDSEED | CPUID_7_0_EBX_ADX |
5d360b
+            CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_MPX,
5d360b
+        /* Missing: XSAVES (not supported by some Linux versions,
5d360b
+         * including v4.1 to v4.12).
5d360b
+         * KVM doesn't yet expose any XSAVES state save component,
5d360b
+         * and the only one defined in Skylake (processor tracing)
5d360b
+         * probably will block migration anyway.
5d360b
+         */
5d360b
+        .features[FEAT_XSAVE] =
5d360b
+            CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC |
5d360b
+            CPUID_XSAVE_XGETBV1,
5d360b
+        .xlevel = 0x80000008,
5d360b
+        .model_id = "Intel Core Processor (Skylake, IBRS)",
5d360b
+    },
5d360b
+    {
5d360b
         .name = "Skylake-Server",
5d360b
         .level = 0xd,
5d360b
         .vendor = CPUID_VENDOR_INTEL,
5d360b
@@ -1133,6 +1369,54 @@ static x86_def_t builtin_x86_defs[] = {
5d360b
         .model_id = "Intel Xeon Processor (Skylake)",
5d360b
     },
5d360b
     {
5d360b
+        .name = "Skylake-Server-IBRS",
5d360b
+        .level = 0xd,
5d360b
+        .vendor = CPUID_VENDOR_INTEL,
5d360b
+        .family = 6,
5d360b
+        .model = 85,
5d360b
+        .stepping = 4,
5d360b
+        .features[FEAT_1_EDX] =
5d360b
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
5d360b
+            CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
5d360b
+            CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
5d360b
+            CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
5d360b
+            CPUID_DE | CPUID_FP87,
5d360b
+        .features[FEAT_1_ECX] =
5d360b
+            CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES |
5d360b
+            CPUID_EXT_POPCNT | CPUID_EXT_X2APIC | CPUID_EXT_SSE42 |
5d360b
+            CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 |
5d360b
+            CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3 |
5d360b
+            CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_FMA | CPUID_EXT_MOVBE |
5d360b
+            CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND,
5d360b
+        .features[FEAT_8000_0001_EDX] =
5d360b
+            CPUID_EXT2_LM | CPUID_EXT2_PDPE1GB | CPUID_EXT2_RDTSCP |
5d360b
+            CPUID_EXT2_NX | CPUID_EXT2_SYSCALL,
5d360b
+        .features[FEAT_8000_0001_ECX] =
5d360b
+            CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH,
5d360b
+	.features[FEAT_7_0_EDX] =
5d360b
+	    CPUID_7_0_EDX_SPEC_CTRL,
5d360b
+        .features[FEAT_7_0_EBX] =
5d360b
+            CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 |
5d360b
+            CPUID_7_0_EBX_HLE | CPUID_7_0_EBX_AVX2 | CPUID_7_0_EBX_SMEP |
5d360b
+            CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCID |
5d360b
+            CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_RDSEED | CPUID_7_0_EBX_ADX |
5d360b
+            CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_MPX | CPUID_7_0_EBX_CLWB |
5d360b
+            CPUID_7_0_EBX_AVX512F | CPUID_7_0_EBX_AVX512DQ |
5d360b
+            CPUID_7_0_EBX_AVX512BW | CPUID_7_0_EBX_AVX512CD |
5d360b
+            CPUID_7_0_EBX_AVX512VL,
5d360b
+        /* Missing: XSAVES (not supported by some Linux versions,
5d360b
+         * including v4.1 to v4.12).
5d360b
+         * KVM doesn't yet expose any XSAVES state save component,
5d360b
+         * and the only one defined in Skylake (processor tracing)
5d360b
+         * probably will block migration anyway.
5d360b
+         */
5d360b
+        .features[FEAT_XSAVE] =
5d360b
+            CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC |
5d360b
+            CPUID_XSAVE_XGETBV1,
5d360b
+        .xlevel = 0x80000008,
5d360b
+        .model_id = "Intel Xeon Processor (Skylake, IBRS)",
5d360b
+    },
5d360b
+    {
5d360b
         .name = "Opteron_G1",
5d360b
         .level = 5,
5d360b
         .vendor = CPUID_VENDOR_AMD,
5d360b
@@ -1332,6 +1616,50 @@ static x86_def_t builtin_x86_defs[] = {
5d360b
         .xlevel = 0x8000000A,
5d360b
         .model_id = "AMD EPYC Processor",
5d360b
     },
5d360b
+    {
5d360b
+        .name = "EPYC-IBPB",
5d360b
+        .level = 0xd,
5d360b
+        .vendor = CPUID_VENDOR_AMD,
5d360b
+        .family = 23,
5d360b
+        .model = 1,
5d360b
+        .stepping = 2,
5d360b
+        .features[FEAT_1_EDX] =
5d360b
+            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | CPUID_CLFLUSH |
5d360b
+            CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA | CPUID_PGE |
5d360b
+            CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | CPUID_MCE |
5d360b
+            CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | CPUID_DE |
5d360b
+            CPUID_VME | CPUID_FP87,
5d360b
+        .features[FEAT_1_ECX] =
5d360b
+            CPUID_EXT_RDRAND | CPUID_EXT_F16C | CPUID_EXT_AVX |
5d360b
+            CPUID_EXT_XSAVE | CPUID_EXT_AES |  CPUID_EXT_POPCNT |
5d360b
+            CPUID_EXT_MOVBE | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 |
5d360b
+            CPUID_EXT_CX16 | CPUID_EXT_FMA | CPUID_EXT_SSSE3 |
5d360b
+            CPUID_EXT_MONITOR | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3,
5d360b
+        .features[FEAT_8000_0001_EDX] =
5d360b
+            CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_PDPE1GB |
5d360b
+            CPUID_EXT2_FFXSR | CPUID_EXT2_MMXEXT | CPUID_EXT2_NX |
5d360b
+            CPUID_EXT2_SYSCALL,
5d360b
+        .features[FEAT_8000_0001_ECX] =
5d360b
+            CPUID_EXT3_OSVW | CPUID_EXT3_3DNOWPREFETCH |
5d360b
+            CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A | CPUID_EXT3_ABM |
5d360b
+            CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM,
5d360b
+	.features[FEAT_8000_0008_EBX] =
5d360b
+	    CPUID_8000_0008_EBX_IBPB,
5d360b
+        .features[FEAT_7_0_EBX] =
5d360b
+            CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_AVX2 |
5d360b
+            CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_RDSEED |
5d360b
+            CPUID_7_0_EBX_ADX | CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_CLFLUSHOPT |
5d360b
+            CPUID_7_0_EBX_SHA_NI,
5d360b
+        /* Missing: XSAVES (not supported by some Linux versions,
5d360b
+         * including v4.1 to v4.12).
5d360b
+         * KVM doesn't yet expose any XSAVES state save component.
5d360b
+         */
5d360b
+        .features[FEAT_XSAVE] =
5d360b
+            CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC |
5d360b
+            CPUID_XSAVE_XGETBV1,
5d360b
+        .xlevel = 0x8000000A,
5d360b
+        .model_id = "AMD EPYC Processor (with IBPB)",
5d360b
+    },
5d360b
 };
5d360b
 
5d360b
 /**
5d360b
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
5d360b
index 7d815cd..a8a640a 100644
5d360b
--- a/target-i386/cpu.h
5d360b
+++ b/target-i386/cpu.h
5d360b
@@ -589,6 +589,9 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
5d360b
 
5d360b
 #define CPUID_7_0_EDX_AVX512_4VNNIW (1U << 2) /* AVX512 Neural Network Instructions */
5d360b
 #define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3) /* AVX512 Multiply Accumulation Single Precision */
5d360b
+#define CPUID_7_0_EDX_SPEC_CTRL     (1U << 26) /* Indirect Branch - Restrict Speculation */
5d360b
+
5d360b
+#define CPUID_8000_0008_EBX_IBPB    (1U << 12) /* Indirect Branch Prediction Barrier */
5d360b
 
5d360b
 #define CPUID_7_0_ECX_PKU      (1U << 3)
5d360b
 #define CPUID_7_0_ECX_OSPKE    (1U << 4)
5d360b
-- 
5d360b
1.8.3.1
5d360b