diff mbox series

[v3,1/2] target/s390x: report deprecated-props in cpu-model-expansion reply

Message ID 20240424215633.48906-2-walling@linux.ibm.com
State New
Headers show
Series query-cpu-model-expansion: report deprecated features | expand

Commit Message

Collin Walling April 24, 2024, 9:56 p.m. UTC
Retain a list of deprecated features disjoint from any particular
CPU model. A query-cpu-model-expansion reply will now provide a list of
properties (i.e. features) that are flagged as deprecated. Example:

    {
      "return": {
        "model": {
          "name": "z14.2-base",
          "deprecated-props": [
            "bpb",
            "csske"
          ],
          "props": {
            "pfmfi": false,
            "exrl": true,
            ...a lot more props...
            "skey": false,
            "vxpdeh2": false
          }
        }
      }
    }

It is recommended that s390 guests operate with these features
explicitly disabled to ensure compatability with future hardware.

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

Comments

Markus Armbruster April 26, 2024, 8:42 a.m. UTC | #1
Collin Walling <walling@linux.ibm.com> writes:

> Retain a list of deprecated features disjoint from any particular
> CPU model. A query-cpu-model-expansion reply will now provide a list of
> properties (i.e. features) that are flagged as deprecated. Example:
>
>     {
>       "return": {
>         "model": {
>           "name": "z14.2-base",
>           "deprecated-props": [
>             "bpb",
>             "csske"
>           ],
>           "props": {
>             "pfmfi": false,
>             "exrl": true,
>             ...a lot more props...
>             "skey": false,
>             "vxpdeh2": false
>           }
>         }
>       }
>     }
>
> It is recommended that s390 guests operate with these features
> explicitly disabled to ensure compatability with future hardware.
>
> Signed-off-by: Collin Walling <walling@linux.ibm.com>
> ---
>  qapi/machine-target.json         |  5 ++++-
>  target/s390x/cpu_features.c      | 14 ++++++++++++++
>  target/s390x/cpu_features.h      |  1 +
>  target/s390x/cpu_models_sysemu.c |  6 ++++++
>  4 files changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/qapi/machine-target.json b/qapi/machine-target.json
> index 29e695aa06..3799a60e3d 100644
> --- a/qapi/machine-target.json
> +++ b/qapi/machine-target.json
> @@ -20,11 +20,14 @@
>  #
>  # @props: a dictionary of QOM properties to be applied
>  #
> +# @deprecated-props: a list of QOM properties that are flagged as deprecated

Deprecated by whom?  QEMU?  The CPU vendor?

docs/devel/qapi-code-gen.rst:

    For legibility, wrap text paragraphs so every line is at most 70
    characters long.

> +#
>  # Since: 2.8
>  ##
>  { 'struct': 'CpuModelInfo',
>    'data': { 'name': 'str',
> -            '*props': 'any' } }
> +            '*props': 'any',
> +            '*deprecated-props': ['str'] } }
>  
>  ##
>  # @CpuModelExpansionType:

[...]
Collin Walling April 26, 2024, 5:35 p.m. UTC | #2
On 4/26/24 04:42, Markus Armbruster wrote:
> Collin Walling <walling@linux.ibm.com> writes:
> 
>> Retain a list of deprecated features disjoint from any particular
>> CPU model. A query-cpu-model-expansion reply will now provide a list of
>> properties (i.e. features) that are flagged as deprecated. Example:
>>
>>     {
>>       "return": {
>>         "model": {
>>           "name": "z14.2-base",
>>           "deprecated-props": [
>>             "bpb",
>>             "csske"
>>           ],
>>           "props": {
>>             "pfmfi": false,
>>             "exrl": true,
>>             ...a lot more props...
>>             "skey": false,
>>             "vxpdeh2": false
>>           }
>>         }
>>       }
>>     }
>>
>> It is recommended that s390 guests operate with these features
>> explicitly disabled to ensure compatability with future hardware.
>>
>> Signed-off-by: Collin Walling <walling@linux.ibm.com>
>> ---
>>  qapi/machine-target.json         |  5 ++++-
>>  target/s390x/cpu_features.c      | 14 ++++++++++++++
>>  target/s390x/cpu_features.h      |  1 +
>>  target/s390x/cpu_models_sysemu.c |  6 ++++++
>>  4 files changed, 25 insertions(+), 1 deletion(-)
>>
>> diff --git a/qapi/machine-target.json b/qapi/machine-target.json
>> index 29e695aa06..3799a60e3d 100644
>> --- a/qapi/machine-target.json
>> +++ b/qapi/machine-target.json
>> @@ -20,11 +20,14 @@
>>  #
>>  # @props: a dictionary of QOM properties to be applied
>>  #
>> +# @deprecated-props: a list of QOM properties that are flagged as deprecated
> 
> Deprecated by whom?  QEMU?  The CPU vendor?
> 

