From nobody Fri Apr 26 07:41:06 2024 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=1573211380; cv=none; d=zoho.com; s=zohoarc; b=eKXB5ehYmmYn6/asdQqOXdmMqcgxSw8gRiGDCYQb+Iwby2+pN9XTmKcC3QbKd6092LQC/A5uKJpcRZkI/lYJPXVNAzT9cI1fmF+2tMaHeuTBx/ZhXhmXqglAmOJrP1Frrn0tnfIFF+nHdOva8ntCLuWQ9j2PzNF5mTM/SZ4oCGg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573211380; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fRoT2vzPdxZWoqU+KDzlvC6Hqldly5Raoyp/3qGxnlo=; b=Hejh23CdsH/IIvs0oUUc5koT6L/51TJ/ZGVkS8ma1Uihpo230kUgy7WUgjwXaa1+Dw5Mg0Fg83S9g0NDgZh+Qk86yIbVkmXd0HFV8tSa6LuxJqFpAxC++1DU3oCNCUxc2zB9a/jMcQs32qd/aoAgDEKvCPF23SF2gQi33as+4PU= 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 1573211380241147.51427144386435; Fri, 8 Nov 2019 03:09:40 -0800 (PST) Received: from localhost ([::1]:52456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iT294-0003y2-Bz for importer@patchew.org; Fri, 08 Nov 2019 06:09:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58007) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iT273-0001Kx-5D for qemu-devel@nongnu.org; Fri, 08 Nov 2019 06:07:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iT271-0007WX-S3 for qemu-devel@nongnu.org; Fri, 08 Nov 2019 06:07:33 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:43674 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iT271-0007Vf-FG for qemu-devel@nongnu.org; Fri, 08 Nov 2019 06:07:31 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-283-npgG-OpXPyulblx9Y-2hkw-1; Fri, 08 Nov 2019 06:07:26 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 833C8800C72; Fri, 8 Nov 2019 11:07:25 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E3955DA70; Fri, 8 Nov 2019 11:07:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573211250; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fRoT2vzPdxZWoqU+KDzlvC6Hqldly5Raoyp/3qGxnlo=; b=FXR7mTcm1aGJv5QdsarHSfhiOsYrkroQ60jL7C0MfFgD5L9uYhGYM4TGOtea0sZYeUJZMf yyD3W5FbOQQh2Qb7SRfjRfqK73QZl9+oR3200nhKzISvADj0ZSrhrfnRgigSgU3I2iKTAx tlbifzf0bTkUcFZnwg+KMwW9I7BbY1M= From: David Hildenbrand To: qemu-devel@nongnu.org Subject: [PATCH v1 1/2] s390x/cpumodels: Factor out CPU feature dependencies Date: Fri, 8 Nov 2019 12:07:13 +0100 Message-Id: <20191108110714.7475-2-david@redhat.com> In-Reply-To: <20191108110714.7475-1-david@redhat.com> References: <20191108110714.7475-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: npgG-OpXPyulblx9Y-2hkw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Thomas Huth , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Janosch Frank , David Hildenbrand , Cornelia Huck , Richard Henderson , Markus Armbruster , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Michael Mueller , Jiri Denemark , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Currently we check "if bit X is set, bit Y is required". We want to perform "if bit Y is not set, bit X must also not be set" when creating CPU models that will pass all consistency checks. Signed-off-by: David Hildenbrand --- target/s390x/cpu_models.c | 115 +++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 009afc38b9..57c06e5ea1 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -88,6 +88,59 @@ static S390CPUDef s390_cpu_defs[] =3D { CPUDEF_INIT(0x8562, 15, 1, 47, 0x08000000U, "gen15b", "IBM 8562 GA1"), }; =20 +static const int cpu_feature_dependencies[][2] =3D { + { S390_FEAT_IPTE_RANGE, S390_FEAT_DAT_ENH }, + { S390_FEAT_IDTE_SEGMENT, S390_FEAT_DAT_ENH }, + { S390_FEAT_IDTE_REGION, S390_FEAT_DAT_ENH }, + { S390_FEAT_IDTE_REGION, S390_FEAT_IDTE_SEGMENT }, + { S390_FEAT_LOCAL_TLB_CLEARING, S390_FEAT_DAT_ENH}, + { S390_FEAT_LONG_DISPLACEMENT_FAST, S390_FEAT_LONG_DISPLACEMENT }, + { S390_FEAT_DFP_FAST, S390_FEAT_DFP }, + { S390_FEAT_TRANSACTIONAL_EXE, S390_FEAT_STFLE_49 }, + { S390_FEAT_EDAT_2, S390_FEAT_EDAT}, + { S390_FEAT_MSA_EXT_5, S390_FEAT_KIMD_SHA_512 }, + { S390_FEAT_MSA_EXT_5, S390_FEAT_KLMD_SHA_512 }, + { S390_FEAT_MSA_EXT_4, S390_FEAT_MSA_EXT_3 }, + { S390_FEAT_SIE_CMMA, S390_FEAT_CMM }, + { S390_FEAT_SIE_CMMA, S390_FEAT_SIE_GSLS }, + { S390_FEAT_SIE_PFMFI, S390_FEAT_EDAT }, + { S390_FEAT_MSA_EXT_8, S390_FEAT_MSA_EXT_3 }, + { S390_FEAT_MSA_EXT_9, S390_FEAT_MSA_EXT_3 }, + { S390_FEAT_MSA_EXT_9, S390_FEAT_MSA_EXT_4 }, + { S390_FEAT_MULTIPLE_EPOCH, S390_FEAT_TOD_CLOCK_STEERING }, + { S390_FEAT_VECTOR_PACKED_DECIMAL, S390_FEAT_VECTOR }, + { S390_FEAT_VECTOR_ENH, S390_FEAT_VECTOR }, + { S390_FEAT_INSTRUCTION_EXEC_PROT, S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2 = }, + { S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2, S390_FEAT_ESOP }, + { S390_FEAT_CMM_NT, S390_FEAT_CMM }, + { S390_FEAT_GUARDED_STORAGE, S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2 }, + { S390_FEAT_MULTIPLE_EPOCH, S390_FEAT_STORE_CLOCK_FAST }, + { S390_FEAT_MULTIPLE_EPOCH, S390_FEAT_TOD_CLOCK_STEERING }, + { S390_FEAT_SEMAPHORE_ASSIST, S390_FEAT_STFLE_49 }, + { S390_FEAT_KIMD_SHA3_224, S390_FEAT_MSA }, + { S390_FEAT_KIMD_SHA3_256, S390_FEAT_MSA }, + { S390_FEAT_KIMD_SHA3_384, S390_FEAT_MSA }, + { S390_FEAT_KIMD_SHA3_512, S390_FEAT_MSA }, + { S390_FEAT_KIMD_SHAKE_128, S390_FEAT_MSA }, + { S390_FEAT_KIMD_SHAKE_256, S390_FEAT_MSA }, + { S390_FEAT_KLMD_SHA3_224, S390_FEAT_MSA }, + { S390_FEAT_KLMD_SHA3_256, S390_FEAT_MSA }, + { S390_FEAT_KLMD_SHA3_384, S390_FEAT_MSA }, + { S390_FEAT_KLMD_SHA3_512, S390_FEAT_MSA }, + { S390_FEAT_KLMD_SHAKE_128, S390_FEAT_MSA }, + { S390_FEAT_KLMD_SHAKE_256, S390_FEAT_MSA }, + { S390_FEAT_PRNO_TRNG_QRTCR, S390_FEAT_MSA_EXT_5 }, + { S390_FEAT_PRNO_TRNG, S390_FEAT_MSA_EXT_5 }, + { S390_FEAT_SIE_KSS, S390_FEAT_SIE_F2 }, + { S390_FEAT_AP_QUERY_CONFIG_INFO, S390_FEAT_AP }, + { S390_FEAT_AP_FACILITIES_TEST, S390_FEAT_AP }, + { S390_FEAT_PTFF_QSIE, S390_FEAT_MULTIPLE_EPOCH }, + { S390_FEAT_PTFF_QTOUE, S390_FEAT_MULTIPLE_EPOCH }, + { S390_FEAT_PTFF_STOE, S390_FEAT_MULTIPLE_EPOCH }, + { S390_FEAT_PTFF_STOUE, S390_FEAT_MULTIPLE_EPOCH }, + { S390_FEAT_AP_QUEUE_INTERRUPT_CONTROL, S390_FEAT_AP }, +}; + #define QEMU_MAX_CPU_TYPE 0x2964 #define QEMU_MAX_CPU_GEN 13 #define QEMU_MAX_CPU_EC_GA 2 @@ -768,66 +821,14 @@ CpuModelBaselineInfo *qmp_query_cpu_model_baseline(Cp= uModelInfo *infoa, =20 static void check_consistency(const S390CPUModel *model) { - static int dep[][2] =3D { - { S390_FEAT_IPTE_RANGE, S390_FEAT_DAT_ENH }, - { S390_FEAT_IDTE_SEGMENT, S390_FEAT_DAT_ENH }, - { S390_FEAT_IDTE_REGION, S390_FEAT_DAT_ENH }, - { S390_FEAT_IDTE_REGION, S390_FEAT_IDTE_SEGMENT }, - { S390_FEAT_LOCAL_TLB_CLEARING, S390_FEAT_DAT_ENH}, - { S390_FEAT_LONG_DISPLACEMENT_FAST, S390_FEAT_LONG_DISPLACEMENT }, - { S390_FEAT_DFP_FAST, S390_FEAT_DFP }, - { S390_FEAT_TRANSACTIONAL_EXE, S390_FEAT_STFLE_49 }, - { S390_FEAT_EDAT_2, S390_FEAT_EDAT}, - { S390_FEAT_MSA_EXT_5, S390_FEAT_KIMD_SHA_512 }, - { S390_FEAT_MSA_EXT_5, S390_FEAT_KLMD_SHA_512 }, - { S390_FEAT_MSA_EXT_4, S390_FEAT_MSA_EXT_3 }, - { S390_FEAT_SIE_CMMA, S390_FEAT_CMM }, - { S390_FEAT_SIE_CMMA, S390_FEAT_SIE_GSLS }, - { S390_FEAT_SIE_PFMFI, S390_FEAT_EDAT }, - { S390_FEAT_MSA_EXT_8, S390_FEAT_MSA_EXT_3 }, - { S390_FEAT_MSA_EXT_9, S390_FEAT_MSA_EXT_3 }, - { S390_FEAT_MSA_EXT_9, S390_FEAT_MSA_EXT_4 }, - { S390_FEAT_MULTIPLE_EPOCH, S390_FEAT_TOD_CLOCK_STEERING }, - { S390_FEAT_VECTOR_PACKED_DECIMAL, S390_FEAT_VECTOR }, - { S390_FEAT_VECTOR_ENH, S390_FEAT_VECTOR }, - { S390_FEAT_INSTRUCTION_EXEC_PROT, S390_FEAT_SIDE_EFFECT_ACCESS_ES= OP2 }, - { S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2, S390_FEAT_ESOP }, - { S390_FEAT_CMM_NT, S390_FEAT_CMM }, - { S390_FEAT_GUARDED_STORAGE, S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2 }, - { S390_FEAT_MULTIPLE_EPOCH, S390_FEAT_STORE_CLOCK_FAST }, - { S390_FEAT_MULTIPLE_EPOCH, S390_FEAT_TOD_CLOCK_STEERING }, - { S390_FEAT_SEMAPHORE_ASSIST, S390_FEAT_STFLE_49 }, - { S390_FEAT_KIMD_SHA3_224, S390_FEAT_MSA }, - { S390_FEAT_KIMD_SHA3_256, S390_FEAT_MSA }, - { S390_FEAT_KIMD_SHA3_384, S390_FEAT_MSA }, - { S390_FEAT_KIMD_SHA3_512, S390_FEAT_MSA }, - { S390_FEAT_KIMD_SHAKE_128, S390_FEAT_MSA }, - { S390_FEAT_KIMD_SHAKE_256, S390_FEAT_MSA }, - { S390_FEAT_KLMD_SHA3_224, S390_FEAT_MSA }, - { S390_FEAT_KLMD_SHA3_256, S390_FEAT_MSA }, - { S390_FEAT_KLMD_SHA3_384, S390_FEAT_MSA }, - { S390_FEAT_KLMD_SHA3_512, S390_FEAT_MSA }, - { S390_FEAT_KLMD_SHAKE_128, S390_FEAT_MSA }, - { S390_FEAT_KLMD_SHAKE_256, S390_FEAT_MSA }, - { S390_FEAT_PRNO_TRNG_QRTCR, S390_FEAT_MSA_EXT_5 }, - { S390_FEAT_PRNO_TRNG, S390_FEAT_MSA_EXT_5 }, - { S390_FEAT_SIE_KSS, S390_FEAT_SIE_F2 }, - { S390_FEAT_AP_QUERY_CONFIG_INFO, S390_FEAT_AP }, - { S390_FEAT_AP_FACILITIES_TEST, S390_FEAT_AP }, - { S390_FEAT_PTFF_QSIE, S390_FEAT_MULTIPLE_EPOCH }, - { S390_FEAT_PTFF_QTOUE, S390_FEAT_MULTIPLE_EPOCH }, - { S390_FEAT_PTFF_STOE, S390_FEAT_MULTIPLE_EPOCH }, - { S390_FEAT_PTFF_STOUE, S390_FEAT_MULTIPLE_EPOCH }, - { S390_FEAT_AP_QUEUE_INTERRUPT_CONTROL, S390_FEAT_AP }, - }; int i; =20 - for (i =3D 0; i < ARRAY_SIZE(dep); i++) { - if (test_bit(dep[i][0], model->features) && - !test_bit(dep[i][1], model->features)) { + for (i =3D 0; i < ARRAY_SIZE(cpu_feature_dependencies); i++) { + if (test_bit(cpu_feature_dependencies[i][0], model->features) && + !test_bit(cpu_feature_dependencies[i][1], model->features)) { warn_report("\'%s\' requires \'%s\'.", - s390_feat_def(dep[i][0])->name, - s390_feat_def(dep[i][1])->name); + s390_feat_def(cpu_feature_dependencies[i][0])->nam= e, + s390_feat_def(cpu_feature_dependencies[i][1])->nam= e); } } } --=20 2.21.0 From nobody Fri Apr 26 07:41:06 2024 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=1573211310; cv=none; d=zoho.com; s=zohoarc; b=SFqdfMqgOvz7dHKK+hZ5n1+V9z4Ehw3oS+E5vcAOwoLD3E5iizZzqR1umnHljLf0d9Y34cNVcJdW2kS8iqSrI6rNYA8DA2PdcyWWcYr0zCyOXq09/0cXBp1FJKkev6Ky9OT0+tbc3tD2JM5DQIk2WQkE+sdTQKM4ILKLKwbBZgM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573211310; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/Qs0wfT67g8m1YAIfOzW7By2Klybg7xnOHdIWRU8Z9g=; b=SUILE4KT2u2tv792nOBkGzgGyYza7LwDgGMi98gCGiODinhf/Dsrg/nKh3NWZOlzJnL1ysPjER/SAgcoITkiPwg8UYNGQ8GAvn1X43MBnxvKmu6iXJFweQvM5G/Z+SUOedaJl66Oz1lzxbjqh3aECpUtJlE/l2W3ySCFzgKNvGM= 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 1573211310259784.11959799968; Fri, 8 Nov 2019 03:08:30 -0800 (PST) Received: from localhost ([::1]:52446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iT27w-0002Pw-8a for importer@patchew.org; Fri, 08 Nov 2019 06:08:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58026) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iT275-0001OF-JH for qemu-devel@nongnu.org; Fri, 08 Nov 2019 06:07:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iT273-0007X5-Rv for qemu-devel@nongnu.org; Fri, 08 Nov 2019 06:07:35 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:36727 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iT273-0007Wq-Ho for qemu-devel@nongnu.org; Fri, 08 Nov 2019 06:07:33 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-297-4Ez46kfFNgu4nJvGRyQn7g-1; Fri, 08 Nov 2019 06:07:29 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8559A107ACC3; Fri, 8 Nov 2019 11:07:28 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id CEA095DA70; Fri, 8 Nov 2019 11:07:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573211253; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/Qs0wfT67g8m1YAIfOzW7By2Klybg7xnOHdIWRU8Z9g=; b=L3VIdnE7JSKy7/cuPA3l68qF7ucMnEpXb7YZZGORta6Oa979Fdt8W8Q9R3u1ZMpRfBFHBN o97eKkLky6NPugZBu1JfGI6mgnaLcQAshEu+c+B2rD89X8yU8HOoN4XuFAlF1g2SPjqBj4 tN3Elrko9QDJMpNUHBohNSgEbAceFYQ= From: David Hildenbrand To: qemu-devel@nongnu.org Subject: [PATCH v1 2/2] s390x/cpumodel: Introduce "best" model variants Date: Fri, 8 Nov 2019 12:07:14 +0100 Message-Id: <20191108110714.7475-3-david@redhat.com> In-Reply-To: <20191108110714.7475-1-david@redhat.com> References: <20191108110714.7475-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: 4Ez46kfFNgu4nJvGRyQn7g-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Thomas Huth , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Janosch Frank , David Hildenbrand , Cornelia Huck , Richard Henderson , Markus Armbruster , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Michael Mueller , Jiri Denemark , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" For a specific CPU model, we have a lot of feature variability depending on - The microcode version of the HW - The hypervisor we're running on (LPAR vs. KVM vs. z/VM) - The hypervisor version we're running on - The KVM version - KVM module parameters (especially, "nested=3D1") - The accelerator Our default models are migration safe, however can only be changed between QEMU releases (glued to QEMU machine). This somewhat collides with the feature variability we have. E.g., the z13 model will not run under TCG. There is the demand from higher levels in the stack to "have the best CPU model possible on a given accelerator, firmware and HW", which should especially include all features that fix security issues. Especially, if we have a new feature due to a security flaw, we want to have a way to backport this feature to older QEMU versions and a way to automatically enable it when asked. This is where "best" CPU models come into play. If upper layers specify "z14-best" on a z14, they will get the best possible feature set in that configuration. "best" usually means "maximum features", besides deprecated features. This will then, for example, include nested virtualization ("SIE" feature) when KVM+HW support is enabled, or fixes via microcode updates (e.g., spectre) "best" models are not migration safe. Upper layers can expand these models to migration-safe and static variants, allowing them to be migrated. Signed-off-by: David Hildenbrand --- target/s390x/cpu-qom.h | 1 + target/s390x/cpu_models.c | 96 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 95 insertions(+), 2 deletions(-) diff --git a/target/s390x/cpu-qom.h b/target/s390x/cpu-qom.h index b809ec8418..73901d1410 100644 --- a/target/s390x/cpu-qom.h +++ b/target/s390x/cpu-qom.h @@ -52,6 +52,7 @@ typedef struct S390CPUClass { bool kvm_required; bool is_static; bool is_migration_safe; + bool is_best; const char *desc; =20 DeviceRealize parent_realize; diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 57c06e5ea1..a379b4c15d 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -557,11 +557,16 @@ static void cpu_model_from_info(S390CPUModel *model, = const CpuModelInfo *info, obj =3D object_new(object_class_get_name(oc)); cpu =3D S390_CPU(obj); =20 - if (!cpu->model) { + if (!cpu->model && !S390_CPU_CLASS(oc)->is_best) { error_setg(errp, "Details about the host CPU model are not availab= le, " "it cannot be used."); object_unref(obj); return; + } else if (!cpu->model) { + error_setg(errp, "There is not best CPU model that is runnable," + "therefore, it cannot be used."); + object_unref(obj); + return; } =20 if (qdict) { @@ -932,7 +937,7 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) return; } =20 - if (!cpu->model) { + if (!cpu->model && !xcc->is_best) { /* no host model support -> perform compatibility stuff */ apply_cpu_model(NULL, errp); return; @@ -944,6 +949,11 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) return; } =20 + if (xcc->is_best && !cpu->model) { + error_setg(errp, "Selected CPU model is too new."); + return; + } + /* copy over properties that can vary */ cpu->model->lowest_ibc =3D max_model->lowest_ibc; cpu->model->cpu_id =3D max_model->cpu_id; @@ -1156,6 +1166,58 @@ static void s390_qemu_cpu_model_initfn(Object *obj) memcpy(cpu->model, &s390_qemu_cpu_model, sizeof(*cpu->model)); } =20 +static void s390_best_cpu_model_initfn(Object *obj) +{ + const S390CPUModel *max_model; + S390CPU *cpu =3D S390_CPU(obj); + S390CPUClass *xcc =3D S390_CPU_GET_CLASS(cpu); + Error *local_err =3D NULL; + int i; + + if (kvm_enabled() && !kvm_s390_cpu_models_supported()) { + return; + } + + max_model =3D get_max_cpu_model(&local_err); + if (local_err) { + /* we expect errors only under KVM, when actually querying the ker= nel */ + g_assert(kvm_enabled()); + error_report_err(local_err); + return; + } + + /* + * Similar to baselining against the "max" model. However, features + * are handled differently and are not used for the search for a defin= ition. + */ + if (xcc->cpu_def->gen =3D=3D max_model->def->gen) { + if (xcc->cpu_def->ec_ga > max_model->def->ec_ga) { + return; + } + } else if (xcc->cpu_def->gen > max_model->def->gen) { + return; + } + + /* The model is theoretically runnable, construct the features. */ + cpu->model =3D g_new(S390CPUModel, 1); + cpu->model->def =3D xcc->cpu_def; + bitmap_copy(cpu->model->features, xcc->cpu_def->full_feat, S390_FEAT_M= AX); + + /* Mask of features that are not available in the "max" model */ + bitmap_and(cpu->model->features, cpu->model->features, max_model->feat= ures, + S390_FEAT_MAX); + + /* Mask off deprecated features */ + clear_bit(S390_FEAT_CONDITIONAL_SSKE, cpu->model->features); + + /* Make sure every model passes consistency checks */ + for (i =3D 0; i < ARRAY_SIZE(cpu_feature_dependencies); i++) { + if (!test_bit(cpu_feature_dependencies[i][1], cpu->model->features= )) { + clear_bit(cpu_feature_dependencies[i][0], cpu->model->features= ); + } + } +} + static void s390_max_cpu_model_initfn(Object *obj) { const S390CPUModel *max_model; @@ -1235,6 +1297,20 @@ static void s390_base_cpu_model_class_init(ObjectCla= ss *oc, void *data) xcc->desc =3D xcc->cpu_def->desc; } =20 +static void s390_best_cpu_model_class_init(ObjectClass *oc, void *data) +{ + S390CPUClass *xcc =3D S390_CPU_CLASS(oc); + + /* + * The "best" models are neither static nor migration safe, similar to + * the "max" model. + */ + xcc->is_best =3D true; + xcc->cpu_def =3D (const S390CPUDef *) data; + xcc->desc =3D g_strdup_printf("%s with best features supported by the = accelerator in the current host", + xcc->cpu_def->desc); +} + static void s390_cpu_model_class_init(ObjectClass *oc, void *data) { S390CPUClass *xcc =3D S390_CPU_CLASS(oc); @@ -1280,6 +1356,12 @@ static char *s390_base_cpu_type_name(const char *mod= el_name) return g_strdup_printf(S390_CPU_TYPE_NAME("%s-base"), model_name); } =20 +/* Generate type name for a best cpu model. Caller has to free the string.= */ +static char *s390_best_cpu_type_name(const char *model_name) +{ + return g_strdup_printf(S390_CPU_TYPE_NAME("%s-best"), model_name); +} + ObjectClass *s390_cpu_class_by_name(const char *name) { char *typename =3D s390_cpu_type_name(name); @@ -1380,9 +1462,19 @@ static void register_types(void) .class_init =3D s390_cpu_model_class_init, .class_data =3D (void *) &s390_cpu_defs[i], }; + char *best_name =3D s390_best_cpu_type_name(s390_cpu_defs[i].name); + TypeInfo ti_best =3D { + .name =3D best_name, + .parent =3D TYPE_S390_CPU, + .instance_init =3D s390_best_cpu_model_initfn, + .instance_finalize =3D s390_cpu_model_finalize, + .class_init =3D s390_best_cpu_model_class_init, + .class_data =3D (void *) &s390_cpu_defs[i], + }; =20 type_register_static(&ti_base); type_register_static(&ti); + type_register_static(&ti_best); g_free(base_name); g_free(name); } --=20 2.21.0