From: Thomas Huth <thuth@redhat.com>
To: Nina Schoetterl-Glausch <nsg@linux.ibm.com>,
qemu-devel@nongnu.org, qemu-s390x@nongnu.org,
Eduardo Habkost <eduardo@habkost.net>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
David Hildenbrand <david@redhat.com>,
Halil Pasic <pasic@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Eric Farman <farman@linux.ibm.com>,
Eric Blake <eblake@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Michael Roth <michael.roth@amd.com>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Ilya Leoshkevich" <iii@linux.ibm.com>,
"Cleber Rosa" <crosa@redhat.com>,
"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
"Beraldo Leal" <bleal@redhat.com>,
"Pierre Morel" <pmorel@linux.ibm.com>
Subject: Re: [PATCH v24 04/21] target/s390x/cpu topology: handle STSI(15) and build the SYSIB
Date: Thu, 28 Sep 2023 15:05:42 +0200 [thread overview]
Message-ID: <f137153e-e6df-9fd9-cf9e-5528a57e3a90@redhat.com> (raw)
In-Reply-To: <20230926121534.406035-5-nsg@linux.ibm.com>
On 26/09/2023 14.15, Nina Schoetterl-Glausch wrote:
> From: Pierre Morel <pmorel@linux.ibm.com>
>
> On interception of STSI(15.1.x) the System Information Block
> (SYSIB) is built from the list of pre-ordered topology entries.
>
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> Reviewed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> Co-developed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> ---
...
> diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topology.h
> index 97b0af2795..350c7ea8aa 100644
> --- a/include/hw/s390x/cpu-topology.h
> +++ b/include/hw/s390x/cpu-topology.h
> @@ -15,10 +15,33 @@
> #include "hw/boards.h"
> #include "qapi/qapi-types-machine-target.h"
>
> +#define S390_TOPOLOGY_CPU_IFL 0x03
> +
> +typedef struct s390_topology_id {
> + uint8_t sentinel;
> + uint8_t drawer;
> + uint8_t book;
> + uint8_t socket;
> + uint8_t type;
> + uint8_t vertical:1;
> + uint8_t entitlement:2;
> + uint8_t dedicated;
> + uint8_t origin;
> +} s390_topology_id;
Sorry for not noticing this earlier, but: Please adapt the name of the
struct to the QEMU coding conventions, i.e. S390TopologyId instead of
s390_topology_id.
...
> diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
> index dfcc1aa1fc..c1ba5c46d6 100644
> --- a/target/s390x/cpu.h
> +++ b/target/s390x/cpu.h
> @@ -571,6 +571,29 @@ typedef struct SysIB_322 {
...
> +/*
> + * CPU Topology List provided by STSI with fc=15 provides a list
> + * of two different Topology List Entries (TLE) types to specify
> + * the topology hierarchy.
> + *
> + * - Container Topology List Entry
> + * Defines a container to contain other Topology List Entries
> + * of any type, nested containers or CPU.
> + * - CPU Topology List Entry
> + * Specifies the CPUs position, type, entitlement and polarization
> + * of the CPUs contained in the last Container TLE.
Please write Container with a small "c" at the beginning.
...
> diff --git a/target/s390x/kvm/stsi-topology.c b/target/s390x/kvm/stsi-topology.c
> new file mode 100644
> index 0000000000..67ecc67184
> --- /dev/null
> +++ b/target/s390x/kvm/stsi-topology.c
> @@ -0,0 +1,339 @@
...
> +/**
> + * s390_topology_fill_list_sorted:
> + * @topology_list: list to fill
> + *
> + * Loop over all CPU and insert it at the right place
I'd like to suggest to change that to:
"Loop over all CPUs and insert each of the at the right place"
> + * inside the TLE entry list.
> + * Fill the S390Topology list with entries according to the order
> + * specified by the PoP.
> + */
> +static void s390_topology_fill_list_sorted(S390TopologyList *topology_list)
> +{
> + CPUState *cs;
> + S390TopologyEntry sentinel = { .id.sentinel = 1 };
> +
> + QTAILQ_INIT(topology_list);
> +
> + QTAILQ_INSERT_HEAD(topology_list, &sentinel, next);
> +
> + CPU_FOREACH(cs) {
> + s390_topology_id id = s390_topology_from_cpu(S390_CPU(cs));
> + S390TopologyEntry *entry = NULL, *tmp;
> +
> + QTAILQ_FOREACH(tmp, topology_list, next) {
> + if (s390_topology_id_eq(&id, &tmp->id)) {
> + entry = tmp;
> + break;
> + } else if (s390_topology_id_lt(&id, &tmp->id)) {
> + entry = g_malloc0(sizeof(*entry));
> + entry->id = id;
> + QTAILQ_INSERT_BEFORE(tmp, entry, next);
> + break;
> + }
> + }
> + assert(entry);
> + s390_topology_add_cpu_to_entry(entry, S390_CPU(cs));
> + }
> +
> + QTAILQ_REMOVE(topology_list, &sentinel, next);
> +}
> +
> +/**
> + * s390_topology_empty_list:
> + *
> + * Clear all entries in the S390Topology list.
> + */
> +static void s390_topology_empty_list(S390TopologyList *topology_list)
> +{
> + S390TopologyEntry *entry = NULL;
> + S390TopologyEntry *tmp = NULL;
> +
> + QTAILQ_FOREACH_SAFE(entry, topology_list, next, tmp) {
> + QTAILQ_REMOVE(topology_list, entry, next);
> + g_free(entry);
> + }
> +}
> +
> +/**
> + * insert_stsi_15_1_x:
> + * @cpu: the CPU doing the call for which we set CC
> + * @sel2: the selector 2, containing the nested level
> + * @addr: Guest logical address of the guest SysIB
> + * @ar: the access register number
> + * @ra: the return address
> + *
> + * Emulate STSI 15.1.x, that is, perform all necessary checks and
> + * fill the SYSIB.
> + * In case the topology description is too long to fit into the SYSIB,
> + * set CC=3 and abort without writing the SYSIB.
> + */
> +void insert_stsi_15_1_x(S390CPU *cpu, int sel2, uint64_t addr, uint8_t ar, uintptr_t ra)
> +{
> + S390TopologyList topology_list;
> + SysIB sysib = {0};
> + int length;
> +
> + if (!s390_has_topology() || sel2 < 2 || sel2 > SCLP_READ_SCP_INFO_MNEST) {
> + setcc(cpu, 3);
> + return;
> + }
> +
> + s390_topology_fill_list_sorted(&topology_list);
> +
> + length = setup_stsi(&topology_list, &sysib.sysib_151x, sel2);
> +
> + if (!length) {
> + s390_topology_empty_list(&topology_list);
> + setcc(cpu, 3);
> + return;
> + }
> +
> + sysib.sysib_151x.length = cpu_to_be16(length);
> + if (!s390_cpu_virt_mem_write(cpu, addr, ar, &sysib, length)) {
> + setcc(cpu, 0);
> + } else {
> + s390_cpu_virt_mem_handle_exc(cpu, ra);
> + }
> +
> + s390_topology_empty_list(&topology_list);
In case this will ever be used with TCG: s390_cpu_virt_mem_handle_exc()
might not return, so the clean-up has to be done before calling that function:
ret = s390_cpu_virt_mem_write(cpu, addr, ar, &sysib, length);
s390_topology_empty_list(&topology_list);
if (!ret) {
setcc(cpu, 0);
} else {
s390_cpu_virt_mem_handle_exc(cpu, ra);
}
}
Or maybe even do it before the "if (!length)" statement, so you don't need
it in the body of that statement?
Thomas
next prev parent reply other threads:[~2023-09-28 13:06 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-26 12:15 [PATCH v24 00/21] s390x: CPU Topology Nina Schoetterl-Glausch
2023-09-26 12:15 ` [PATCH v24 01/21] qapi: machine.json: change docs regarding CpuInstanceProperties Nina Schoetterl-Glausch
2023-10-12 5:59 ` Markus Armbruster
2023-10-13 11:46 ` Nina Schoetterl-Glausch
2023-09-26 12:15 ` [PATCH v24 02/21] CPU topology: extend with s390 specifics Nina Schoetterl-Glausch
2023-09-28 11:31 ` Thomas Huth
2023-10-04 16:39 ` Nina Schoetterl-Glausch
2023-10-04 17:32 ` Thomas Huth
2023-09-26 12:15 ` [PATCH v24 03/21] s390x/cpu topology: add topology entries on CPU hotplug Nina Schoetterl-Glausch
2023-09-26 12:15 ` [PATCH v24 04/21] target/s390x/cpu topology: handle STSI(15) and build the SYSIB Nina Schoetterl-Glausch
2023-09-28 13:05 ` Thomas Huth [this message]
2023-09-26 12:15 ` [PATCH v24 05/21] s390x/sclp: reporting the maximum nested topology entries Nina Schoetterl-Glausch
2023-09-26 12:15 ` [PATCH v24 06/21] s390x/cpu topology: resetting the Topology-Change-Report Nina Schoetterl-Glausch
2023-09-26 12:15 ` [PATCH v24 07/21] s390x/cpu topology: interception of PTF instruction Nina Schoetterl-Glausch
2023-09-26 12:15 ` [PATCH v24 08/21] target/s390x/cpu topology: activate CPU topology Nina Schoetterl-Glausch
2023-09-26 12:15 ` [PATCH v24 09/21] qapi/s390x/cpu topology: set-cpu-topology qmp command Nina Schoetterl-Glausch
2023-09-28 13:29 ` Thomas Huth
2023-09-26 12:15 ` [PATCH v24 10/21] machine: adding s390 topology to query-cpu-fast Nina Schoetterl-Glausch
2023-09-26 12:15 ` [PATCH v24 11/21] machine: adding s390 topology to info hotpluggable-cpus Nina Schoetterl-Glausch
2023-09-26 12:15 ` [PATCH v24 12/21] qapi/s390x/cpu topology: CPU_POLARIZATION_CHANGE qapi event Nina Schoetterl-Glausch
2023-09-26 12:15 ` [PATCH v24 13/21] qapi/s390x/cpu topology: add query-s390x-cpu-polarization command Nina Schoetterl-Glausch
2023-09-26 12:15 ` [PATCH v24 14/21] docs/s390x/cpu topology: document s390x cpu topology Nina Schoetterl-Glausch
2023-09-26 12:15 ` [PATCH v24 15/21] tests/avocado: s390x cpu topology core Nina Schoetterl-Glausch
2023-09-28 14:54 ` Thomas Huth
2023-09-26 12:15 ` [PATCH v24 16/21] tests/avocado: s390x cpu topology polarization Nina Schoetterl-Glausch
2023-09-26 12:15 ` [PATCH v24 17/21] tests/avocado: s390x cpu topology entitlement tests Nina Schoetterl-Glausch
2023-09-28 14:55 ` Thomas Huth
2023-09-26 12:15 ` [PATCH v24 18/21] tests/avocado: s390x cpu topology test dedicated CPU Nina Schoetterl-Glausch
2023-09-26 12:15 ` [PATCH v24 19/21] tests/avocado: s390x cpu topology test socket full Nina Schoetterl-Glausch
2023-09-26 12:15 ` [PATCH v24 20/21] tests/avocado: s390x cpu topology dedicated errors Nina Schoetterl-Glausch
2023-09-26 12:15 ` [PATCH v24 21/21] tests/avocado: s390x cpu topology bad move Nina Schoetterl-Glausch
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=f137153e-e6df-9fd9-cf9e-5528a57e3a90@redhat.com \
--to=thuth@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=bleal@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=crosa@redhat.com \
--cc=david@redhat.com \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=farman@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=michael.roth@amd.com \
--cc=nsg@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=pmorel@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=wainersm@redhat.com \
--cc=wangyanan55@huawei.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).