From: Cornelia Huck <cohuck@redhat.com>
To: Halil Pasic <pasic@linux.ibm.com>
Cc: Pierre Morel <pmorel@linux.ibm.com>,
linux-s390@vger.kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, qemu-devel@nongnu.org,
qemu-s390x@nongnu.org, Dong Jia Shi <bjsdjshi@linux.ibm.com>
Subject: Re: [qemu-s390x] [PATCH RFC 2/2] vfio-ccw: support for halt/clear subchannel
Date: Thu, 7 Jun 2018 18:34:07 +0200 [thread overview]
Message-ID: <20180607183407.1ea5ab89.cohuck@redhat.com> (raw)
In-Reply-To: <10c8a0ac-fe61-d7c7-c7bb-0fffc6909cb3@linux.ibm.com>
On Thu, 7 Jun 2018 18:17:57 +0200
Halil Pasic <pasic@linux.ibm.com> wrote:
> On 06/07/2018 11:54 AM, Cornelia Huck wrote:
> > Hm, I think we need to be more precise as to what scsw we're talking
> > about. Bad ascii art time:
> >
> > --------------
> > | scsw(g) | ssch
> > -------------- |
> > | guest
> > --------------------------------------------------------------
> > | qemu
> > -------------- v
> > | scsw(q) | emulate
> > -------------- |
> > |
> > -------------- v
> > | scsw(r) | pwrite()
> > -------------- |
> > |
> > --------------------------------------------------------------
> > | vfio
> > v
> > ssch
> > |
> > --------------------------------------------------------------
> > | hardware
> > -------------- v
> > | scsw(h) | actually do something
> > --------------
> >
> > The guest issues a ssch (which gets intercepted; it won't get control
> > back until ssch finishes with a cc set.) scsw(g) won't change, unless
> > the guest does a stsch for the subchannel on another vcpu, in which
> > case it will get whatever information qemu holds in scsw(q) at that
> > point in time.
>
> (1) I think BQL make other cpu or not other kind of the same. We will
> effectively start processing the stsch in QEMU after we are done
> with the ssch in QEMU.
Yeah, but my main point was that the change is in scsw(q) only.
>
> >
> > When qemu starts to emulate the guest's ssch, it will set the start
> > function bit in the fctl field of scsw(q). It then copies scsw(q) to
> > scsw(r) in the vfio region.
> >
>
> (2) This is architecturally wrong AFAIK. The fctl bit is supposed to be set on
> cc 0. But because of (1) this might not be a observable by the guest --
> we can fix it up.
The bit is set some time during the processing of the instruction - we
need finite time to do the processing, but it should not be observable
by the guest. We should not set the bit if we won't set cc 0.
>
> (3)IMHO scsw(r) is not a real scsw as defined by the architecture but
> a strange communication structure (not) defined vfio-ccw.
IIRC it was intended as a real scsw; we just did not want to define the
whole structure as both Linux and QEMU have scsw definitions that map
to the same hardware structure but look different.
>
> > The vfio code will then proceed to call ssch on the real subchannel.
> > This is the first time we get really asynchronous, as the ssch will
> > return with cc set and the start function will be performed at some
> > point in time. If we would do a stsch on the real subchannel, we would
> > see that scsw(h) now has the start function bit set.
> >
>
> (4) I guess only if cc 0.
Yes, obviously.
>
> > Currently, we won't return back up the chain until we get an interrupt
> > from the hardware, at which time we update the scsw(r) from the irb.
> > This will propagate into the scsw(q). At the time we finish handling
> > the guest's ssch and return control to it, we're all done and if the
> > guest does a stsch to update its scsw(g), it will get the current
> > scsw(q) which will already contain the scsw from the interrupt's irb
> > (indicating that the start function is already finished).
> >
> > Now let's imagine we have a future implementation that handles actually
> > performing the start on the hardware asynchronously, i.e. it returns
> > control to the guest without the interrupt having been posted (let's
> > say that it is a longer-running I/O request). If the guest now did a
> > stsch to update scsw(g), it would get the current state of scsw(q),
> > which would be "start function set, but not done yet".
>
> (5) AFAIK this is how the current implementation works. We don't wait
> for the I/O interrupt on the host to present a cc to the guest for it's
> ssch.
But the vfio code does wait, no? We just signal the interrupt via
eventfd as well.
>
> >
> > If the guest now does a hsch, it would trap in the same way as the ssch
> > before. When qemu gets control, it adds the halt bit in scsw(q) (which
> > is in accordance with the architecture).
>
> (7) Again it's when is fctl set according to the architecture...
Same comment as above. If we do a hsch for a subchannel with the start
function set, we'll set cc 0.
>
> > My proposal is to do the same
> > copying to scsw(r) again, which would mean we get a request with both
> > the halt and the start bit set.
>
> (8) IMHO when receiving the 'request' we are and should be in instruction
> context -- opposed to basic io function context. So we should not set fctl
> before we know what will our guest cc be. But since scsw(r) is not a real
> scsw it is just strange.
I think what we are doing is really 'performing the start function' -
it's just not asynchronous in the current implementation. So we already
know that ssch will return with cc 0.
>
> > The vfio code now needs to do a hsch
> > (instead of a ssch). The real channel subsystem should figure this out,
> > as we can't reliably check whether the start function has concluded
> > already (there's always a race window).
> >
>
> (9) Yes we can't tell for sure if the start function is still being performed
> by the stuff below.
We'll need to figure out a way to outsource most of those decisions to
the real hardware. If we're not sure whether we can set cc 0, we should
probably just set cc 2 and be done with it. (Serialization with regard
to interrupts needed, of course.)
>
> Regards,
> Halil
Thanks for reading!
>
> > For csch, things are a bit different (which the code posted here did
> > not take into account). The qemu emulation of csch needs to clear any
> > start/halt bits in scsw(q) when setting the clear bit there, and
> > therefore scsw(r) will only have the clear bit set in that case. We
> > still should do an unconditional csch for the same reasons as above;
> > the hardware will do the same things (clearing start/halt, setting
> > clear) in the scsw(h).
> >
> > Congratulations, you've reached the end:) I hope that was helpful and
> > not too confusing.
> >
>
WARNING: multiple messages have this Message-ID (diff)
From: Cornelia Huck <cohuck@redhat.com>
To: Halil Pasic <pasic@linux.ibm.com>
Cc: Pierre Morel <pmorel@linux.ibm.com>,
linux-s390@vger.kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, qemu-devel@nongnu.org,
qemu-s390x@nongnu.org, Dong Jia Shi <bjsdjshi@linux.ibm.com>
Subject: Re: [Qemu-devel] [qemu-s390x] [PATCH RFC 2/2] vfio-ccw: support for halt/clear subchannel
Date: Thu, 7 Jun 2018 18:34:07 +0200 [thread overview]
Message-ID: <20180607183407.1ea5ab89.cohuck@redhat.com> (raw)
In-Reply-To: <10c8a0ac-fe61-d7c7-c7bb-0fffc6909cb3@linux.ibm.com>
On Thu, 7 Jun 2018 18:17:57 +0200
Halil Pasic <pasic@linux.ibm.com> wrote:
> On 06/07/2018 11:54 AM, Cornelia Huck wrote:
> > Hm, I think we need to be more precise as to what scsw we're talking
> > about. Bad ascii art time:
> >
> > --------------
> > | scsw(g) | ssch
> > -------------- |
> > | guest
> > --------------------------------------------------------------
> > | qemu
> > -------------- v
> > | scsw(q) | emulate
> > -------------- |
> > |
> > -------------- v
> > | scsw(r) | pwrite()
> > -------------- |
> > |
> > --------------------------------------------------------------
> > | vfio
> > v
> > ssch
> > |
> > --------------------------------------------------------------
> > | hardware
> > -------------- v
> > | scsw(h) | actually do something
> > --------------
> >
> > The guest issues a ssch (which gets intercepted; it won't get control
> > back until ssch finishes with a cc set.) scsw(g) won't change, unless
> > the guest does a stsch for the subchannel on another vcpu, in which
> > case it will get whatever information qemu holds in scsw(q) at that
> > point in time.
>
> (1) I think BQL make other cpu or not other kind of the same. We will
> effectively start processing the stsch in QEMU after we are done
> with the ssch in QEMU.
Yeah, but my main point was that the change is in scsw(q) only.
>
> >
> > When qemu starts to emulate the guest's ssch, it will set the start
> > function bit in the fctl field of scsw(q). It then copies scsw(q) to
> > scsw(r) in the vfio region.
> >
>
> (2) This is architecturally wrong AFAIK. The fctl bit is supposed to be set on
> cc 0. But because of (1) this might not be a observable by the guest --
> we can fix it up.
The bit is set some time during the processing of the instruction - we
need finite time to do the processing, but it should not be observable
by the guest. We should not set the bit if we won't set cc 0.
>
> (3)IMHO scsw(r) is not a real scsw as defined by the architecture but
> a strange communication structure (not) defined vfio-ccw.
IIRC it was intended as a real scsw; we just did not want to define the
whole structure as both Linux and QEMU have scsw definitions that map
to the same hardware structure but look different.
>
> > The vfio code will then proceed to call ssch on the real subchannel.
> > This is the first time we get really asynchronous, as the ssch will
> > return with cc set and the start function will be performed at some
> > point in time. If we would do a stsch on the real subchannel, we would
> > see that scsw(h) now has the start function bit set.
> >
>
> (4) I guess only if cc 0.
Yes, obviously.
>
> > Currently, we won't return back up the chain until we get an interrupt
> > from the hardware, at which time we update the scsw(r) from the irb.
> > This will propagate into the scsw(q). At the time we finish handling
> > the guest's ssch and return control to it, we're all done and if the
> > guest does a stsch to update its scsw(g), it will get the current
> > scsw(q) which will already contain the scsw from the interrupt's irb
> > (indicating that the start function is already finished).
> >
> > Now let's imagine we have a future implementation that handles actually
> > performing the start on the hardware asynchronously, i.e. it returns
> > control to the guest without the interrupt having been posted (let's
> > say that it is a longer-running I/O request). If the guest now did a
> > stsch to update scsw(g), it would get the current state of scsw(q),
> > which would be "start function set, but not done yet".
>
> (5) AFAIK this is how the current implementation works. We don't wait
> for the I/O interrupt on the host to present a cc to the guest for it's
> ssch.
But the vfio code does wait, no? We just signal the interrupt via
eventfd as well.
>
> >
> > If the guest now does a hsch, it would trap in the same way as the ssch
> > before. When qemu gets control, it adds the halt bit in scsw(q) (which
> > is in accordance with the architecture).
>
> (7) Again it's when is fctl set according to the architecture...
Same comment as above. If we do a hsch for a subchannel with the start
function set, we'll set cc 0.
>
> > My proposal is to do the same
> > copying to scsw(r) again, which would mean we get a request with both
> > the halt and the start bit set.
>
> (8) IMHO when receiving the 'request' we are and should be in instruction
> context -- opposed to basic io function context. So we should not set fctl
> before we know what will our guest cc be. But since scsw(r) is not a real
> scsw it is just strange.
I think what we are doing is really 'performing the start function' -
it's just not asynchronous in the current implementation. So we already
know that ssch will return with cc 0.
>
> > The vfio code now needs to do a hsch
> > (instead of a ssch). The real channel subsystem should figure this out,
> > as we can't reliably check whether the start function has concluded
> > already (there's always a race window).
> >
>
> (9) Yes we can't tell for sure if the start function is still being performed
> by the stuff below.
We'll need to figure out a way to outsource most of those decisions to
the real hardware. If we're not sure whether we can set cc 0, we should
probably just set cc 2 and be done with it. (Serialization with regard
to interrupts needed, of course.)
>
> Regards,
> Halil
Thanks for reading!
>
> > For csch, things are a bit different (which the code posted here did
> > not take into account). The qemu emulation of csch needs to clear any
> > start/halt bits in scsw(q) when setting the clear bit there, and
> > therefore scsw(r) will only have the clear bit set in that case. We
> > still should do an unconditional csch for the same reasons as above;
> > the hardware will do the same things (clearing start/halt, setting
> > clear) in the scsw(h).
> >
> > Congratulations, you've reached the end:) I hope that was helpful and
> > not too confusing.
> >
>
next prev parent reply other threads:[~2018-06-07 16:34 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-09 15:48 [PATCH RFC 0/2] vfio-ccw: support for {halt,clear} subchannel Cornelia Huck
2018-05-09 15:48 ` [Qemu-devel] [PATCH RFC 0/2] vfio-ccw: support for {halt, clear} subchannel Cornelia Huck
2018-05-09 15:48 ` [PATCH RFC 1/2] s390/cio: export hsch to modules Cornelia Huck
2018-05-09 15:48 ` [Qemu-devel] " Cornelia Huck
2018-05-11 9:36 ` Pierre Morel
2018-05-11 9:36 ` [Qemu-devel] " Pierre Morel
2018-05-09 15:48 ` [PATCH RFC 2/2] vfio-ccw: support for halt/clear subchannel Cornelia Huck
2018-05-09 15:48 ` [Qemu-devel] " Cornelia Huck
2018-05-11 9:33 ` Pierre Morel
2018-05-11 9:33 ` [Qemu-devel] " Pierre Morel
2018-05-15 16:10 ` Cornelia Huck
2018-05-15 16:10 ` [Qemu-devel] " Cornelia Huck
2018-05-16 13:32 ` Pierre Morel
2018-05-16 13:32 ` [Qemu-devel] " Pierre Morel
2018-05-22 12:52 ` Cornelia Huck
2018-05-22 12:52 ` [Qemu-devel] " Cornelia Huck
2018-05-22 15:10 ` Pierre Morel
2018-05-22 15:10 ` [Qemu-devel] " Pierre Morel
2018-06-05 13:14 ` Cornelia Huck
2018-06-05 13:14 ` [Qemu-devel] " Cornelia Huck
2018-06-05 15:23 ` Pierre Morel
2018-06-05 15:23 ` [Qemu-devel] " Pierre Morel
2018-06-05 15:36 ` Cornelia Huck
2018-06-05 15:36 ` [Qemu-devel] " Cornelia Huck
2018-06-06 12:21 ` Cornelia Huck
2018-06-06 12:21 ` [Qemu-devel] " Cornelia Huck
2018-06-06 14:15 ` Pierre Morel
2018-06-06 14:15 ` [Qemu-devel] " Pierre Morel
2018-06-07 9:54 ` Cornelia Huck
2018-06-07 9:54 ` [Qemu-devel] " Cornelia Huck
2018-06-07 16:17 ` [qemu-s390x] " Halil Pasic
2018-06-07 16:17 ` [Qemu-devel] " Halil Pasic
2018-06-07 16:34 ` Cornelia Huck [this message]
2018-06-07 16:34 ` Cornelia Huck
2018-06-08 20:40 ` Halil Pasic
2018-06-08 20:40 ` [Qemu-devel] " Halil Pasic
2018-06-11 11:12 ` Cornelia Huck
2018-06-11 11:12 ` [Qemu-devel] " Cornelia Huck
2018-06-11 16:00 ` Cornelia Huck
2018-06-11 16:00 ` [Qemu-devel] " Cornelia Huck
2018-06-07 16:37 ` Pierre Morel
2018-06-07 16:37 ` [Qemu-devel] " Pierre Morel
2018-06-08 12:20 ` Cornelia Huck
2018-06-08 12:20 ` [Qemu-devel] " Cornelia Huck
2018-06-08 13:13 ` Halil Pasic
2018-06-08 13:13 ` [Qemu-devel] " Halil Pasic
2018-06-08 14:45 ` Cornelia Huck
2018-06-08 14:45 ` [Qemu-devel] " Cornelia Huck
2018-06-08 15:51 ` Pierre Morel
2018-06-08 15:51 ` [Qemu-devel] " Pierre Morel
2018-06-12 9:59 ` Cornelia Huck
2018-06-12 9:59 ` [Qemu-devel] " Cornelia Huck
2018-06-12 13:56 ` Pierre Morel
2018-06-12 13:56 ` [Qemu-devel] " Pierre Morel
2018-06-12 14:08 ` Halil Pasic
2018-06-12 14:08 ` [Qemu-devel] " Halil Pasic
2018-06-12 15:25 ` Cornelia Huck
2018-06-12 15:25 ` [Qemu-devel] " Cornelia Huck
2018-06-08 21:10 ` Halil Pasic
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=20180607183407.1ea5ab89.cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=bjsdjshi@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pasic@linux.ibm.com \
--cc=pmorel@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.