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