From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: Alexander Graf <agraf@suse.de>
Cc: linux-s390 <linux-s390@vger.kernel.org>,
Anthony Liguori <aliguori@us.ibm.com>, KVM <kvm@vger.kernel.org>,
Carsten Otte <cotte@de.ibm.com>,
Sebastian Ott <sebott@linux.vnet.ibm.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
qemu-devel <qemu-devel@nongnu.org>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Avi Kivity <avi@redhat.com>,
Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: Re: [Qemu-devel] [PATCH 2/3] s390: Virtual channel subsystem support.
Date: Tue, 20 Nov 2012 10:27:53 +0100 [thread overview]
Message-ID: <20121120102753.4104ec05@BR9GNB5Z> (raw)
In-Reply-To: <B6F2031C-0AC3-486A-9A95-51DE66F747AA@suse.de>
On Mon, 19 Nov 2012 14:30:00 +0100
Alexander Graf <agraf@suse.de> wrote:
>
> On 31.10.2012, at 17:24, Cornelia Huck wrote:
>
> > Provide a mechanism for qemu to provide fully virtual subchannels to
> > the guest. In the KVM case, this relies on the kernel's css support
> > for I/O and machine check interrupt handling. The !KVM case handles
> > interrupts on its own.
> >
> > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> > ---
> > hw/s390x/Makefile.objs | 1 +
> > hw/s390x/css.c | 1209 ++++++++++++++++++++++++++++++++++++++++++++
> > hw/s390x/css.h | 90 ++++
> > target-s390x/Makefile.objs | 2 +-
> > target-s390x/cpu.h | 232 +++++++++
> > target-s390x/helper.c | 146 ++++++
> > target-s390x/ioinst.c | 737 +++++++++++++++++++++++++++
> > target-s390x/ioinst.h | 213 ++++++++
> > target-s390x/kvm.c | 251 ++++++++-
> > target-s390x/misc_helper.c | 6 +-
> > 10 files changed, 2872 insertions(+), 15 deletions(-)
> > create mode 100644 hw/s390x/css.c
> > create mode 100644 hw/s390x/css.h
> > create mode 100644 target-s390x/ioinst.c
> > create mode 100644 target-s390x/ioinst.h
> >
> > diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs
> > index 096dfcd..378b099 100644
> > --- a/hw/s390x/Makefile.objs
> > +++ b/hw/s390x/Makefile.objs
> > @@ -4,3 +4,4 @@ obj-y := $(addprefix ../,$(obj-y))
> > obj-y += sclp.o
> > obj-y += event-facility.o
> > obj-y += sclpquiesce.o sclpconsole.o
> > +obj-y += css.o
> > diff --git a/hw/s390x/css.c b/hw/s390x/css.c
> > new file mode 100644
> > index 0000000..9adffb3
> > --- /dev/null
> > +++ b/hw/s390x/css.c
> > @@ -0,0 +1,1209 @@
> > +/*
> > + * Channel subsystem base support.
> > + *
> > + * Copyright 2012 IBM Corp.
> > + * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
> > + *
> > + * This work is licensed under the terms of the GNU GPL, version 2 or (at
> > + * your option) any later version. See the COPYING file in the top-level
> > + * directory.
> > + */
> > +
> > +#include "qemu-thread.h"
> > +#include "qemu-queue.h"
> > +#include <hw/qdev.h>
> > +#include "bitops.h"
> > +#include "kvm.h"
> > +#include "cpu.h"
> > +#include "ioinst.h"
> > +#include "css.h"
> > +#include "virtio-ccw.h"
> > +
> > +typedef struct CrwContainer {
> > + CRW crw;
> > + QTAILQ_ENTRY(CrwContainer) sibling;
> > +} CrwContainer;
> > +
> > +typedef struct ChpInfo {
> > + uint8_t in_use;
> > + uint8_t type;
> > + uint8_t is_virtual;
> > +} ChpInfo;
> > +
> > +typedef struct SubchSet {
> > + SubchDev *sch[MAX_SCHID + 1];
> > + unsigned long schids_used[BITS_TO_LONGS(MAX_SCHID + 1)];
> > + unsigned long devnos_used[BITS_TO_LONGS(MAX_SCHID + 1)];
> > +} SubchSet;
> > +
> > +typedef struct CssImage {
> > + SubchSet *sch_set[MAX_SSID + 1];
> > + ChpInfo chpids[MAX_CHPID + 1];
> > +} CssImage;
> > +
> > +typedef struct ChannelSubSys {
> > + QTAILQ_HEAD(, CrwContainer) pending_crws;
> > + bool do_crw_mchk;
> > + bool crws_lost;
> > + uint8_t max_cssid;
> > + uint8_t max_ssid;
> > + bool chnmon_active;
> > + uint64_t chnmon_area;
> > + CssImage *css[MAX_CSSID + 1];
> > + uint8_t default_cssid;
> > +} ChannelSubSys;
> > +
> > +static ChannelSubSys *channel_subsys;
> > +
> > +int css_create_css_image(uint8_t cssid, bool default_image)
> > +{
> > + if (cssid > MAX_CSSID) {
> > + return -EINVAL;
> > + }
> > + if (channel_subsys->css[cssid]) {
> > + return -EBUSY;
> > + }
> > + channel_subsys->css[cssid] = g_try_malloc0(sizeof(CssImage));
> > + if (!channel_subsys->css[cssid]) {
> > + return -ENOMEM;
> > + }
> > + if (default_image) {
> > + channel_subsys->default_cssid = cssid;
> > + }
> > + return 0;
> > +}
> > +
> > +static void css_write_phys_pmcw(uint64_t addr, PMCW *pmcw)
> > +{
> > + int i;
> > + uint32_t offset = 0;
> > + struct copy_pmcw {
> > + uint32_t intparm;
> > + uint16_t flags;
> > + uint16_t devno;
> > + uint8_t lpm;
> > + uint8_t pnom;
> > + uint8_t lpum;
> > + uint8_t pim;
> > + uint16_t mbi;
> > + uint8_t pom;
> > + uint8_t pam;
> > + uint8_t chpid[8];
> > + uint32_t chars;
> > + } *copy;
>
> This needs to be packed. Also, it might be a good idea to separate the struct definition from the actual code ;).
>
> > +
> > + copy = (struct copy_pmcw *)pmcw;
>
> This will break on any system that doesn't coincidently stick to the same bitfield order as s390x. Please drop any usage of bitfields in QEMU source code :).
>
> > + stl_phys(addr + offset, copy->intparm);
> > + offset += sizeof(copy->intparm);
>
> Can't you just use cpu_physical_memory_map() and assign things left and right as you see fit? Or prepare the target endianness struct on the stack and cpu_physical_memory_read/write it from/to guest memory.
All that copying stuff (other places as well) was still on my todo list
- just wanted to get the patches out of the door so people could take a
look at the interface.
>
> Also, please split this patch into smaller patches :). As it is now it's very hard to review. However, apart from the above issues (which may happen in other places of the code further down, I just didn't comment then) I couldn't see major problems so far. But please split it nevertheless so that I have an easier time reviewing it :)
I'll try, but I found it hard to come up with a logical split.
>
>
> Alex
>
next prev parent reply other threads:[~2012-11-20 9:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-31 16:24 [Qemu-devel] [RFC PATCH v3 0/3] s390: channel I/O support in qemu Cornelia Huck
2012-10-31 16:24 ` [Qemu-devel] [PATCH 1/3] Update linux headers Cornelia Huck
2012-10-31 16:24 ` [Qemu-devel] [PATCH 2/3] s390: Virtual channel subsystem support Cornelia Huck
2012-11-13 1:17 ` Marcelo Tosatti
2012-11-13 10:11 ` Cornelia Huck
2012-11-19 13:30 ` Alexander Graf
2012-11-20 9:27 ` Cornelia Huck [this message]
2012-10-31 16:24 ` [Qemu-devel] [PATCH 3/3] s390: Add new channel I/O based virtio transport Cornelia Huck
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=20121120102753.4104ec05@BR9GNB5Z \
--to=cornelia.huck@de.ibm.com \
--cc=agraf@suse.de \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cotte@de.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=schwidefsky@de.ibm.com \
--cc=sebott@linux.vnet.ibm.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).