From: Cornelia Huck <cohuck@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Eric Farman <farman@linux.ibm.com>,
Thomas Huth <thuth@redhat.com>,
QEMU Developers <qemu-devel@nongnu.org>,
qemu-s390x <qemu-s390x@nongnu.org>
Subject: Re: getting the console output for s390 cdrom-test?
Date: Tue, 9 Feb 2021 18:10:09 +0100 [thread overview]
Message-ID: <20210209181009.7f2cb328.cohuck@redhat.com> (raw)
In-Reply-To: <CAFEAcA_JLx6NAd_YPzKy6iXWqP_c1jkW42bscK+Q=zKN4xAbzQ@mail.gmail.com>
On Tue, 9 Feb 2021 14:58:53 +0000
Peter Maydell <peter.maydell@linaro.org> wrote:
> On Mon, 8 Feb 2021 at 12:08, Peter Maydell <peter.maydell@linaro.org> wrote:
> > Yes, virtio_scsi_parse_req() returns ENOTSUP because it
> > fails the "if (out_size && in_size)" test.
> >
> > I am becoming somewhat suspicious that the s390-ccw BIOS's
> > implementation of virtio is not putting in sufficient barriers,
> > and so if you get unlucky then the QEMU thread sees an inconsistent
> > view of the in-memory virtio data structures.
>
> As a test of this theory, I tried adding some barrier insns
> (with the definition of the barrier insn borrowed from s390x Linux):
>
> diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
> index ab49840db85..0af901264b6 100644
> --- a/pc-bios/s390-ccw/virtio.c
> +++ b/pc-bios/s390-ccw/virtio.c
> @@ -17,6 +17,12 @@
> #include "helper.h"
> #include "s390-time.h"
>
> +#define membarrier() do { asm volatile("bcr 15,0\n" :: : "memory"); } while (0)
> +
> +#define __ASM_BARRIER "bcr 15,0\n"
> +
> +
> +
> #define VRING_WAIT_REPLY_TIMEOUT 30
>
> static VRing block[VIRTIO_MAX_VQS];
> @@ -154,12 +160,15 @@ void vring_send_buf(VRing *vr, void *p, int len,
> int flags)
>
> /* Chains only have a single ID */
> if (!(flags & VRING_DESC_F_NEXT)) {
> + membarrier();
> vr->avail->idx++;
> + membarrier();
> }
> }
>
> int vr_poll(VRing *vr)
> {
> + membarrier();
> if (vr->used->idx == vr->used_idx) {
> vring_notify(vr);
> yield();
> @@ -169,7 +178,9 @@ int vr_poll(VRing *vr)
> vr->used_idx = vr->used->idx;
> vr->next_idx = 0;
> vr->desc[0].len = 0;
> + membarrier();
> vr->desc[0].flags = 0;
> + membarrier();
> return 1; /* vr has been updated */
> }
>
> This change significantly reduces the frequency with which I see
> the hang; but it doesn't get rid of it altogether. Also I couldn't
> really figure out from the virtio spec exactly where barriers
> were required: I think I would need to read the whole thing in
> more detail rather than trying to fish out the information by
> just reading small pieces of it.
The Linux virtio-ccw code uses 'weak barriers', i.e. the heavy bcr15
should not be needed. We might well miss other (lightweight) barriers
in other parts of the code part, though.
> But some of the ordering of
> operations the spec describes doesn't match how the s390-ccw
> BIOS code is doing it at all (eg the spec says that when feeding
> a batch of descriptors to the device the driver isn't supposed to
> update the flags on the first descriptor until it's finished
> writing all of the descriptors, but the code doesn't seem to
> try to do that). So I think the code could use an overhaul from
> somebody with a better understanding of virtio than me...
Yeah, the bios virtio code could probably use some love.
I'm wondering how much memory ordering on the host platform influences
things. I doubt many people try to run an s390x guest on an aarch64
host...
next prev parent reply other threads:[~2021-02-09 17:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-22 20:32 getting the console output for s390 cdrom-test? Peter Maydell
2021-02-04 16:08 ` Thomas Huth
2021-02-08 10:27 ` Peter Maydell
2021-02-08 11:34 ` Thomas Huth
2021-02-08 12:08 ` Peter Maydell
2021-02-09 14:58 ` Peter Maydell
2021-02-09 17:10 ` Cornelia Huck [this message]
2021-02-09 17:17 ` Peter Maydell
2021-02-09 17:24 ` Cornelia Huck
2021-02-09 18:25 ` Peter Maydell
2021-02-12 11:44 ` Thomas Huth
2021-02-12 12:05 ` Peter Maydell
2021-02-12 14:10 ` Thomas Huth
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=20210209181009.7f2cb328.cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=farman@linux.ibm.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).