From: David Hildenbrand <david@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Thomas Huth" <thuth@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Janosch Frank" <frankja@linux.ibm.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
qemu-devel@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
"Halil Pasic" <pasic@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@de.ibm.com>,
qemu-s390x@nongnu.org, "Michael Mueller" <mimu@linux.ibm.com>,
"Jiri Denemark" <jdenemar@redhat.com>
Subject: Re: [PATCH v1 2/2] s390x/cpumodel: Introduce "best" model variants
Date: Fri, 8 Nov 2019 22:18:56 +0100 [thread overview]
Message-ID: <2bebdcd5-799a-8c8b-62fa-455cf284f6ad@redhat.com> (raw)
In-Reply-To: <20191108195106.GA3812@habkost.net>
On 08.11.19 20:51, Eduardo Habkost wrote:
> On Fri, Nov 08, 2019 at 12:07:14PM +0100, David Hildenbrand wrote:
>> For a specific CPU model, we have a lot of feature variability depending on
>> - The microcode version of the HW
>> - The hypervisor we're running on (LPAR vs. KVM vs. z/VM)
>> - The hypervisor version we're running on
>> - The KVM version
>> - KVM module parameters (especially, "nested=1")
>> - The accelerator
>>
>> Our default models are migration safe, however can only be changed
>> between QEMU releases (glued to QEMU machine). This somewhat collides
>> with the feature variability we have. E.g., the z13 model will not run
>> under TCG. There is the demand from higher levels in the stack to "have the
>> best CPU model possible on a given accelerator, firmware and HW", which
>> should especially include all features that fix security issues.
>> Especially, if we have a new feature due to a security flaw, we want to
>> have a way to backport this feature to older QEMU versions and a way to
>> automatically enable it when asked.
>>
>> This is where "best" CPU models come into play. If upper layers specify
>> "z14-best" on a z14, they will get the best possible feature set in that
>> configuration. "best" usually means "maximum features", besides deprecated
>> features. This will then, for example, include nested virtualization
>> ("SIE" feature) when KVM+HW support is enabled, or fixes via
>> microcode updates (e.g., spectre)
>>
>> "best" models are not migration safe. Upper layers can expand these
>> models to migration-safe and static variants, allowing them to be
>> migrated.
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>
> Makes sense to me, and the code looks good. I just have one
> question below:
>
>> ---
> [...]
>> +static void s390_best_cpu_model_initfn(Object *obj)
>> +{
>> + const S390CPUModel *max_model;
>> + S390CPU *cpu = S390_CPU(obj);
>> + S390CPUClass *xcc = S390_CPU_GET_CLASS(cpu);
>> + Error *local_err = NULL;
>> + int i;
>> +
>> + if (kvm_enabled() && !kvm_s390_cpu_models_supported()) {
>> + return;
>> + }
>> +
>> + max_model = get_max_cpu_model(&local_err);
>> + if (local_err) {
>> + /* we expect errors only under KVM, when actually querying the kernel */
>> + g_assert(kvm_enabled());
>> + error_report_err(local_err);
>> + return;
>> + }
>> +
>> + /*
>> + * Similar to baselining against the "max" model. However, features
>> + * are handled differently and are not used for the search for a definition.
>> + */
>> + if (xcc->cpu_def->gen == max_model->def->gen) {
>> + if (xcc->cpu_def->ec_ga > max_model->def->ec_ga) {
>> + return;
>> + }
>> + } else if (xcc->cpu_def->gen > max_model->def->gen) {
>> + return;
>> + }
>
> What exactly is expected to happen if we return from the function
> here?
cpu->model is NULL. That fact (and xcc->is_best) is checked when the
model is to be used (e.g., via qmp or when creating VCPUs), and a rather
generic error is reported. This is suboptimal and ...
>
> (In x86, we worked around the inability to report errors inside
> instance_init by adding another step to CPU object initialization
> called "CPU expansion", implemented by
> x86_cpu_expand_features().)
... doing something like that makes a lot of sense. We also have to
rework this for the "host" and "max" model.
I'll look into that when I'm back from holidays in one week.
Thanks!
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2019-11-08 21:21 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-08 11:07 [PATCH v1 0/2] s390x/cpumodel: Introduce "best" model variants David Hildenbrand
2019-11-08 11:07 ` [PATCH v1 1/2] s390x/cpumodels: Factor out CPU feature dependencies David Hildenbrand
2019-11-08 11:07 ` [PATCH v1 2/2] s390x/cpumodel: Introduce "best" model variants David Hildenbrand
2019-11-08 19:51 ` Eduardo Habkost
2019-11-08 21:18 ` David Hildenbrand [this message]
2019-11-08 11:10 ` [PATCH v1 0/2] " Peter Maydell
2019-11-08 12:46 ` David Hildenbrand
2019-11-08 13:02 ` Peter Maydell
2019-11-08 19:10 ` Eduardo Habkost
2019-11-08 22:58 ` David Hildenbrand
2019-11-09 16:07 ` Peter Maydell
2019-11-18 10:47 ` David Hildenbrand
2019-11-18 10:53 ` Peter Maydell
2019-11-18 10:56 ` David Hildenbrand
2019-11-18 10:59 ` Peter Maydell
2019-11-18 18:49 ` Eduardo Habkost
2019-11-18 21:19 ` Peter Maydell
2019-11-18 22:04 ` Eduardo Habkost
2019-11-19 9:22 ` Peter Maydell
2019-11-19 9:58 ` David Hildenbrand
2019-11-19 10:36 ` Peter Maydell
2019-11-19 11:00 ` David Hildenbrand
2019-11-19 19:42 ` Eduardo Habkost
2019-11-20 10:28 ` David Hildenbrand
2019-11-20 14:04 ` Eduardo Habkost
2019-11-20 14:21 ` David Hildenbrand
2019-11-08 16:59 ` no-reply
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=2bebdcd5-799a-8c8b-62fa-455cf284f6ad@redhat.com \
--to=david@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=ehabkost@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=jdenemar@redhat.com \
--cc=mimu@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.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).