All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <dahi@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: ehabkost@redhat.com, jdenemar@redhat.com, imammedo@redhat.com,
	cornelia.huck@de.ibm.com, borntraeger@de.ibm.com,
	fiuczy@linux.vnet.ibm.com, mimu@linux.vnet.ibm.com
Subject: [Qemu-devel] [Patch v3 08/30] s390x/cpumodel: register defined CPU models as subclasses
Date: Wed, 24 Aug 2016 20:10:44 +0200	[thread overview]
Message-ID: <1472062266-53206-9-git-send-email-dahi@linux.vnet.ibm.com> (raw)
In-Reply-To: <1472062266-53206-1-git-send-email-dahi@linux.vnet.ibm.com>

This patch adds the CPU model definitions that are known on s390x -
like z900, zBC12 or z13. For each definition, introduce two CPU models:

1. Base model (e.g. z13-base): Minimum feature set we expect to be around
   on all z13 systems. These models are migration-safe and will never
   change.
2. Flexible models (e.g. z13): Models that can change between QEMU versions
   and will be extended over time as we implement further features that
   are already part of such a model in real hardware of certain
   configurations.

Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
---
 target-s390x/cpu-qom.h    |   2 +
 target-s390x/cpu_models.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++
 target-s390x/cpu_models.h |  36 +++++++++++++++
 3 files changed, 151 insertions(+)
 create mode 100644 target-s390x/cpu_models.h

diff --git a/target-s390x/cpu-qom.h b/target-s390x/cpu-qom.h
index bb993d4..4e936e7 100644
--- a/target-s390x/cpu-qom.h
+++ b/target-s390x/cpu-qom.h
@@ -21,6 +21,7 @@
 #define QEMU_S390_CPU_QOM_H
 
 #include "qom/cpu.h"
+#include "cpu_models.h"
 
 #define TYPE_S390_CPU "s390-cpu"
 
