From: Cornelia Huck <cohuck@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Thomas Huth <thuth@redhat.com>,
qemu-s390x@nongnu.org, Cornelia Huck <cohuck@redhat.com>,
qemu-devel@nongnu.org, David Hildenbrand <david@redhat.com>
Subject: [PULL 14/15] hw/s390x: Add a more verbose comment about get_machine_class() and the wrappers
Date: Mon, 27 Jan 2020 13:20:15 +0100 [thread overview]
Message-ID: <20200127122016.18752-15-cohuck@redhat.com> (raw)
In-Reply-To: <20200127122016.18752-1-cohuck@redhat.com>
From: Thomas Huth <thuth@redhat.com>
While working on the "Enable adapter interruption suppression again"
recently, I had to discover that the meaning of get_machine_class()
and the related *_allowed() wrappers is not very obvious. Add a more
verbose comment here to clarify how these should be used.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20200123170256.12386-1-thuth@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
---
hw/s390x/s390-virtio-ccw.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index e0e28139a263..e759eb5f83cf 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -505,6 +505,19 @@ static inline void machine_set_dea_key_wrap(Object *obj, bool value,
static S390CcwMachineClass *current_mc;
+/*
+ * Get the class of the s390-ccw-virtio machine that is currently in use.
+ * Note: libvirt is using the "none" machine to probe for the features of the
+ * host CPU, so in case this is called with the "none" machine, the function
+ * returns the TYPE_S390_CCW_MACHINE base class. In this base class, all the
+ * various "*_allowed" variables are enabled, so that the *_allowed() wrappers
+ * below return the correct default value for the "none" machine.
+ *
+ * Attention! Do *not* add additional new wrappers for CPU features (e.g. like
+ * the ri_allowed() wrapper) via this mechanism anymore. CPU features should
+ * be handled via the CPU models, i.e. checking with cpu_model_allowed() during
+ * CPU initialization and s390_has_feat() later should be sufficient.
+ */
static S390CcwMachineClass *get_machine_class(void)
{
if (unlikely(!current_mc)) {
@@ -521,19 +534,16 @@ static S390CcwMachineClass *get_machine_class(void)
bool ri_allowed(void)
{
- /* for "none" machine this results in true */
return get_machine_class()->ri_allowed;
}
bool cpu_model_allowed(void)
{
- /* for "none" machine this results in true */
return get_machine_class()->cpu_model_allowed;
}
bool hpage_1m_allowed(void)
{
- /* for "none" machine this results in true */
return get_machine_class()->hpage_1m_allowed;
}
--
2.21.1
next prev parent reply other threads:[~2020-01-27 12:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-27 12:20 [PULL 00/15] s390x update Cornelia Huck
2020-01-27 12:20 ` [PULL 01/15] s390x/sclp.c: remove unneeded label in sclp_service_call() Cornelia Huck
2020-01-27 12:20 ` [PULL 02/15] intc/s390_flic_kvm.c: remove unneeded label in kvm_flic_load() Cornelia Huck
2020-01-27 12:20 ` [PULL 03/15] s390x/event-facility.c: remove unneeded labels Cornelia Huck
2020-01-27 12:20 ` [PULL 04/15] s390x: adapter routes error handling Cornelia Huck
2020-01-27 12:20 ` [PULL 05/15] s390x/event-facility: fix error propagation Cornelia Huck
2020-01-27 12:20 ` [PULL 06/15] target/s390x: Remove duplicated ifdef macro Cornelia Huck
2020-01-27 12:20 ` [PULL 07/15] docs/devel: fix stable process doc formatting Cornelia Huck
2020-01-27 12:20 ` [PULL 08/15] target/s390x/kvm: Enable adapter interruption suppression again Cornelia Huck
2020-01-27 12:20 ` [PULL 09/15] target/s390x: Move struct DisasFields definition earlier Cornelia Huck
2020-01-27 12:20 ` [PULL 10/15] target/s390x: Remove DisasFields argument from callbacks Cornelia Huck
2020-01-27 12:20 ` [PULL 11/15] target/s390x: Pass DisasContext to get_field and have_field Cornelia Huck
2020-01-27 12:20 ` [PULL 12/15] target/s390x: Move DisasFields into DisasContext Cornelia Huck
2020-01-27 12:20 ` [PULL 13/15] target/s390x: Remove DisasFields argument from extract_insn Cornelia Huck
2020-01-27 12:20 ` Cornelia Huck [this message]
2020-01-27 12:20 ` [PULL 15/15] s390x: sigp: Fix sense running reporting Cornelia Huck
2020-01-27 13:54 ` [PULL 00/15] s390x update Peter Maydell
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=20200127122016.18752-15-cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.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).