|
Pablo Greco |
e6a3ae |
From 127410386296459cf3eec4b12d7451afc50d2503 Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
e6a3ae |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Date: Fri, 22 Nov 2019 11:53:36 +0000
|
|
Pablo Greco |
e6a3ae |
Subject: [PATCH 03/16] target/i386: define a new MSR based feature word -
|
|
Pablo Greco |
e6a3ae |
FEAT_CORE_CAPABILITY
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Message-id: <20191122115348.25000-4-pbonzini@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Patchwork-id: 92603
|
|
Pablo Greco |
e6a3ae |
O-Subject: [RHEL8.2/rhel qemu-kvm PATCH 03/15] target/i386: define a new MSR based feature word - FEAT_CORE_CAPABILITY
|
|
Pablo Greco |
e6a3ae |
Bugzilla: 1689270
|
|
Pablo Greco |
e6a3ae |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
Pablo Greco |
e6a3ae |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
Pablo Greco |
e6a3ae |
RH-Acked-by: Maxim Levitsky <mlevitsk@redhat.com>
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
From: Xiaoyao Li <xiaoyao.li@linux.intel.com>
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
MSR IA32_CORE_CAPABILITY is a feature-enumerating MSR, which only
|
|
Pablo Greco |
e6a3ae |
enumerates the feature split lock detection (via bit 5) by now.
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
The existence of MSR IA32_CORE_CAPABILITY is enumerated by CPUID.7_0:EDX[30].
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
The latest kernel patches about them can be found here:
|
|
Pablo Greco |
e6a3ae |
https://lkml.org/lkml/2019/4/24/1909
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
Signed-off-by: Xiaoyao Li <xiaoyao.li@linux.intel.com>
|
|
Pablo Greco |
e6a3ae |
Message-Id: <20190617153654.916-1-xiaoyao.li@linux.intel.com>
|
|
Pablo Greco |
e6a3ae |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
Pablo Greco |
e6a3ae |
(cherry picked from commit 597360c0d8ebda9ca6f239db724a25bddec62b2f)
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
RHEL: context
|
|
Pablo Greco |
e6a3ae |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
Pablo Greco |
e6a3ae |
---
|
|
Pablo Greco |
e6a3ae |
target/i386/cpu.c | 22 +++++++++++++++++++++-
|
|
Pablo Greco |
e6a3ae |
target/i386/cpu.h | 5 +++++
|
|
Pablo Greco |
e6a3ae |
target/i386/kvm.c | 9 +++++++++
|
|
Pablo Greco |
e6a3ae |
3 files changed, 35 insertions(+), 1 deletion(-)
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
|
|
Pablo Greco |
e6a3ae |
index 8c1338f..52f1f33 100644
|
|
Pablo Greco |
e6a3ae |
--- a/target/i386/cpu.c
|
|
Pablo Greco |
e6a3ae |
+++ b/target/i386/cpu.c
|
|
Pablo Greco |
e6a3ae |
@@ -1045,7 +1045,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
|
|
Pablo Greco |
e6a3ae |
NULL, NULL, NULL, NULL,
|
|
Pablo Greco |
e6a3ae |
NULL, NULL, NULL, NULL,
|
|
Pablo Greco |
e6a3ae |
NULL, NULL, "spec-ctrl", "stibp",
|
|
Pablo Greco |
e6a3ae |
- NULL, "arch-capabilities", NULL, "ssbd",
|
|
Pablo Greco |
e6a3ae |
+ NULL, "arch-capabilities", "core-capability", "ssbd",
|
|
Pablo Greco |
e6a3ae |
},
|
|
Pablo Greco |
e6a3ae |
.cpuid = {
|
|
Pablo Greco |
e6a3ae |
.eax = 7,
|
|
Pablo Greco |
e6a3ae |
@@ -1163,6 +1163,26 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
|
|
Pablo Greco |
e6a3ae |
}
|
|
Pablo Greco |
e6a3ae |
},
|
|
Pablo Greco |
e6a3ae |
},
|
|
Pablo Greco |
e6a3ae |
+ [FEAT_CORE_CAPABILITY] = {
|
|
Pablo Greco |
e6a3ae |
+ .type = MSR_FEATURE_WORD,
|
|
Pablo Greco |
e6a3ae |
+ .feat_names = {
|
|
Pablo Greco |
e6a3ae |
+ NULL, NULL, NULL, NULL,
|
|
Pablo Greco |
e6a3ae |
+ NULL, "split-lock-detect", NULL, NULL,
|
|
Pablo Greco |
e6a3ae |
+ NULL, NULL, NULL, NULL,
|
|
Pablo Greco |
e6a3ae |
+ NULL, NULL, NULL, NULL,
|
|
Pablo Greco |
e6a3ae |
+ NULL, NULL, NULL, NULL,
|
|
Pablo Greco |
e6a3ae |
+ NULL, NULL, NULL, NULL,
|
|
Pablo Greco |
e6a3ae |
+ NULL, NULL, NULL, NULL,
|
|
Pablo Greco |
e6a3ae |
+ NULL, NULL, NULL, NULL,
|
|
Pablo Greco |
e6a3ae |
+ },
|
|
Pablo Greco |
e6a3ae |
+ .msr = {
|
|
Pablo Greco |
e6a3ae |
+ .index = MSR_IA32_CORE_CAPABILITY,
|
|
Pablo Greco |
e6a3ae |
+ .cpuid_dep = {
|
|
Pablo Greco |
e6a3ae |
+ FEAT_7_0_EDX,
|
|
Pablo Greco |
e6a3ae |
+ CPUID_7_0_EDX_CORE_CAPABILITY,
|
|
Pablo Greco |
e6a3ae |
+ },
|
|
Pablo Greco |
e6a3ae |
+ },
|
|
Pablo Greco |
e6a3ae |
+ },
|
|
Pablo Greco |
e6a3ae |
};
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
typedef struct X86RegisterInfo32 {
|
|
Pablo Greco |
e6a3ae |
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
|
|
Pablo Greco |
e6a3ae |
index 1ad54bd..f9b93be 100644
|
|
Pablo Greco |
e6a3ae |
--- a/target/i386/cpu.h
|
|
Pablo Greco |
e6a3ae |
+++ b/target/i386/cpu.h
|
|
Pablo Greco |
e6a3ae |
@@ -353,6 +353,7 @@ typedef enum X86Seg {
|
|
Pablo Greco |
e6a3ae |
#define MSR_IA32_SPEC_CTRL 0x48
|
|
Pablo Greco |
e6a3ae |
#define MSR_VIRT_SSBD 0xc001011f
|
|
Pablo Greco |
e6a3ae |
#define MSR_IA32_PRED_CMD 0x49
|
|
Pablo Greco |
e6a3ae |
+#define MSR_IA32_CORE_CAPABILITY 0xcf
|
|
Pablo Greco |
e6a3ae |
#define MSR_IA32_ARCH_CAPABILITIES 0x10a
|
|
Pablo Greco |
e6a3ae |
#define MSR_IA32_TSCDEADLINE 0x6e0
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
@@ -501,6 +502,7 @@ typedef enum FeatureWord {
|
|
Pablo Greco |
e6a3ae |
FEAT_XSAVE_COMP_LO, /* CPUID[EAX=0xd,ECX=0].EAX */
|
|
Pablo Greco |
e6a3ae |
FEAT_XSAVE_COMP_HI, /* CPUID[EAX=0xd,ECX=0].EDX */
|
|
Pablo Greco |
e6a3ae |
FEAT_ARCH_CAPABILITIES,
|
|
Pablo Greco |
e6a3ae |
+ FEAT_CORE_CAPABILITY,
|
|
Pablo Greco |
e6a3ae |
FEATURE_WORDS,
|
|
Pablo Greco |
e6a3ae |
} FeatureWord;
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
@@ -690,6 +692,7 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
|
|
Pablo Greco |
e6a3ae |
#define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3) /* AVX512 Multiply Accumulation Single Precision */
|
|
Pablo Greco |
e6a3ae |
#define CPUID_7_0_EDX_SPEC_CTRL (1U << 26) /* Speculation Control */
|
|
Pablo Greco |
e6a3ae |
#define CPUID_7_0_EDX_ARCH_CAPABILITIES (1U << 29) /*Arch Capabilities*/
|
|
Pablo Greco |
e6a3ae |
+#define CPUID_7_0_EDX_CORE_CAPABILITY (1U << 30) /*Core Capability*/
|
|
Pablo Greco |
e6a3ae |
#define CPUID_7_0_EDX_SPEC_CTRL_SSBD (1U << 31) /* Speculative Store Bypass Disable */
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
#define KVM_HINTS_DEDICATED (1U << 0)
|
|
Pablo Greco |
e6a3ae |
@@ -744,6 +747,8 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
|
|
Pablo Greco |
e6a3ae |
#define MSR_ARCH_CAP_SKIP_L1DFL_VMENTRY (1U << 3)
|
|
Pablo Greco |
e6a3ae |
#define MSR_ARCH_CAP_SSB_NO (1U << 4)
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
+#define MSR_CORE_CAP_SPLIT_LOCK_DETECT (1U << 5)
|
|
Pablo Greco |
e6a3ae |
+
|
|
Pablo Greco |
e6a3ae |
#ifndef HYPERV_SPINLOCK_NEVER_RETRY
|
|
Pablo Greco |
e6a3ae |
#define HYPERV_SPINLOCK_NEVER_RETRY 0xFFFFFFFF
|
|
Pablo Greco |
e6a3ae |
#endif
|
|
Pablo Greco |
e6a3ae |
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
|
|
Pablo Greco |
e6a3ae |
index da5f07e..849a11a 100644
|
|
Pablo Greco |
e6a3ae |
--- a/target/i386/kvm.c
|
|
Pablo Greco |
e6a3ae |
+++ b/target/i386/kvm.c
|
|
Pablo Greco |
e6a3ae |
@@ -95,6 +95,7 @@ static bool has_msr_spec_ctrl;
|
|
Pablo Greco |
e6a3ae |
static bool has_msr_virt_ssbd;
|
|
Pablo Greco |
e6a3ae |
static bool has_msr_smi_count;
|
|
Pablo Greco |
e6a3ae |
static bool has_msr_arch_capabs;
|
|
Pablo Greco |
e6a3ae |
+static bool has_msr_core_capabs;
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
static uint32_t has_architectural_pmu_version;
|
|
Pablo Greco |
e6a3ae |
static uint32_t num_architectural_pmu_gp_counters;
|
|
Pablo Greco |
e6a3ae |
@@ -1428,6 +1429,9 @@ static int kvm_get_supported_msrs(KVMState *s)
|
|
Pablo Greco |
e6a3ae |
case MSR_IA32_ARCH_CAPABILITIES:
|
|
Pablo Greco |
e6a3ae |
has_msr_arch_capabs = true;
|
|
Pablo Greco |
e6a3ae |
break;
|
|
Pablo Greco |
e6a3ae |
+ case MSR_IA32_CORE_CAPABILITY:
|
|
Pablo Greco |
e6a3ae |
+ has_msr_core_capabs = true;
|
|
Pablo Greco |
e6a3ae |
+ break;
|
|
Pablo Greco |
e6a3ae |
}
|
|
Pablo Greco |
e6a3ae |
}
|
|
Pablo Greco |
e6a3ae |
}
|
|
Pablo Greco |
e6a3ae |
@@ -1947,6 +1951,11 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
|
|
Pablo Greco |
e6a3ae |
env->features[FEAT_ARCH_CAPABILITIES]);
|
|
Pablo Greco |
e6a3ae |
}
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
+ if (has_msr_core_capabs) {
|
|
Pablo Greco |
e6a3ae |
+ kvm_msr_entry_add(cpu, MSR_IA32_CORE_CAPABILITY,
|
|
Pablo Greco |
e6a3ae |
+ env->features[FEAT_CORE_CAPABILITY]);
|
|
Pablo Greco |
e6a3ae |
+ }
|
|
Pablo Greco |
e6a3ae |
+
|
|
Pablo Greco |
e6a3ae |
/*
|
|
Pablo Greco |
e6a3ae |
* The following MSRs have side effects on the guest or are too heavy
|
|
Pablo Greco |
e6a3ae |
* for normal writeback. Limit them to reset or full state updates.
|
|
Pablo Greco |
e6a3ae |
--
|
|
Pablo Greco |
e6a3ae |
1.8.3.1
|
|
Pablo Greco |
e6a3ae |
|