Skip to contentSkip to conversation

target/s390x: introduce "host-recommended" option for model expansion

PATCH In review Collin Walling 2 participants 5 messages Sep 11, 2023 – Sep 14, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 target/s390x: introduce "host-recommended" option for model expansion

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.

---
 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(-)
qapi/machine-target.json +7 -1
index f0a6b72414..4dc891809d 100644
@@ -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:
target/s390x/cpu_features.c +14 -0
index d28eb65845..efafc9711c 100644
@@ -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,                               \
target/s390x/cpu_features.h +1 -0
index 87463f064d..5421762db5 100644
@@ -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 {
target/s390x/cpu_models_sysemu.c +21 -5
index 63981bf36b..1aa3d076b4 100644
@@ -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;
 }
 
Signature · 1 line
2.41.0
#1 lore raw

PATCH 2/2 target/s390x: flag te and cte as deprecated

Add the CONSTRAINT_TRANSACTIONAL_EXE (cte) and TRANSACTIONAL_EXE (te) under the list of deprecated features.

---
 target/s390x/cpu_features.c | 3 +++
 1 file changed, 3 insertions(+)
target/s390x/cpu_features.c +3 -0
index efafc9711c..cb4e2b8920 100644
@@ -218,6 +218,9 @@ void s390_get_deprecated_features(S390FeatBitmap features)
          /* CSSKE is deprecated on newer generations */
          S390_FEAT_CONDITIONAL_SSKE,
          S390_FEAT_BPB,
+         /* Deprecated on z16 */
+         S390_FEAT_CONSTRAINT_TRANSACTIONAL_EXE,
+         S390_FEAT_TRANSACTIONAL_EXE
     };
     int i;
 
Signature · 1 line
2.41.0
#2 lore raw

Re: [PATCH v1 2/2] target/s390x: flag te and cte as deprecated

Quoted 13 lines · Collin Walling

Add the CONSTRAINT_TRANSACTIONAL_EXE (cte) and TRANSACTIONAL_EXE (te) under the list of deprecated features.

---
  target/s390x/cpu_features.c | 3 +++
  1 file changed, 3 insertions(+)
target/s390x/cpu_features.c +0 -0
index efafc9711c..cb4e2b8920 100644

target/s390x/cpu_features.c void s390_get_deprecated_features(S390FeatBitmap features) · line 226

Quoted 9 lines
target/s390x/cpu_features.c +3 -0
@@ -218,6 +218,9 @@ void s390_get_deprecated_features(S390FeatBitmap features)
           /* CSSKE is deprecated on newer generations */
           S390_FEAT_CONDITIONAL_SSKE,
           S390_FEAT_BPB,
+         /* Deprecated on z16 */
+         S390_FEAT_CONSTRAINT_TRANSACTIONAL_EXE,
+         S390_FEAT_TRANSACTIONAL_EXE
      };
      int i;
 

We don't have to consider them in init_ignored_base_feat, because they have never been part of base model I guess?

Signature · 3 lines
Cheers,

David / dhildenb
#3 lore raw
In reply to Collin Walling

On 11.09.23 22:52, Collin Walling wrote:

Patch subject is wrong (should contain "static-recommended")

Quoted 23 lines

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.

---
  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(-)
qapi/machine-target.json +0 -0
index f0a6b72414..4dc891809d 100644

qapi/machine-target.json line 50

Quoted 9 lines
qapi/machine-target.json +6 -0
@@ -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.
+#

Can we instead make this a new parameter for query-cpu-model-expansion ("no-deprecated-features" ? ), that properly gets rejected from other archs when not supported?

[...]

qapi/machine-target.json line 53

Quoted 4 lines
qapi/machine-target.json +1 -1
  /* 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)

"dep" can be misleading ("depended")

"no_deprecated_feat" ?

Signature · 3 lines
Cheers,

David / dhildenb
#4 lore raw
Quoted 41 lines · David Hildenbrand

On 11.09.23 22:52, Collin Walling wrote:

Patch subject is wrong (should contain "static-recommended")

Quoted 23 lines

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.

---
  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(-)
qapi/machine-target.json +0 -0
index f0a6b72414..4dc891809d 100644

qapi/machine-target.json line 50

Quoted 9 lines
qapi/machine-target.json +6 -0
@@ -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.
+#

Can we instead make this a new parameter for query-cpu-model-expansion ("no-deprecated-features" ? ), that properly gets rejected from other archs when not supported?

Quoted 2 lines

[...]

So instead of a "type": "static-recommended" add an entirely new (optional) parameter key-value to the command? "disable-deprecated-features": "true|false"?

Quoted 10 lines

qapi/machine-target.json

Quoted 4 lines

/* convert S390CPUDef into a static CpuModelInfo */
static void cpu_info_from_model(CpuModelInfo *info, const S390CPUModel *model,

qapi/machine-target.json +1 -1
-                                bool delta_changes)
+                                bool delta_changes, bool disable_dep_feats)

"dep" can be misleading ("depended")

"no_deprecated_feat" ?

Good call. Tricky one to short-hand :)

With respect to labeling this as "no-deprecated-features", I think that may also be misleading: it sounds like an exclusion, when in fact we *want* the deprecated feats to show up paired with the false value. So I think "disable-deprecated-features" is a better label. Would you agree?

Signature · 2 lines
Regards,
  Collin