|
|
ae23c9 |
From 8b64571f3ce90fc14c571ea588f608bce4328d34 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: "plai@redhat.com" <plai@redhat.com>
|
|
|
ae23c9 |
Date: Wed, 3 Apr 2019 15:54:32 +0100
|
|
|
ae23c9 |
Subject: [PATCH 08/10] x86: define a new MSR based feature word --
|
|
|
ae23c9 |
FEATURE_WORDS_ARCH_CAPABILITIES
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: plai@redhat.com
|
|
|
ae23c9 |
Message-id: <1554306874-28796-9-git-send-email-plai@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 85385
|
|
|
ae23c9 |
O-Subject: [RHEL8.1 qemu-kvm PATCH resend 08/10] x86: define a new MSR based feature word -- FEATURE_WORDS_ARCH_CAPABILITIES
|
|
|
ae23c9 |
Bugzilla: 1561761
|
|
|
ae23c9 |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
From: Robert Hoo <robert.hu@linux.intel.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Note RSBA is specially treated -- no matter host support it or not, qemu
|
|
|
ae23c9 |
pretends it is supported.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: Robert Hoo <robert.hu@linux.intel.com>
|
|
|
ae23c9 |
Message-Id: <1539578845-37944-4-git-send-email-robert.hu@linux.intel.com>
|
|
|
ae23c9 |
[ehabkost: removed automatic enabling of RSBA]
|
|
|
ae23c9 |
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
(cherry picked from commit d86f963694df27f11b3681ffd225c9362de1b634)
|
|
|
ae23c9 |
Signed-off-by: Paul Lai <plai@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
target/i386/cpu.c | 24 +++++++++++++++++++++++-
|
|
|
ae23c9 |
target/i386/cpu.h | 8 ++++++++
|
|
|
ae23c9 |
target/i386/kvm.c | 11 +++++++++++
|
|
|
ae23c9 |
3 files changed, 42 insertions(+), 1 deletion(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
|
|
|
ae23c9 |
index a0fdd3a..8750f64 100644
|
|
|
ae23c9 |
--- a/target/i386/cpu.c
|
|
|
ae23c9 |
+++ b/target/i386/cpu.c
|
|
|
ae23c9 |
@@ -1143,6 +1143,27 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
|
|
|
ae23c9 |
},
|
|
|
ae23c9 |
.tcg_features = ~0U,
|
|
|
ae23c9 |
},
|
|
|
ae23c9 |
+ /*Below are MSR exposed features*/
|
|
|
ae23c9 |
+ [FEAT_ARCH_CAPABILITIES] = {
|
|
|
ae23c9 |
+ .type = MSR_FEATURE_WORD,
|
|
|
ae23c9 |
+ .feat_names = {
|
|
|
ae23c9 |
+ "rdctl-no", "ibrs-all", "rsba", "skip-l1dfl-vmentry",
|
|
|
ae23c9 |
+ "ssb-no", NULL, NULL, NULL,
|
|
|
ae23c9 |
+ NULL, NULL, NULL, NULL,
|
|
|
ae23c9 |
+ NULL, NULL, NULL, NULL,
|
|
|
ae23c9 |
+ NULL, NULL, NULL, NULL,
|
|
|
ae23c9 |
+ NULL, NULL, NULL, NULL,
|
|
|
ae23c9 |
+ NULL, NULL, NULL, NULL,
|
|
|
ae23c9 |
+ NULL, NULL, NULL, NULL,
|
|
|
ae23c9 |
+ },
|
|
|
ae23c9 |
+ .msr = {
|
|
|
ae23c9 |
+ .index = MSR_IA32_ARCH_CAPABILITIES,
|
|
|
ae23c9 |
+ .cpuid_dep = {
|
|
|
ae23c9 |
+ FEAT_7_0_EDX,
|
|
|
ae23c9 |
+ CPUID_7_0_EDX_ARCH_CAPABILITIES
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+ },
|
|
|
ae23c9 |
+ },
|
|
|
ae23c9 |
};
|
|
|
ae23c9 |
|
|
|
ae23c9 |
typedef struct X86RegisterInfo32 {
|
|
|
ae23c9 |
@@ -3665,7 +3686,8 @@ static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,
|
|
|
ae23c9 |
wi->cpuid.reg);
|
|
|
ae23c9 |
break;
|
|
|
ae23c9 |
case MSR_FEATURE_WORD:
|
|
|
ae23c9 |
- r = kvm_arch_get_supported_msr_feature(kvm_state, wi->msr.index);
|
|
|
ae23c9 |
+ r = kvm_arch_get_supported_msr_feature(kvm_state,
|
|
|
ae23c9 |
+ wi->msr.index);
|
|
|
ae23c9 |
break;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
} else if (hvf_enabled()) {
|
|
|
ae23c9 |
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
|
|
|
ae23c9 |
index dd4493e..63f692f 100644
|
|
|
ae23c9 |
--- a/target/i386/cpu.h
|
|
|
ae23c9 |
+++ b/target/i386/cpu.h
|
|
|
ae23c9 |
@@ -500,6 +500,7 @@ typedef enum FeatureWord {
|
|
|
ae23c9 |
FEAT_6_EAX, /* CPUID[6].EAX */
|
|
|
ae23c9 |
FEAT_XSAVE_COMP_LO, /* CPUID[EAX=0xd,ECX=0].EAX */
|
|
|
ae23c9 |
FEAT_XSAVE_COMP_HI, /* CPUID[EAX=0xd,ECX=0].EDX */
|
|
|
ae23c9 |
+ FEAT_ARCH_CAPABILITIES,
|
|
|
ae23c9 |
FEATURE_WORDS,
|
|
|
ae23c9 |
} FeatureWord;
|
|
|
ae23c9 |
|
|
|
ae23c9 |
@@ -729,6 +730,13 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
|
|
|
ae23c9 |
#define CPUID_TOPOLOGY_LEVEL_SMT (1U << 8)
|
|
|
ae23c9 |
#define CPUID_TOPOLOGY_LEVEL_CORE (2U << 8)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+/* MSR Feature Bits */
|
|
|
ae23c9 |
+#define MSR_ARCH_CAP_RDCL_NO (1U << 0)
|
|
|
ae23c9 |
+#define MSR_ARCH_CAP_IBRS_ALL (1U << 1)
|
|
|
ae23c9 |
+#define MSR_ARCH_CAP_RSBA (1U << 2)
|
|
|
ae23c9 |
+#define MSR_ARCH_CAP_SKIP_L1DFL_VMENTRY (1U << 3)
|
|
|
ae23c9 |
+#define MSR_ARCH_CAP_SSB_NO (1U << 4)
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
#ifndef HYPERV_SPINLOCK_NEVER_RETRY
|
|
|
ae23c9 |
#define HYPERV_SPINLOCK_NEVER_RETRY 0xFFFFFFFF
|
|
|
ae23c9 |
#endif
|
|
|
ae23c9 |
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
|
|
|
ae23c9 |
index 096ed24..f1626a4 100644
|
|
|
ae23c9 |
--- a/target/i386/kvm.c
|
|
|
ae23c9 |
+++ b/target/i386/kvm.c
|
|
|
ae23c9 |
@@ -1833,6 +1833,17 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
#endif
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+ /* If host supports feature MSR, write down. */
|
|
|
ae23c9 |
+ if (kvm_feature_msrs) {
|
|
|
ae23c9 |
+ int i;
|
|
|
ae23c9 |
+ for (i = 0; i < kvm_feature_msrs->nmsrs; i++)
|
|
|
ae23c9 |
+ if (kvm_feature_msrs->indices[i] == MSR_IA32_ARCH_CAPABILITIES) {
|
|
|
ae23c9 |
+ kvm_msr_entry_add(cpu, MSR_IA32_ARCH_CAPABILITIES,
|
|
|
ae23c9 |
+ env->features[FEAT_ARCH_CAPABILITIES]);
|
|
|
ae23c9 |
+ break;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
/*
|
|
|
ae23c9 |
* The following MSRs have side effects on the guest or are too heavy
|
|
|
ae23c9 |
* for normal writeback. Limit them to reset or full state updates.
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|