From nobody Tue Feb 10 21:19:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507327020508921.4397726744082; Fri, 6 Oct 2017 14:57:00 -0700 (PDT) Received: from localhost ([::1]:47273 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0abt-0006d9-QN for importer@patchew.org; Fri, 06 Oct 2017 17:56:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0aYE-0003r5-R5 for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:52:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e0aYE-0001cm-2d for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:52:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43522) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e0aYD-0001by-T8 for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:52:58 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CE9B420271 for ; Fri, 6 Oct 2017 21:52:56 +0000 (UTC) Received: from localhost (ovpn-116-25.gru2.redhat.com [10.97.116.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id C496770904; Fri, 6 Oct 2017 21:52:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CE9B420271 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 6 Oct 2017 18:52:39 -0300 Message-Id: <20171006215244.27104-3-ehabkost@redhat.com> In-Reply-To: <20171006215244.27104-1-ehabkost@redhat.com> References: <20171006215244.27104-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 06 Oct 2017 21:52:56 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/7] target/i386: x86_cpu_expand_feature() helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" x86_cpu_expand_features() needs to ensure it won't touch user-configured features when changing cpu->features. Make a helper for that, and use it when handling cpu->max_features. Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 98732cd65f..90c969363e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3486,6 +3486,25 @@ static void x86_cpu_enable_xsave_components(X86CPU *= cpu) * any CPUID data based on host capabilities. */ =20 +/** + * x86_cpu_expand_feature: + * + * Change cpu->features, being careful to not override features explicitly + * configured bv the user. + * + * @w: the feature word to be changed + * @mask: the bits to be changed in cpu->features[w] + * @value: the new value for the bits in (cpu->features[w] & @mask) + */ +static void x86_cpu_expand_feature(X86CPU *cpu, FeatureWord w, + uint32_t mask, uint32_t value) +{ + assert((value & mask) =3D=3D value); + mask &=3D ~cpu->env.user_features[w]; + cpu->env.features[w] &=3D ~mask; + cpu->env.features[w] |=3D value & mask; +} + /* Expand CPU configuration data, based on configured features * and host/accelerator capabilities when appropriate. */ @@ -3503,12 +3522,8 @@ static void x86_cpu_expand_features(X86CPU *cpu, Err= or **errp) */ if (cpu->max_features) { for (w =3D 0; w < FEATURE_WORDS; w++) { - /* Override only features that weren't set explicitly - * by the user. - */ - env->features[w] |=3D - x86_cpu_get_supported_feature_word(w, cpu->migratable) & - ~env->user_features[w]; + uint32_t f =3D x86_cpu_get_supported_feature_word(w, cpu->migr= atable); + x86_cpu_expand_feature(cpu, w, ~0, f); } } =20 --=20 2.13.6