qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Collin Walling <walling@linux.ibm.com>
To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org
Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com,
	philmd@linaro.org, wangyanan55@huawei.com, eblake@redhat.com,
	armbru@redhat.com, david@redhat.com,
	richard.henderson@linaro.org, iii@linux.ibm.com,
	thuth@redhat.com
Subject: [PATCH v1 1/2] target/s390x: introduce "host-recommended" option for model expansion
Date: Mon, 11 Sep 2023 16:52:31 -0400	[thread overview]
Message-ID: <20230911205232.71735-1-walling@linux.ibm.com> (raw)

Newer S390 machines may drop support for features completely, rendering
guests operating with older CPU models incapable of running on said
machines. A manual effort to disable certain CPU features would be
required.

To alleviate this issue, a list of "deprecated" features are now
retained within QEMU, and a new "static-recommended" CPU model expansion
type has been created to allow a query of the host-model with deprecated
features explicitly disabled.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
---
 qapi/machine-target.json         |  8 +++++++-
 target/s390x/cpu_features.c      | 14 ++++++++++++++
 target/s390x/cpu_features.h      |  1 +
 target/s390x/cpu_models_sysemu.c | 26 +++++++++++++++++++++-----
 4 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/qapi/machine-target.json b/qapi/machine-target.json
index f0a6b72414..4dc891809d 100644
--- a/qapi/machine-target.json
+++ b/qapi/machine-target.json
@@ -42,6 +42,12 @@
 #     to be migration-safe, but allows tooling to get an insight and
 #     work with model details.
 #
+# @static-recommended: Expand to a static CPU model with property
+#     changes suggested by the architecture. This is useful for
+#     expanding a CPU model expected to operate in mixed
+#     CPU-generation environments. The @static-recommended CPU
+#     models are migration-safe.
+#
 # Note: When a non-migration-safe CPU model is expanded in static
 #     mode, some features enabled by the CPU model may be omitted,
 #     because they can't be implemented by a static CPU model
@@ -55,7 +61,7 @@
 # Since: 2.8
 ##
 { 'enum': 'CpuModelExpansionType',
-  'data': [ 'static', 'full' ] }
+  'data': [ 'static', 'full', 'static-recommended' ] }
 
 ##
 # @CpuModelCompareResult:
diff --git a/target/s390x/cpu_features.c b/target/s390x/cpu_features.c
index d28eb65845..efafc9711c 100644
--- a/target/s390x/cpu_features.c
+++ b/target/s390x/cpu_features.c
@@ -212,6 +212,20 @@ void s390_feat_bitmap_to_ascii(const S390FeatBitmap features, void *opaque,
     };
 }
 
