[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [Patch v1 00/29] s390x CPU models: exposing features
From: |
David Hildenbrand |
Subject: |
[Qemu-devel] [Patch v1 00/29] s390x CPU models: exposing features |
Date: |
Tue, 2 Aug 2016 13:58:46 +0200 |
After a very helpful discussion with Eduardo, we I did some changes to the
patch series, the most important ones being:
- All models except "host" will be "migration-safe" on s390x
- CPU model expansion now has only two types "full" and "static"
- The parameter "type" from CPU model baseline has been dropped
- "query-cpu-definitions" is extended by "static" and "migration-safe"
- Updated + clarified description of new QMP interfaces
Full list of changes can be found at the end of this length cover letter.
Latest version can be found on branch:
github.com/cohuck/qemu cpumodel-s390x-v1
--------------------------------Concept------------------------------------
This is our second attempt to implement CPU models for s390x. We realized
that we also want to have features exposed via the CPU model. While doing
that we realized that we want to have a better interface for libvirt.
Unfortunately, CPU models on s390x are special and we have to take care of:
- A CPU like z13 looks differently in various environments (under different
LPAR versions, under different z/VM versions, under different KVM
versions, export regulation) - we have _a lot_ of feature variability.
- We still have certain features that are not published but might be
implemented/introduced in the future. As they are a theoretical part
of a CPU already, we have to find a way to model these future changes.
- We still have certain features that are already published, but not
implemented. Implementation might be added in the future in KVM.
- We heavily rely on KVM to tell us which features it can actually
virtualize - user space queries like "STFL(e)" give no guarantees.
- Certain "subfeatures" were introduced in one run. In practice, they are
always around, but in theory, subfeatures could be dropped in the future.
- Just because two CPU models have the same features doesn't mean they
are equal - some internal numbers might be different. E.g. we won't allow
running a z13 under a zBC12 just by turning off features.
- We cannot blindly enable all possible features for a CPU generation,
the IBC "Instruction Blocking Control" in KVM will try to block
instructions introduced with certain features. So a CPU generation always
has some maximum feature set that is guaranteed to work.
It all boils down to a specific released CPU to have.
a) A minimum feature set that we expect it to be have on every hypervisor.
b) A variable part that depends on the hypervisor and that could be
extended in the future (adding not yet implemented features) that we
always want to enable later on.
c) A variable part that we want to enable only if requested - nested
virtualization ("vsie") and assists are one example.
As we want our users to always make use of most features, e.g. when using
the "z13" CPU model, we will have to update our CPU models between QEMU
releases, to include the latest feature additions we implemented/unlocked.
We're badically trying to be able at one point in the future to really look
like a maximum "z13" CPU in QEMU. However, that means that a "z13" CPU
looks differently on different QEMU versions. We will make sure using
compatibility machines, that migration stays safe.
However, if the feature set of a CPU model is bound to a compatibility
machine, how can it be of any help when used without a compatibility
machine? E.g. when indicating the host CPU model in "virsh capabilities",
simply saying "z13" is not really clear. Also when baselining and
comparing CPU models, we usually have no compatibility machine "context"
at hand. For this reason we introduce "static" CPU models, which will
never change, so everybody knows without a compatibility machine, what we
are talking about.
CPU definitions/models can be categorized:
1. migratable: all features _can_ be identified + properly migrated.
--> With migratable=off on x86, "host" cannot be migrated properly.
2. migration-safe: in combination with a QEMU machine, migration will work.
--> No CPU features are lost/added during migration
3. static: not bound to a QEMU machine - featureset will never* change.
--> Everybody knows which features are part of it, not affected by a compat
machine. "virsh capabilities" can show this as "host" model.
*except for trivial bugfixes, especially on very old models nobody used in
production. Should be avoided.
We are currently planning to also support a "migratable=off" on s390x
for the "-cpu host" model, in order to enable all features, including not
recognized ones.
So we have on s390x:
a) A static CPU model for each released CPU that will never change and
maps to the minimum feature set we expect to be around on all
hypervisors. e.g. "z13-base" or "z10EC.2-base".
b) A "default" CPU model for each released CPU, that can change between
QEMU versions and that will always include the features we expect to
be around in our currently supported environments and will contain only
features we expect to be stable. E.g. nested virtualization will not be
contained in these models for now. "z13" or "z10EC.2" are examples.
c) An internal "maximum" CPU model for each generation that tells us which
features were supported as a maximum back when the hardware was
released. This will not be exposed but used internally.
To not have to replicate all CPU model changes ("new default fetaures") in
libvirt, to not duplicate the logic about compatibility and the like,
our approach tries to keep all the QEMU logic in libvirt and provide
standardized interfaces for libvirt to e.g. baseline, compare. This
allows libvirt to not have to care about any model names or feature names,
it can just pass the data from interface to interface and report it to
the user.
Also, libvirt might want to know what the "host" model looks like and
convert a CPU model to a migration safe variant. For this reason, a QMP
command is added that can create a migration safe variant of a variable
CPU model, indicating only the delta changes done to a stable model.
So we have:
a) "query-cpu-model-expansion" - tell us what the "host" or another CPU
model looks like. Either falling back to a static model or
completely exposing all properties.
b) "query-cpu-model-comparison" - tell us how two CPU models compare,
indicating which properties were responsible for the decision.
c) "query-cpu-model-baseline" - create a new model out of two models,
taking a requested level of stability into account.
--------------------------------Libvirt usecase----------------------------
Testing for runability:
- Simply try to start QEMU with KVM, compat machine, CPU model
- Could be done using query-cpu-model-comparison in the future.
Identifying host model, e.g. "virsh capabilities"
- query-cpu-model-expansion on "host" with "-M none --enable-kvm"
<cpu mode='host-model'>:
- simply copy the identified host model
<cpu mode='host-passthrough'>:
- "-cpu host"
"virsh cpu-baseline":
- query-cpu-model-baseline on two models with "-M none"
"virsh cpu-compare":
- query-cpu-model-comparison on two models with "-M none"
There might be some cenarios where libvirt wants to convert another CPU
model to a static variant, this can be done using query-cpu-model-expansion
--------------------------------QMP examples------------------------------
Expanding "host" on z13.2 without nested virtualization support:
{ "execute":"query-cpu-model-expansion",
"arguments":{
"type":"static",
"model":{
"name":"host"
}}}
{ "return":{
"model":{
"name":"z13.2-base",
"props":{
"aefsi":true,
"msa5":true,
"msa4":true,
"msa3":true,
"msa2":true,
"msa1":true,
"ri":true,
"edat2":true,
"edat1":true,
"vx":true,
"ipter":true,
"esop":true,
"ctx":true,
"cmm":true,
"tx":true
}}}}
Expanding "host" on zEC12.2 without nested virtualization support:
{ "execute":"query-cpu-model-expansion",
"arguments":{
"type":"static",
"model":{
"name":"host"
}}}
{ "return":{
"model":{
"name":"zEC12.2-base",
"props":{
"aefsi":true,
"msa5":true,
"msa4":true,
"msa3":true,
"msa2":true,
"msa1":true,
"ri":true,
"edat2":true,
"edat1":true,
"ipter":true,
"cei":true,
"gpereh":true,
"esop":true,
"ib":true,
"siif":true,
"ibs":true,
"sief2":true,
"ctx":true,
"64bscao":true,
"cmm":true,
"gsls":true,
"tx":true
}}}}
Comparing both models (dropping features for readability)
{ "execute":"query-cpu-model-comparison",
"arguments":{
"modela":{
"name":"z13.2-base",
"props":{ ... }
},
"modelb":{
"name":"zEC12.2-base",
"props":{ ... }
}
}}}
{"return":{
"result":"incompatible",
"responsible-properties":[
"cei",
"ib",
"siif",
"gpereh",
"sief2",
"ibs",
"64bscao",
"gsls",
"vx",
"dfppc",
"gen13e",
"gen13ptff",
"type"
]
}}
Indicated are all z13 features + nested virtualization features. "type"
indicates that both models can never be made identical (as different
CPU generations).
Baselining both models (dropping features for readability)
{ "execute":"query-cpu-model-baseline",
"arguments":{
"modela":{
"name":"z13.2-base",
"props":{ ... }
},
"modelb":{
"name":"zEC12.2-base",
"props":{ ... }
}}}}
{
"return":{
"model":{
"name":"zEC12.2-base",
"props":{
"aefsi":true,
"msa5":true,
"msa4":true,
"msa3":true,
"msa2":true,
"msa1":true,
"ri":true,
"edat2":true,
"edat1":true,
"ipter":true,
"esop":true,
"ctx":true,
"cmm":true,
"tx":true
}}}}
Which is in fact a zEC12.2 without nested virtualization.
--------------------------------Changes-----------------------------------
RFC -> Patch v1:
- Rebased to master, had to fixup qmp_visitor and CPU ceation stuff
- Changed function calls from (*fn)(...) to fn(...)
- Mark models not only as migration-safe but also as static
- Introduced "qmp: details about CPU definitions in query-cpu-definitions"
- Expose "static" as CPU class property
- All CPU models except "host" are now migration-safe (e.g. qemu and z13)
- Replaced linux-header update by a proper kvm/next update
- Removed baseline type parameter from "query-cpu-model-baseline" to KIS
- Renamed "stable" expansion to "static" (as stable sounds misleading)
- Removed "migratable" expansion type, can be done via "migratable=off"
- Heavily improved description of the new QMP interfaces
- Actually tested all QMP interfaces. Various bugfixes.
David Hildenbrand (27):
qmp: details about CPU definitions in query-cpu-definitions
s390x/cpumodel: "host" and "qemu" as CPU subclasses
s390x/cpumodel: expose CPU class properties
s390x/cpumodel: generate CPU feature group lists
s390x/cpumodel: introduce CPU feature group definitions
s390x/cpumodel: register defined CPU models as subclasses
s390x/cpumodel: store the CPU model in the CPU instance
s390x/cpumodel: expose features and feature groups as properties
s390x/cpumodel: let the CPU model handle feature checks
s390x/cpumodel: check and apply the CPU model
s390x/sclp: factor out preparation of cpu entries
s390x/sclp: introduce sclp feature blocks
s390x/sclp: indicate sclp features
s390x/sclp: propagate the ibc val(lowest and unblocked ibc)
s390x/sclp: propagate the mha via sclp
s390x/sclp: propagate hmfai
linux-headers: update against kvm/next
s390x/kvm: allow runtime-instrumentation for "none" machine
s390x/kvm: implement CPU model support
s390x/kvm: disable host model for existing compat machines
s390x/kvm: let the CPU model control CMM(A)
qmp: add QMP interface "query-cpu-model-expansion"
qmp: add QMP interface "query-cpu-model-comparison"
qmp: add QMP interface "query-cpu-model-baseline"
s390x/cpumodel: implement QMP interface "query-cpu-model-expansion"
s390x/cpumodel: implement QMP interface "query-cpu-model-comparison"
s390x/cpumodel: implement QMP interface "query-cpu-model-baseline"
Michael Mueller (2):
s390x/cpumodel: introduce CPU features
s390x/cpumodel: generate CPU feature lists for CPU models
Makefile.target | 2 +-
hw/s390x/s390-virtio-ccw.c | 5 +
hw/s390x/s390-virtio.c | 6 +-
hw/s390x/sclp.c | 35 +-
include/hw/s390x/sclp.h | 17 +-
include/sysemu/arch_init.h | 9 +
linux-headers/asm-arm64/kvm.h | 2 +
linux-headers/asm-s390/kvm.h | 41 ++
linux-headers/linux/kvm.h | 12 +-
qapi-schema.json | 200 +++++-
qmp-commands.hx | 18 +
qmp.c | 21 +
rules.mak | 1 +
stubs/Makefile.objs | 3 +
stubs/arch-query-cpu-model-baseline.c | 12 +
stubs/arch-query-cpu-model-comparison.c | 12 +
stubs/arch-query-cpu-model-expansion.c | 12 +
target-s390x/Makefile.objs | 22 +-
target-s390x/cpu-qom.h | 6 +
target-s390x/cpu.c | 35 +-
target-s390x/cpu.h | 5 +
target-s390x/cpu_features.c | 376 +++++++++++
target-s390x/cpu_features.h | 302 +++++++++
target-s390x/cpu_models.c | 1083 +++++++++++++++++++++++++++++++
target-s390x/cpu_models.h | 113 ++++
target-s390x/gen-features.c | 587 +++++++++++++++++
target-s390x/helper.c | 33 +-
target-s390x/kvm.c | 346 +++++++++-
target-s390x/machine.c | 14 +-
29 files changed, 3262 insertions(+), 68 deletions(-)
create mode 100644 stubs/arch-query-cpu-model-baseline.c
create mode 100644 stubs/arch-query-cpu-model-comparison.c
create mode 100644 stubs/arch-query-cpu-model-expansion.c
create mode 100644 target-s390x/cpu_features.c
create mode 100644 target-s390x/cpu_features.h
create mode 100644 target-s390x/cpu_models.c
create mode 100644 target-s390x/cpu_models.h
create mode 100644 target-s390x/gen-features.c
--
2.6.6
- [Qemu-devel] [Patch v1 00/29] s390x CPU models: exposing features,
David Hildenbrand <=
- [Qemu-devel] [Patch v1 02/29] s390x/cpumodel: "host" and "qemu" as CPU subclasses, David Hildenbrand, 2016/08/02
- [Qemu-devel] [Patch v1 05/29] s390x/cpumodel: generate CPU feature lists for CPU models, David Hildenbrand, 2016/08/02
- [Qemu-devel] [Patch v1 01/29] qmp: details about CPU definitions in query-cpu-definitions, David Hildenbrand, 2016/08/02
- Re: [Qemu-devel] [Patch v1 01/29] qmp: details about CPU definitions in query-cpu-definitions, Eduardo Habkost, 2016/08/02
- Re: [Qemu-devel] [Patch v1 01/29] qmp: details about CPU definitions in query-cpu-definitions, David Hildenbrand, 2016/08/02
- Re: [Qemu-devel] [Patch v1 01/29] qmp: details about CPU definitions in query-cpu-definitions, Eduardo Habkost, 2016/08/02
- Re: [Qemu-devel] [Patch v1 01/29] qmp: details about CPU definitions in query-cpu-definitions, David Hildenbrand, 2016/08/02
- Re: [Qemu-devel] [Patch v1 01/29] qmp: details about CPU definitions in query-cpu-definitions, Eduardo Habkost, 2016/08/02
- Re: [Qemu-devel] [Patch v1 01/29] qmp: details about CPU definitions in query-cpu-definitions, David Hildenbrand, 2016/08/02
[Qemu-devel] [Patch v1 16/29] s390x/sclp: propagate the ibc val(lowest and unblocked ibc), David Hildenbrand, 2016/08/02