The CPU vendor would be the one who decides which props are deprecated.
How about:

# @deprecated-props: a list of QOM properties that are flagged as
		     deprecated by the CPU vendor

> docs/devel/qapi-code-gen.rst:
> 
>     For legibility, wrap text paragraphs so every line is at most 70
>     characters long.
> 

Noted for next iteration.  Thank you.

>> +#
>>  # Since: 2.8
>>  ##
>>  { 'struct': 'CpuModelInfo',
>>    'data': { 'name': 'str',
>> -            '*props': 'any' } }
>> +            '*props': 'any',
>> +            '*deprecated-props': ['str'] } }
>>  
>>  ##
>>  # @CpuModelExpansionType:
> 
> [...]
> 
>
David Hildenbrand April 26, 2024, 5:44 p.m. UTC | #3
On 24.04.24 23:56, Collin Walling wrote:
> Retain a list of deprecated features disjoint from any particular
> CPU model. A query-cpu-model-expansion reply will now provide a list of
> properties (i.e. features) that are flagged as deprecated. Example:
> 
>      {
>        "return": {
>          "model": {
>            "name": "z14.2-base",
>            "deprecated-props": [
>              "bpb",
>              "csske"
>            ],
>            "props": {
>              "pfmfi": false,
>              "exrl": true,
>              ...a lot more props...
>              "skey": false,
>              "vxpdeh2": false
>            }
>          }
>        }
>      }
> 
> It is recommended that s390 guests operate with these features
> explicitly disabled to ensure compatability with future hardware.

Likely you should only report features that are applicable to a model. 
that is, if it's part of the full_feat.

Otherwise, the caller might simply want do set all features to "false", 
and we'd fail setting a feature that is unknown to a specific CPU 
generation.

That is, you would AND the bitmap with the full_feat of the underlying 
CPU definition.
David Hildenbrand April 26, 2024, 5:45 p.m. UTC | #4
On 26.04.24 19:44, David Hildenbrand wrote:
> On 24.04.24 23:56, Collin Walling wrote:
>> Retain a list of deprecated features disjoint from any particular
>> CPU model. A query-cpu-model-expansion reply will now provide a list of
>> properties (i.e. features) that are flagged as deprecated. Example:
>>
>>       {
>>         "return": {
>>           "model": {
>>             "name": "z14.2-base",
>>             "deprecated-props": [
>>               "bpb",
>>               "csske"
>>             ],
>>             "props": {
>>               "pfmfi": false,
>>               "exrl": true,
>>               ...a lot more props...
>>               "skey": false,
>>               "vxpdeh2": false
>>             }
>>           }
>>         }
>>       }
>>
>> It is recommended that s390 guests operate with these features
>> explicitly disabled to ensure compatability with future hardware.
> 
> Likely you should only report features that are applicable to a model.
> that is, if it's part of the full_feat.
> 
> Otherwise, the caller might simply want do set all features to "false",
> and we'd fail setting a feature that is unknown to a specific CPU
> generation.
> 
> That is, you would AND the bitmap with the full_feat of the underlying
> CPU definition.

Refreshing my memory, I think we can just clear any CPU features. We 
only bail out when setting them!
Collin Walling April 26, 2024, 7:28 p.m. UTC | #5
On 4/26/24 13:45, David Hildenbrand wrote:
> On 26.04.24 19:44, David Hildenbrand wrote:
>> On 24.04.24 23:56, Collin Walling wrote:
>>> Retain a list of deprecated features disjoint from any particular
>>> CPU model. A query-cpu-model-expansion reply will now provide a list of
>>> properties (i.e. features) that are flagged as deprecated. Example:
>>>
>>>       {
>>>         "return": {
>>>           "model": {
>>>             "name": "z14.2-base",
>>>             "deprecated-props": [
>>>               "bpb",
>>>               "csske"
>>>             ],
>>>             "props": {
>>>               "pfmfi": false,
>>>               "exrl": true,
>>>               ...a lot more props...
>>>               "skey": false,
>>>               "vxpdeh2": false
>>>             }
>>>           }
>>>         }
>>>       }
>>>
>>> It is recommended that s390 guests operate with these features
>>> explicitly disabled to ensure compatability with future hardware.
>>
>> Likely you should only report features that are applicable to a model.
>> that is, if it's part of the full_feat.
>>
>> Otherwise, the caller might simply want do set all features to "false",
>> and we'd fail setting a feature that is unknown to a specific CPU
>> generation.
>>
>> That is, you would AND the bitmap with the full_feat of the underlying
>> CPU definition.
> 
> Refreshing my memory, I think we can just clear any CPU features. We 
> only bail out when setting them!
> 

