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