@@ -45,6 +46,7 @@ typedef struct S390CPUClass {
     /*< private >*/
     CPUClass parent_class;
     /*< public >*/
+    const S390CPUDef *cpu_def;
     bool kvm_required;
     bool is_static;
     bool is_migration_safe;
diff --git a/target-s390x/cpu_models.c b/target-s390x/cpu_models.c
index 7b887f7..b59765c 100644
--- a/target-s390x/cpu_models.c
+++ b/target-s390x/cpu_models.c
@@ -12,11 +12,66 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
+#include "gen-features.h"
 #include "qapi/error.h"
 #ifndef CONFIG_USER_ONLY
 #include "sysemu/arch_init.h"
 #endif
 
+#define CPUDEF_INIT(_type, _gen, _ec_ga, _mha_pow, _hmfai, _name, _desc) \
+    {                                                                    \
+        .name = _name,                                                   \
+        .type = _type,                                                   \
+        .gen = _gen,                                                     \
+        .ec_ga = _ec_ga,                                                 \
+        .mha_pow = _mha_pow,                                             \
+        .hmfai = _hmfai,                                                 \
+        .desc = _desc,                                                   \
+        .base_feat = { S390_FEAT_LIST_GEN ## _gen ## _GA ## _ec_ga ## _BASE },  \
+        .default_feat = { S390_FEAT_LIST_GEN ## _gen ## _GA ## _ec_ga ## _DEFAULT },  \
+        .full_feat = { S390_FEAT_LIST_GEN ## _gen ## _GA ## _ec_ga ## _FULL },  \
+    }
+
+/*
+ * CPU definiton list in order of release. For now, base features of a
+ * following release are always a subset of base features of the previous
+ * release. Same is correct for the other feature sets.
+ * A BC release always follows the corresponding EC release.
+ */
+static const S390CPUDef s390_cpu_defs[] = {
+    CPUDEF_INIT(0x2064, 7, 1, 38, 0x00000000U, "z900", "IBM zSeries 900 GA1"),
+    CPUDEF_INIT(0x2064, 7, 2, 38, 0x00000000U, "z900.2", "IBM zSeries 900 GA2"),
+    CPUDEF_INIT(0x2064, 7, 3, 38, 0x00000000U, "z900.3", "IBM zSeries 900 GA3"),
+    CPUDEF_INIT(0x2066, 7, 3, 38, 0x00000000U, "z800", "IBM zSeries 800 GA1"),
+    CPUDEF_INIT(0x2084, 8, 1, 38, 0x00000000U, "z990", "IBM zSeries 990 GA1"),
+    CPUDEF_INIT(0x2084, 8, 2, 38, 0x00000000U, "z990.2", "IBM zSeries 990 GA2"),
+    CPUDEF_INIT(0x2084, 8, 3, 38, 0x00000000U, "z990.3", "IBM zSeries 990 GA3"),
+    CPUDEF_INIT(0x2086, 8, 3, 38, 0x00000000U, "z890", "IBM zSeries 880 GA1"),
+    CPUDEF_INIT(0x2084, 8, 4, 38, 0x00000000U, "z990.4", "IBM zSeries 990 GA4"),
+    CPUDEF_INIT(0x2086, 8, 4, 38, 0x00000000U, "z890.2", "IBM zSeries 880 GA2"),
+    CPUDEF_INIT(0x2084, 8, 5, 38, 0x00000000U, "z990.5", "IBM zSeries 990 GA5"),
+    CPUDEF_INIT(0x2086, 8, 5, 38, 0x00000000U, "z890.3", "IBM zSeries 880 GA3"),
+    CPUDEF_INIT(0x2094, 9, 1, 40, 0x00000000U, "z9EC", "IBM System z9 EC GA1"),
+    CPUDEF_INIT(0x2094, 9, 2, 40, 0x00000000U, "z9EC.2", "IBM System z9 EC GA2"),
+    CPUDEF_INIT(0x2096, 9, 2, 40, 0x00000000U, "z9BC", "IBM System z9 BC GA1"),
+    CPUDEF_INIT(0x2094, 9, 3, 40, 0x00000000U, "z9EC.3", "IBM System z9 EC GA3"),
+    CPUDEF_INIT(0x2096, 9, 3, 40, 0x00000000U, "z9BC.2", "IBM System z9 BC GA2"),
+    CPUDEF_INIT(0x2097, 10, 1, 43, 0x00000000U, "z10EC", "IBM System z10 EC GA1"),
+    CPUDEF_INIT(0x2097, 10, 2, 43, 0x00000000U, "z10EC.2", "IBM System z10 EC GA2"),
+    CPUDEF_INIT(0x2098, 10, 2, 43, 0x00000000U, "z10BC", "IBM System z10 BC GA1"),
+    CPUDEF_INIT(0x2097, 10, 3, 43, 0x00000000U, "z10EC.3", "IBM System z10 EC GA3"),
+    CPUDEF_INIT(0x2098, 10, 3, 43, 0x00000000U, "z10BC.2", "IBM System z10 BC GA2"),
+    CPUDEF_INIT(0x2817, 11, 1, 44, 0x08000000U, "z196", "IBM zEnterprise 196 GA1"),
+    CPUDEF_INIT(0x2817, 11, 2, 44, 0x08000000U, "z196.2", "IBM zEnterprise 196 GA2"),
+    CPUDEF_INIT(0x2818, 11, 2, 44, 0x08000000U, "z114", "IBM zEnterprise 114 GA1"),
+    CPUDEF_INIT(0x2827, 12, 1, 44, 0x08000000U, "zEC12", "IBM zEnterprise EC12 GA1"),
+    CPUDEF_INIT(0x2827, 12, 2, 44, 0x08000000U, "zEC12.2", "IBM zEnterprise EC12 GA2"),
+    CPUDEF_INIT(0x2828, 12, 2, 44, 0x08000000U, "zBC12", "IBM zEnterprise BC12 GA1"),
+    CPUDEF_INIT(0x2964, 13, 1, 47, 0x08000000U, "z13", "IBM z13 GA1"),
+    CPUDEF_INIT(0x2964, 13, 2, 47, 0x08000000U, "z13.2", "IBM z13 GA2"),
+    CPUDEF_INIT(0x2965, 13, 2, 47, 0x08000000U, "z13s", "IBM z13s GA1"),
+};
+
 struct S390PrintCpuListInfo {
     FILE *f;
     fprintf_function print;
@@ -96,6 +151,10 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp)
     }
 }
 
+static void s390_cpu_model_initfn(Object *obj)
+{
+}
+
 #ifdef CONFIG_KVM
 static void s390_host_cpu_model_initfn(Object *obj)
 {
@@ -145,6 +204,27 @@ static void s390_host_cpu_model_class_init(ObjectClass *oc, void *data)
 }
 #endif
 
+static void s390_base_cpu_model_class_init(ObjectClass *oc, void *data)
+{
+    S390CPUClass *xcc = S390_CPU_CLASS(oc);
+
+    /* all base models are migration safe */
+    xcc->cpu_def = (const S390CPUDef *) data;
+    xcc->is_migration_safe = true;
+    xcc->is_static = true;
+    xcc->desc = xcc->cpu_def->desc;
+}
+
+static void s390_cpu_model_class_init(ObjectClass *oc, void *data)
+{
+    S390CPUClass *xcc = S390_CPU_CLASS(oc);
+
+    /* model that can change between QEMU versions */
+    xcc->cpu_def = (const S390CPUDef *) data;
+    xcc->is_migration_safe = true;
+    xcc->desc = xcc->cpu_def->desc;
+}
+
 static void s390_qemu_cpu_model_class_init(ObjectClass *oc, void *data)
 {
     S390CPUClass *xcc = S390_CPU_CLASS(oc);
@@ -163,6 +243,12 @@ static char *s390_cpu_type_name(const char *model_name)
     return g_strdup_printf(S390_CPU_TYPE_NAME("%s"), model_name);
 }
 
+/* Generate type name for a base cpu model. Caller has to free the string. */
+static char *s390_base_cpu_type_name(const char *model_name)
+{
+    return g_strdup_printf(S390_CPU_TYPE_NAME("%s-base"), model_name);
+}
+
 ObjectClass *s390_cpu_class_by_name(const char *name)
 {
     char *typename = s390_cpu_type_name(name);
@@ -193,6 +279,33 @@ static const TypeInfo host_s390_cpu_type_info = {
 
 static void register_types(void)
 {
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(s390_cpu_defs); i++) {
+        char *base_name = s390_base_cpu_type_name(s390_cpu_defs[i].name);
+        TypeInfo ti_base = {
+            .name = base_name,
+            .parent = TYPE_S390_CPU,
+            .instance_init = s390_cpu_model_initfn,
+            .instance_finalize = s390_cpu_model_finalize,
+            .class_init = s390_base_cpu_model_class_init,
+            .class_data = (void *) &s390_cpu_defs[i],
+        };
+        char *name = s390_cpu_type_name(s390_cpu_defs[i].name);
+        TypeInfo ti = {
+            .name = name,
+            .parent = TYPE_S390_CPU,
+            .instance_init = s390_cpu_model_initfn,
+            .instance_finalize = s390_cpu_model_finalize,
+            .class_init = s390_cpu_model_class_init,
+            .class_data = (void *) &s390_cpu_defs[i],
+        };
+
+        type_register_static(&ti_base);
+        type_register_static(&ti);
+        g_free(base_name);
+        g_free(name);
+    }
     type_register_static(&qemu_s390_cpu_type_info);
 #ifdef CONFIG_KVM
     type_register_static(&host_s390_cpu_type_info);
diff --git a/target-s390x/cpu_models.h b/target-s390x/cpu_models.h
new file mode 100644
index 0000000..13f7217
--- /dev/null
+++ b/target-s390x/cpu_models.h
@@ -0,0 +1,36 @@
+/*
+ * CPU models for s390x
+ *
+ * Copyright 2016 IBM Corp.
+ *
+ * Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
+ * your option) any later version. See the COPYING file in the top-level
+ * directory.
+ */
+
+#ifndef TARGET_S390X_CPU_MODELS_H
+#define TARGET_S390X_CPU_MODELS_H
+
+#include "cpu_features.h"
+#include "qom/cpu.h"
+
+/* static CPU definition */
+typedef struct S390CPUDef {
+    const char *name;       /* name exposed to the user */
+    const char *desc;       /* description exposed to the user */
+    uint8_t gen;            /* hw generation identification */
+    uint16_t type;          /* cpu type identification */
+    uint8_t ec_ga;          /* EC GA version (on which also the BC is based) */
+    uint8_t mha_pow;        /* Maximum Host Adress Power, mha = 2^pow-1 */
+    uint32_t hmfai;         /* hypervisor-managed facilities */
+    /* base/min features, must never be changed between QEMU versions */
+    S390FeatBitmap base_feat;
+    /* deafault features, QEMU version specific */
+    S390FeatBitmap default_feat;
+    /* max allowed features, QEMU version specific */
+    S390FeatBitmap full_feat;
+} S390CPUDef;
+
+#endif /* TARGET_S390X_CPU_MODELS_H */
-- 
2.6.6

  parent reply	other threads:[~2016-08-24 18:11 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-24 18:10 [Qemu-devel] [Patch v3 00/30] s390x CPU models: exposing features David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 01/30] qmp: details about CPU definitions in query-cpu-definitions David Hildenbrand
2016-08-24 20:49   ` Eric Blake
2016-08-24 20:55     ` David Hildenbrand
2016-08-29  9:09       ` Cornelia Huck
2016-08-29 10:13   ` [Qemu-devel] [Patch " David Hildenbrand
2016-08-29 14:47     ` Eric Blake
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 02/30] s390x/cpumodel: "host" and "qemu" as CPU subclasses David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 03/30] s390x/cpumodel: expose CPU class properties David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 04/30] s390x/cpumodel: introduce CPU features David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 05/30] s390x/cpumodel: generate CPU feature lists for CPU models David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 06/30] s390x/cpumodel: generate CPU feature group lists David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 07/30] s390x/cpumodel: introduce CPU feature group definitions David Hildenbrand
2016-08-24 18:10 ` David Hildenbrand [this message]
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 09/30] s390x/cpumodel: store the CPU model in the CPU instance David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 10/30] s390x/cpumodel: expose features and feature groups as properties David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 11/30] s390x/cpumodel: let the CPU model handle feature checks David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 12/30] s390x/cpumodel: check and apply the CPU model David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 13/30] s390x/sclp: factor out preparation of cpu entries David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 14/30] s390x/sclp: introduce sclp feature blocks David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 15/30] s390x/sclp: indicate sclp features David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 16/30] s390x/sclp: propagate the ibc val(lowest and unblocked ibc) David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 17/30] s390x/sclp: propagate the mha via sclp David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 18/30] s390x/sclp: propagate hmfai David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 19/30] linux-headers: update against kvm/next David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 20/30] s390x/kvm: allow runtime-instrumentation for "none" machine David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 21/30] s390x/kvm: implement CPU model support David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 22/30] s390x/kvm: disable host model for problematic compat machines David Hildenbrand
2016-08-24 18:10 ` [Qemu-devel] [Patch v3 23/30] s390x/kvm: let the CPU model control CMM(A) David Hildenbrand
2016-08-24 18:11 ` [Qemu-devel] [Patch v3 24/30] s390x/kvm: don't enable key wrapping if msa3 is disabled David Hildenbrand
2016-08-24 18:11 ` [Qemu-devel] [Patch v3 25/30] qmp: add QMP interface "query-cpu-model-expansion" David Hildenbrand
2016-08-24 19:43   ` Eduardo Habkost
2016-08-24 18:11 ` [Qemu-devel] [Patch v3 26/30] qmp: add QMP interface "query-cpu-model-comparison" David Hildenbrand
2016-08-24 19:45   ` Eduardo Habkost
2016-08-24 18:11 ` [Qemu-devel] [Patch v3 27/30] qmp: add QMP interface "query-cpu-model-baseline" David Hildenbrand
2016-08-24 19:46   ` Eduardo Habkost
2016-08-24 18:11 ` [Qemu-devel] [Patch v3 28/30] s390x/cpumodel: implement QMP interface "query-cpu-model-expansion" David Hildenbrand
2016-08-24 18:11 ` [Qemu-devel] [Patch v3 29/30] s390x/cpumodel: implement QMP interface "query-cpu-model-comparison" David Hildenbrand
2016-08-24 18:11 ` [Qemu-devel] [Patch v3 30/30] s390x/cpumodel: implement QMP interface "query-cpu-model-baseline" David Hildenbrand
2016-08-24 19:02 ` [Qemu-devel] [Patch v3 00/30] s390x CPU models: exposing features no-reply
2016-08-29  8:34 ` David Hildenbrand
2016-08-29  9:11   ` Cornelia Huck
2016-08-29 11:37 ` Cornelia Huck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1472062266-53206-9-git-send-email-dahi@linux.vnet.ibm.com \
    --to=dahi@linux.vnet.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=ehabkost@redhat.com \
    --cc=fiuczy@linux.vnet.ibm.com \
    --cc=imammedo@redhat.com \
    --cc=jdenemar@redhat.com \
    --cc=mimu@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.