Very good point.  I've been working only with newer-gen machines and
would not have thought to test / catch that case.  I will filter the
deprecated-props array with features that are only available on the
full_model of the expanded CPU model.
Collin Walling April 26, 2024, 8:11 p.m. UTC | #6
On 4/26/24 13:35, Collin Walling wrote:
> On 4/26/24 04:42, Markus Armbruster wrote:
>> Collin Walling <walling@linux.ibm.com> writes:
>>
>>> Retain a list of deprecated features disjoint from any particular
>>> CPU model. A query-cpu-model-expansion reply will now provide a list of
>>> properties (i.e. features) that are flagged as deprecated. Example:
>>>
>>>     {
>>>       "return": {
>>>         "model": {
>>>           "name": "z14.2-base",
>>>           "deprecated-props": [
>>>             "bpb",
>>>             "csske"
>>>           ],
>>>           "props": {
>>>             "pfmfi": false,
>>>             "exrl": true,
>>>             ...a lot more props...
>>>             "skey": false,
>>>             "vxpdeh2": false
>>>           }
>>>         }
>>>       }
>>>     }
>>>
>>> It is recommended that s390 guests operate with these features
>>> explicitly disabled to ensure compatability with future hardware.
>>>
>>> Signed-off-by: Collin Walling <walling@linux.ibm.com>
>>> ---
>>>  qapi/machine-target.json         |  5 ++++-
>>>  target/s390x/cpu_features.c      | 14 ++++++++++++++
>>>  target/s390x/cpu_features.h      |  1 +
>>>  target/s390x/cpu_models_sysemu.c |  6 ++++++
>>>  4 files changed, 25 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/qapi/machine-target.json b/qapi/machine-target.json
>>> index 29e695aa06..3799a60e3d 100644
>>> --- a/qapi/machine-target.json
>>> +++ b/qapi/machine-target.json
>>> @@ -20,11 +20,14 @@
>>>  #
>>>  # @props: a dictionary of QOM properties to be applied
>>>  #
>>> +# @deprecated-props: a list of QOM properties that are flagged as deprecated
>>
>> Deprecated by whom?  QEMU?  The CPU vendor?
>>
> 
> The CPU vendor would be the one who decides which props are deprecated.
> How about:
> 
> # @deprecated-props: a list of QOM properties that are flagged as
> 		     deprecated by the CPU vendor
> 

^ let's ignore the incorrect indentation here.

Actually, I may be wildly incorrect with my description by referring to
this as "a list of QOM properties", when in fact this is just an array
of strings.  Also, the deprecated props may not always reflect the
features that are found by a static expansion, so I added another
sentence to describe that they are a part of a full model expansion.

# @deprecated-props: a list of properties that are flagged as deprecated
#     by the CPU vendor.  These props are a subset of the model's full
#     definition list of properties. (since X.Y)

I may need some help with the wording on the 2nd sentence.

[...]

> 
>>> +#
>>>  # Since: 2.8
>>>  ##
>>>  { 'struct': 'CpuModelInfo',
>>>    'data': { 'name': 'str',
>>> -            '*props': 'any' } }
>>> +            '*props': 'any',
>>> +            '*deprecated-props': ['str'] } }
>>>  
>>>  ##
>>>  # @CpuModelExpansionType:
>>
>> [...]
>>
>>
>
diff mbox series

Patch

diff --git a/qapi/machine-target.json b/qapi/machine-target.json
index 29e695aa06..3799a60e3d 100644
--- a/qapi/machine-target.json
+++ b/qapi/machine-target.json
@@ -20,11 +20,14 @@ 
 #
 # @props: a dictionary of QOM properties to be applied
 #
+# @deprecated-props: a list of QOM properties that are flagged as deprecated
+#
 # Since: 2.8
 ##
 { 'struct': 'CpuModelInfo',
   'data': { 'name': 'str',
-            '*props': 'any' } }
+            '*props': 'any',
+            '*deprecated-props': ['str'] } }
 
 ##
 # @CpuModelExpansionType:
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 a9bd68a2e1..661a8cd6db 100644
--- a/target/s390x/cpu_features.h
+++ b/target/s390x/cpu_features.h
@@ -69,6 +69,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 2d99218069..307e3885f4 100644
--- a/target/s390x/cpu_models_sysemu.c
+++ b/target/s390x/cpu_models_sysemu.c
@@ -206,6 +206,12 @@  static void cpu_info_from_model(CpuModelInfo *info, const S390CPUModel *model,
     } else {
         info->props = QOBJECT(qdict);
     }
+
+    bitmap_zero(bitmap, S390_FEAT_MAX);
+    s390_get_deprecated_features(bitmap);
+    s390_feat_bitmap_to_ascii(bitmap, &info->deprecated_props,
+                              list_add_feat);
+    info->has_deprecated_props = !!info->deprecated_props;
 }
 
 CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,