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