From nobody Fri Mar 29 08:03:04 2024 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.zoho.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 1495616148324834.40778855736; Wed, 24 May 2017 01:55:48 -0700 (PDT) Received: from localhost ([::1]:53624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDS54-0007ZB-Sq for importer@patchew.org; Wed, 24 May 2017 04:55:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44324) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDS3u-0006ym-Vz for qemu-devel@nongnu.org; Wed, 24 May 2017 04:54:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDS3o-0006eD-Vb for qemu-devel@nongnu.org; Wed, 24 May 2017 04:54:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42582) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDS3o-0006do-My for qemu-devel@nongnu.org; Wed, 24 May 2017 04:54:28 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6E4ABC0467D7; Wed, 24 May 2017 08:54:27 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-128.ams2.redhat.com [10.36.116.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0979F5C8BF; Wed, 24 May 2017 08:54:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6E4ABC0467D7 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thuth@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6E4ABC0467D7 From: Thomas Huth To: qemu-devel@nongnu.org, Richard Henderson Date: Wed, 24 May 2017 10:54:23 +0200 Message-Id: <1495616063-19386-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 24 May 2017 08:54:27 +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] target/s390x/cpu_models: Allow some additional feature bits for the "qemu" CPU 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: Alexander Graf , Aurelien Jarno , David Hildenbrand 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" Currently we only present the plain z900 feature bits to the guest, but QEMU already emulates some additional features (but not all of the next CPU generation, so we can not use the next CPU level as default yet). Since newer Linux kernels are checking the feature bits and refuse to work if a required feature is missing, it would be nice to have a way to present more of the supported features when we are running with the "qemu" CPU. This patch now adds the supported features to the "full_feat" bitmap, so that additional features can be enabled on the command line now, for example with: qemu-system-s390x -cpu qemu,stfle=3Dtrue,ldisp=3Dtrue,eimm=3Dtrue,stckf=3D= true Signed-off-by: Thomas Huth --- Note: This is a revised version of my previous patch "Set some additional feature bits for the qemu CPU" - but this time, the feature bits are not enabled by default, so this version should not create any issues with migration, I think. Rationale for not enabling it by default yet: It does not make sense to do add all the migration compatibility magic here yet as long as we do not provide enough facilities yet for running recent Linux kernels, so having just a way to enable the features on the command line for further development/experiments should be enough right now. Another change wrt. to my original patch: I've now also added the additional feature bits that Aurelien suggested. target/s390x/cpu_models.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 8d27363..654a6bc 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -658,6 +658,29 @@ static void check_compatibility(const S390CPUModel *ma= x_model, "available in the configuration: "); } =20 +/** + * The base TCG CPU model "qemu" is based on the z900. However, we already + * can also emulate some additional features of later CPU generations, so + * we add these additional feature bits here. + */ +static void add_qemu_cpu_model_features(S390FeatBitmap fbm) +{ + int i, feats[] =3D { + S390_FEAT_STFLE, + S390_FEAT_EXTENDED_IMMEDIATE, + S390_FEAT_LONG_DISPLACEMENT, + S390_FEAT_LONG_DISPLACEMENT_FAST, + S390_FEAT_STORE_CLOCK_FAST, + S390_FEAT_GENERAL_INSTRUCTIONS_EXT, + S390_FEAT_EXECUTE_EXT, + S390_FEAT_STFLE_45, + }; + + for (i =3D 0; i < ARRAY_SIZE(feats); i++) { + set_bit(feats[i], fbm); + } +} + static S390CPUModel *get_max_cpu_model(Error **errp) { static S390CPUModel max_model; @@ -670,10 +693,11 @@ static S390CPUModel *get_max_cpu_model(Error **errp) if (kvm_enabled()) { kvm_s390_get_host_cpu_model(&max_model, errp); } else { - /* TCG emulates a z900 */ + /* TCG emulates a z900 (with some optional additional features) */ max_model.def =3D &s390_cpu_defs[0]; bitmap_copy(max_model.features, max_model.def->default_feat, S390_FEAT_MAX); + add_qemu_cpu_model_features(max_model.features); } if (!*errp) { cached =3D true; @@ -925,11 +949,14 @@ static void s390_host_cpu_model_initfn(Object *obj) =20 static void s390_qemu_cpu_model_initfn(Object *obj) { + static S390CPUDef s390_qemu_cpu_defs; S390CPU *cpu =3D S390_CPU(obj); =20 cpu->model =3D g_malloc0(sizeof(*cpu->model)); - /* TCG emulates a z900 */ - cpu->model->def =3D &s390_cpu_defs[0]; + /* TCG emulates a z900 (with some optional additional features) */ + memcpy(&s390_qemu_cpu_defs, &s390_cpu_defs[0], sizeof(s390_qemu_cpu_de= fs)); + add_qemu_cpu_model_features(s390_qemu_cpu_defs.full_feat); + cpu->model->def =3D &s390_qemu_cpu_defs; bitmap_copy(cpu->model->features, cpu->model->def->default_feat, S390_FEAT_MAX); } --=20 1.8.3.1