|
|
4ec855 |
From a31ce6a9fa171f677bf52dd0b0076e7b92d9ae33 Mon Sep 17 00:00:00 2001
|
|
|
4ec855 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4ec855 |
Date: Fri, 22 Nov 2019 11:53:41 +0000
|
|
|
4ec855 |
Subject: [PATCH 08/16] target/i386: expand feature words to 64 bits
|
|
|
4ec855 |
|
|
|
4ec855 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4ec855 |
Message-id: <20191122115348.25000-9-pbonzini@redhat.com>
|
|
|
4ec855 |
Patchwork-id: 92612
|
|
|
4ec855 |
O-Subject: [RHEL8.2/rhel qemu-kvm PATCH 08/15] target/i386: expand feature words to 64 bits
|
|
|
4ec855 |
Bugzilla: 1689270
|
|
|
4ec855 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
4ec855 |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
4ec855 |
RH-Acked-by: Maxim Levitsky <mlevitsk@redhat.com>
|
|
|
4ec855 |
|
|
|
4ec855 |
VMX requires 64-bit feature words for the IA32_VMX_EPT_VPID_CAP
|
|
|
4ec855 |
and IA32_VMX_BASIC MSRs. (The VMX control MSRs are 64-bit wide but
|
|
|
4ec855 |
actually have only 32 bits of information).
|
|
|
4ec855 |
|
|
|
4ec855 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4ec855 |
(cherry picked from commit ede146c2e720b670350c7ef5e9af44e80a73fe97)
|
|
|
4ec855 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
4ec855 |
---
|
|
|
4ec855 |
include/sysemu/kvm.h | 2 +-
|
|
|
4ec855 |
target/i386/cpu.c | 71 +++++++++++++++++++++++++++-------------------------
|
|
|
4ec855 |
target/i386/cpu.h | 2 +-
|
|
|
4ec855 |
target/i386/kvm.c | 2 +-
|
|
|
4ec855 |
4 files changed, 40 insertions(+), 37 deletions(-)
|
|
|
4ec855 |
|
|
|
4ec855 |
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
|
|
|
4ec855 |
index 3cf04cf..2c7f841 100644
|
|
|
4ec855 |
--- a/include/sysemu/kvm.h
|
|
|
4ec855 |
+++ b/include/sysemu/kvm.h
|
|
|
4ec855 |
@@ -466,7 +466,7 @@ int kvm_vm_check_extension(KVMState *s, unsigned int extension);
|
|
|
4ec855 |
|
|
|
4ec855 |
uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
|
|
|
4ec855 |
uint32_t index, int reg);
|
|
|
4ec855 |
-uint32_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index);
|
|
|
4ec855 |
+uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index);
|
|
|
4ec855 |
|
|
|
4ec855 |
|
|
|
4ec855 |
void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len);
|
|
|
4ec855 |
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
|
|
|
4ec855 |
index a7360b3..3e77830 100644
|
|
|
4ec855 |
--- a/target/i386/cpu.c
|
|
|
4ec855 |
+++ b/target/i386/cpu.c
|
|
|
4ec855 |
@@ -785,7 +785,7 @@ typedef struct FeatureWordInfo {
|
|
|
4ec855 |
* In cases of disagreement between feature naming conventions,
|
|
|
4ec855 |
* aliases may be added.
|
|
|
4ec855 |
*/
|
|
|
4ec855 |
- const char *feat_names[32];
|
|
|
4ec855 |
+ const char *feat_names[64];
|
|
|
4ec855 |
union {
|
|
|
4ec855 |
/* If type==CPUID_FEATURE_WORD */
|
|
|
4ec855 |
struct {
|
|
|
4ec855 |
@@ -799,11 +799,11 @@ typedef struct FeatureWordInfo {
|
|
|
4ec855 |
uint32_t index;
|
|
|
4ec855 |
} msr;
|
|
|
4ec855 |
};
|
|
|
4ec855 |
- uint32_t tcg_features; /* Feature flags supported by TCG */
|
|
|
4ec855 |
- uint32_t unmigratable_flags; /* Feature flags known to be unmigratable */
|
|
|
4ec855 |
- uint32_t migratable_flags; /* Feature flags known to be migratable */
|
|
|
4ec855 |
+ uint64_t tcg_features; /* Feature flags supported by TCG */
|
|
|
4ec855 |
+ uint64_t unmigratable_flags; /* Feature flags known to be unmigratable */
|
|
|
4ec855 |
+ uint64_t migratable_flags; /* Feature flags known to be migratable */
|
|
|
4ec855 |
/* Features that shouldn't be auto-enabled by "-cpu host" */
|
|
|
4ec855 |
- uint32_t no_autoenable_flags;
|
|
|
4ec855 |
+ uint64_t no_autoenable_flags;
|
|
|
4ec855 |
} FeatureWordInfo;
|
|
|
4ec855 |
|
|
|
4ec855 |
static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
|
|
|
4ec855 |
@@ -1175,7 +1175,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
|
|
|
4ec855 |
|
|
|
4ec855 |
typedef struct FeatureMask {
|
|
|
4ec855 |
FeatureWord index;
|
|
|
4ec855 |
- uint32_t mask;
|
|
|
4ec855 |
+ uint64_t mask;
|
|
|
4ec855 |
} FeatureMask;
|
|
|
4ec855 |
|
|
|
4ec855 |
typedef struct FeatureDep {
|
|
|
4ec855 |
@@ -1185,11 +1185,11 @@ typedef struct FeatureDep {
|
|
|
4ec855 |
static FeatureDep feature_dependencies[] = {
|
|
|
4ec855 |
{
|
|
|
4ec855 |
.from = { FEAT_7_0_EDX, CPUID_7_0_EDX_ARCH_CAPABILITIES },
|
|
|
4ec855 |
- .to = { FEAT_ARCH_CAPABILITIES, ~0u },
|
|
|
4ec855 |
+ .to = { FEAT_ARCH_CAPABILITIES, ~0ull },
|
|
|
4ec855 |
},
|
|
|
4ec855 |
{
|
|
|
4ec855 |
.from = { FEAT_7_0_EDX, CPUID_7_0_EDX_CORE_CAPABILITY },
|
|
|
4ec855 |
- .to = { FEAT_CORE_CAPABILITY, ~0u },
|
|
|
4ec855 |
+ .to = { FEAT_CORE_CAPABILITY, ~0ull },
|
|
|
4ec855 |
},
|
|
|
4ec855 |
};
|
|
|
4ec855 |
|
|
|
4ec855 |
@@ -1301,14 +1301,14 @@ const char *get_register_name_32(unsigned int reg)
|
|
|
4ec855 |
* Returns the set of feature flags that are supported and migratable by
|
|
|
4ec855 |
* QEMU, for a given FeatureWord.
|
|
|
4ec855 |
*/
|
|
|
4ec855 |
-static uint32_t x86_cpu_get_migratable_flags(FeatureWord w)
|
|
|
4ec855 |
+static uint64_t x86_cpu_get_migratable_flags(FeatureWord w)
|
|
|
4ec855 |
{
|
|
|
4ec855 |
FeatureWordInfo *wi = &feature_word_info[w];
|
|
|
4ec855 |
- uint32_t r = 0;
|
|
|
4ec855 |
+ uint64_t r = 0;
|
|
|
4ec855 |
int i;
|
|
|
4ec855 |
|
|
|
4ec855 |
- for (i = 0; i < 32; i++) {
|
|
|
4ec855 |
- uint32_t f = 1U << i;
|
|
|
4ec855 |
+ for (i = 0; i < 64; i++) {
|
|
|
4ec855 |
+ uint64_t f = 1ULL << i;
|
|
|
4ec855 |
|
|
|
4ec855 |
/* If the feature name is known, it is implicitly considered migratable,
|
|
|
4ec855 |
* unless it is explicitly set in unmigratable_flags */
|
|
|
4ec855 |
@@ -2948,7 +2948,7 @@ void x86_cpu_change_kvm_default(const char *prop, const char *value)
|
|
|
4ec855 |
assert(pv->prop);
|
|
|
4ec855 |
}
|
|
|
4ec855 |
|
|
|
4ec855 |
-static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,
|
|
|
4ec855 |
+static uint64_t x86_cpu_get_supported_feature_word(FeatureWord w,
|
|
|
4ec855 |
bool migratable_only);
|
|
|
4ec855 |
|
|
|
4ec855 |
static bool lmce_supported(void)
|
|
|
4ec855 |
@@ -3142,7 +3142,7 @@ static bool x86_cpu_have_filtered_features(X86CPU *cpu)
|
|
|
4ec855 |
return false;
|
|
|
4ec855 |
}
|
|
|
4ec855 |
|
|
|
4ec855 |
-static void mark_unavailable_features(X86CPU *cpu, FeatureWord w, uint32_t mask,
|
|
|
4ec855 |
+static void mark_unavailable_features(X86CPU *cpu, FeatureWord w, uint64_t mask,
|
|
|
4ec855 |
const char *verbose_prefix)
|
|
|
4ec855 |
{
|
|
|
4ec855 |
CPUX86State *env = &cpu->env;
|
|
|
4ec855 |
@@ -3159,8 +3159,8 @@ static void mark_unavailable_features(X86CPU *cpu, FeatureWord w, uint32_t mask,
|
|
|
4ec855 |
return;
|
|
|
4ec855 |
}
|
|
|
4ec855 |
|
|
|
4ec855 |
- for (i = 0; i < 32; ++i) {
|
|
|
4ec855 |
- if ((1UL << i) & mask) {
|
|
|
4ec855 |
+ for (i = 0; i < 64; ++i) {
|
|
|
4ec855 |
+ if ((1ULL << i) & mask) {
|
|
|
4ec855 |
feat_word_str = feature_word_description(f, i);
|
|
|
4ec855 |
warn_report("%s: %s%s%s [bit %d]",
|
|
|
4ec855 |
verbose_prefix,
|
|
|
4ec855 |
@@ -3403,7 +3403,7 @@ static void x86_cpu_get_feature_words(Object *obj, Visitor *v,
|
|
|
4ec855 |
const char *name, void *opaque,
|
|
|
4ec855 |
Error **errp)
|
|
|
4ec855 |
{
|
|
|
4ec855 |
- uint32_t *array = (uint32_t *)opaque;
|
|
|
4ec855 |
+ uint64_t *array = (uint64_t *)opaque;
|
|
|
4ec855 |
FeatureWord w;
|
|
|
4ec855 |
X86CPUFeatureWordInfo word_infos[FEATURE_WORDS] = { };
|
|
|
4ec855 |
X86CPUFeatureWordInfoList list_entries[FEATURE_WORDS] = { };
|
|
|
4ec855 |
@@ -3487,6 +3487,7 @@ static inline void feat2prop(char *s)
|
|
|
4ec855 |
/* Return the feature property name for a feature flag bit */
|
|
|
4ec855 |
static const char *x86_cpu_feature_name(FeatureWord w, int bitnr)
|
|
|
4ec855 |
{
|
|
|
4ec855 |
+ const char *name;
|
|
|
4ec855 |
/* XSAVE components are automatically enabled by other features,
|
|
|
4ec855 |
* so return the original feature name instead
|
|
|
4ec855 |
*/
|
|
|
4ec855 |
@@ -3500,9 +3501,11 @@ static const char *x86_cpu_feature_name(FeatureWord w, int bitnr)
|
|
|
4ec855 |
}
|
|
|
4ec855 |
}
|
|
|
4ec855 |
|
|
|
4ec855 |
- assert(bitnr < 32);
|
|
|
4ec855 |
+ assert(bitnr < 64);
|
|
|
4ec855 |
assert(w < FEATURE_WORDS);
|
|
|
4ec855 |
- return feature_word_info[w].feat_names[bitnr];
|
|
|
4ec855 |
+ name = feature_word_info[w].feat_names[bitnr];
|
|
|
4ec855 |
+ assert(bitnr < 32 || !(name && feature_word_info[w].type == CPUID_FEATURE_WORD));
|
|
|
4ec855 |
+ return name;
|
|
|
4ec855 |
}
|
|
|
4ec855 |
|
|
|
4ec855 |
/* Compatibily hack to maintain legacy +-feat semantic,
|
|
|
4ec855 |
@@ -3619,10 +3622,10 @@ static void x86_cpu_list_feature_names(FeatureWordArray features,
|
|
|
4ec855 |
strList **next = feat_names;
|
|
|
4ec855 |
|
|
|
4ec855 |
for (w = 0; w < FEATURE_WORDS; w++) {
|
|
|
4ec855 |
- uint32_t filtered = features[w];
|
|
|
4ec855 |
+ uint64_t filtered = features[w];
|
|
|
4ec855 |
int i;
|
|
|
4ec855 |
- for (i = 0; i < 32; i++) {
|
|
|
4ec855 |
- if (filtered & (1UL << i)) {
|
|
|
4ec855 |
+ for (i = 0; i < 64; i++) {
|
|
|
4ec855 |
+ if (filtered & (1ULL << i)) {
|
|
|
4ec855 |
strList *new = g_new0(strList, 1);
|
|
|
4ec855 |
new->value = g_strdup(x86_cpu_feature_name(w, i));
|
|
|
4ec855 |
*next = new;
|
|
|
4ec855 |
@@ -3760,7 +3763,7 @@ void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
|
|
|
4ec855 |
names = NULL;
|
|
|
4ec855 |
for (i = 0; i < ARRAY_SIZE(feature_word_info); i++) {
|
|
|
4ec855 |
FeatureWordInfo *fw = &feature_word_info[i];
|
|
|
4ec855 |
- for (j = 0; j < 32; j++) {
|
|
|
4ec855 |
+ for (j = 0; j < 64; j++) {
|
|
|
4ec855 |
if (fw->feat_names[j]) {
|
|
|
4ec855 |
names = g_list_append(names, (gpointer)fw->feat_names[j]);
|
|
|
4ec855 |
}
|
|
|
4ec855 |
@@ -3807,11 +3810,11 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
|
|
|
4ec855 |
return cpu_list;
|
|
|
4ec855 |
}
|
|
|
4ec855 |
|
|
|
4ec855 |
-static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,
|
|
|
4ec855 |
+static uint64_t x86_cpu_get_supported_feature_word(FeatureWord w,
|
|
|
4ec855 |
bool migratable_only)
|
|
|
4ec855 |
{
|
|
|
4ec855 |
FeatureWordInfo *wi = &feature_word_info[w];
|
|
|
4ec855 |
- uint32_t r = 0;
|
|
|
4ec855 |
+ uint64_t r = 0;
|
|
|
4ec855 |
|
|
|
4ec855 |
if (kvm_enabled()) {
|
|
|
4ec855 |
switch (wi->type) {
|
|
|
4ec855 |
@@ -3950,7 +3953,7 @@ static QDict *x86_cpu_static_props(void)
|
|
|
4ec855 |
for (w = 0; w < FEATURE_WORDS; w++) {
|
|
|
4ec855 |
FeatureWordInfo *fi = &feature_word_info[w];
|
|
|
4ec855 |
int bit;
|
|
|
4ec855 |
- for (bit = 0; bit < 32; bit++) {
|
|
|
4ec855 |
+ for (bit = 0; bit < 64; bit++) {
|
|
|
4ec855 |
if (!fi->feat_names[bit]) {
|
|
|
4ec855 |
continue;
|
|
|
4ec855 |
}
|
|
|
4ec855 |
@@ -5015,7 +5018,7 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
|
|
|
4ec855 |
for (i = 0; i < ARRAY_SIZE(feature_dependencies); i++) {
|
|
|
4ec855 |
FeatureDep *d = &feature_dependencies[i];
|
|
|
4ec855 |
if (!(env->features[d->from.index] & d->from.mask)) {
|
|
|
4ec855 |
- uint32_t unavailable_features = env->features[d->to.index] & d->to.mask;
|
|
|
4ec855 |
+ uint64_t unavailable_features = env->features[d->to.index] & d->to.mask;
|
|
|
4ec855 |
|
|
|
4ec855 |
/* Not an error unless the dependent feature was added explicitly. */
|
|
|
4ec855 |
mark_unavailable_features(cpu, d->to.index,
|
|
|
4ec855 |
@@ -5094,10 +5097,10 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool verbose)
|
|
|
4ec855 |
}
|
|
|
4ec855 |
|
|
|
4ec855 |
for (w = 0; w < FEATURE_WORDS; w++) {
|
|
|
4ec855 |
- uint32_t host_feat =
|
|
|
4ec855 |
+ uint64_t host_feat =
|
|
|
4ec855 |
x86_cpu_get_supported_feature_word(w, false);
|
|
|
4ec855 |
- uint32_t requested_features = env->features[w];
|
|
|
4ec855 |
- uint32_t unavailable_features = requested_features & ~host_feat;
|
|
|
4ec855 |
+ uint64_t requested_features = env->features[w];
|
|
|
4ec855 |
+ uint64_t unavailable_features = requested_features & ~host_feat;
|
|
|
4ec855 |
mark_unavailable_features(cpu, w, unavailable_features, prefix);
|
|
|
4ec855 |
}
|
|
|
4ec855 |
|
|
|
4ec855 |
@@ -5380,7 +5383,7 @@ static void x86_cpu_unrealizefn(DeviceState *dev, Error **errp)
|
|
|
4ec855 |
|
|
|
4ec855 |
typedef struct BitProperty {
|
|
|
4ec855 |
FeatureWord w;
|
|
|
4ec855 |
- uint32_t mask;
|
|
|
4ec855 |
+ uint64_t mask;
|
|
|
4ec855 |
} BitProperty;
|
|
|
4ec855 |
|
|
|
4ec855 |
static void x86_cpu_get_bit_prop(Object *obj, Visitor *v, const char *name,
|
|
|
4ec855 |
@@ -5388,7 +5391,7 @@ static void x86_cpu_get_bit_prop(Object *obj, Visitor *v, const char *name,
|
|
|
4ec855 |
{
|
|
|
4ec855 |
X86CPU *cpu = X86_CPU(obj);
|
|
|
4ec855 |
BitProperty *fp = opaque;
|
|
|
4ec855 |
- uint32_t f = cpu->env.features[fp->w];
|
|
|
4ec855 |
+ uint64_t f = cpu->env.features[fp->w];
|
|
|
4ec855 |
bool value = (f & fp->mask) == fp->mask;
|
|
|
4ec855 |
visit_type_bool(v, name, &value, errp);
|
|
|
4ec855 |
}
|
|
|
4ec855 |
@@ -5441,7 +5444,7 @@ static void x86_cpu_register_bit_prop(X86CPU *cpu,
|
|
|
4ec855 |
{
|
|
|
4ec855 |
BitProperty *fp;
|
|
|
4ec855 |
ObjectProperty *op;
|
|
|
4ec855 |
- uint32_t mask = (1UL << bitnr);
|
|
|
4ec855 |
+ uint64_t mask = (1ULL << bitnr);
|
|
|
4ec855 |
|
|
|
4ec855 |
op = object_property_find(OBJECT(cpu), prop_name, NULL);
|
|
|
4ec855 |
if (op) {
|
|
|
4ec855 |
@@ -5577,7 +5580,7 @@ static void x86_cpu_initfn(Object *obj)
|
|
|
4ec855 |
for (w = 0; w < FEATURE_WORDS; w++) {
|
|
|
4ec855 |
int bitnr;
|
|
|
4ec855 |
|
|
|
4ec855 |
- for (bitnr = 0; bitnr < 32; bitnr++) {
|
|
|
4ec855 |
+ for (bitnr = 0; bitnr < 64; bitnr++) {
|
|
|
4ec855 |
x86_cpu_register_feature_bit_props(cpu, w, bitnr);
|
|
|
4ec855 |
}
|
|
|
4ec855 |
}
|
|
|
4ec855 |
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
|
|
|
4ec855 |
index f9b93be..edba84e 100644
|
|
|
4ec855 |
--- a/target/i386/cpu.h
|
|
|
4ec855 |
+++ b/target/i386/cpu.h
|
|
|
4ec855 |
@@ -506,7 +506,7 @@ typedef enum FeatureWord {
|
|
|
4ec855 |
FEATURE_WORDS,
|
|
|
4ec855 |
} FeatureWord;
|
|
|
4ec855 |
|
|
|
4ec855 |
-typedef uint32_t FeatureWordArray[FEATURE_WORDS];
|
|
|
4ec855 |
+typedef uint64_t FeatureWordArray[FEATURE_WORDS];
|
|
|
4ec855 |
|
|
|
4ec855 |
/* cpuid_features bits */
|
|
|
4ec855 |
#define CPUID_FP87 (1U << 0)
|
|
|
4ec855 |
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
|
|
|
4ec855 |
index 2290c5d..85abd37 100644
|
|
|
4ec855 |
--- a/target/i386/kvm.c
|
|
|
4ec855 |
+++ b/target/i386/kvm.c
|
|
|
4ec855 |
@@ -423,7 +423,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
|
|
|
4ec855 |
return ret;
|
|
|
4ec855 |
}
|
|
|
4ec855 |
|
|
|
4ec855 |
-uint32_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index)
|
|
|
4ec855 |
+uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index)
|
|
|
4ec855 |
{
|
|
|
4ec855 |
struct {
|
|
|
4ec855 |
struct kvm_msrs info;
|
|
|
4ec855 |
--
|
|
|
4ec855 |
1.8.3.1
|
|
|
4ec855 |
|