[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 21/54] i386: Add support for SPEC_CTRL MSR
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 21/54] i386: Add support for SPEC_CTRL MSR |
Date: |
Tue, 6 Feb 2018 13:14:42 -0600 |
From: Paolo Bonzini <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
(cherry picked from commit a33a2cfe2f771b360b3422f6cdf566a560860bfc)
Signed-off-by: Michael Roth <address@hidden>
---
target/i386/cpu.h | 3 +++
target/i386/kvm.c | 14 ++++++++++++++
target/i386/machine.c | 20 ++++++++++++++++++++
3 files changed, 37 insertions(+)
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index b086b1528b..03de74a8d3 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -335,6 +335,7 @@
#define MSR_IA32_APICBASE_BASE (0xfffffU<<12)
#define MSR_IA32_FEATURE_CONTROL 0x0000003a
#define MSR_TSC_ADJUST 0x0000003b
+#define MSR_IA32_SPEC_CTRL 0x48
#define MSR_IA32_TSCDEADLINE 0x6e0
#define FEATURE_CONTROL_LOCKED (1<<0)
@@ -1082,6 +1083,8 @@ typedef struct CPUX86State {
uint32_t pkru;
+ uint64_t spec_ctrl;
+
/* End of state preserved by INIT (dummy marker). */
struct {} end_init_save;
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index b1e32e95d3..3ac5302bc5 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -91,6 +91,7 @@ static bool has_msr_hv_synic;
static bool has_msr_hv_stimer;
static bool has_msr_hv_frequencies;
static bool has_msr_xss;
+static bool has_msr_spec_ctrl;
static bool has_msr_architectural_pmu;
static uint32_t num_architectural_pmu_counters;
@@ -1144,6 +1145,9 @@ static int kvm_get_supported_msrs(KVMState *s)
case HV_X64_MSR_TSC_FREQUENCY:
has_msr_hv_frequencies = true;
break;
+ case MSR_IA32_SPEC_CTRL:
+ has_msr_spec_ctrl = true;
+ break;
}
}
}
@@ -1626,6 +1630,9 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
if (has_msr_xss) {
kvm_msr_entry_add(cpu, MSR_IA32_XSS, env->xss);
}
+ if (has_msr_spec_ctrl) {
+ kvm_msr_entry_add(cpu, MSR_IA32_SPEC_CTRL, env->spec_ctrl);
+ }
#ifdef TARGET_X86_64
if (lm_capable_kernel) {
kvm_msr_entry_add(cpu, MSR_CSTAR, env->cstar);
@@ -1634,6 +1641,7 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
kvm_msr_entry_add(cpu, MSR_LSTAR, env->lstar);
}
#endif
+
/*
* The following MSRs have side effects on the guest or are too heavy
* for normal writeback. Limit them to reset or full state updates.
@@ -1998,6 +2006,9 @@ static int kvm_get_msrs(X86CPU *cpu)
if (has_msr_xss) {
kvm_msr_entry_add(cpu, MSR_IA32_XSS, 0);
}
+ if (has_msr_spec_ctrl) {
+ kvm_msr_entry_add(cpu, MSR_IA32_SPEC_CTRL, 0);
+ }
if (!env->tsc_valid) {
@@ -2347,6 +2358,9 @@ static int kvm_get_msrs(X86CPU *cpu)
env->mtrr_var[MSR_MTRRphysIndex(index)].base = msrs[i].data;
}
break;
+ case MSR_IA32_SPEC_CTRL:
+ env->spec_ctrl = msrs[i].data;
+ break;
}
}
diff --git a/target/i386/machine.c b/target/i386/machine.c
index df5ec359eb..361c05aedf 100644
--- a/target/i386/machine.c
+++ b/target/i386/machine.c
@@ -818,6 +818,25 @@ static const VMStateDescription vmstate_mcg_ext_ctl = {
}
};
+static bool spec_ctrl_needed(void *opaque)
+{
+ X86CPU *cpu = opaque;
+ CPUX86State *env = &cpu->env;
+
+ return env->spec_ctrl != 0;
+}
+
+static const VMStateDescription vmstate_spec_ctrl = {
+ .name = "cpu/spec_ctrl",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .needed = spec_ctrl_needed,
+ .fields = (VMStateField[]){
+ VMSTATE_UINT64(env.spec_ctrl, X86CPU),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
VMStateDescription vmstate_x86_cpu = {
.name = "cpu",
.version_id = 12,
@@ -936,6 +955,7 @@ VMStateDescription vmstate_x86_cpu = {
#ifdef TARGET_X86_64
&vmstate_pkru,
#endif
+ &vmstate_spec_ctrl,
&vmstate_mcg_ext_ctl,
NULL
}
--
2.11.0
- [Qemu-stable] [PATCH 11/54] hw/intc/arm_gicv3: Make reserved register addresses RAZ/WI, (continued)
- [Qemu-stable] [PATCH 11/54] hw/intc/arm_gicv3: Make reserved register addresses RAZ/WI, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 12/54] hw/intc/arm_gic: reserved register addresses are RAZ/WI, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 13/54] virtio_error: don't invoke status callbacks, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 14/54] vhost: remove assertion to prevent crash, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 18/54] scsi-disk: release AioContext in unaligned WRITE SAME case, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 15/54] hw/sd/pl181: Reset SD card on controller reset, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 17/54] hw/sd/ssi-sd: Reset SD card on controller reset, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 16/54] hw/sd/milkymist-memcard: Reset SD card on controller reset, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 20/54] i386: Change X86CPUDefinition::model_id to const char*, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 01/54] target/i386: Fix handling of VEX prefixes, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 21/54] i386: Add support for SPEC_CTRL MSR,
Michael Roth <=
- [Qemu-stable] [PATCH 23/54] i386: Add FEAT_8000_0008_EBX CPUID feature word, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 19/54] hw/pci-bridge: fix QEMU crash because of pcie-root-port, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 27/54] s390x: fix storage attributes migration for non-small guests, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 22/54] i386: Add spec-ctrl CPUID bit, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 26/54] linux-user: Fix locking order in fork_start(), Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 28/54] linux-headers: update to 4.15-rc1, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 37/54] spapr: Add pseries-2.12 machine type, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 35/54] linux-user/signal.c: Rename MC_* defines, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 29/54] linux-headers: update, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 33/54] usb-storage: Fix share-rw option parsing, Michael Roth, 2018/02/06