|
|
4ec855 |
From 9c3757a2d7302918456da459a8d188bb41299891 Mon Sep 17 00:00:00 2001
|
|
|
4ec855 |
From: Tao Xu <tao3.xu@intel.com>
|
|
|
4ec855 |
Date: Fri, 11 Oct 2019 15:41:03 +0800
|
|
|
4ec855 |
Subject: [PATCH 11/11] target/i386: Add support for save/load
|
|
|
4ec855 |
IA32_UMWAIT_CONTROL MSR
|
|
|
4ec855 |
|
|
|
4ec855 |
RH-Author: plai@redhat.com
|
|
|
4ec855 |
Message-id: <1574797015-32564-8-git-send-email-plai@redhat.com>
|
|
|
4ec855 |
Patchwork-id: 92693
|
|
|
4ec855 |
O-Subject: [RHEL8.2 qemu-kvm PATCH 7/7] target/i386: Add support for save/load IA32_UMWAIT_CONTROL MSR
|
|
|
4ec855 |
Bugzilla: 1634827
|
|
|
4ec855 |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
4ec855 |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
4ec855 |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
4ec855 |
|
|
|
4ec855 |
UMWAIT and TPAUSE instructions use 32bits IA32_UMWAIT_CONTROL at MSR
|
|
|
4ec855 |
index E1H to determines the maximum time in TSC-quanta that the processor
|
|
|
4ec855 |
can reside in either C0.1 or C0.2.
|
|
|
4ec855 |
|
|
|
4ec855 |
This patch is to Add support for save/load IA32_UMWAIT_CONTROL MSR in
|
|
|
4ec855 |
guest.
|
|
|
4ec855 |
|
|
|
4ec855 |
Co-developed-by: Jingqi Liu <jingqi.liu@intel.com>
|
|
|
4ec855 |
Signed-off-by: Jingqi Liu <jingqi.liu@intel.com>
|
|
|
4ec855 |
Signed-off-by: Tao Xu <tao3.xu@intel.com>
|
|
|
4ec855 |
Message-Id: <20191011074103.30393-3-tao3.xu@intel.com>
|
|
|
4ec855 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4ec855 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
4ec855 |
---
|
|
|
4ec855 |
target/i386/cpu.h | 2 ++
|
|
|
4ec855 |
target/i386/kvm.c | 13 +++++++++++++
|
|
|
4ec855 |
target/i386/machine.c | 20 ++++++++++++++++++++
|
|
|
4ec855 |
3 files changed, 35 insertions(+)
|
|
|
4ec855 |
|
|
|
4ec855 |
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
|
|
|
4ec855 |
index fac98aa..ecbe4f0 100644
|
|
|
4ec855 |
--- a/target/i386/cpu.h
|
|
|
4ec855 |
+++ b/target/i386/cpu.h
|
|
|
4ec855 |
@@ -461,6 +461,7 @@ typedef enum X86Seg {
|
|
|
4ec855 |
|
|
|
4ec855 |
#define MSR_IA32_BNDCFGS 0x00000d90
|
|
|
4ec855 |
#define MSR_IA32_XSS 0x00000da0
|
|
|
4ec855 |
+#define MSR_IA32_UMWAIT_CONTROL 0xe1
|
|
|
4ec855 |
|
|
|
4ec855 |
#define MSR_IA32_VMX_BASIC 0x00000480
|
|
|
4ec855 |
#define MSR_IA32_VMX_PINBASED_CTLS 0x00000481
|
|
|
4ec855 |
@@ -1510,6 +1511,7 @@ typedef struct CPUX86State {
|
|
|
4ec855 |
uint16_t fpregs_format_vmstate;
|
|
|
4ec855 |
|
|
|
4ec855 |
uint64_t xss;
|
|
|
4ec855 |
+ uint32_t umwait;
|
|
|
4ec855 |
|
|
|
4ec855 |
TPRAccess tpr_access_type;
|
|
|
4ec855 |
} CPUX86State;
|
|
|
4ec855 |
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
|
|
|
4ec855 |
index 0fd5650..ad58bfb 100644
|
|
|
4ec855 |
--- a/target/i386/kvm.c
|
|
|
4ec855 |
+++ b/target/i386/kvm.c
|
|
|
4ec855 |
@@ -91,6 +91,7 @@ static bool has_msr_hv_synic;
|
|
|
4ec855 |
static bool has_msr_hv_stimer;
|
|
|
4ec855 |
static bool has_msr_hv_frequencies;
|
|
|
4ec855 |
static bool has_msr_xss;
|
|
|
4ec855 |
+static bool has_msr_umwait;
|
|
|
4ec855 |
static bool has_msr_spec_ctrl;
|
|
|
4ec855 |
static bool has_msr_tsx_ctrl;
|
|
|
4ec855 |
static bool has_msr_virt_ssbd;
|
|
|
4ec855 |
@@ -1450,6 +1451,9 @@ static int kvm_get_supported_msrs(KVMState *s)
|
|
|
4ec855 |
case MSR_IA32_XSS:
|
|
|
4ec855 |
has_msr_xss = true;
|
|
|
4ec855 |
break;
|
|
|
4ec855 |
+ case MSR_IA32_UMWAIT_CONTROL:
|
|
|
4ec855 |
+ has_msr_umwait = true;
|
|
|
4ec855 |
+ break;
|
|
|
4ec855 |
case HV_X64_MSR_CRASH_CTL:
|
|
|
4ec855 |
has_msr_hv_crash = true;
|
|
|
4ec855 |
break;
|
|
|
4ec855 |
@@ -2134,6 +2138,9 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
|
|
|
4ec855 |
if (has_msr_xss) {
|
|
|
4ec855 |
kvm_msr_entry_add(cpu, MSR_IA32_XSS, env->xss);
|
|
|
4ec855 |
}
|
|
|
4ec855 |
+ if (has_msr_umwait) {
|
|
|
4ec855 |
+ kvm_msr_entry_add(cpu, MSR_IA32_UMWAIT_CONTROL, env->umwait);
|
|
|
4ec855 |
+ }
|
|
|
4ec855 |
if (has_msr_spec_ctrl) {
|
|
|
4ec855 |
kvm_msr_entry_add(cpu, MSR_IA32_SPEC_CTRL, env->spec_ctrl);
|
|
|
4ec855 |
}
|
|
|
4ec855 |
@@ -2533,6 +2540,9 @@ static int kvm_get_msrs(X86CPU *cpu)
|
|
|
4ec855 |
if (has_msr_xss) {
|
|
|
4ec855 |
kvm_msr_entry_add(cpu, MSR_IA32_XSS, 0);
|
|
|
4ec855 |
}
|
|
|
4ec855 |
+ if (has_msr_umwait) {
|
|
|
4ec855 |
+ kvm_msr_entry_add(cpu, MSR_IA32_UMWAIT_CONTROL, 0);
|
|
|
4ec855 |
+ }
|
|
|
4ec855 |
if (has_msr_spec_ctrl) {
|
|
|
4ec855 |
kvm_msr_entry_add(cpu, MSR_IA32_SPEC_CTRL, 0);
|
|
|
4ec855 |
}
|
|
|
4ec855 |
@@ -2780,6 +2790,9 @@ static int kvm_get_msrs(X86CPU *cpu)
|
|
|
4ec855 |
case MSR_IA32_XSS:
|
|
|
4ec855 |
env->xss = msrs[i].data;
|
|
|
4ec855 |
break;
|
|
|
4ec855 |
+ case MSR_IA32_UMWAIT_CONTROL:
|
|
|
4ec855 |
+ env->umwait = msrs[i].data;
|
|
|
4ec855 |
+ break;
|
|
|
4ec855 |
default:
|
|
|
4ec855 |
if (msrs[i].index >= MSR_MC0_CTL &&
|
|
|
4ec855 |
msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) {
|
|
|
4ec855 |
diff --git a/target/i386/machine.c b/target/i386/machine.c
|
|
|
4ec855 |
index 76b173c..960cb51 100644
|
|
|
4ec855 |
--- a/target/i386/machine.c
|
|
|
4ec855 |
+++ b/target/i386/machine.c
|
|
|
4ec855 |
@@ -894,6 +894,25 @@ static const VMStateDescription vmstate_xss = {
|
|
|
4ec855 |
}
|
|
|
4ec855 |
};
|
|
|
4ec855 |
|
|
|
4ec855 |
+static bool umwait_needed(void *opaque)
|
|
|
4ec855 |
+{
|
|
|
4ec855 |
+ X86CPU *cpu = opaque;
|
|
|
4ec855 |
+ CPUX86State *env = &cpu->env;
|
|
|
4ec855 |
+
|
|
|
4ec855 |
+ return env->umwait != 0;
|
|
|
4ec855 |
+}
|
|
|
4ec855 |
+
|
|
|
4ec855 |
+static const VMStateDescription vmstate_umwait = {
|
|
|
4ec855 |
+ .name = "cpu/umwait",
|
|
|
4ec855 |
+ .version_id = 1,
|
|
|
4ec855 |
+ .minimum_version_id = 1,
|
|
|
4ec855 |
+ .needed = umwait_needed,
|
|
|
4ec855 |
+ .fields = (VMStateField[]) {
|
|
|
4ec855 |
+ VMSTATE_UINT32(env.umwait, X86CPU),
|
|
|
4ec855 |
+ VMSTATE_END_OF_LIST()
|
|
|
4ec855 |
+ }
|
|
|
4ec855 |
+};
|
|
|
4ec855 |
+
|
|
|
4ec855 |
#ifdef TARGET_X86_64
|
|
|
4ec855 |
static bool pkru_needed(void *opaque)
|
|
|
4ec855 |
{
|
|
|
4ec855 |
@@ -1360,6 +1379,7 @@ VMStateDescription vmstate_x86_cpu = {
|
|
|
4ec855 |
&vmstate_msr_hyperv_stimer,
|
|
|
4ec855 |
&vmstate_avx512,
|
|
|
4ec855 |
&vmstate_xss,
|
|
|
4ec855 |
+ &vmstate_umwait,
|
|
|
4ec855 |
&vmstate_tsc_khz,
|
|
|
4ec855 |
&vmstate_msr_smi_count,
|
|
|
4ec855 |
#ifdef TARGET_X86_64
|
|
|
4ec855 |
--
|
|
|
4ec855 |
1.8.3.1
|
|
|
4ec855 |
|