From patchwork Wed Jun 7 00:30:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9770401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7A3DF60353 for ; Wed, 7 Jun 2017 01:00:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58DD825D9E for ; Wed, 7 Jun 2017 01:00:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C36828539; Wed, 7 Jun 2017 01:00:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B959E284A8 for ; Wed, 7 Jun 2017 01:00:46 +0000 (UTC) Received: from localhost ([::1]:40676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIPL3-00042u-S0 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 06 Jun 2017 21:00:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIOtV-00038I-A3 for qemu-devel@nongnu.org; Tue, 06 Jun 2017 20:32:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIOtU-00026T-3l for qemu-devel@nongnu.org; Tue, 06 Jun 2017 20:32:17 -0400 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:33815) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dIOtU-00026K-04 for qemu-devel@nongnu.org; Tue, 06 Jun 2017 20:32:16 -0400 Received: by mail-qk0-x242.google.com with SMTP id d14so12248395qkb.1 for ; Tue, 06 Jun 2017 17:32:15 -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=QtVU3S3ExKRrRO2uGAkKIN6OGlOq/Tq+pe76mw4iRRiizlvfpH2m/dCs/W8FKfnswY c7vbMgVHQFfKG8Ko22D7Fi0qno9ANEEDne1Vpip/toj03081lU9Baq742m2ffrY9fOe6 RLX4+0QKTq2fS1vEBvN8E8M9s7hpGSsVqv0Ujl8TakiBVs6gRe5CXfLI7BwNTCaWb61+ KkqQ2kx/fOdRcQDzvfuHObi6W9uZ8ib7BACqdZWf3IAQrFxpSdw9USxAVHwgIyHAuhvw InoYjsfrrrPvC1MHVe5mgnCNFVoXmYHbAnKPXgta5YTEZcg4KV6ajnufKNaykIaQEo1r RrkQ== 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=EEwsv7XAG5dsH7dIHpn+NQs/fsxCyJ7EmPeqztdTXlepuM4GXqWbF3g4VDr3Gj5ZrC 03gKAHUe70n76ssXv7JARHvU1vwDYTZ7g8RMVBdDKKL3mbT3ACIQshO4xIN3bxtQeQIR FLjQ4lOAbmWnGZaQDsEznkXQEkee+P9KOKWnbiewD3kT2FNAKwyP8Mw3DvyrV1K0r9mk DMym6aQXOt7KR7N0mybI0+g0uYBLJIrwc76TBeBDBdrIY45R/mFiPK11xOrqsjCWuasR 3qkUgrQ7YOJbTgB0wEJvOZdIfWTuDp1yxDorp73umgnuhf2fMoTSf4Bo1CmDBYFzxhfJ dn4g== X-Gm-Message-State: AODbwcAVuYPo78Oso8zg390gydESD1f697r3G9JtQpxL75s29AHpEseK +imRpyWyjuUWb+iMdyk= X-Received: by 10.55.43.93 with SMTP id r90mr32219247qkh.196.1496795535249; Tue, 06 Jun 2017 17:32:15 -0700 (PDT) Received: from bigtime.twiddle.net.com (71-217-91-69.tukw.qwest.net. [71.217.91.69]) by smtp.gmail.com with ESMTPSA id m47sm29286qtc.36.2017.06.06.17.32.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 17:32:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 6 Jun 2017 17:30:48 -0700 Message-Id: <20170607003119.14778-40-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170607003119.14778-1-rth@twiddle.net> References: <20170607003119.14778-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::242 Subject: [Qemu-devel] [PULL v2 39/70] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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=true,ldisp=true,eimm=true,stckf=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 *max_model, "available in the configuration: "); } +/** + * 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[] = { + 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 = 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 = &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 = true; @@ -925,11 +950,14 @@ static void s390_host_cpu_model_initfn(Object *obj) static void s390_qemu_cpu_model_initfn(Object *obj) { + static S390CPUDef s390_qemu_cpu_defs; S390CPU *cpu = S390_CPU(obj); cpu->model = g_malloc0(sizeof(*cpu->model)); - /* TCG emulates a z900 */ - cpu->model->def = &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_defs)); + add_qemu_cpu_model_features(s390_qemu_cpu_defs.full_feat); + cpu->model->def = &s390_qemu_cpu_defs; bitmap_copy(cpu->model->features, cpu->model->def->default_feat, S390_FEAT_MAX); }