From: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
To: Pierre Morel <pmorel@linux.ibm.com>, qemu-s390x@nongnu.org
Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com,
pasic@linux.ibm.com, richard.henderson@linaro.org,
david@redhat.com, thuth@redhat.com, cohuck@redhat.com,
mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org,
ehabkost@redhat.com, marcel.apfelbaum@gmail.com,
eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com,
nrb@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com,
clg@kaod.org
Subject: Re: [PATCH v10 2/9] s390x/cpu topology: reporting the CPU topology to the guest
Date: Mon, 07 Nov 2022 14:20:58 +0100 [thread overview]
Message-ID: <ebfe8dea72adaf23913797c482377f4fd58fd097.camel@linux.ibm.com> (raw)
In-Reply-To: <d82372a9-581a-9544-eb6d-7b3e125926f5@linux.ibm.com>
On Fri, 2022-10-28 at 12:00 +0200, Pierre Morel wrote:
>
> On 10/27/22 22:42, Janis Schoetterl-Glausch wrote:
> > On Wed, 2022-10-12 at 18:21 +0200, Pierre Morel wrote:
> > > The guest can use the STSI instruction to get a buffer filled
> > > with the CPU topology description.
> > >
> > > Let us implement the STSI instruction for the basis CPU topology
> > > level, level 2.
> > >
> > > Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> > > ---
> > > include/hw/s390x/cpu-topology.h | 3 +
> > > target/s390x/cpu.h | 48 ++++++++++++++
> > > hw/s390x/cpu-topology.c | 8 ++-
> > > target/s390x/cpu_topology.c | 109 ++++++++++++++++++++++++++++++++
> > > target/s390x/kvm/kvm.c | 6 +-
> > > target/s390x/meson.build | 1 +
> > > 6 files changed, 172 insertions(+), 3 deletions(-)
> > > create mode 100644 target/s390x/cpu_topology.c
> > >
> > > diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topology.h
> > > index 66c171d0bc..61c11db017 100644
> > > --- a/include/hw/s390x/cpu-topology.h
> > > +++ b/include/hw/s390x/cpu-topology.h
> > > @@ -13,6 +13,8 @@
> > > #include "hw/qdev-core.h"
> > > #include "qom/object.h"
> > >
> > > +#define S390_TOPOLOGY_POLARITY_H 0x00
> > > +
> > > typedef struct S390TopoContainer {
> > > int active_count;
> > > } S390TopoContainer;
> > > @@ -29,6 +31,7 @@ struct S390Topology {
> > > S390TopoContainer *socket;
> > > S390TopoTLE *tle;
> > > MachineState *ms;
> > > + QemuMutex topo_mutex;
> > > };
> > >
> > > #define TYPE_S390_CPU_TOPOLOGY "s390-topology"
> > > diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
> > > index 7d6d01325b..d604aa9c78 100644
> > > --- a/target/s390x/cpu.h
> > > +++ b/target/s390x/cpu.h
> > >
> > [...]
> > > +
> > > +/* Maxi size of a SYSIB structure is when all CPU are alone in a container */
> >
> > Max or Maximum.
> >
> > > +#define S390_TOPOLOGY_SYSIB_SIZE (sizeof(SysIB_151x) + \
> > > + S390_MAX_CPUS * (sizeof(SysIBTl_container) + \
> > > + sizeof(SysIBTl_cpu)))
> >
> > Currently this is 16+248*3*8 == 5968 and will grow with books, drawer support to
> > 16+248*5*8 == 9936 ...
> >
> > [...]
> > >
> > > +
> > > +void insert_stsi_15_1_x(S390CPU *cpu, int sel2, __u64 addr, uint8_t ar)
> > > +{
> > > + uint64_t page[S390_TOPOLOGY_SYSIB_SIZE / sizeof(uint64_t)] = {};
> >
> > ... so calling this page is a bit misleading. Also why not make it a char[]?
> > And maybe use a union for type punning.
>
> OK, what about:
>
> union {
> char place_holder[S390_TOPOLOGY_SYSIB_SIZE];
> SysIB_151x sysib;
> } buffer QEMU_ALIGNED(8);
>
I don't think you need the QEMU_ALIGNED since SysIB_151x already has it. Not that it hurts to be
explicit. If you declared the tle member as uint64_t[], you should get the correct alignment
automatically and can then drop the explicit one.
Btw, [] seems to be preferred over [0], at least there is a commit doing a conversion:
f7795e4096 ("misc: Replace zero-length arrays with flexible array member (automatic)")
>
> >
> > > + SysIB_151x *sysib = (SysIB_151x *) page;
> > > + int len;
> > > +
> > > + if (s390_is_pv() || !s390_has_topology() ||
> > > + sel2 < 2 || sel2 > S390_TOPOLOGY_MAX_MNEST) {
> > > + setcc(cpu, 3);
> > > + return;
> > > + }
> > > +
> > > + len = setup_stsi(sysib, sel2);
> >
> > This should now be memory safe, but might be larger than 4k,
> > the maximum size of the SYSIB. I guess you want to set cc code 3
> > in this case and return.
>
> I do not find why the SYSIB can not be larger than 4k.
> Can you point me to this restriction?
Says so at the top of the description of STSI:
The SYSIB is 4K bytes and must begin at a 4 K-byte
boundary; otherwise, a specification exception may
be recognized.
Also the graphics show that it is 1024 words long.
>
>
> Regards,
> Pierre
>
next prev parent reply other threads:[~2022-11-07 13:22 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-12 16:20 [PATCH v10 0/9] s390x: CPU Topology Pierre Morel
2022-10-12 16:20 ` [PATCH v10 1/9] s390x/cpu topology: core_id sets s390x CPU topology Pierre Morel
2022-10-18 16:43 ` Cédric Le Goater
2022-10-19 15:39 ` Pierre Morel
2022-10-19 17:56 ` Janis Schoetterl-Glausch
2022-10-24 9:22 ` Cédric Le Goater
2022-10-24 19:26 ` Janis Schoetterl-Glausch
2022-10-24 19:25 ` Janis Schoetterl-Glausch
2022-10-27 8:05 ` Thomas Huth
2022-10-27 9:13 ` Janis Schoetterl-Glausch
2022-10-25 19:58 ` Janis Schoetterl-Glausch
2022-10-26 8:34 ` Pierre Morel
2022-10-27 20:20 ` Janis Schoetterl-Glausch
2022-10-28 9:30 ` Pierre Morel
2022-11-07 18:04 ` Janis Schoetterl-Glausch
2022-11-08 10:28 ` Pierre Morel
2022-10-12 16:21 ` [PATCH v10 2/9] s390x/cpu topology: reporting the CPU topology to the guest Pierre Morel
2022-10-18 17:10 ` Cédric Le Goater
2022-10-27 8:12 ` Thomas Huth
2022-10-27 11:24 ` Pierre Morel
2022-10-27 20:42 ` Janis Schoetterl-Glausch
2022-10-28 10:00 ` Pierre Morel
2022-11-07 13:20 ` Janis Schoetterl-Glausch [this message]
2022-11-07 13:57 ` Pierre Morel
2022-10-12 16:21 ` [PATCH v10 3/9] s390x/cpu_topology: resetting the Topology-Change-Report Pierre Morel
2022-10-18 17:19 ` Cédric Le Goater
2022-10-27 8:14 ` Thomas Huth
2022-10-27 9:11 ` Pierre Morel
2022-10-27 9:58 ` Cédric Le Goater
2022-10-27 11:26 ` Pierre Morel
2022-10-12 16:21 ` [PATCH v10 4/9] s390x/cpu_topology: CPU topology migration Pierre Morel
2022-10-12 16:21 ` [PATCH v10 5/9] target/s390x: interception of PTF instruction Pierre Morel
2022-10-12 16:21 ` [PATCH v10 6/9] s390x/cpu topology: add topology-disable machine property Pierre Morel
2022-10-18 17:34 ` Cédric Le Goater
2022-10-19 9:03 ` Cornelia Huck
2022-10-19 15:48 ` Pierre Morel
2022-10-20 14:01 ` Pierre Morel
2022-10-18 17:51 ` Cédric Le Goater
2022-10-20 14:32 ` Pierre Morel
2022-10-12 16:21 ` [PATCH v10 7/9] s390x/cpu topology: add max_threads machine class attribute Pierre Morel
2022-10-18 17:36 ` Cédric Le Goater
2022-10-26 9:04 ` Pierre Morel
2022-10-27 10:00 ` Cédric Le Goater
2022-10-27 11:28 ` Pierre Morel
2022-10-12 16:21 ` [PATCH v10 8/9] s390x/cpu_topology: activating CPU topology Pierre Morel
2022-10-12 16:21 ` [PATCH v10 9/9] docs/s390x: document s390x cpu topology Pierre Morel
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=ebfe8dea72adaf23913797c482377f4fd58fd097.camel@linux.ibm.com \
--to=scgl@linux.ibm.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=clg@kaod.org \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=nrb@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=pmorel@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=seiden@linux.ibm.com \
--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).