+void s390_get_deprecated_features(S390FeatBitmap features)
+{
+    static const int feats[] = {
+         /* CSSKE is deprecated on newer generations */
+         S390_FEAT_CONDITIONAL_SSKE,
+         S390_FEAT_BPB,
+    };
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(feats); i++) {
+        set_bit(feats[i], features);
+    }
+}
+
 #define FEAT_GROUP_INIT(_name, _group, _desc)        \
     {                                                \
         .name = _name,                               \
diff --git a/target/s390x/cpu_features.h b/target/s390x/cpu_features.h
index 87463f064d..5421762db5 100644
--- a/target/s390x/cpu_features.h
+++ b/target/s390x/cpu_features.h
@@ -68,6 +68,7 @@ void s390_add_from_feat_block(S390FeatBitmap features, S390FeatType type,
                           uint8_t *data);
 void s390_feat_bitmap_to_ascii(const S390FeatBitmap features, void *opaque,
                                void (*fn)(const char *name, void *opaque));
+void s390_get_deprecated_features(S390FeatBitmap features);
 
 /* Definition of a CPU feature group */
 typedef struct {
diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sysemu.c
index 63981bf36b..1aa3d076b4 100644
--- a/target/s390x/cpu_models_sysemu.c
+++ b/target/s390x/cpu_models_sysemu.c
@@ -176,7 +176,7 @@ static void qdict_add_enabled_feat(const char *name, void *opaque)
 
 /* convert S390CPUDef into a static CpuModelInfo */
 static void cpu_info_from_model(CpuModelInfo *info, const S390CPUModel *model,
-                                bool delta_changes)
+                                bool delta_changes, bool disable_dep_feats)
 {
     QDict *qdict = qdict_new();
     S390FeatBitmap bitmap;
@@ -198,6 +198,13 @@ static void cpu_info_from_model(CpuModelInfo *info, const S390CPUModel *model,
         if (!bitmap_empty(bitmap, S390_FEAT_MAX)) {
             s390_feat_bitmap_to_ascii(bitmap, qdict, qdict_add_enabled_feat);
         }
+
+        /* features flagged as deprecated */
+        if (disable_dep_feats) {
+            bitmap_zero(bitmap, S390_FEAT_MAX);
+            s390_get_deprecated_features(bitmap);
+            s390_feat_bitmap_to_ascii(bitmap, qdict, qdict_add_disabled_feat);
+        }
     } else {
         /* expand all features */
         s390_feat_bitmap_to_ascii(model->features, qdict,
@@ -221,6 +228,7 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,
     CpuModelExpansionInfo *expansion_info = NULL;
     S390CPUModel s390_model;
     bool delta_changes = false;
+    bool disable_dep_feats = false;
 
     /* convert it to our internal representation */
     cpu_model_from_info(&s390_model, model, &err);
@@ -229,9 +237,16 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,
         return NULL;
     }
 
-    if (type == CPU_MODEL_EXPANSION_TYPE_STATIC) {
+    switch (type) {
+    case CPU_MODEL_EXPANSION_TYPE_STATIC_RECOMMENDED:
+        disable_dep_feats = true;
+        /* fall through */
+    case CPU_MODEL_EXPANSION_TYPE_STATIC:
         delta_changes = true;
-    } else if (type != CPU_MODEL_EXPANSION_TYPE_FULL) {
+        break;
+    case CPU_MODEL_EXPANSION_TYPE_FULL:
+        break;
+    default:
         error_setg(errp, "The requested expansion type is not supported.");
         return NULL;
     }
@@ -239,7 +254,8 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,
     /* convert it back to a static representation */
     expansion_info = g_new0(CpuModelExpansionInfo, 1);
     expansion_info->model = g_malloc0(sizeof(*expansion_info->model));
-    cpu_info_from_model(expansion_info->model, &s390_model, delta_changes);
+    cpu_info_from_model(expansion_info->model, &s390_model,
+                        delta_changes, disable_dep_feats);
     return expansion_info;
 }
 
@@ -388,7 +404,7 @@ CpuModelBaselineInfo *qmp_query_cpu_model_baseline(CpuModelInfo *infoa,
 
     baseline_info = g_new0(CpuModelBaselineInfo, 1);
     baseline_info->model = g_malloc0(sizeof(*baseline_info->model));
-    cpu_info_from_model(baseline_info->model, &model, true);
+    cpu_info_from_model(baseline_info->model, &model, true, false);
     return baseline_info;
 }
 
-- 
2.41.0



             reply	other threads:[~2023-09-11 20:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11 20:52 Collin Walling [this message]
2023-09-11 20:52 ` [PATCH v1 2/2] target/s390x: flag te and cte as deprecated Collin Walling
2023-09-12  6:59   ` David Hildenbrand
2023-09-12  6:57 ` [PATCH v1 1/2] target/s390x: introduce "host-recommended" option for model expansion David Hildenbrand
2023-09-14 19:28   ` Collin Walling

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=20230911205232.71735-1-walling@linux.ibm.com \
    --to=walling@linux.ibm.com \
    --cc=armbru@redhat.com \
    --cc=david@redhat.com \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=iii@linux.ibm.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    --cc=wangyanan55@huawei.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).