|
|
26ba25 |
From 96f6d8855246a66bde59fd3e663bee0da00f709b Mon Sep 17 00:00:00 2001
|
|
|
26ba25 |
From: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
26ba25 |
Date: Wed, 13 Jun 2018 18:08:11 +0200
|
|
|
26ba25 |
Subject: [PATCH 152/268] i386: Define the Virt SSBD MSR and handling of it
|
|
|
26ba25 |
(CVE-2018-3639)
|
|
|
26ba25 |
MIME-Version: 1.0
|
|
|
26ba25 |
Content-Type: text/plain; charset=UTF-8
|
|
|
26ba25 |
Content-Transfer-Encoding: 8bit
|
|
|
26ba25 |
|
|
|
26ba25 |
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
26ba25 |
Message-id: <20180613180812.28169-2-ehabkost@redhat.com>
|
|
|
26ba25 |
Patchwork-id: 80677
|
|
|
26ba25 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 1/2] i386: Define the Virt SSBD MSR and handling of it (CVE-2018-3639)
|
|
|
26ba25 |
Bugzilla: 1574216
|
|
|
26ba25 |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
26ba25 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
26ba25 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
26ba25 |
|
|
|
26ba25 |
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
|
|
|
26ba25 |
|
|
|
26ba25 |
"Some AMD processors only support a non-architectural means of enabling
|
|
|
26ba25 |
speculative store bypass disable (SSBD). To allow a simplified view of
|
|
|
26ba25 |
this to a guest, an architectural definition has been created through a new
|
|
|
26ba25 |
CPUID bit, 0x80000008_EBX[25], and a new MSR, 0xc001011f. With this, a
|
|
|
26ba25 |
hypervisor can virtualize the existence of this definition and provide an
|
|
|
26ba25 |
architectural method for using SSBD to a guest.
|
|
|
26ba25 |
|
|
|
26ba25 |
Add the new CPUID feature, the new MSR and update the existing SSBD
|
|
|
26ba25 |
support to use this MSR when present." (from x86/speculation: Add virtualized
|
|
|
26ba25 |
speculative store bypass disable support in Linux).
|
|
|
26ba25 |
|
|
|
26ba25 |
Backport conflicts:
|
|
|
26ba25 |
* target-i386/machine.c: trivial conflict with vmstate_xsave section
|
|
|
26ba25 |
|
|
|
26ba25 |
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
|
|
|
26ba25 |
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
26ba25 |
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
26ba25 |
Message-Id: <20180521215424.13520-4-berrange@redhat.com>
|
|
|
26ba25 |
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
26ba25 |
(cherry picked from commit cfeea0c021db6234c154dbc723730e81553924ff)
|
|
|
26ba25 |
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
26ba25 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
26ba25 |
---
|
|
|
26ba25 |
target/i386/cpu.h | 2 ++
|
|
|
26ba25 |
target/i386/kvm.c | 16 ++++++++++++++--
|
|
|
26ba25 |
target/i386/machine.c | 20 ++++++++++++++++++++
|
|
|
26ba25 |
3 files changed, 36 insertions(+), 2 deletions(-)
|
|
|
26ba25 |
|
|
|
26ba25 |
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
|
|
|
26ba25 |
index 88fdf80..c47db96 100644
|
|
|
26ba25 |
--- a/target/i386/cpu.h
|
|
|
26ba25 |
+++ b/target/i386/cpu.h
|
|
|
26ba25 |
@@ -351,6 +351,7 @@ typedef enum X86Seg {
|
|
|
26ba25 |
#define MSR_IA32_FEATURE_CONTROL 0x0000003a
|
|
|
26ba25 |
#define MSR_TSC_ADJUST 0x0000003b
|
|
|
26ba25 |
#define MSR_IA32_SPEC_CTRL 0x48
|
|
|
26ba25 |
+#define MSR_VIRT_SSBD 0xc001011f
|
|
|
26ba25 |
#define MSR_IA32_TSCDEADLINE 0x6e0
|
|
|
26ba25 |
|
|
|
26ba25 |
#define FEATURE_CONTROL_LOCKED (1<<0)
|
|
|
26ba25 |
@@ -1208,6 +1209,7 @@ typedef struct CPUX86State {
|
|
|
26ba25 |
uint32_t pkru;
|
|
|
26ba25 |
|
|
|
26ba25 |
uint64_t spec_ctrl;
|
|
|
26ba25 |
+ uint64_t virt_ssbd;
|
|
|
26ba25 |
|
|
|
26ba25 |
/* End of state preserved by INIT (dummy marker). */
|
|
|
26ba25 |
struct {} end_init_save;
|
|
|
26ba25 |
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
|
|
|
26ba25 |
index bb5e485..00f2141 100644
|
|
|
26ba25 |
--- a/target/i386/kvm.c
|
|
|
26ba25 |
+++ b/target/i386/kvm.c
|
|
|
26ba25 |
@@ -92,6 +92,7 @@ static bool has_msr_hv_stimer;
|
|
|
26ba25 |
static bool has_msr_hv_frequencies;
|
|
|
26ba25 |
static bool has_msr_xss;
|
|
|
26ba25 |
static bool has_msr_spec_ctrl;
|
|
|
26ba25 |
+static bool has_msr_virt_ssbd;
|
|
|
26ba25 |
static bool has_msr_smi_count;
|
|
|
26ba25 |
|
|
|
26ba25 |
static uint32_t has_architectural_pmu_version;
|
|
|
26ba25 |
@@ -1248,6 +1249,9 @@ static int kvm_get_supported_msrs(KVMState *s)
|
|
|
26ba25 |
case MSR_IA32_SPEC_CTRL:
|
|
|
26ba25 |
has_msr_spec_ctrl = true;
|
|
|
26ba25 |
break;
|
|
|
26ba25 |
+ case MSR_VIRT_SSBD:
|
|
|
26ba25 |
+ has_msr_virt_ssbd = true;
|
|
|
26ba25 |
+ break;
|
|
|
26ba25 |
}
|
|
|
26ba25 |
}
|
|
|
26ba25 |
}
|
|
|
26ba25 |
@@ -1736,6 +1740,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
|
|
|
26ba25 |
if (has_msr_spec_ctrl) {
|
|
|
26ba25 |
kvm_msr_entry_add(cpu, MSR_IA32_SPEC_CTRL, env->spec_ctrl);
|
|
|
26ba25 |
}
|
|
|
26ba25 |
+ if (has_msr_virt_ssbd) {
|
|
|
26ba25 |
+ kvm_msr_entry_add(cpu, MSR_VIRT_SSBD, env->virt_ssbd);
|
|
|
26ba25 |
+ }
|
|
|
26ba25 |
+
|
|
|
26ba25 |
#ifdef TARGET_X86_64
|
|
|
26ba25 |
if (lm_capable_kernel) {
|
|
|
26ba25 |
kvm_msr_entry_add(cpu, MSR_CSTAR, env->cstar);
|
|
|
26ba25 |
@@ -2107,8 +2115,9 @@ static int kvm_get_msrs(X86CPU *cpu)
|
|
|
26ba25 |
if (has_msr_spec_ctrl) {
|
|
|
26ba25 |
kvm_msr_entry_add(cpu, MSR_IA32_SPEC_CTRL, 0);
|
|
|
26ba25 |
}
|
|
|
26ba25 |
-
|
|
|
26ba25 |
-
|
|
|
26ba25 |
+ if (has_msr_virt_ssbd) {
|
|
|
26ba25 |
+ kvm_msr_entry_add(cpu, MSR_VIRT_SSBD, 0);
|
|
|
26ba25 |
+ }
|
|
|
26ba25 |
if (!env->tsc_valid) {
|
|
|
26ba25 |
kvm_msr_entry_add(cpu, MSR_IA32_TSC, 0);
|
|
|
26ba25 |
env->tsc_valid = !runstate_is_running();
|
|
|
26ba25 |
@@ -2474,6 +2483,9 @@ static int kvm_get_msrs(X86CPU *cpu)
|
|
|
26ba25 |
case MSR_IA32_SPEC_CTRL:
|
|
|
26ba25 |
env->spec_ctrl = msrs[i].data;
|
|
|
26ba25 |
break;
|
|
|
26ba25 |
+ case MSR_VIRT_SSBD:
|
|
|
26ba25 |
+ env->virt_ssbd = msrs[i].data;
|
|
|
26ba25 |
+ break;
|
|
|
26ba25 |
case MSR_IA32_RTIT_CTL:
|
|
|
26ba25 |
env->msr_rtit_ctrl = msrs[i].data;
|
|
|
26ba25 |
break;
|
|
|
26ba25 |
diff --git a/target/i386/machine.c b/target/i386/machine.c
|
|
|
26ba25 |
index c9a3b5c..5e9a19b 100644
|
|
|
26ba25 |
--- a/target/i386/machine.c
|
|
|
26ba25 |
+++ b/target/i386/machine.c
|
|
|
26ba25 |
@@ -913,6 +913,25 @@ static const VMStateDescription vmstate_xsave ={
|
|
|
26ba25 |
}
|
|
|
26ba25 |
};
|
|
|
26ba25 |
|
|
|
26ba25 |
+static bool virt_ssbd_needed(void *opaque)
|
|
|
26ba25 |
+{
|
|
|
26ba25 |
+ X86CPU *cpu = opaque;
|
|
|
26ba25 |
+ CPUX86State *env = &cpu->env;
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+ return env->virt_ssbd != 0;
|
|
|
26ba25 |
+}
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+static const VMStateDescription vmstate_msr_virt_ssbd = {
|
|
|
26ba25 |
+ .name = "cpu/virt_ssbd",
|
|
|
26ba25 |
+ .version_id = 1,
|
|
|
26ba25 |
+ .minimum_version_id = 1,
|
|
|
26ba25 |
+ .needed = virt_ssbd_needed,
|
|
|
26ba25 |
+ .fields = (VMStateField[]){
|
|
|
26ba25 |
+ VMSTATE_UINT64(env.virt_ssbd, X86CPU),
|
|
|
26ba25 |
+ VMSTATE_END_OF_LIST()
|
|
|
26ba25 |
+ }
|
|
|
26ba25 |
+};
|
|
|
26ba25 |
+
|
|
|
26ba25 |
VMStateDescription vmstate_x86_cpu = {
|
|
|
26ba25 |
.name = "cpu",
|
|
|
26ba25 |
.version_id = 12,
|
|
|
26ba25 |
@@ -1036,6 +1055,7 @@ VMStateDescription vmstate_x86_cpu = {
|
|
|
26ba25 |
&vmstate_mcg_ext_ctl,
|
|
|
26ba25 |
&vmstate_msr_intel_pt,
|
|
|
26ba25 |
&vmstate_xsave,
|
|
|
26ba25 |
+ &vmstate_msr_virt_ssbd,
|
|
|
26ba25 |
NULL
|
|
|
26ba25 |
}
|
|
|
26ba25 |
};
|
|
|
26ba25 |
--
|
|
|
26ba25 |
1.8.3.1
|
|
|
26ba25 |
|