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