From nobody Mon Feb 9 16:53:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568717523; cv=none; d=zoho.com; s=zohoarc; b=oW6ioc3UJvi/K/2YPU7xigne4ZN8MZ3mzX9REO021aQzmK7pWABeipsnrT2elsg/y7gxb3XVe2IlK0kuaNWOnjLTXyuMJj2Bz0diBZW9TwIJIuIvkt1nO8DSBT5hSqno8MBVI3QtCiGd4/EZcrkFHGKQMd7qGanz75nx22+aZvw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568717523; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=NnaErPzXThpQEqupywwj1kbSRYy+wBjcSB+cVdscC9E=; b=R9AQKn8S9TABv6+/1vbZfOXPHGvnPfbNyCwEXPM6QMS3pJbBKPOh3rjx+cfPrQRSiaboG8bsUtqGoK7FBv7ekjtqAZbcnnB9PuOD8ct9sVoqWpaPObHdDXmr4AXDE1o1fBJG8x5ufQOjRGu5euCQ5xQyaYj3yqWHv5MHgbepdLA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568717523206240.6000910833145; Tue, 17 Sep 2019 03:52:03 -0700 (PDT) Received: from localhost ([::1]:43974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAB5V-0000jc-6J for importer@patchew.org; Tue, 17 Sep 2019 06:52:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46848) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAAot-0001oz-24 for qemu-devel@nongnu.org; Tue, 17 Sep 2019 06:34:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAAor-0004zD-2v for qemu-devel@nongnu.org; Tue, 17 Sep 2019 06:34:50 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:34653) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iAAop-0004xq-6Q for qemu-devel@nongnu.org; Tue, 17 Sep 2019 06:34:48 -0400 Received: by mail-wr1-x444.google.com with SMTP id a11so2608334wrx.1 for ; Tue, 17 Sep 2019 03:34:46 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id q3sm1985415wrm.86.2019.09.17.03.34.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Sep 2019 03:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=NnaErPzXThpQEqupywwj1kbSRYy+wBjcSB+cVdscC9E=; b=KE952sdSU0I/P/TR+9s/uEbVHjrSw2LdRdNjokrcgaKMM7au/SjefvSey8zbjwGSIP hFnCiUQAnRwmXLDZH0icwZU+MB7bIfqEiB+tfd4nPbEUALDyLROcFlHCvcqPuKfFJtA1 zAA11I/POcYPTCT0Yo6Dg6u7aYY8F8m4+lF0gbU/AdFLFLxzRFlpJu1vj4qZNAlcyYhU GgYbVW6EOQLnwFM1AuGORBf9Yyf8e6tVN1Dj6CwGNCvDgM7OelzcieIQC6VUmiWwqh5h yYofyR2fbKqc5hIY30scQkd0P3ZuDeE0YMtla9jj6lAoAm7WcRfGimDGlAkNyJsE8IWS OvmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=NnaErPzXThpQEqupywwj1kbSRYy+wBjcSB+cVdscC9E=; b=aZFR6lgd7gS21Bu2BA+6oTS0jKcjQqoj39ExYwq0GKoEuoXvudRe0ROlGaUU1A4YMH s96udLhy6YgYuGBJMUpwq/f7BcIq9MLIeSYKQixMBFrsQmwP5GPGkPpciSobEys5ekZ/ PH20bAloAgqmSnwTmLTQ6Odp8RLUuKC6wwhIukhK5eyf35CzA35e+D/T9Wpmwcq84iyn MBJp2KfD0dYR1Xg3PM0SE+xshI8/QNa3z4ArkhI1eqBCv8QE+rNC6gOrdEEXUbvcRrtE +jDjxOXlXDjv5r7B0ulvq7UM4Hldcyy+fhkWdNaAnCRYBtRq1ix4xvjkVa5JG8nbVyrC kwpg== X-Gm-Message-State: APjAAAVmrvzqbkV/jVrpjc1IvZwyq+l+9MwR2OrljDCE5OpIbLJC60oV FRhgpC8C5IjXgL8MVsJzsFCeGpMW X-Google-Smtp-Source: APXvYqz6Myiuk/iuIOkvojaR+ua0es9FWJhjXpLNV/hBXrT+j3C1St5j3I3CqBVVceHFrDxe9+5yJw== X-Received: by 2002:adf:ec91:: with SMTP id z17mr2561505wrn.346.1568716485555; Tue, 17 Sep 2019 03:34:45 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 17 Sep 2019 12:34:36 +0200 Message-Id: <1568716480-9973-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568716480-9973-1-git-send-email-pbonzini@redhat.com> References: <1568716480-9973-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH 3/7] target/i386: expand feature words to 64 bits X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: liran.alon@oracle.com, ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" VMX requires 64-bit feature words for the IA32_VMX_EPT_VPID_CAP and IA32_VMX_BASIC MSRs. (The VMX control MSRs are 64-bit wide but actually have only 32 bits of information). Signed-off-by: Paolo Bonzini --- include/sysemu/kvm.h | 2 +- target/i386/cpu.c | 71 +++++++++++++++++++++++++++---------------------= ---- target/i386/cpu.h | 2 +- target/i386/kvm.c | 2 +- 4 files changed, 40 insertions(+), 37 deletions(-) diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 909bcd7..d691e45 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -462,7 +462,7 @@ int kvm_vm_check_extension(KVMState *s, unsigned int ex= tension); =20 uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, uint32_t index, int reg); -uint32_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index); +uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index); =20 =20 void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index fae458c..83a3692 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -789,7 +789,7 @@ typedef struct FeatureWordInfo { * In cases of disagreement between feature naming conventions, * aliases may be added. */ - const char *feat_names[32]; + const char *feat_names[64]; union { /* If type=3D=3DCPUID_FEATURE_WORD */ struct { @@ -803,11 +803,11 @@ typedef struct FeatureWordInfo { uint32_t index; } msr; }; - uint32_t tcg_features; /* Feature flags supported by TCG */ - uint32_t unmigratable_flags; /* Feature flags known to be unmigratable= */ - uint32_t migratable_flags; /* Feature flags known to be migratable */ + uint64_t tcg_features; /* Feature flags supported by TCG */ + uint64_t unmigratable_flags; /* Feature flags known to be unmigratable= */ + uint64_t migratable_flags; /* Feature flags known to be migratable */ /* Features that shouldn't be auto-enabled by "-cpu host" */ - uint32_t no_autoenable_flags; + uint64_t no_autoenable_flags; } FeatureWordInfo; =20 static FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { @@ -1236,7 +1236,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORD= S] =3D { =20 typedef struct FeatureMask { FeatureWord index; - uint32_t mask; + uint64_t mask; } FeatureMask; =20 typedef struct FeatureDep { @@ -1246,11 +1246,11 @@ typedef struct FeatureDep { static FeatureDep feature_dependencies[] =3D { { .from =3D { FEAT_7_0_EDX, CPUID_7_0_EDX_ARCH_CAPABILIT= IES }, - .to =3D { FEAT_ARCH_CAPABILITIES, ~0u }, + .to =3D { FEAT_ARCH_CAPABILITIES, ~0ull }, }, { .from =3D { FEAT_7_0_EDX, CPUID_7_0_EDX_CORE_CAPABILIT= Y }, - .to =3D { FEAT_CORE_CAPABILITY, ~0u }, + .to =3D { FEAT_CORE_CAPABILITY, ~0ull }, }, }; =20 @@ -1362,14 +1362,14 @@ const char *get_register_name_32(unsigned int reg) * Returns the set of feature flags that are supported and migratable by * QEMU, for a given FeatureWord. */ -static uint32_t x86_cpu_get_migratable_flags(FeatureWord w) +static uint64_t x86_cpu_get_migratable_flags(FeatureWord w) { FeatureWordInfo *wi =3D &feature_word_info[w]; - uint32_t r =3D 0; + uint64_t r =3D 0; int i; =20 - for (i =3D 0; i < 32; i++) { - uint32_t f =3D 1U << i; + for (i =3D 0; i < 64; i++) { + uint64_t f =3D 1ULL << i; =20 /* If the feature name is known, it is implicitly considered migra= table, * unless it is explicitly set in unmigratable_flags */ @@ -2931,7 +2931,7 @@ void x86_cpu_change_kvm_default(const char *prop, con= st char *value) assert(pv->prop); } =20 -static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w, +static uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, bool migratable_only); =20 static bool lmce_supported(void) @@ -3117,7 +3117,7 @@ static bool x86_cpu_have_filtered_features(X86CPU *cp= u) return false; } =20 -static void mark_unavailable_features(X86CPU *cpu, FeatureWord w, uint32_t= mask, +static void mark_unavailable_features(X86CPU *cpu, FeatureWord w, uint64_t= mask, const char *verbose_prefix) { CPUX86State *env =3D &cpu->env; @@ -3134,8 +3134,8 @@ static void mark_unavailable_features(X86CPU *cpu, Fe= atureWord w, uint32_t mask, return; } =20 - for (i =3D 0; i < 32; ++i) { - if ((1UL << i) & mask) { + for (i =3D 0; i < 64; ++i) { + if ((1ULL << i) & mask) { feat_word_str =3D feature_word_description(f, i); warn_report("%s: %s%s%s [bit %d]", verbose_prefix, @@ -3378,7 +3378,7 @@ static void x86_cpu_get_feature_words(Object *obj, Vi= sitor *v, const char *name, void *opaque, Error **errp) { - uint32_t *array =3D (uint32_t *)opaque; + uint64_t *array =3D (uint64_t *)opaque; FeatureWord w; X86CPUFeatureWordInfo word_infos[FEATURE_WORDS] =3D { }; X86CPUFeatureWordInfoList list_entries[FEATURE_WORDS] =3D { }; @@ -3422,6 +3422,7 @@ static inline void feat2prop(char *s) /* Return the feature property name for a feature flag bit */ static const char *x86_cpu_feature_name(FeatureWord w, int bitnr) { + const char *name; /* XSAVE components are automatically enabled by other features, * so return the original feature name instead */ @@ -3435,9 +3436,11 @@ static const char *x86_cpu_feature_name(FeatureWord = w, int bitnr) } } =20 - assert(bitnr < 32); + assert(bitnr < 64); assert(w < FEATURE_WORDS); - return feature_word_info[w].feat_names[bitnr]; + name =3D feature_word_info[w].feat_names[bitnr]; + assert(bitnr < 32 || !(name && feature_word_info[w].type =3D=3D CPUID_= FEATURE_WORD)); + return name; } =20 /* Compatibily hack to maintain legacy +-feat semantic, @@ -3553,10 +3556,10 @@ static void x86_cpu_list_feature_names(FeatureWordA= rray features, strList **next =3D feat_names; =20 for (w =3D 0; w < FEATURE_WORDS; w++) { - uint32_t filtered =3D features[w]; + uint64_t filtered =3D features[w]; int i; - for (i =3D 0; i < 32; i++) { - if (filtered & (1UL << i)) { + for (i =3D 0; i < 64; i++) { + if (filtered & (1ULL << i)) { strList *new =3D g_new0(strList, 1); new->value =3D g_strdup(x86_cpu_feature_name(w, i)); *next =3D new; @@ -3725,7 +3728,7 @@ void x86_cpu_list(void) names =3D NULL; for (i =3D 0; i < ARRAY_SIZE(feature_word_info); i++) { FeatureWordInfo *fw =3D &feature_word_info[i]; - for (j =3D 0; j < 32; j++) { + for (j =3D 0; j < 64; j++) { if (fw->feat_names[j]) { names =3D g_list_append(names, (gpointer)fw->feat_names[j]= ); } @@ -3780,11 +3783,11 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Er= ror **errp) return cpu_list; } =20 -static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w, +static uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, bool migratable_only) { FeatureWordInfo *wi =3D &feature_word_info[w]; - uint32_t r =3D 0; + uint64_t r =3D 0; =20 if (kvm_enabled()) { switch (wi->type) { @@ -3955,7 +3958,7 @@ static QDict *x86_cpu_static_props(void) for (w =3D 0; w < FEATURE_WORDS; w++) { FeatureWordInfo *fi =3D &feature_word_info[w]; int bit; - for (bit =3D 0; bit < 32; bit++) { + for (bit =3D 0; bit < 64; bit++) { if (!fi->feat_names[bit]) { continue; } @@ -5111,7 +5114,7 @@ static void x86_cpu_expand_features(X86CPU *cpu, Erro= r **errp) for (i =3D 0; i < ARRAY_SIZE(feature_dependencies); i++) { FeatureDep *d =3D &feature_dependencies[i]; if (!(env->features[d->from.index] & d->from.mask)) { - uint32_t unavailable_features =3D env->features[d->to.index] &= d->to.mask; + uint64_t unavailable_features =3D env->features[d->to.index] &= d->to.mask; =20 /* Not an error unless the dependent feature was added explici= tly. */ mark_unavailable_features(cpu, d->to.index, @@ -5206,10 +5209,10 @@ static void x86_cpu_filter_features(X86CPU *cpu, bo= ol verbose) } =20 for (w =3D 0; w < FEATURE_WORDS; w++) { - uint32_t host_feat =3D + uint64_t host_feat =3D x86_cpu_get_supported_feature_word(w, false); - uint32_t requested_features =3D env->features[w]; - uint32_t unavailable_features =3D requested_features & ~host_feat; + uint64_t requested_features =3D env->features[w]; + uint64_t unavailable_features =3D requested_features & ~host_feat; mark_unavailable_features(cpu, w, unavailable_features, prefix); } =20 @@ -5506,7 +5509,7 @@ static void x86_cpu_unrealizefn(DeviceState *dev, Err= or **errp) =20 typedef struct BitProperty { FeatureWord w; - uint32_t mask; + uint64_t mask; } BitProperty; =20 static void x86_cpu_get_bit_prop(Object *obj, Visitor *v, const char *name, @@ -5514,7 +5517,7 @@ static void x86_cpu_get_bit_prop(Object *obj, Visitor= *v, const char *name, { X86CPU *cpu =3D X86_CPU(obj); BitProperty *fp =3D opaque; - uint32_t f =3D cpu->env.features[fp->w]; + uint64_t f =3D cpu->env.features[fp->w]; bool value =3D (f & fp->mask) =3D=3D fp->mask; visit_type_bool(v, name, &value, errp); } @@ -5567,7 +5570,7 @@ static void x86_cpu_register_bit_prop(X86CPU *cpu, { BitProperty *fp; ObjectProperty *op; - uint32_t mask =3D (1UL << bitnr); + uint64_t mask =3D (1ULL << bitnr); =20 op =3D object_property_find(OBJECT(cpu), prop_name, NULL); if (op) { @@ -5701,7 +5704,7 @@ static void x86_cpu_initfn(Object *obj) for (w =3D 0; w < FEATURE_WORDS; w++) { int bitnr; =20 - for (bitnr =3D 0; bitnr < 32; bitnr++) { + for (bitnr =3D 0; bitnr < 64; bitnr++) { x86_cpu_register_feature_bit_props(cpu, w, bitnr); } } diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 5f6e3a0..c00cc35 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -502,7 +502,7 @@ typedef enum FeatureWord { FEATURE_WORDS, } FeatureWord; =20 -typedef uint32_t FeatureWordArray[FEATURE_WORDS]; +typedef uint64_t FeatureWordArray[FEATURE_WORDS]; =20 /* cpuid_features bits */ #define CPUID_FP87 (1U << 0) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 8023c67..52f98d7 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -441,7 +441,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint= 32_t function, return ret; } =20 -uint32_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index) +uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index) { struct { struct kvm_msrs info; --=20 1.8.3.1