From nobody Sun Feb 8 19:17:23 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.zoho.com; dkim=fail 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 1496599860174340.5017951740699; Sun, 4 Jun 2017 11:11:00 -0700 (PDT) Received: from localhost ([::1]:57983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHZzO-0007DZ-PI for importer@patchew.org; Sun, 04 Jun 2017 14:10:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHZRg-0007qp-Vg for qemu-devel@nongnu.org; Sun, 04 Jun 2017 13:36:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dHZRf-0003a2-J4 for qemu-devel@nongnu.org; Sun, 04 Jun 2017 13:36:08 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:35904) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dHZRf-0003Yw-CV for qemu-devel@nongnu.org; Sun, 04 Jun 2017 13:36:07 -0400 Received: by mail-pg0-x243.google.com with SMTP id v18so3986547pgb.3 for ; Sun, 04 Jun 2017 10:36:07 -0700 (PDT) Received: from bigtime.ASUS (cpe-98-155-27-246.hawaii.res.rr.com. [98.155.27.246]) by smtp.gmail.com with ESMTPSA id j191sm52854419pgc.53.2017.06.04.10.36.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Jun 2017 10:36:05 -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=c5BgNqfHyFGCcuu3fG4DeIhExwBiHL7ytqoU9RK+fyk=; b=nXmqyiXk0+BB1RMcDMGSp10R+pn5D16aJI91CAV/kE0s4052tFF3nw/HtZ0eaUWzaY R5Q+Q5rGdQrXi9fh2Mxum0K2tgZ9XPJsU/Uh9IejrMUfGb2fBQ+8ZqE+N7/2JaLYIXHA e/zrN2XWvHQrSUGAvGjs3JJ3wzNGJTEkl6831KKwRxIbOu5AjqMYfvQx5bieYYoIasr9 tv9VzGTqf/TK8p8UXuvIDa7ZZQDqXI/lKXvz2SSFT7KZPFKPR951zwMAAPZWlauvd9h1 ipCDwBRLR22L6JOCcAR4RwE0Mhcjjm+q7shoLHK9tujegXRyuijP5mIoWOasSyDpps4Q xBlQ== 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=c5BgNqfHyFGCcuu3fG4DeIhExwBiHL7ytqoU9RK+fyk=; b=OM6MAOorVLs2TtyDpdpY+kAXR51nUhmVOZ3pKnBmwQ2PfLvJTRj9ut7GFnfzvXT7zo FljPUyaDc6jMvPZ4QISoWVZjkRPwwMs8q0R4ZjnV9dgkdPOQuL11ojhIuzcXPw3u5+OH l//2H39vamsDDHfej3yiS4+wz06D/fgPQg2iF8NKwjQM3CMAL13qyeJiur7HmVbl9PU6 y9N8MWTlZVL8pdWx9FxRhdprpnADU2nBGoh/om7SsZiD2LzkskJm+R3X0j3ORBXNIcIL myWOA6s3RkQQF39vSxO4NIuMhvNgEZC6zJ+WM8oka+VedJpVswIwZWf4y8IEviOLwQug igQA== X-Gm-Message-State: AODbwcBW9wOBpabQBDpoot4+KxWn4QDF5QxW0WikRZTYdWBDnzWipN4E 9xuVi80Fbk877ghCW3o= X-Received: by 10.98.60.139 with SMTP id b11mr5636489pfk.170.1496597766243; Sun, 04 Jun 2017 10:36:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 4 Jun 2017 10:34:39 -0700 Message-Id: <20170604173509.29684-40-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170604173509.29684-1-rth@twiddle.net> References: <20170604173509.29684-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PULL 39/69] 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: peter.maydell@linaro.org, Thomas Huth , aurelien@aurel32.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth 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 Acked-by: David Hildenbrand Reviewed-by: Aurelien Jarno Signed-off-by: Thomas Huth Message-Id: <1495704132-5675-1-git-send-email-thuth@redhat.com> Signed-off-by: Richard Henderson --- target/s390x/cpu_models.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 8d27363..e5e005a 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -658,6 +658,30 @@ 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) +{ + static const int 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, + }; + int i; + + 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 +694,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 +950,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 2.9.4