OASIS Virtual I/O Device (VIRTIO) TC

 View Only
Expand all | Collapse all

[PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

  • 1.  [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-09-2013 16:00
    Extend vq_info_block so that the addresses for descriptor table, available ring and used ring may be transmitted independently. Depending upon the selected revision, post a command reject instead of a channel program check if the driver uses the legacy format and length checks are suppressed. VIRTIO-23 Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> --- This is an alternate approach, extending the exiting structure instead of creating a different layout. I'm not 100% sure whether doing a command reject instead of a channel program check in case of a short buffer is the right approach, though. Doing a channel program check would probably cover that error just as well, and we could resolve VIRTIO-23 independently of VIRTIO-42. --- virtio-v1.0-wd01-part1-specification.txt 32 +++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt index ae646db..baff12f 100644 --- a/virtio-v1.0-wd01-part1-specification.txt +++ b/virtio-v1.0-wd01-part1-specification.txt @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted structure is struct vq_info_block { + __u64 desc; + __u32 res0; + __u16 index; + __u16 num; + __u64 avail; + __u64 used; +} __attribute__ ((packed)); + +desc, avail and used contain the guest addresses for the descriptor table, +available ring and used ring for queue index, respectively. The actual +virtqueue size (number of allocated buffers) is transmitted in num. +res0 is reserved and must contain 0; otherwise, the device MUST post a +unit check with command reject. + +If the revision selected by the driver is at least 1, the device MUST +post a unit check with command reject if the transmitted data is between +16 and 31 bytes if the driver suppressed incorrect length indication +for the channel command. Otherwise, the normal conditions for handling +incorrect data lenghts apply. + +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue +---------------------------------------------------------------- + +For a legacy driver or for a driver that selected revision 0, +CCW_CMD_SET_VQ uses the following communication block: + +struct vq_info_block_legacy { __u64 queue; __u32 align; __u16 index; __u16 num; } __attribute__ ((packed)); -queue contains the guest address for queue index. The actual -number of allocated buffers is transmitted in num and their -alignment in align. +queue contains the guest address for queue index, num the number of buffers +and align the alignment. 100.3.3.2.2. Virtqueue Layout ------------------------------ -- 1.7.9.5


  • 2.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 05:24
    On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote: > Extend vq_info_block so that the addresses for descriptor table, > available ring and used ring may be transmitted independently. > > Depending upon the selected revision, post a command reject instead > of a channel program check if the driver uses the legacy format > and length checks are suppressed. > > VIRTIO-23 > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> > > --- > > This is an alternate approach, extending the exiting structure instead > of creating a different layout. I'm not 100% sure whether doing a > command reject instead of a channel program check in case of a short > buffer is the right approach, though. Doing a channel program check > would probably cover that error just as well, and we could resolve > VIRTIO-23 independently of VIRTIO-42. > --- > virtio-v1.0-wd01-part1-specification.txt 32 +++++++++++++++++++++++++++--- > 1 file changed, 29 insertions(+), 3 deletions(-) > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt > index ae646db..baff12f 100644 > --- a/virtio-v1.0-wd01-part1-specification.txt > +++ b/virtio-v1.0-wd01-part1-specification.txt > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted > structure is > > struct vq_info_block { > + __u64 desc; > + __u32 res0; > + __u16 index; > + __u16 num; > + __u64 avail; > + __u64 used; > +} __attribute__ ((packed)); > + > +desc, avail and used contain the guest addresses for the descriptor table, > +available ring and used ring for queue index, respectively. The actual > +virtqueue size (number of allocated buffers) is transmitted in num. > +res0 is reserved and must contain 0; otherwise, the device MUST post a > +unit check with command reject. > + > +If the revision selected by the driver is at least 1, Where's the revision field and how does driver select it? I don't see it anywhere in spec? > the device MUST > +post a unit check with command reject if the transmitted data is between > +16 and 31 bytes if the driver suppressed incorrect length indication > +for the channel command. Otherwise, the normal conditions for handling > +incorrect data lenghts apply. > + > +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue > +---------------------------------------------------------------- > + > +For a legacy driver or for a driver that selected revision 0, > +CCW_CMD_SET_VQ uses the following communication block: > + > +struct vq_info_block_legacy { > __u64 queue; > __u32 align; > __u16 index; > __u16 num; > } __attribute__ ((packed)); > > -queue contains the guest address for queue index. The actual > -number of allocated buffers is transmitted in num and their > -alignment in align. > +queue contains the guest address for queue index, num the number of buffers > +and align the alignment. > > 100.3.3.2.2. Virtqueue Layout > ------------------------------ > -- > 1.7.9.5


  • 3.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 05:26
    On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote:
    > Extend vq_info_block so that the addresses for descriptor table,
    > available ring and used ring may be transmitted independently.
    >
    > Depending upon the selected revision, post a command reject instead
    > of a channel program check if the driver uses the legacy format
    > and length checks are suppressed.
    >
    > VIRTIO-23
    >
    > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
    >
    > ---
    >
    > This is an alternate approach, extending the exiting structure instead
    > of creating a different layout. I'm not 100% sure whether doing a
    > command reject instead of a channel program check in case of a short
    > buffer is the right approach, though. Doing a channel program check
    > would probably cover that error just as well, and we could resolve
    > VIRTIO-23 independently of VIRTIO-42.
    > ---
    > virtio-v1.0-wd01-part1-specification.txt | 32 +++++++++++++++++++++++++++---
    > 1 file changed, 29 insertions(+), 3 deletions(-)
    >
    > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt
    > index ae646db..baff12f 100644
    > --- a/virtio-v1.0-wd01-part1-specification.txt
    > +++ b/virtio-v1.0-wd01-part1-specification.txt
    > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted
    > structure is
    >
    > struct vq_info_block {
    > + __u64 desc;
    > + __u32 res0;
    > + __u16 index;
    > + __u16 num;
    > + __u64 avail;
    > + __u64 used;
    > +} __attribute__ ((packed));
    > +
    > +desc, avail and used contain the guest addresses for the descriptor table,
    > +available ring and used ring for queue index, respectively. The actual
    > +virtqueue size (number of allocated buffers) is transmitted in num.
    > +res0 is reserved and must contain 0; otherwise, the device MUST post a
    > +unit check with command reject.
    > +
    > +If the revision selected by the driver is at least 1,

    Where's the revision field and how does driver select it?
    I don't see it anywhere in spec?

    > the device MUST
    > +post a unit check with command reject if the transmitted data is between
    > +16 and 31 bytes if the driver suppressed incorrect length indication
    > +for the channel command. Otherwise, the normal conditions for handling
    > +incorrect data lenghts apply.
    > +
    > +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue
    > +----------------------------------------------------------------
    > +
    > +For a legacy driver or for a driver that selected revision 0,
    > +CCW_CMD_SET_VQ uses the following communication block:
    > +
    > +struct vq_info_block_legacy {
    > __u64 queue;
    > __u32 align;
    > __u16 index;
    > __u16 num;
    > } __attribute__ ((packed));
    >
    > -queue contains the guest address for queue index. The actual
    > -number of allocated buffers is transmitted in num and their
    > -alignment in align.
    > +queue contains the guest address for queue index, num the number of buffers
    > +and align the alignment.
    >
    > 100.3.3.2.2. Virtqueue Layout
    > ------------------------------
    > --
    > 1.7.9.5



  • 4.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 08:04
    On Thu, 10 Oct 2013 08:26:13 +0300
    "Michael S. Tsirkin" <mst@redhat.com> wrote:

    > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote:
    > > Extend vq_info_block so that the addresses for descriptor table,
    > > available ring and used ring may be transmitted independently.
    > >
    > > Depending upon the selected revision, post a command reject instead
    > > of a channel program check if the driver uses the legacy format
    > > and length checks are suppressed.
    > >
    > > VIRTIO-23
    > >
    > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
    > >
    > > ---
    > >
    > > This is an alternate approach, extending the exiting structure instead
    > > of creating a different layout. I'm not 100% sure whether doing a
    > > command reject instead of a channel program check in case of a short
    > > buffer is the right approach, though. Doing a channel program check
    > > would probably cover that error just as well, and we could resolve
    > > VIRTIO-23 independently of VIRTIO-42.
    > > ---
    > > virtio-v1.0-wd01-part1-specification.txt | 32 +++++++++++++++++++++++++++---
    > > 1 file changed, 29 insertions(+), 3 deletions(-)
    > >
    > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt
    > > index ae646db..baff12f 100644
    > > --- a/virtio-v1.0-wd01-part1-specification.txt
    > > +++ b/virtio-v1.0-wd01-part1-specification.txt
    > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted
    > > structure is
    > >
    > > struct vq_info_block {
    > > + __u64 desc;
    > > + __u32 res0;
    > > + __u16 index;
    > > + __u16 num;
    > > + __u64 avail;
    > > + __u64 used;
    > > +} __attribute__ ((packed));
    > > +
    > > +desc, avail and used contain the guest addresses for the descriptor table,
    > > +available ring and used ring for queue index, respectively. The actual
    > > +virtqueue size (number of allocated buffers) is transmitted in num.
    > > +res0 is reserved and must contain 0; otherwise, the device MUST post a
    > > +unit check with command reject.
    > > +
    > > +If the revision selected by the driver is at least 1,
    >
    > Where's the revision field and how does driver select it?
    > I don't see it anywhere in spec?

    This one is depending on VIRTIO-42; sorry about not being clear on it.

    (If we ditch the revision check, the dependency goes away.)

    >
    > > the device MUST
    > > +post a unit check with command reject if the transmitted data is between
    > > +16 and 31 bytes if the driver suppressed incorrect length indication
    > > +for the channel command. Otherwise, the normal conditions for handling
    > > +incorrect data lenghts apply.
    > > +
    > > +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue
    > > +----------------------------------------------------------------
    > > +
    > > +For a legacy driver or for a driver that selected revision 0,
    > > +CCW_CMD_SET_VQ uses the following communication block:
    > > +
    > > +struct vq_info_block_legacy {
    > > __u64 queue;
    > > __u32 align;
    > > __u16 index;
    > > __u16 num;
    > > } __attribute__ ((packed));
    > >
    > > -queue contains the guest address for queue index. The actual
    > > -number of allocated buffers is transmitted in num and their
    > > -alignment in align.
    > > +queue contains the guest address for queue index, num the number of buffers
    > > +and align the alignment.
    > >
    > > 100.3.3.2.2. Virtqueue Layout
    > > ------------------------------
    > > --
    > > 1.7.9.5
    >




  • 5.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 08:05
    On Thu, 10 Oct 2013 08:26:13 +0300 "Michael S. Tsirkin" <mst@redhat.com> wrote: > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote: > > Extend vq_info_block so that the addresses for descriptor table, > > available ring and used ring may be transmitted independently. > > > > Depending upon the selected revision, post a command reject instead > > of a channel program check if the driver uses the legacy format > > and length checks are suppressed. > > > > VIRTIO-23 > > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> > > > > --- > > > > This is an alternate approach, extending the exiting structure instead > > of creating a different layout. I'm not 100% sure whether doing a > > command reject instead of a channel program check in case of a short > > buffer is the right approach, though. Doing a channel program check > > would probably cover that error just as well, and we could resolve > > VIRTIO-23 independently of VIRTIO-42. > > --- > > virtio-v1.0-wd01-part1-specification.txt 32 +++++++++++++++++++++++++++--- > > 1 file changed, 29 insertions(+), 3 deletions(-) > > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt > > index ae646db..baff12f 100644 > > --- a/virtio-v1.0-wd01-part1-specification.txt > > +++ b/virtio-v1.0-wd01-part1-specification.txt > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted > > structure is > > > > struct vq_info_block { > > + __u64 desc; > > + __u32 res0; > > + __u16 index; > > + __u16 num; > > + __u64 avail; > > + __u64 used; > > +} __attribute__ ((packed)); > > + > > +desc, avail and used contain the guest addresses for the descriptor table, > > +available ring and used ring for queue index, respectively. The actual > > +virtqueue size (number of allocated buffers) is transmitted in num. > > +res0 is reserved and must contain 0; otherwise, the device MUST post a > > +unit check with command reject. > > + > > +If the revision selected by the driver is at least 1, > > Where's the revision field and how does driver select it? > I don't see it anywhere in spec? This one is depending on VIRTIO-42; sorry about not being clear on it. (If we ditch the revision check, the dependency goes away.) > > > the device MUST > > +post a unit check with command reject if the transmitted data is between > > +16 and 31 bytes if the driver suppressed incorrect length indication > > +for the channel command. Otherwise, the normal conditions for handling > > +incorrect data lenghts apply. > > + > > +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue > > +---------------------------------------------------------------- > > + > > +For a legacy driver or for a driver that selected revision 0, > > +CCW_CMD_SET_VQ uses the following communication block: > > + > > +struct vq_info_block_legacy { > > __u64 queue; > > __u32 align; > > __u16 index; > > __u16 num; > > } __attribute__ ((packed)); > > > > -queue contains the guest address for queue index. The actual > > -number of allocated buffers is transmitted in num and their > > -alignment in align. > > +queue contains the guest address for queue index, num the number of buffers > > +and align the alignment. > > > > 100.3.3.2.2. Virtqueue Layout > > ------------------------------ > > -- > > 1.7.9.5 >


  • 6.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 08:47
    On Thu, Oct 10, 2013 at 10:03:58AM +0200, Cornelia Huck wrote: > On Thu, 10 Oct 2013 08:26:13 +0300 > "Michael S. Tsirkin" <mst@redhat.com> wrote: > > > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote: > > > Extend vq_info_block so that the addresses for descriptor table, > > > available ring and used ring may be transmitted independently. > > > > > > Depending upon the selected revision, post a command reject instead > > > of a channel program check if the driver uses the legacy format > > > and length checks are suppressed. > > > > > > VIRTIO-23 > > > > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> > > > > > > --- > > > > > > This is an alternate approach, extending the exiting structure instead > > > of creating a different layout. I'm not 100% sure whether doing a > > > command reject instead of a channel program check in case of a short > > > buffer is the right approach, though. Doing a channel program check > > > would probably cover that error just as well, and we could resolve > > > VIRTIO-23 independently of VIRTIO-42. > > > --- > > > virtio-v1.0-wd01-part1-specification.txt 32 +++++++++++++++++++++++++++--- > > > 1 file changed, 29 insertions(+), 3 deletions(-) > > > > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt > > > index ae646db..baff12f 100644 > > > --- a/virtio-v1.0-wd01-part1-specification.txt > > > +++ b/virtio-v1.0-wd01-part1-specification.txt > > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted > > > structure is > > > > > > struct vq_info_block { > > > + __u64 desc; > > > + __u32 res0; > > > + __u16 index; > > > + __u16 num; > > > + __u64 avail; > > > + __u64 used; > > > +} __attribute__ ((packed)); > > > + > > > +desc, avail and used contain the guest addresses for the descriptor table, > > > +available ring and used ring for queue index, respectively. The actual > > > +virtqueue size (number of allocated buffers) is transmitted in num. > > > +res0 is reserved and must contain 0; otherwise, the device MUST post a > > > +unit check with command reject. > > > + > > > +If the revision selected by the driver is at least 1, > > > > Where's the revision field and how does driver select it? > > I don't see it anywhere in spec? > > This one is depending on VIRTIO-42; sorry about not being clear on it. > > (If we ditch the revision check, the dependency goes away.) Okay, so we voted in VIRTIO-30, I'll just commit that as it's a generic replacement solving same problem. For now could you rephrase the text to say "when used through legacy interface" for devices and "when using legacy interface" for drivers? That's the language we use elsewhere. Then VIRTIO-42 would be independent. > > > > > the device MUST > > > +post a unit check with command reject if the transmitted data is between > > > +16 and 31 bytes if the driver suppressed incorrect length indication > > > +for the channel command. Otherwise, the normal conditions for handling > > > +incorrect data lenghts apply. > > > + > > > +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue > > > +---------------------------------------------------------------- > > > + > > > +For a legacy driver or for a driver that selected revision 0, > > > +CCW_CMD_SET_VQ uses the following communication block: > > > + > > > +struct vq_info_block_legacy { > > > __u64 queue; > > > __u32 align; > > > __u16 index; > > > __u16 num; > > > } __attribute__ ((packed)); > > > > > > -queue contains the guest address for queue index. The actual > > > -number of allocated buffers is transmitted in num and their > > > -alignment in align. > > > +queue contains the guest address for queue index, num the number of buffers > > > +and align the alignment. > > > > > > 100.3.3.2.2. Virtqueue Layout > > > ------------------------------ > > > -- > > > 1.7.9.5 > >


  • 7.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 08:49
    On Thu, Oct 10, 2013 at 10:03:58AM +0200, Cornelia Huck wrote:
    > On Thu, 10 Oct 2013 08:26:13 +0300
    > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    >
    > > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote:
    > > > Extend vq_info_block so that the addresses for descriptor table,
    > > > available ring and used ring may be transmitted independently.
    > > >
    > > > Depending upon the selected revision, post a command reject instead
    > > > of a channel program check if the driver uses the legacy format
    > > > and length checks are suppressed.
    > > >
    > > > VIRTIO-23
    > > >
    > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
    > > >
    > > > ---
    > > >
    > > > This is an alternate approach, extending the exiting structure instead
    > > > of creating a different layout. I'm not 100% sure whether doing a
    > > > command reject instead of a channel program check in case of a short
    > > > buffer is the right approach, though. Doing a channel program check
    > > > would probably cover that error just as well, and we could resolve
    > > > VIRTIO-23 independently of VIRTIO-42.
    > > > ---
    > > > virtio-v1.0-wd01-part1-specification.txt | 32 +++++++++++++++++++++++++++---
    > > > 1 file changed, 29 insertions(+), 3 deletions(-)
    > > >
    > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt
    > > > index ae646db..baff12f 100644
    > > > --- a/virtio-v1.0-wd01-part1-specification.txt
    > > > +++ b/virtio-v1.0-wd01-part1-specification.txt
    > > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted
    > > > structure is
    > > >
    > > > struct vq_info_block {
    > > > + __u64 desc;
    > > > + __u32 res0;
    > > > + __u16 index;
    > > > + __u16 num;
    > > > + __u64 avail;
    > > > + __u64 used;
    > > > +} __attribute__ ((packed));
    > > > +
    > > > +desc, avail and used contain the guest addresses for the descriptor table,
    > > > +available ring and used ring for queue index, respectively. The actual
    > > > +virtqueue size (number of allocated buffers) is transmitted in num.
    > > > +res0 is reserved and must contain 0; otherwise, the device MUST post a
    > > > +unit check with command reject.
    > > > +
    > > > +If the revision selected by the driver is at least 1,
    > >
    > > Where's the revision field and how does driver select it?
    > > I don't see it anywhere in spec?
    >
    > This one is depending on VIRTIO-42; sorry about not being clear on it.
    >
    > (If we ditch the revision check, the dependency goes away.)

    Okay, so we voted in VIRTIO-30, I'll just commit that as it's
    a generic replacement solving same problem.
    For now could you rephrase the text to say
    "when used through legacy interface" for devices
    and "when using legacy interface" for drivers?

    That's the language we use elsewhere.

    Then VIRTIO-42 would be independent.

    > >
    > > > the device MUST
    > > > +post a unit check with command reject if the transmitted data is between
    > > > +16 and 31 bytes if the driver suppressed incorrect length indication
    > > > +for the channel command. Otherwise, the normal conditions for handling
    > > > +incorrect data lenghts apply.
    > > > +
    > > > +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue
    > > > +----------------------------------------------------------------
    > > > +
    > > > +For a legacy driver or for a driver that selected revision 0,
    > > > +CCW_CMD_SET_VQ uses the following communication block:
    > > > +
    > > > +struct vq_info_block_legacy {
    > > > __u64 queue;
    > > > __u32 align;
    > > > __u16 index;
    > > > __u16 num;
    > > > } __attribute__ ((packed));
    > > >
    > > > -queue contains the guest address for queue index. The actual
    > > > -number of allocated buffers is transmitted in num and their
    > > > -alignment in align.
    > > > +queue contains the guest address for queue index, num the number of buffers
    > > > +and align the alignment.
    > > >
    > > > 100.3.3.2.2. Virtqueue Layout
    > > > ------------------------------
    > > > --
    > > > 1.7.9.5
    > >



  • 8.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 05:41
    On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote: > Extend vq_info_block so that the addresses for descriptor table, > available ring and used ring may be transmitted independently. > > Depending upon the selected revision, post a command reject instead > of a channel program check if the driver uses the legacy format > and length checks are suppressed. > > VIRTIO-23 > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> > > --- > > This is an alternate approach, extending the exiting structure instead > of creating a different layout. I'm not 100% sure whether doing a > command reject instead of a channel program check in case of a short > buffer is the right approach, though. Doing a channel program check > would probably cover that error just as well, and we could resolve > VIRTIO-23 independently of VIRTIO-42. > --- > virtio-v1.0-wd01-part1-specification.txt 32 +++++++++++++++++++++++++++--- > 1 file changed, 29 insertions(+), 3 deletions(-) > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt > index ae646db..baff12f 100644 > --- a/virtio-v1.0-wd01-part1-specification.txt > +++ b/virtio-v1.0-wd01-part1-specification.txt > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted > structure is > > struct vq_info_block { > + __u64 desc; > + __u32 res0; > + __u16 index; > + __u16 num; > + __u64 avail; > + __u64 used; > +} __attribute__ ((packed)); > + > +desc, avail and used contain the guest addresses for the descriptor table, > +available ring and used ring for queue index, respectively. The actual > +virtqueue size (number of allocated buffers) is transmitted in num. > +res0 is reserved and must contain 0; otherwise, the device MUST post a > +unit check with command reject. > + > +If the revision selected by the driver is at least 1, the device MUST > +post a unit check with command reject if the transmitted data is between > +16 and 31 bytes if the driver suppressed incorrect length indication > +for the channel command. Otherwise, the normal conditions for handling > +incorrect data lenghts apply. Also I don't understand the following: is there any flexibility for drivers wrt the transmitted data length? Above structure is 32 bytes in size. So any other length is a driver bug. I'm guessing there's any number of other possibly invalid values that drivers can supply in some fields. E.g. stick a wrong PA outside RAM in one of the fields - seems more likely to happen actually. Why worry what happens then? > +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue > +---------------------------------------------------------------- > + > +For a legacy driver or for a driver that selected revision 0, > +CCW_CMD_SET_VQ uses the following communication block: > + > +struct vq_info_block_legacy { > __u64 queue; > __u32 align; > __u16 index; > __u16 num; > } __attribute__ ((packed)); > > -queue contains the guest address for queue index. The actual > -number of allocated buffers is transmitted in num and their > -alignment in align. > +queue contains the guest address for queue index, num the number of buffers > +and align the alignment. > > 100.3.3.2.2. Virtqueue Layout > ------------------------------ > -- > 1.7.9.5


  • 9.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 05:44
    On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote:
    > Extend vq_info_block so that the addresses for descriptor table,
    > available ring and used ring may be transmitted independently.
    >
    > Depending upon the selected revision, post a command reject instead
    > of a channel program check if the driver uses the legacy format
    > and length checks are suppressed.
    >
    > VIRTIO-23
    >
    > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
    >
    > ---
    >
    > This is an alternate approach, extending the exiting structure instead
    > of creating a different layout. I'm not 100% sure whether doing a
    > command reject instead of a channel program check in case of a short
    > buffer is the right approach, though. Doing a channel program check
    > would probably cover that error just as well, and we could resolve
    > VIRTIO-23 independently of VIRTIO-42.
    > ---
    > virtio-v1.0-wd01-part1-specification.txt | 32 +++++++++++++++++++++++++++---
    > 1 file changed, 29 insertions(+), 3 deletions(-)
    >
    > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt
    > index ae646db..baff12f 100644
    > --- a/virtio-v1.0-wd01-part1-specification.txt
    > +++ b/virtio-v1.0-wd01-part1-specification.txt
    > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted
    > structure is
    >
    > struct vq_info_block {
    > + __u64 desc;
    > + __u32 res0;
    > + __u16 index;
    > + __u16 num;
    > + __u64 avail;
    > + __u64 used;
    > +} __attribute__ ((packed));
    > +
    > +desc, avail and used contain the guest addresses for the descriptor table,
    > +available ring and used ring for queue index, respectively. The actual
    > +virtqueue size (number of allocated buffers) is transmitted in num.
    > +res0 is reserved and must contain 0; otherwise, the device MUST post a
    > +unit check with command reject.
    > +
    > +If the revision selected by the driver is at least 1, the device MUST
    > +post a unit check with command reject if the transmitted data is between
    > +16 and 31 bytes if the driver suppressed incorrect length indication
    > +for the channel command. Otherwise, the normal conditions for handling
    > +incorrect data lenghts apply.

    Also I don't understand the following: is there any
    flexibility for drivers wrt the transmitted data length?
    Above structure is 32 bytes in size.
    So any other length is a driver bug.

    I'm guessing there's any
    number of other possibly invalid values that drivers can supply
    in some fields.
    E.g. stick a wrong PA outside RAM in one of the fields - seems
    more likely to happen actually.
    Why worry what happens then?


    > +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue
    > +----------------------------------------------------------------
    > +
    > +For a legacy driver or for a driver that selected revision 0,
    > +CCW_CMD_SET_VQ uses the following communication block:
    > +
    > +struct vq_info_block_legacy {
    > __u64 queue;
    > __u32 align;
    > __u16 index;
    > __u16 num;
    > } __attribute__ ((packed));
    >
    > -queue contains the guest address for queue index. The actual
    > -number of allocated buffers is transmitted in num and their
    > -alignment in align.
    > +queue contains the guest address for queue index, num the number of buffers
    > +and align the alignment.
    >
    > 100.3.3.2.2. Virtqueue Layout
    > ------------------------------
    > --
    > 1.7.9.5



  • 10.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 08:17
    On Thu, 10 Oct 2013 08:43:44 +0300
    "Michael S. Tsirkin" <mst@redhat.com> wrote:

    > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote:
    > > Extend vq_info_block so that the addresses for descriptor table,
    > > available ring and used ring may be transmitted independently.
    > >
    > > Depending upon the selected revision, post a command reject instead
    > > of a channel program check if the driver uses the legacy format
    > > and length checks are suppressed.
    > >
    > > VIRTIO-23
    > >
    > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
    > >
    > > ---
    > >
    > > This is an alternate approach, extending the exiting structure instead
    > > of creating a different layout. I'm not 100% sure whether doing a
    > > command reject instead of a channel program check in case of a short
    > > buffer is the right approach, though. Doing a channel program check
    > > would probably cover that error just as well, and we could resolve
    > > VIRTIO-23 independently of VIRTIO-42.
    > > ---
    > > virtio-v1.0-wd01-part1-specification.txt | 32 +++++++++++++++++++++++++++---
    > > 1 file changed, 29 insertions(+), 3 deletions(-)
    > >
    > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt
    > > index ae646db..baff12f 100644
    > > --- a/virtio-v1.0-wd01-part1-specification.txt
    > > +++ b/virtio-v1.0-wd01-part1-specification.txt
    > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted
    > > structure is
    > >
    > > struct vq_info_block {
    > > + __u64 desc;
    > > + __u32 res0;
    > > + __u16 index;
    > > + __u16 num;
    > > + __u64 avail;
    > > + __u64 used;
    > > +} __attribute__ ((packed));
    > > +
    > > +desc, avail and used contain the guest addresses for the descriptor table,
    > > +available ring and used ring for queue index, respectively. The actual
    > > +virtqueue size (number of allocated buffers) is transmitted in num.
    > > +res0 is reserved and must contain 0; otherwise, the device MUST post a
    > > +unit check with command reject.
    > > +
    > > +If the revision selected by the driver is at least 1, the device MUST
    > > +post a unit check with command reject if the transmitted data is between
    > > +16 and 31 bytes if the driver suppressed incorrect length indication
    > > +for the channel command. Otherwise, the normal conditions for handling
    > > +incorrect data lenghts apply.
    >
    > Also I don't understand the following: is there any
    > flexibility for drivers wrt the transmitted data length?
    > Above structure is 32 bytes in size.
    > So any other length is a driver bug.

    Not really. The driver may transmit a larger buffer then is needed, and
    suppress length checking via a ccw flag. The device can then process
    the data it needs, and disregard the rest. This is used sometimes for
    variable-length responses where a driver can just supply the largest
    possible buffer and check afterwards how much data it got. Depending on
    the command, this may work with short buffers as well.

    (In the virtio-ccw code so far, I required a minimum length and allowed
    a larger length when length checks have been turned off.)

    >
    > I'm guessing there's any
    > number of other possibly invalid values that drivers can supply
    > in some fields.
    > E.g. stick a wrong PA outside RAM in one of the fields - seems
    > more likely to happen actually.
    > Why worry what happens then?

    There are really two different cases there:

    - The driver puts in values that are obviously incorrect, like a reserved
    field that is != 0 - this should be answered with a check, most likely
    a channel program check. (We may want to do this as well if an address
    can be immediately verified to be incorrect; many commands for other
    devices do.)
    - The driver puts in junk that looks valid. The command will succeed,
    problems will happen later.

    >
    >
    > > +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue
    > > +----------------------------------------------------------------
    > > +
    > > +For a legacy driver or for a driver that selected revision 0,
    > > +CCW_CMD_SET_VQ uses the following communication block:
    > > +
    > > +struct vq_info_block_legacy {
    > > __u64 queue;
    > > __u32 align;
    > > __u16 index;
    > > __u16 num;
    > > } __attribute__ ((packed));
    > >
    > > -queue contains the guest address for queue index. The actual
    > > -number of allocated buffers is transmitted in num and their
    > > -alignment in align.
    > > +queue contains the guest address for queue index, num the number of buffers
    > > +and align the alignment.
    > >
    > > 100.3.3.2.2. Virtqueue Layout
    > > ------------------------------
    > > --
    > > 1.7.9.5
    >




  • 11.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 08:17
    On Thu, 10 Oct 2013 08:43:44 +0300 "Michael S. Tsirkin" <mst@redhat.com> wrote: > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote: > > Extend vq_info_block so that the addresses for descriptor table, > > available ring and used ring may be transmitted independently. > > > > Depending upon the selected revision, post a command reject instead > > of a channel program check if the driver uses the legacy format > > and length checks are suppressed. > > > > VIRTIO-23 > > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> > > > > --- > > > > This is an alternate approach, extending the exiting structure instead > > of creating a different layout. I'm not 100% sure whether doing a > > command reject instead of a channel program check in case of a short > > buffer is the right approach, though. Doing a channel program check > > would probably cover that error just as well, and we could resolve > > VIRTIO-23 independently of VIRTIO-42. > > --- > > virtio-v1.0-wd01-part1-specification.txt 32 +++++++++++++++++++++++++++--- > > 1 file changed, 29 insertions(+), 3 deletions(-) > > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt > > index ae646db..baff12f 100644 > > --- a/virtio-v1.0-wd01-part1-specification.txt > > +++ b/virtio-v1.0-wd01-part1-specification.txt > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted > > structure is > > > > struct vq_info_block { > > + __u64 desc; > > + __u32 res0; > > + __u16 index; > > + __u16 num; > > + __u64 avail; > > + __u64 used; > > +} __attribute__ ((packed)); > > + > > +desc, avail and used contain the guest addresses for the descriptor table, > > +available ring and used ring for queue index, respectively. The actual > > +virtqueue size (number of allocated buffers) is transmitted in num. > > +res0 is reserved and must contain 0; otherwise, the device MUST post a > > +unit check with command reject. > > + > > +If the revision selected by the driver is at least 1, the device MUST > > +post a unit check with command reject if the transmitted data is between > > +16 and 31 bytes if the driver suppressed incorrect length indication > > +for the channel command. Otherwise, the normal conditions for handling > > +incorrect data lenghts apply. > > Also I don't understand the following: is there any > flexibility for drivers wrt the transmitted data length? > Above structure is 32 bytes in size. > So any other length is a driver bug. Not really. The driver may transmit a larger buffer then is needed, and suppress length checking via a ccw flag. The device can then process the data it needs, and disregard the rest. This is used sometimes for variable-length responses where a driver can just supply the largest possible buffer and check afterwards how much data it got. Depending on the command, this may work with short buffers as well. (In the virtio-ccw code so far, I required a minimum length and allowed a larger length when length checks have been turned off.) > > I'm guessing there's any > number of other possibly invalid values that drivers can supply > in some fields. > E.g. stick a wrong PA outside RAM in one of the fields - seems > more likely to happen actually. > Why worry what happens then? There are really two different cases there: - The driver puts in values that are obviously incorrect, like a reserved field that is != 0 - this should be answered with a check, most likely a channel program check. (We may want to do this as well if an address can be immediately verified to be incorrect; many commands for other devices do.) - The driver puts in junk that looks valid. The command will succeed, problems will happen later. > > > > +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue > > +---------------------------------------------------------------- > > + > > +For a legacy driver or for a driver that selected revision 0, > > +CCW_CMD_SET_VQ uses the following communication block: > > + > > +struct vq_info_block_legacy { > > __u64 queue; > > __u32 align; > > __u16 index; > > __u16 num; > > } __attribute__ ((packed)); > > > > -queue contains the guest address for queue index. The actual > > -number of allocated buffers is transmitted in num and their > > -alignment in align. > > +queue contains the guest address for queue index, num the number of buffers > > +and align the alignment. > > > > 100.3.3.2.2. Virtqueue Layout > > ------------------------------ > > -- > > 1.7.9.5 >


  • 12.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 08:44
    On Thu, Oct 10, 2013 at 10:16:35AM +0200, Cornelia Huck wrote: > On Thu, 10 Oct 2013 08:43:44 +0300 > "Michael S. Tsirkin" <mst@redhat.com> wrote: > > > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote: > > > Extend vq_info_block so that the addresses for descriptor table, > > > available ring and used ring may be transmitted independently. > > > > > > Depending upon the selected revision, post a command reject instead > > > of a channel program check if the driver uses the legacy format > > > and length checks are suppressed. > > > > > > VIRTIO-23 > > > > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> > > > > > > --- > > > > > > This is an alternate approach, extending the exiting structure instead > > > of creating a different layout. I'm not 100% sure whether doing a > > > command reject instead of a channel program check in case of a short > > > buffer is the right approach, though. Doing a channel program check > > > would probably cover that error just as well, and we could resolve > > > VIRTIO-23 independently of VIRTIO-42. > > > --- > > > virtio-v1.0-wd01-part1-specification.txt 32 +++++++++++++++++++++++++++--- > > > 1 file changed, 29 insertions(+), 3 deletions(-) > > > > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt > > > index ae646db..baff12f 100644 > > > --- a/virtio-v1.0-wd01-part1-specification.txt > > > +++ b/virtio-v1.0-wd01-part1-specification.txt > > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted > > > structure is > > > > > > struct vq_info_block { > > > + __u64 desc; > > > + __u32 res0; > > > + __u16 index; > > > + __u16 num; > > > + __u64 avail; > > > + __u64 used; > > > +} __attribute__ ((packed)); > > > + > > > +desc, avail and used contain the guest addresses for the descriptor table, > > > +available ring and used ring for queue index, respectively. The actual > > > +virtqueue size (number of allocated buffers) is transmitted in num. > > > +res0 is reserved and must contain 0; otherwise, the device MUST post a > > > +unit check with command reject. > > > + > > > +If the revision selected by the driver is at least 1, the device MUST > > > +post a unit check with command reject if the transmitted data is between > > > +16 and 31 bytes if the driver suppressed incorrect length indication > > > +for the channel command. Otherwise, the normal conditions for handling > > > +incorrect data lenghts apply. > > > > Also I don't understand the following: is there any > > flexibility for drivers wrt the transmitted data length? > > Above structure is 32 bytes in size. > > So any other length is a driver bug. > > Not really. The driver may transmit a larger buffer then is needed, and > suppress length checking via a ccw flag. The device can then process > the data it needs, and disregard the rest. This is used sometimes for > variable-length responses where a driver can just supply the largest > possible buffer and check afterwards how much data it got. Depending on > the command, this may work with short buffers as well. > > (In the virtio-ccw code so far, I required a minimum length and allowed > a larger length when length checks have been turned off.) If drivers rely on this, this probably should be documented in the spec. Specifically if I read the spec today it says command legth is X, it seems quite reasonable to just stick assert(length == X) in code, and people will interpret it like this - was saw it with message framing. If you think devices should assept longer lengths, please put a MUST in text saying this. > > > > I'm guessing there's any > > number of other possibly invalid values that drivers can supply > > in some fields. > > E.g. stick a wrong PA outside RAM in one of the fields - seems > > more likely to happen actually. > > Why worry what happens then? > > There are really two different cases there: > > - The driver puts in values that are obviously incorrect, like a reserved > field that is != 0 - this should be answered with a check, most likely > a channel program check. (We may want to do this as well if an address > can be immediately verified to be incorrect; many commands for other > devices do.) > - The driver puts in junk that looks valid. The command will succeed, > problems will happen later. Fine, so let's add text in the CCW section to explain that device can validate commands and suggest good ways to handle broken drivers (e.g. reject). But I don't see why it's a MUST - help debugging broken drivers does not seem to merit more than a MAY. Also in this specific case, it seems to be more trouble than it's worth: sticking specific length requirements in the spec will just add maintainance overhead as we'll have to remember to update it if/when structure changes. finally, the wording looks very strange to me: "if the transmitted data is between 16 and 31 bytes" what if it's less than 16? > > > > > > > +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue > > > +---------------------------------------------------------------- > > > + > > > +For a legacy driver or for a driver that selected revision 0, > > > +CCW_CMD_SET_VQ uses the following communication block: > > > + > > > +struct vq_info_block_legacy { > > > __u64 queue; > > > __u32 align; > > > __u16 index; > > > __u16 num; > > > } __attribute__ ((packed)); > > > > > > -queue contains the guest address for queue index. The actual > > > -number of allocated buffers is transmitted in num and their > > > -alignment in align. > > > +queue contains the guest address for queue index, num the number of buffers > > > +and align the alignment. > > > > > > 100.3.3.2.2. Virtqueue Layout > > > ------------------------------ > > > -- > > > 1.7.9.5 > >


  • 13.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 08:46
    On Thu, Oct 10, 2013 at 10:16:35AM +0200, Cornelia Huck wrote:
    > On Thu, 10 Oct 2013 08:43:44 +0300
    > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    >
    > > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote:
    > > > Extend vq_info_block so that the addresses for descriptor table,
    > > > available ring and used ring may be transmitted independently.
    > > >
    > > > Depending upon the selected revision, post a command reject instead
    > > > of a channel program check if the driver uses the legacy format
    > > > and length checks are suppressed.
    > > >
    > > > VIRTIO-23
    > > >
    > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
    > > >
    > > > ---
    > > >
    > > > This is an alternate approach, extending the exiting structure instead
    > > > of creating a different layout. I'm not 100% sure whether doing a
    > > > command reject instead of a channel program check in case of a short
    > > > buffer is the right approach, though. Doing a channel program check
    > > > would probably cover that error just as well, and we could resolve
    > > > VIRTIO-23 independently of VIRTIO-42.
    > > > ---
    > > > virtio-v1.0-wd01-part1-specification.txt | 32 +++++++++++++++++++++++++++---
    > > > 1 file changed, 29 insertions(+), 3 deletions(-)
    > > >
    > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt
    > > > index ae646db..baff12f 100644
    > > > --- a/virtio-v1.0-wd01-part1-specification.txt
    > > > +++ b/virtio-v1.0-wd01-part1-specification.txt
    > > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted
    > > > structure is
    > > >
    > > > struct vq_info_block {
    > > > + __u64 desc;
    > > > + __u32 res0;
    > > > + __u16 index;
    > > > + __u16 num;
    > > > + __u64 avail;
    > > > + __u64 used;
    > > > +} __attribute__ ((packed));
    > > > +
    > > > +desc, avail and used contain the guest addresses for the descriptor table,
    > > > +available ring and used ring for queue index, respectively. The actual
    > > > +virtqueue size (number of allocated buffers) is transmitted in num.
    > > > +res0 is reserved and must contain 0; otherwise, the device MUST post a
    > > > +unit check with command reject.
    > > > +
    > > > +If the revision selected by the driver is at least 1, the device MUST
    > > > +post a unit check with command reject if the transmitted data is between
    > > > +16 and 31 bytes if the driver suppressed incorrect length indication
    > > > +for the channel command. Otherwise, the normal conditions for handling
    > > > +incorrect data lenghts apply.
    > >
    > > Also I don't understand the following: is there any
    > > flexibility for drivers wrt the transmitted data length?
    > > Above structure is 32 bytes in size.
    > > So any other length is a driver bug.
    >
    > Not really. The driver may transmit a larger buffer then is needed, and
    > suppress length checking via a ccw flag. The device can then process
    > the data it needs, and disregard the rest. This is used sometimes for
    > variable-length responses where a driver can just supply the largest
    > possible buffer and check afterwards how much data it got. Depending on
    > the command, this may work with short buffers as well.
    >
    > (In the virtio-ccw code so far, I required a minimum length and allowed
    > a larger length when length checks have been turned off.)

    If drivers rely on this, this probably should be documented in the spec.
    Specifically if I read the spec today it says command legth is X,
    it seems quite reasonable to just stick
    assert(length == X) in code, and people will interpret it
    like this - was saw it with message framing.

    If you think devices should assept longer lengths,
    please put a MUST in text saying this.


    > >
    > > I'm guessing there's any
    > > number of other possibly invalid values that drivers can supply
    > > in some fields.
    > > E.g. stick a wrong PA outside RAM in one of the fields - seems
    > > more likely to happen actually.
    > > Why worry what happens then?
    >
    > There are really two different cases there:
    >
    > - The driver puts in values that are obviously incorrect, like a reserved
    > field that is != 0 - this should be answered with a check, most likely
    > a channel program check. (We may want to do this as well if an address
    > can be immediately verified to be incorrect; many commands for other
    > devices do.)
    > - The driver puts in junk that looks valid. The command will succeed,
    > problems will happen later.

    Fine, so let's add text in the CCW section to
    explain that device can validate commands and suggest
    good ways to handle broken drivers (e.g. reject).
    But I don't see why it's a MUST - help debugging broken drivers
    does not seem to merit more than a MAY.
    Also in this specific case, it seems to be more
    trouble than it's worth:
    sticking specific length requirements in the spec will
    just add maintainance overhead as we'll
    have to remember to update it if/when structure changes.
    finally, the wording looks very strange to me:
    "if the transmitted data is between 16 and 31 bytes"
    what if it's less than 16?

    > >
    > >
    > > > +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue
    > > > +----------------------------------------------------------------
    > > > +
    > > > +For a legacy driver or for a driver that selected revision 0,
    > > > +CCW_CMD_SET_VQ uses the following communication block:
    > > > +
    > > > +struct vq_info_block_legacy {
    > > > __u64 queue;
    > > > __u32 align;
    > > > __u16 index;
    > > > __u16 num;
    > > > } __attribute__ ((packed));
    > > >
    > > > -queue contains the guest address for queue index. The actual
    > > > -number of allocated buffers is transmitted in num and their
    > > > -alignment in align.
    > > > +queue contains the guest address for queue index, num the number of buffers
    > > > +and align the alignment.
    > > >
    > > > 100.3.3.2.2. Virtqueue Layout
    > > > ------------------------------
    > > > --
    > > > 1.7.9.5
    > >



  • 14.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 09:05
    On Thu, 10 Oct 2013 11:46:05 +0300
    "Michael S. Tsirkin" <mst@redhat.com> wrote:

    > On Thu, Oct 10, 2013 at 10:16:35AM +0200, Cornelia Huck wrote:
    > > On Thu, 10 Oct 2013 08:43:44 +0300
    > > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    > >
    > > > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote:
    > > > > Extend vq_info_block so that the addresses for descriptor table,
    > > > > available ring and used ring may be transmitted independently.
    > > > >
    > > > > Depending upon the selected revision, post a command reject instead
    > > > > of a channel program check if the driver uses the legacy format
    > > > > and length checks are suppressed.
    > > > >
    > > > > VIRTIO-23
    > > > >
    > > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
    > > > >
    > > > > ---
    > > > >
    > > > > This is an alternate approach, extending the exiting structure instead
    > > > > of creating a different layout. I'm not 100% sure whether doing a
    > > > > command reject instead of a channel program check in case of a short
    > > > > buffer is the right approach, though. Doing a channel program check
    > > > > would probably cover that error just as well, and we could resolve
    > > > > VIRTIO-23 independently of VIRTIO-42.
    > > > > ---
    > > > > virtio-v1.0-wd01-part1-specification.txt | 32 +++++++++++++++++++++++++++---
    > > > > 1 file changed, 29 insertions(+), 3 deletions(-)
    > > > >
    > > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt
    > > > > index ae646db..baff12f 100644
    > > > > --- a/virtio-v1.0-wd01-part1-specification.txt
    > > > > +++ b/virtio-v1.0-wd01-part1-specification.txt
    > > > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted
    > > > > structure is
    > > > >
    > > > > struct vq_info_block {
    > > > > + __u64 desc;
    > > > > + __u32 res0;
    > > > > + __u16 index;
    > > > > + __u16 num;
    > > > > + __u64 avail;
    > > > > + __u64 used;
    > > > > +} __attribute__ ((packed));
    > > > > +
    > > > > +desc, avail and used contain the guest addresses for the descriptor table,
    > > > > +available ring and used ring for queue index, respectively. The actual
    > > > > +virtqueue size (number of allocated buffers) is transmitted in num.
    > > > > +res0 is reserved and must contain 0; otherwise, the device MUST post a
    > > > > +unit check with command reject.
    > > > > +
    > > > > +If the revision selected by the driver is at least 1, the device MUST
    > > > > +post a unit check with command reject if the transmitted data is between
    > > > > +16 and 31 bytes if the driver suppressed incorrect length indication
    > > > > +for the channel command. Otherwise, the normal conditions for handling
    > > > > +incorrect data lenghts apply.
    > > >
    > > > Also I don't understand the following: is there any
    > > > flexibility for drivers wrt the transmitted data length?
    > > > Above structure is 32 bytes in size.
    > > > So any other length is a driver bug.
    > >
    > > Not really. The driver may transmit a larger buffer then is needed, and
    > > suppress length checking via a ccw flag. The device can then process
    > > the data it needs, and disregard the rest. This is used sometimes for
    > > variable-length responses where a driver can just supply the largest
    > > possible buffer and check afterwards how much data it got. Depending on
    > > the command, this may work with short buffers as well.
    > >
    > > (In the virtio-ccw code so far, I required a minimum length and allowed
    > > a larger length when length checks have been turned off.)
    >
    > If drivers rely on this, this probably should be documented in the spec.
    > Specifically if I read the spec today it says command legth is X,
    > it seems quite reasonable to just stick
    > assert(length == X) in code, and people will interpret it
    > like this - was saw it with message framing.
    >
    > If you think devices should assept longer lengths,
    > please put a MUST in text saying this.

    I don't think this should be a MUST; but a SHOULD would be reasonable.

    I can put in language as well that drivers SHOULD specify the correct
    length; the virtio-ccw commands do not lend themselves to the scenario
    I described above, and suppressing a length check would be more of a
    crutch for not-so-good drivers.

    >
    >
    > > >
    > > > I'm guessing there's any
    > > > number of other possibly invalid values that drivers can supply
    > > > in some fields.
    > > > E.g. stick a wrong PA outside RAM in one of the fields - seems
    > > > more likely to happen actually.
    > > > Why worry what happens then?
    > >
    > > There are really two different cases there:
    > >
    > > - The driver puts in values that are obviously incorrect, like a reserved
    > > field that is != 0 - this should be answered with a check, most likely
    > > a channel program check. (We may want to do this as well if an address
    > > can be immediately verified to be incorrect; many commands for other
    > > devices do.)
    > > - The driver puts in junk that looks valid. The command will succeed,
    > > problems will happen later.
    >
    > Fine, so let's add text in the CCW section to
    > explain that device can validate commands and suggest
    > good ways to handle broken drivers (e.g. reject).

    I'd probably need to the s390 architecture there; it's all in there :)

    > But I don't see why it's a MUST - help debugging broken drivers
    > does not seem to merit more than a MAY.

    It's not really a case of "help debugging broken drivers". If I were
    writing a real s390 attachment specification, I'd be expected to write
    down what the device _does_ in case of checking. I'd really like to put
    down what we do as a MUST where it makes sense, so driver authors know
    what they can rely on.

    > Also in this specific case, it seems to be more
    > trouble than it's worth:
    > sticking specific length requirements in the spec will
    > just add maintainance overhead as we'll
    > have to remember to update it if/when structure changes.
    > finally, the wording looks very strange to me:
    > "if the transmitted data is between 16 and 31 bytes"
    > what if it's less than 16?

    I'm more and more inclinded to just drop the command reject in that
    case and use the normal channel program check instead.

    >
    > > >
    > > >
    > > > > +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue
    > > > > +----------------------------------------------------------------
    > > > > +
    > > > > +For a legacy driver or for a driver that selected revision 0,
    > > > > +CCW_CMD_SET_VQ uses the following communication block:
    > > > > +
    > > > > +struct vq_info_block_legacy {
    > > > > __u64 queue;
    > > > > __u32 align;
    > > > > __u16 index;
    > > > > __u16 num;
    > > > > } __attribute__ ((packed));
    > > > >
    > > > > -queue contains the guest address for queue index. The actual
    > > > > -number of allocated buffers is transmitted in num and their
    > > > > -alignment in align.
    > > > > +queue contains the guest address for queue index, num the number of buffers
    > > > > +and align the alignment.
    > > > >
    > > > > 100.3.3.2.2. Virtqueue Layout
    > > > > ------------------------------
    > > > > --
    > > > > 1.7.9.5
    > > >
    >




  • 15.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 09:05
    On Thu, 10 Oct 2013 11:46:05 +0300 "Michael S. Tsirkin" <mst@redhat.com> wrote: > On Thu, Oct 10, 2013 at 10:16:35AM +0200, Cornelia Huck wrote: > > On Thu, 10 Oct 2013 08:43:44 +0300 > > "Michael S. Tsirkin" <mst@redhat.com> wrote: > > > > > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote: > > > > Extend vq_info_block so that the addresses for descriptor table, > > > > available ring and used ring may be transmitted independently. > > > > > > > > Depending upon the selected revision, post a command reject instead > > > > of a channel program check if the driver uses the legacy format > > > > and length checks are suppressed. > > > > > > > > VIRTIO-23 > > > > > > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> > > > > > > > > --- > > > > > > > > This is an alternate approach, extending the exiting structure instead > > > > of creating a different layout. I'm not 100% sure whether doing a > > > > command reject instead of a channel program check in case of a short > > > > buffer is the right approach, though. Doing a channel program check > > > > would probably cover that error just as well, and we could resolve > > > > VIRTIO-23 independently of VIRTIO-42. > > > > --- > > > > virtio-v1.0-wd01-part1-specification.txt 32 +++++++++++++++++++++++++++--- > > > > 1 file changed, 29 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt > > > > index ae646db..baff12f 100644 > > > > --- a/virtio-v1.0-wd01-part1-specification.txt > > > > +++ b/virtio-v1.0-wd01-part1-specification.txt > > > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted > > > > structure is > > > > > > > > struct vq_info_block { > > > > + __u64 desc; > > > > + __u32 res0; > > > > + __u16 index; > > > > + __u16 num; > > > > + __u64 avail; > > > > + __u64 used; > > > > +} __attribute__ ((packed)); > > > > + > > > > +desc, avail and used contain the guest addresses for the descriptor table, > > > > +available ring and used ring for queue index, respectively. The actual > > > > +virtqueue size (number of allocated buffers) is transmitted in num. > > > > +res0 is reserved and must contain 0; otherwise, the device MUST post a > > > > +unit check with command reject. > > > > + > > > > +If the revision selected by the driver is at least 1, the device MUST > > > > +post a unit check with command reject if the transmitted data is between > > > > +16 and 31 bytes if the driver suppressed incorrect length indication > > > > +for the channel command. Otherwise, the normal conditions for handling > > > > +incorrect data lenghts apply. > > > > > > Also I don't understand the following: is there any > > > flexibility for drivers wrt the transmitted data length? > > > Above structure is 32 bytes in size. > > > So any other length is a driver bug. > > > > Not really. The driver may transmit a larger buffer then is needed, and > > suppress length checking via a ccw flag. The device can then process > > the data it needs, and disregard the rest. This is used sometimes for > > variable-length responses where a driver can just supply the largest > > possible buffer and check afterwards how much data it got. Depending on > > the command, this may work with short buffers as well. > > > > (In the virtio-ccw code so far, I required a minimum length and allowed > > a larger length when length checks have been turned off.) > > If drivers rely on this, this probably should be documented in the spec. > Specifically if I read the spec today it says command legth is X, > it seems quite reasonable to just stick > assert(length == X) in code, and people will interpret it > like this - was saw it with message framing. > > If you think devices should assept longer lengths, > please put a MUST in text saying this. I don't think this should be a MUST; but a SHOULD would be reasonable. I can put in language as well that drivers SHOULD specify the correct length; the virtio-ccw commands do not lend themselves to the scenario I described above, and suppressing a length check would be more of a crutch for not-so-good drivers. > > > > > > > > I'm guessing there's any > > > number of other possibly invalid values that drivers can supply > > > in some fields. > > > E.g. stick a wrong PA outside RAM in one of the fields - seems > > > more likely to happen actually. > > > Why worry what happens then? > > > > There are really two different cases there: > > > > - The driver puts in values that are obviously incorrect, like a reserved > > field that is != 0 - this should be answered with a check, most likely > > a channel program check. (We may want to do this as well if an address > > can be immediately verified to be incorrect; many commands for other > > devices do.) > > - The driver puts in junk that looks valid. The command will succeed, > > problems will happen later. > > Fine, so let's add text in the CCW section to > explain that device can validate commands and suggest > good ways to handle broken drivers (e.g. reject). I'd probably need to the s390 architecture there; it's all in there :) > But I don't see why it's a MUST - help debugging broken drivers > does not seem to merit more than a MAY. It's not really a case of "help debugging broken drivers". If I were writing a real s390 attachment specification, I'd be expected to write down what the device _does_ in case of checking. I'd really like to put down what we do as a MUST where it makes sense, so driver authors know what they can rely on. > Also in this specific case, it seems to be more > trouble than it's worth: > sticking specific length requirements in the spec will > just add maintainance overhead as we'll > have to remember to update it if/when structure changes. > finally, the wording looks very strange to me: > "if the transmitted data is between 16 and 31 bytes" > what if it's less than 16? I'm more and more inclinded to just drop the command reject in that case and use the normal channel program check instead. > > > > > > > > > > > +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue > > > > +---------------------------------------------------------------- > > > > + > > > > +For a legacy driver or for a driver that selected revision 0, > > > > +CCW_CMD_SET_VQ uses the following communication block: > > > > + > > > > +struct vq_info_block_legacy { > > > > __u64 queue; > > > > __u32 align; > > > > __u16 index; > > > > __u16 num; > > > > } __attribute__ ((packed)); > > > > > > > > -queue contains the guest address for queue index. The actual > > > > -number of allocated buffers is transmitted in num and their > > > > -alignment in align. > > > > +queue contains the guest address for queue index, num the number of buffers > > > > +and align the alignment. > > > > > > > > 100.3.3.2.2. Virtqueue Layout > > > > ------------------------------ > > > > -- > > > > 1.7.9.5 > > > >


  • 16.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 09:28
    On Thu, Oct 10, 2013 at 11:04:39AM +0200, Cornelia Huck wrote: > On Thu, 10 Oct 2013 11:46:05 +0300 > "Michael S. Tsirkin" <mst@redhat.com> wrote: > > > On Thu, Oct 10, 2013 at 10:16:35AM +0200, Cornelia Huck wrote: > > > On Thu, 10 Oct 2013 08:43:44 +0300 > > > "Michael S. Tsirkin" <mst@redhat.com> wrote: > > > > > > > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote: > > > > > Extend vq_info_block so that the addresses for descriptor table, > > > > > available ring and used ring may be transmitted independently. > > > > > > > > > > Depending upon the selected revision, post a command reject instead > > > > > of a channel program check if the driver uses the legacy format > > > > > and length checks are suppressed. > > > > > > > > > > VIRTIO-23 > > > > > > > > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> > > > > > > > > > > --- > > > > > > > > > > This is an alternate approach, extending the exiting structure instead > > > > > of creating a different layout. I'm not 100% sure whether doing a > > > > > command reject instead of a channel program check in case of a short > > > > > buffer is the right approach, though. Doing a channel program check > > > > > would probably cover that error just as well, and we could resolve > > > > > VIRTIO-23 independently of VIRTIO-42. > > > > > --- > > > > > virtio-v1.0-wd01-part1-specification.txt 32 +++++++++++++++++++++++++++--- > > > > > 1 file changed, 29 insertions(+), 3 deletions(-) > > > > > > > > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt > > > > > index ae646db..baff12f 100644 > > > > > --- a/virtio-v1.0-wd01-part1-specification.txt > > > > > +++ b/virtio-v1.0-wd01-part1-specification.txt > > > > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted > > > > > structure is > > > > > > > > > > struct vq_info_block { > > > > > + __u64 desc; > > > > > + __u32 res0; > > > > > + __u16 index; > > > > > + __u16 num; > > > > > + __u64 avail; > > > > > + __u64 used; > > > > > +} __attribute__ ((packed)); > > > > > + > > > > > +desc, avail and used contain the guest addresses for the descriptor table, > > > > > +available ring and used ring for queue index, respectively. The actual > > > > > +virtqueue size (number of allocated buffers) is transmitted in num. > > > > > +res0 is reserved and must contain 0; otherwise, the device MUST post a > > > > > +unit check with command reject. > > > > > + > > > > > +If the revision selected by the driver is at least 1, the device MUST > > > > > +post a unit check with command reject if the transmitted data is between > > > > > +16 and 31 bytes if the driver suppressed incorrect length indication > > > > > +for the channel command. Otherwise, the normal conditions for handling > > > > > +incorrect data lenghts apply. > > > > > > > > Also I don't understand the following: is there any > > > > flexibility for drivers wrt the transmitted data length? > > > > Above structure is 32 bytes in size. > > > > So any other length is a driver bug. > > > > > > Not really. The driver may transmit a larger buffer then is needed, and > > > suppress length checking via a ccw flag. The device can then process > > > the data it needs, and disregard the rest. This is used sometimes for > > > variable-length responses where a driver can just supply the largest > > > possible buffer and check afterwards how much data it got. Depending on > > > the command, this may work with short buffers as well. > > > > > > (In the virtio-ccw code so far, I required a minimum length and allowed > > > a larger length when length checks have been turned off.) > > > > If drivers rely on this, this probably should be documented in the spec. > > Specifically if I read the spec today it says command legth is X, > > it seems quite reasonable to just stick > > assert(length == X) in code, and people will interpret it > > like this - was saw it with message framing. > > > > If you think devices should assept longer lengths, > > please put a MUST in text saying this. > > I don't think this should be a MUST; but a SHOULD would be reasonable. > > I can put in language as well that drivers SHOULD specify the correct > length; the virtio-ccw commands do not lend themselves to the scenario > I described above, and suppressing a length check would be more of a > crutch for not-so-good drivers. Hmm if it's not a MUST then drivers can't rely on it. So why is it useful? I guess I'm kind of confused as to why this is useful - on the one hand you prefer failing on easy to handle errors such as reserved field != 0 (device could simply ignore it). I kind of see the point - this makes sure drivers initialize everything. On the other hand you want this flexibility to pass large lengths. I thought the point is to make drivers simpler: they can always use large length and not worry that device will be confused. But if it's a SHOULD then drivers can't rely on it being there, so I guess that's not the prupose? > > > > > > > > > > > > I'm guessing there's any > > > > number of other possibly invalid values that drivers can supply > > > > in some fields. > > > > E.g. stick a wrong PA outside RAM in one of the fields - seems > > > > more likely to happen actually. > > > > Why worry what happens then? > > > > > > There are really two different cases there: > > > > > > - The driver puts in values that are obviously incorrect, like a reserved > > > field that is != 0 - this should be answered with a check, most likely > > > a channel program check. (We may want to do this as well if an address > > > can be immediately verified to be incorrect; many commands for other > > > devices do.) > > > - The driver puts in junk that looks valid. The command will succeed, > > > problems will happen later. > > > > Fine, so let's add text in the CCW section to > > explain that device can validate commands and suggest > > good ways to handle broken drivers (e.g. reject). > > I'd probably need to the s390 architecture there; it's all in there :) > > > But I don't see why it's a MUST - help debugging broken drivers > > does not seem to merit more than a MAY. > > It's not really a case of "help debugging broken drivers". If I were > writing a real s390 attachment specification, I'd be expected to write > down what the device _does_ in case of checking. I'd really like to put > down what we do as a MUST where it makes sense, so driver authors know > what they can rely on. > > > Also in this specific case, it seems to be more > > trouble than it's worth: > > sticking specific length requirements in the spec will > > just add maintainance overhead as we'll > > have to remember to update it if/when structure changes. > > finally, the wording looks very strange to me: > > "if the transmitted data is between 16 and 31 bytes" > > what if it's less than 16? > > I'm more and more inclinded to just drop the command reject in that > case and use the normal channel program check instead. > > > > > > > > > > > > > > > > +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue > > > > > +---------------------------------------------------------------- > > > > > + > > > > > +For a legacy driver or for a driver that selected revision 0, > > > > > +CCW_CMD_SET_VQ uses the following communication block: > > > > > + > > > > > +struct vq_info_block_legacy { > > > > > __u64 queue; > > > > > __u32 align; > > > > > __u16 index; > > > > > __u16 num; > > > > > } __attribute__ ((packed)); > > > > > > > > > > -queue contains the guest address for queue index. The actual > > > > > -number of allocated buffers is transmitted in num and their > > > > > -alignment in align. > > > > > +queue contains the guest address for queue index, num the number of buffers > > > > > +and align the alignment. > > > > > > > > > > 100.3.3.2.2. Virtqueue Layout > > > > > ------------------------------ > > > > > -- > > > > > 1.7.9.5 > > > > > >


  • 17.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 09:30
    On Thu, Oct 10, 2013 at 11:04:39AM +0200, Cornelia Huck wrote:
    > On Thu, 10 Oct 2013 11:46:05 +0300
    > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    >
    > > On Thu, Oct 10, 2013 at 10:16:35AM +0200, Cornelia Huck wrote:
    > > > On Thu, 10 Oct 2013 08:43:44 +0300
    > > > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    > > >
    > > > > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote:
    > > > > > Extend vq_info_block so that the addresses for descriptor table,
    > > > > > available ring and used ring may be transmitted independently.
    > > > > >
    > > > > > Depending upon the selected revision, post a command reject instead
    > > > > > of a channel program check if the driver uses the legacy format
    > > > > > and length checks are suppressed.
    > > > > >
    > > > > > VIRTIO-23
    > > > > >
    > > > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
    > > > > >
    > > > > > ---
    > > > > >
    > > > > > This is an alternate approach, extending the exiting structure instead
    > > > > > of creating a different layout. I'm not 100% sure whether doing a
    > > > > > command reject instead of a channel program check in case of a short
    > > > > > buffer is the right approach, though. Doing a channel program check
    > > > > > would probably cover that error just as well, and we could resolve
    > > > > > VIRTIO-23 independently of VIRTIO-42.
    > > > > > ---
    > > > > > virtio-v1.0-wd01-part1-specification.txt | 32 +++++++++++++++++++++++++++---
    > > > > > 1 file changed, 29 insertions(+), 3 deletions(-)
    > > > > >
    > > > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt
    > > > > > index ae646db..baff12f 100644
    > > > > > --- a/virtio-v1.0-wd01-part1-specification.txt
    > > > > > +++ b/virtio-v1.0-wd01-part1-specification.txt
    > > > > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted
    > > > > > structure is
    > > > > >
    > > > > > struct vq_info_block {
    > > > > > + __u64 desc;
    > > > > > + __u32 res0;
    > > > > > + __u16 index;
    > > > > > + __u16 num;
    > > > > > + __u64 avail;
    > > > > > + __u64 used;
    > > > > > +} __attribute__ ((packed));
    > > > > > +
    > > > > > +desc, avail and used contain the guest addresses for the descriptor table,
    > > > > > +available ring and used ring for queue index, respectively. The actual
    > > > > > +virtqueue size (number of allocated buffers) is transmitted in num.
    > > > > > +res0 is reserved and must contain 0; otherwise, the device MUST post a
    > > > > > +unit check with command reject.
    > > > > > +
    > > > > > +If the revision selected by the driver is at least 1, the device MUST
    > > > > > +post a unit check with command reject if the transmitted data is between
    > > > > > +16 and 31 bytes if the driver suppressed incorrect length indication
    > > > > > +for the channel command. Otherwise, the normal conditions for handling
    > > > > > +incorrect data lenghts apply.
    > > > >
    > > > > Also I don't understand the following: is there any
    > > > > flexibility for drivers wrt the transmitted data length?
    > > > > Above structure is 32 bytes in size.
    > > > > So any other length is a driver bug.
    > > >
    > > > Not really. The driver may transmit a larger buffer then is needed, and
    > > > suppress length checking via a ccw flag. The device can then process
    > > > the data it needs, and disregard the rest. This is used sometimes for
    > > > variable-length responses where a driver can just supply the largest
    > > > possible buffer and check afterwards how much data it got. Depending on
    > > > the command, this may work with short buffers as well.
    > > >
    > > > (In the virtio-ccw code so far, I required a minimum length and allowed
    > > > a larger length when length checks have been turned off.)
    > >
    > > If drivers rely on this, this probably should be documented in the spec.
    > > Specifically if I read the spec today it says command legth is X,
    > > it seems quite reasonable to just stick
    > > assert(length == X) in code, and people will interpret it
    > > like this - was saw it with message framing.
    > >
    > > If you think devices should assept longer lengths,
    > > please put a MUST in text saying this.
    >
    > I don't think this should be a MUST; but a SHOULD would be reasonable.
    >
    > I can put in language as well that drivers SHOULD specify the correct
    > length; the virtio-ccw commands do not lend themselves to the scenario
    > I described above, and suppressing a length check would be more of a
    > crutch for not-so-good drivers.

    Hmm if it's not a MUST then drivers can't rely on it.
    So why is it useful?

    I guess I'm kind of confused as to why this is useful - on the one hand
    you prefer failing on easy to handle errors such as reserved field
    != 0 (device could simply ignore it).
    I kind of see the point - this makes sure drivers initialize everything.
    On the other hand you want this flexibility to pass large
    lengths. I thought the point is to make drivers simpler:
    they can always use large length and not worry that device
    will be confused. But if it's a SHOULD then drivers can't rely
    on it being there, so I guess that's not the prupose?

    > >
    > >
    > > > >
    > > > > I'm guessing there's any
    > > > > number of other possibly invalid values that drivers can supply
    > > > > in some fields.
    > > > > E.g. stick a wrong PA outside RAM in one of the fields - seems
    > > > > more likely to happen actually.
    > > > > Why worry what happens then?
    > > >
    > > > There are really two different cases there:
    > > >
    > > > - The driver puts in values that are obviously incorrect, like a reserved
    > > > field that is != 0 - this should be answered with a check, most likely
    > > > a channel program check. (We may want to do this as well if an address
    > > > can be immediately verified to be incorrect; many commands for other
    > > > devices do.)
    > > > - The driver puts in junk that looks valid. The command will succeed,
    > > > problems will happen later.
    > >
    > > Fine, so let's add text in the CCW section to
    > > explain that device can validate commands and suggest
    > > good ways to handle broken drivers (e.g. reject).
    >
    > I'd probably need to the s390 architecture there; it's all in there :)
    >
    > > But I don't see why it's a MUST - help debugging broken drivers
    > > does not seem to merit more than a MAY.
    >
    > It's not really a case of "help debugging broken drivers". If I were
    > writing a real s390 attachment specification, I'd be expected to write
    > down what the device _does_ in case of checking. I'd really like to put
    > down what we do as a MUST where it makes sense, so driver authors know
    > what they can rely on.
    >
    > > Also in this specific case, it seems to be more
    > > trouble than it's worth:
    > > sticking specific length requirements in the spec will
    > > just add maintainance overhead as we'll
    > > have to remember to update it if/when structure changes.
    > > finally, the wording looks very strange to me:
    > > "if the transmitted data is between 16 and 31 bytes"
    > > what if it's less than 16?
    >
    > I'm more and more inclinded to just drop the command reject in that
    > case and use the normal channel program check instead.
    >
    > >
    > > > >
    > > > >
    > > > > > +2.3.3.2.2.1. Legacy Interface: A Note on Configuring a Virtqueue
    > > > > > +----------------------------------------------------------------
    > > > > > +
    > > > > > +For a legacy driver or for a driver that selected revision 0,
    > > > > > +CCW_CMD_SET_VQ uses the following communication block:
    > > > > > +
    > > > > > +struct vq_info_block_legacy {
    > > > > > __u64 queue;
    > > > > > __u32 align;
    > > > > > __u16 index;
    > > > > > __u16 num;
    > > > > > } __attribute__ ((packed));
    > > > > >
    > > > > > -queue contains the guest address for queue index. The actual
    > > > > > -number of allocated buffers is transmitted in num and their
    > > > > > -alignment in align.
    > > > > > +queue contains the guest address for queue index, num the number of buffers
    > > > > > +and align the alignment.
    > > > > >
    > > > > > 100.3.3.2.2. Virtqueue Layout
    > > > > > ------------------------------
    > > > > > --
    > > > > > 1.7.9.5
    > > > >
    > >



  • 18.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 10:57
    On Thu, 10 Oct 2013 12:29:59 +0300
    "Michael S. Tsirkin" <mst@redhat.com> wrote:

    > On Thu, Oct 10, 2013 at 11:04:39AM +0200, Cornelia Huck wrote:
    > > On Thu, 10 Oct 2013 11:46:05 +0300
    > > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    > >
    > > > On Thu, Oct 10, 2013 at 10:16:35AM +0200, Cornelia Huck wrote:
    > > > > On Thu, 10 Oct 2013 08:43:44 +0300
    > > > > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    > > > >
    > > > > > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote:
    > > > > > > Extend vq_info_block so that the addresses for descriptor table,
    > > > > > > available ring and used ring may be transmitted independently.
    > > > > > >
    > > > > > > Depending upon the selected revision, post a command reject instead
    > > > > > > of a channel program check if the driver uses the legacy format
    > > > > > > and length checks are suppressed.
    > > > > > >
    > > > > > > VIRTIO-23
    > > > > > >
    > > > > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
    > > > > > >
    > > > > > > ---
    > > > > > >
    > > > > > > This is an alternate approach, extending the exiting structure instead
    > > > > > > of creating a different layout. I'm not 100% sure whether doing a
    > > > > > > command reject instead of a channel program check in case of a short
    > > > > > > buffer is the right approach, though. Doing a channel program check
    > > > > > > would probably cover that error just as well, and we could resolve
    > > > > > > VIRTIO-23 independently of VIRTIO-42.
    > > > > > > ---
    > > > > > > virtio-v1.0-wd01-part1-specification.txt | 32 +++++++++++++++++++++++++++---
    > > > > > > 1 file changed, 29 insertions(+), 3 deletions(-)
    > > > > > >
    > > > > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt
    > > > > > > index ae646db..baff12f 100644
    > > > > > > --- a/virtio-v1.0-wd01-part1-specification.txt
    > > > > > > +++ b/virtio-v1.0-wd01-part1-specification.txt
    > > > > > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted
    > > > > > > structure is
    > > > > > >
    > > > > > > struct vq_info_block {
    > > > > > > + __u64 desc;
    > > > > > > + __u32 res0;
    > > > > > > + __u16 index;
    > > > > > > + __u16 num;
    > > > > > > + __u64 avail;
    > > > > > > + __u64 used;
    > > > > > > +} __attribute__ ((packed));
    > > > > > > +
    > > > > > > +desc, avail and used contain the guest addresses for the descriptor table,
    > > > > > > +available ring and used ring for queue index, respectively. The actual
    > > > > > > +virtqueue size (number of allocated buffers) is transmitted in num.
    > > > > > > +res0 is reserved and must contain 0; otherwise, the device MUST post a
    > > > > > > +unit check with command reject.
    > > > > > > +
    > > > > > > +If the revision selected by the driver is at least 1, the device MUST
    > > > > > > +post a unit check with command reject if the transmitted data is between
    > > > > > > +16 and 31 bytes if the driver suppressed incorrect length indication
    > > > > > > +for the channel command. Otherwise, the normal conditions for handling
    > > > > > > +incorrect data lenghts apply.
    > > > > >
    > > > > > Also I don't understand the following: is there any
    > > > > > flexibility for drivers wrt the transmitted data length?
    > > > > > Above structure is 32 bytes in size.
    > > > > > So any other length is a driver bug.
    > > > >
    > > > > Not really. The driver may transmit a larger buffer then is needed, and
    > > > > suppress length checking via a ccw flag. The device can then process
    > > > > the data it needs, and disregard the rest. This is used sometimes for
    > > > > variable-length responses where a driver can just supply the largest
    > > > > possible buffer and check afterwards how much data it got. Depending on
    > > > > the command, this may work with short buffers as well.
    > > > >
    > > > > (In the virtio-ccw code so far, I required a minimum length and allowed
    > > > > a larger length when length checks have been turned off.)
    > > >
    > > > If drivers rely on this, this probably should be documented in the spec.
    > > > Specifically if I read the spec today it says command legth is X,
    > > > it seems quite reasonable to just stick
    > > > assert(length == X) in code, and people will interpret it
    > > > like this - was saw it with message framing.
    > > >
    > > > If you think devices should assept longer lengths,
    > > > please put a MUST in text saying this.
    > >
    > > I don't think this should be a MUST; but a SHOULD would be reasonable.
    > >
    > > I can put in language as well that drivers SHOULD specify the correct
    > > length; the virtio-ccw commands do not lend themselves to the scenario
    > > I described above, and suppressing a length check would be more of a
    > > crutch for not-so-good drivers.
    >
    > Hmm if it's not a MUST then drivers can't rely on it.
    > So why is it useful?

    It obviously must be either two MUSTs or two SHOULDs. It probably
    should not be MUST, as I don't remember another device failing on a too
    large buffer. SHOULD is more like a 'best practice' to me.

    Remember that an incorrect length without length check disabled will
    always yield a check; this is mandated by the architecture.

    >
    > I guess I'm kind of confused as to why this is useful - on the one hand
    > you prefer failing on easy to handle errors such as reserved field
    > != 0 (device could simply ignore it).

    Well, we _can_ ignore it, if we specify it that way :) A
    reserved/ignored or reserved/must be zero field are both fine for this
    case.

    > I kind of see the point - this makes sure drivers initialize everything.
    > On the other hand you want this flexibility to pass large
    > lengths. I thought the point is to make drivers simpler:
    > they can always use large length and not worry that device
    > will be confused. But if it's a SHOULD then drivers can't rely
    > on it being there, so I guess that's not the prupose?

    No, the purpose is not to be too different from other devices
    implementing channel architecture. A driver will usually only suppress
    length checking in special cases (like the variable data length case);
    the normal mode of operation is to specify the correct length and leave
    the length check on.




  • 19.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 10:57
    On Thu, 10 Oct 2013 12:29:59 +0300 "Michael S. Tsirkin" <mst@redhat.com> wrote: > On Thu, Oct 10, 2013 at 11:04:39AM +0200, Cornelia Huck wrote: > > On Thu, 10 Oct 2013 11:46:05 +0300 > > "Michael S. Tsirkin" <mst@redhat.com> wrote: > > > > > On Thu, Oct 10, 2013 at 10:16:35AM +0200, Cornelia Huck wrote: > > > > On Thu, 10 Oct 2013 08:43:44 +0300 > > > > "Michael S. Tsirkin" <mst@redhat.com> wrote: > > > > > > > > > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote: > > > > > > Extend vq_info_block so that the addresses for descriptor table, > > > > > > available ring and used ring may be transmitted independently. > > > > > > > > > > > > Depending upon the selected revision, post a command reject instead > > > > > > of a channel program check if the driver uses the legacy format > > > > > > and length checks are suppressed. > > > > > > > > > > > > VIRTIO-23 > > > > > > > > > > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> > > > > > > > > > > > > --- > > > > > > > > > > > > This is an alternate approach, extending the exiting structure instead > > > > > > of creating a different layout. I'm not 100% sure whether doing a > > > > > > command reject instead of a channel program check in case of a short > > > > > > buffer is the right approach, though. Doing a channel program check > > > > > > would probably cover that error just as well, and we could resolve > > > > > > VIRTIO-23 independently of VIRTIO-42. > > > > > > --- > > > > > > virtio-v1.0-wd01-part1-specification.txt 32 +++++++++++++++++++++++++++--- > > > > > > 1 file changed, 29 insertions(+), 3 deletions(-) > > > > > > > > > > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt > > > > > > index ae646db..baff12f 100644 > > > > > > --- a/virtio-v1.0-wd01-part1-specification.txt > > > > > > +++ b/virtio-v1.0-wd01-part1-specification.txt > > > > > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted > > > > > > structure is > > > > > > > > > > > > struct vq_info_block { > > > > > > + __u64 desc; > > > > > > + __u32 res0; > > > > > > + __u16 index; > > > > > > + __u16 num; > > > > > > + __u64 avail; > > > > > > + __u64 used; > > > > > > +} __attribute__ ((packed)); > > > > > > + > > > > > > +desc, avail and used contain the guest addresses for the descriptor table, > > > > > > +available ring and used ring for queue index, respectively. The actual > > > > > > +virtqueue size (number of allocated buffers) is transmitted in num. > > > > > > +res0 is reserved and must contain 0; otherwise, the device MUST post a > > > > > > +unit check with command reject. > > > > > > + > > > > > > +If the revision selected by the driver is at least 1, the device MUST > > > > > > +post a unit check with command reject if the transmitted data is between > > > > > > +16 and 31 bytes if the driver suppressed incorrect length indication > > > > > > +for the channel command. Otherwise, the normal conditions for handling > > > > > > +incorrect data lenghts apply. > > > > > > > > > > Also I don't understand the following: is there any > > > > > flexibility for drivers wrt the transmitted data length? > > > > > Above structure is 32 bytes in size. > > > > > So any other length is a driver bug. > > > > > > > > Not really. The driver may transmit a larger buffer then is needed, and > > > > suppress length checking via a ccw flag. The device can then process > > > > the data it needs, and disregard the rest. This is used sometimes for > > > > variable-length responses where a driver can just supply the largest > > > > possible buffer and check afterwards how much data it got. Depending on > > > > the command, this may work with short buffers as well. > > > > > > > > (In the virtio-ccw code so far, I required a minimum length and allowed > > > > a larger length when length checks have been turned off.) > > > > > > If drivers rely on this, this probably should be documented in the spec. > > > Specifically if I read the spec today it says command legth is X, > > > it seems quite reasonable to just stick > > > assert(length == X) in code, and people will interpret it > > > like this - was saw it with message framing. > > > > > > If you think devices should assept longer lengths, > > > please put a MUST in text saying this. > > > > I don't think this should be a MUST; but a SHOULD would be reasonable. > > > > I can put in language as well that drivers SHOULD specify the correct > > length; the virtio-ccw commands do not lend themselves to the scenario > > I described above, and suppressing a length check would be more of a > > crutch for not-so-good drivers. > > Hmm if it's not a MUST then drivers can't rely on it. > So why is it useful? It obviously must be either two MUSTs or two SHOULDs. It probably should not be MUST, as I don't remember another device failing on a too large buffer. SHOULD is more like a 'best practice' to me. Remember that an incorrect length without length check disabled will always yield a check; this is mandated by the architecture. > > I guess I'm kind of confused as to why this is useful - on the one hand > you prefer failing on easy to handle errors such as reserved field > != 0 (device could simply ignore it). Well, we _can_ ignore it, if we specify it that way :) A reserved/ignored or reserved/must be zero field are both fine for this case. > I kind of see the point - this makes sure drivers initialize everything. > On the other hand you want this flexibility to pass large > lengths. I thought the point is to make drivers simpler: > they can always use large length and not worry that device > will be confused. But if it's a SHOULD then drivers can't rely > on it being there, so I guess that's not the prupose? No, the purpose is not to be too different from other devices implementing channel architecture. A driver will usually only suppress length checking in special cases (like the variable data length case); the normal mode of operation is to specify the correct length and leave the length check on.


  • 20.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 11:08
    On Thu, Oct 10, 2013 at 12:56:56PM +0200, Cornelia Huck wrote: > On Thu, 10 Oct 2013 12:29:59 +0300 > "Michael S. Tsirkin" <mst@redhat.com> wrote: > > > On Thu, Oct 10, 2013 at 11:04:39AM +0200, Cornelia Huck wrote: > > > On Thu, 10 Oct 2013 11:46:05 +0300 > > > "Michael S. Tsirkin" <mst@redhat.com> wrote: > > > > > > > On Thu, Oct 10, 2013 at 10:16:35AM +0200, Cornelia Huck wrote: > > > > > On Thu, 10 Oct 2013 08:43:44 +0300 > > > > > "Michael S. Tsirkin" <mst@redhat.com> wrote: > > > > > > > > > > > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote: > > > > > > > Extend vq_info_block so that the addresses for descriptor table, > > > > > > > available ring and used ring may be transmitted independently. > > > > > > > > > > > > > > Depending upon the selected revision, post a command reject instead > > > > > > > of a channel program check if the driver uses the legacy format > > > > > > > and length checks are suppressed. > > > > > > > > > > > > > > VIRTIO-23 > > > > > > > > > > > > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> > > > > > > > > > > > > > > --- > > > > > > > > > > > > > > This is an alternate approach, extending the exiting structure instead > > > > > > > of creating a different layout. I'm not 100% sure whether doing a > > > > > > > command reject instead of a channel program check in case of a short > > > > > > > buffer is the right approach, though. Doing a channel program check > > > > > > > would probably cover that error just as well, and we could resolve > > > > > > > VIRTIO-23 independently of VIRTIO-42. > > > > > > > --- > > > > > > > virtio-v1.0-wd01-part1-specification.txt 32 +++++++++++++++++++++++++++--- > > > > > > > 1 file changed, 29 insertions(+), 3 deletions(-) > > > > > > > > > > > > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt > > > > > > > index ae646db..baff12f 100644 > > > > > > > --- a/virtio-v1.0-wd01-part1-specification.txt > > > > > > > +++ b/virtio-v1.0-wd01-part1-specification.txt > > > > > > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted > > > > > > > structure is > > > > > > > > > > > > > > struct vq_info_block { > > > > > > > + __u64 desc; > > > > > > > + __u32 res0; > > > > > > > + __u16 index; > > > > > > > + __u16 num; > > > > > > > + __u64 avail; > > > > > > > + __u64 used; > > > > > > > +} __attribute__ ((packed)); > > > > > > > + > > > > > > > +desc, avail and used contain the guest addresses for the descriptor table, > > > > > > > +available ring and used ring for queue index, respectively. The actual > > > > > > > +virtqueue size (number of allocated buffers) is transmitted in num. > > > > > > > +res0 is reserved and must contain 0; otherwise, the device MUST post a > > > > > > > +unit check with command reject. > > > > > > > + > > > > > > > +If the revision selected by the driver is at least 1, the device MUST > > > > > > > +post a unit check with command reject if the transmitted data is between > > > > > > > +16 and 31 bytes if the driver suppressed incorrect length indication > > > > > > > +for the channel command. Otherwise, the normal conditions for handling > > > > > > > +incorrect data lenghts apply. > > > > > > > > > > > > Also I don't understand the following: is there any > > > > > > flexibility for drivers wrt the transmitted data length? > > > > > > Above structure is 32 bytes in size. > > > > > > So any other length is a driver bug. > > > > > > > > > > Not really. The driver may transmit a larger buffer then is needed, and > > > > > suppress length checking via a ccw flag. The device can then process > > > > > the data it needs, and disregard the rest. This is used sometimes for > > > > > variable-length responses where a driver can just supply the largest > > > > > possible buffer and check afterwards how much data it got. Depending on > > > > > the command, this may work with short buffers as well. > > > > > > > > > > (In the virtio-ccw code so far, I required a minimum length and allowed > > > > > a larger length when length checks have been turned off.) > > > > > > > > If drivers rely on this, this probably should be documented in the spec. > > > > Specifically if I read the spec today it says command legth is X, > > > > it seems quite reasonable to just stick > > > > assert(length == X) in code, and people will interpret it > > > > like this - was saw it with message framing. > > > > > > > > If you think devices should assept longer lengths, > > > > please put a MUST in text saying this. > > > > > > I don't think this should be a MUST; but a SHOULD would be reasonable. > > > > > > I can put in language as well that drivers SHOULD specify the correct > > > length; the virtio-ccw commands do not lend themselves to the scenario > > > I described above, and suppressing a length check would be more of a > > > crutch for not-so-good drivers. > > > > Hmm if it's not a MUST then drivers can't rely on it. > > So why is it useful? > > It obviously must be either two MUSTs or two SHOULDs. It probably > should not be MUST, as I don't remember another device failing on a too > large buffer. SHOULD is more like a 'best practice' to me. > > Remember that an incorrect length without length check disabled will > always yield a check; this is mandated by the architecture. > > > > > I guess I'm kind of confused as to why this is useful - on the one hand > > you prefer failing on easy to handle errors such as reserved field > > != 0 (device could simply ignore it). > > Well, we _can_ ignore it, if we specify it that way :) A > reserved/ignored or reserved/must be zero field are both fine for this > case. > > > I kind of see the point - this makes sure drivers initialize everything. > > On the other hand you want this flexibility to pass large > > lengths. I thought the point is to make drivers simpler: > > they can always use large length and not worry that device > > will be confused. But if it's a SHOULD then drivers can't rely > > on it being there, so I guess that's not the prupose? > > No, the purpose is not to be too different from other devices > implementing channel architecture. A driver will usually only suppress > length checking in special cases (like the variable data length case); > the normal mode of operation is to specify the correct length and leave > the length check on. I don't know too much about this. I was going by your text: Otherwise, the normal conditions for handling incorrect data lenghts apply. which makes one think we are making some kind of exception here. In any case, I think if it's a SHOULD that's fine, but it seems a separate issue from ring layout. Maybe a separate chapter explaining the virtio-ccw specific length handling rules will make sense?


  • 21.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 11:11
    On Thu, Oct 10, 2013 at 12:56:56PM +0200, Cornelia Huck wrote:
    > On Thu, 10 Oct 2013 12:29:59 +0300
    > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    >
    > > On Thu, Oct 10, 2013 at 11:04:39AM +0200, Cornelia Huck wrote:
    > > > On Thu, 10 Oct 2013 11:46:05 +0300
    > > > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    > > >
    > > > > On Thu, Oct 10, 2013 at 10:16:35AM +0200, Cornelia Huck wrote:
    > > > > > On Thu, 10 Oct 2013 08:43:44 +0300
    > > > > > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    > > > > >
    > > > > > > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote:
    > > > > > > > Extend vq_info_block so that the addresses for descriptor table,
    > > > > > > > available ring and used ring may be transmitted independently.
    > > > > > > >
    > > > > > > > Depending upon the selected revision, post a command reject instead
    > > > > > > > of a channel program check if the driver uses the legacy format
    > > > > > > > and length checks are suppressed.
    > > > > > > >
    > > > > > > > VIRTIO-23
    > > > > > > >
    > > > > > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
    > > > > > > >
    > > > > > > > ---
    > > > > > > >
    > > > > > > > This is an alternate approach, extending the exiting structure instead
    > > > > > > > of creating a different layout. I'm not 100% sure whether doing a
    > > > > > > > command reject instead of a channel program check in case of a short
    > > > > > > > buffer is the right approach, though. Doing a channel program check
    > > > > > > > would probably cover that error just as well, and we could resolve
    > > > > > > > VIRTIO-23 independently of VIRTIO-42.
    > > > > > > > ---
    > > > > > > > virtio-v1.0-wd01-part1-specification.txt | 32 +++++++++++++++++++++++++++---
    > > > > > > > 1 file changed, 29 insertions(+), 3 deletions(-)
    > > > > > > >
    > > > > > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt
    > > > > > > > index ae646db..baff12f 100644
    > > > > > > > --- a/virtio-v1.0-wd01-part1-specification.txt
    > > > > > > > +++ b/virtio-v1.0-wd01-part1-specification.txt
    > > > > > > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted
    > > > > > > > structure is
    > > > > > > >
    > > > > > > > struct vq_info_block {
    > > > > > > > + __u64 desc;
    > > > > > > > + __u32 res0;
    > > > > > > > + __u16 index;
    > > > > > > > + __u16 num;
    > > > > > > > + __u64 avail;
    > > > > > > > + __u64 used;
    > > > > > > > +} __attribute__ ((packed));
    > > > > > > > +
    > > > > > > > +desc, avail and used contain the guest addresses for the descriptor table,
    > > > > > > > +available ring and used ring for queue index, respectively. The actual
    > > > > > > > +virtqueue size (number of allocated buffers) is transmitted in num.
    > > > > > > > +res0 is reserved and must contain 0; otherwise, the device MUST post a
    > > > > > > > +unit check with command reject.
    > > > > > > > +
    > > > > > > > +If the revision selected by the driver is at least 1, the device MUST
    > > > > > > > +post a unit check with command reject if the transmitted data is between
    > > > > > > > +16 and 31 bytes if the driver suppressed incorrect length indication
    > > > > > > > +for the channel command. Otherwise, the normal conditions for handling
    > > > > > > > +incorrect data lenghts apply.
    > > > > > >
    > > > > > > Also I don't understand the following: is there any
    > > > > > > flexibility for drivers wrt the transmitted data length?
    > > > > > > Above structure is 32 bytes in size.
    > > > > > > So any other length is a driver bug.
    > > > > >
    > > > > > Not really. The driver may transmit a larger buffer then is needed, and
    > > > > > suppress length checking via a ccw flag. The device can then process
    > > > > > the data it needs, and disregard the rest. This is used sometimes for
    > > > > > variable-length responses where a driver can just supply the largest
    > > > > > possible buffer and check afterwards how much data it got. Depending on
    > > > > > the command, this may work with short buffers as well.
    > > > > >
    > > > > > (In the virtio-ccw code so far, I required a minimum length and allowed
    > > > > > a larger length when length checks have been turned off.)
    > > > >
    > > > > If drivers rely on this, this probably should be documented in the spec.
    > > > > Specifically if I read the spec today it says command legth is X,
    > > > > it seems quite reasonable to just stick
    > > > > assert(length == X) in code, and people will interpret it
    > > > > like this - was saw it with message framing.
    > > > >
    > > > > If you think devices should assept longer lengths,
    > > > > please put a MUST in text saying this.
    > > >
    > > > I don't think this should be a MUST; but a SHOULD would be reasonable.
    > > >
    > > > I can put in language as well that drivers SHOULD specify the correct
    > > > length; the virtio-ccw commands do not lend themselves to the scenario
    > > > I described above, and suppressing a length check would be more of a
    > > > crutch for not-so-good drivers.
    > >
    > > Hmm if it's not a MUST then drivers can't rely on it.
    > > So why is it useful?
    >
    > It obviously must be either two MUSTs or two SHOULDs. It probably
    > should not be MUST, as I don't remember another device failing on a too
    > large buffer. SHOULD is more like a 'best practice' to me.
    >
    > Remember that an incorrect length without length check disabled will
    > always yield a check; this is mandated by the architecture.
    >
    > >
    > > I guess I'm kind of confused as to why this is useful - on the one hand
    > > you prefer failing on easy to handle errors such as reserved field
    > > != 0 (device could simply ignore it).
    >
    > Well, we _can_ ignore it, if we specify it that way :) A
    > reserved/ignored or reserved/must be zero field are both fine for this
    > case.
    >
    > > I kind of see the point - this makes sure drivers initialize everything.
    > > On the other hand you want this flexibility to pass large
    > > lengths. I thought the point is to make drivers simpler:
    > > they can always use large length and not worry that device
    > > will be confused. But if it's a SHOULD then drivers can't rely
    > > on it being there, so I guess that's not the prupose?
    >
    > No, the purpose is not to be too different from other devices
    > implementing channel architecture. A driver will usually only suppress
    > length checking in special cases (like the variable data length case);
    > the normal mode of operation is to specify the correct length and leave
    > the length check on.

    I don't know too much about this. I was going by your text:

    Otherwise, the normal conditions for handling incorrect data lenghts apply.

    which makes one think we are making some kind of exception here.

    In any case, I think if it's a SHOULD that's fine, but it seems
    a separate issue from ring layout.
    Maybe a separate chapter explaining the virtio-ccw specific
    length handling rules will make sense?







  • 22.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 12:30
    On Thu, 10 Oct 2013 14:10:39 +0300
    "Michael S. Tsirkin" <mst@redhat.com> wrote:

    > On Thu, Oct 10, 2013 at 12:56:56PM +0200, Cornelia Huck wrote:
    > > On Thu, 10 Oct 2013 12:29:59 +0300
    > > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    > >
    > > > On Thu, Oct 10, 2013 at 11:04:39AM +0200, Cornelia Huck wrote:
    > > > > On Thu, 10 Oct 2013 11:46:05 +0300
    > > > > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    > > > >
    > > > > > On Thu, Oct 10, 2013 at 10:16:35AM +0200, Cornelia Huck wrote:
    > > > > > > On Thu, 10 Oct 2013 08:43:44 +0300
    > > > > > > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    > > > > > >
    > > > > > > > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote:
    > > > > > > > > Extend vq_info_block so that the addresses for descriptor table,
    > > > > > > > > available ring and used ring may be transmitted independently.
    > > > > > > > >
    > > > > > > > > Depending upon the selected revision, post a command reject instead
    > > > > > > > > of a channel program check if the driver uses the legacy format
    > > > > > > > > and length checks are suppressed.
    > > > > > > > >
    > > > > > > > > VIRTIO-23
    > > > > > > > >
    > > > > > > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
    > > > > > > > >
    > > > > > > > > ---
    > > > > > > > >
    > > > > > > > > This is an alternate approach, extending the exiting structure instead
    > > > > > > > > of creating a different layout. I'm not 100% sure whether doing a
    > > > > > > > > command reject instead of a channel program check in case of a short
    > > > > > > > > buffer is the right approach, though. Doing a channel program check
    > > > > > > > > would probably cover that error just as well, and we could resolve
    > > > > > > > > VIRTIO-23 independently of VIRTIO-42.
    > > > > > > > > ---
    > > > > > > > > virtio-v1.0-wd01-part1-specification.txt | 32 +++++++++++++++++++++++++++---
    > > > > > > > > 1 file changed, 29 insertions(+), 3 deletions(-)
    > > > > > > > >
    > > > > > > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt
    > > > > > > > > index ae646db..baff12f 100644
    > > > > > > > > --- a/virtio-v1.0-wd01-part1-specification.txt
    > > > > > > > > +++ b/virtio-v1.0-wd01-part1-specification.txt
    > > > > > > > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted
    > > > > > > > > structure is
    > > > > > > > >
    > > > > > > > > struct vq_info_block {
    > > > > > > > > + __u64 desc;
    > > > > > > > > + __u32 res0;
    > > > > > > > > + __u16 index;
    > > > > > > > > + __u16 num;
    > > > > > > > > + __u64 avail;
    > > > > > > > > + __u64 used;
    > > > > > > > > +} __attribute__ ((packed));
    > > > > > > > > +
    > > > > > > > > +desc, avail and used contain the guest addresses for the descriptor table,
    > > > > > > > > +available ring and used ring for queue index, respectively. The actual
    > > > > > > > > +virtqueue size (number of allocated buffers) is transmitted in num.
    > > > > > > > > +res0 is reserved and must contain 0; otherwise, the device MUST post a
    > > > > > > > > +unit check with command reject.
    > > > > > > > > +
    > > > > > > > > +If the revision selected by the driver is at least 1, the device MUST
    > > > > > > > > +post a unit check with command reject if the transmitted data is between
    > > > > > > > > +16 and 31 bytes if the driver suppressed incorrect length indication
    > > > > > > > > +for the channel command. Otherwise, the normal conditions for handling
    > > > > > > > > +incorrect data lenghts apply.
    > > > > > > >
    > > > > > > > Also I don't understand the following: is there any
    > > > > > > > flexibility for drivers wrt the transmitted data length?
    > > > > > > > Above structure is 32 bytes in size.
    > > > > > > > So any other length is a driver bug.
    > > > > > >
    > > > > > > Not really. The driver may transmit a larger buffer then is needed, and
    > > > > > > suppress length checking via a ccw flag. The device can then process
    > > > > > > the data it needs, and disregard the rest. This is used sometimes for
    > > > > > > variable-length responses where a driver can just supply the largest
    > > > > > > possible buffer and check afterwards how much data it got. Depending on
    > > > > > > the command, this may work with short buffers as well.
    > > > > > >
    > > > > > > (In the virtio-ccw code so far, I required a minimum length and allowed
    > > > > > > a larger length when length checks have been turned off.)
    > > > > >
    > > > > > If drivers rely on this, this probably should be documented in the spec.
    > > > > > Specifically if I read the spec today it says command legth is X,
    > > > > > it seems quite reasonable to just stick
    > > > > > assert(length == X) in code, and people will interpret it
    > > > > > like this - was saw it with message framing.
    > > > > >
    > > > > > If you think devices should assept longer lengths,
    > > > > > please put a MUST in text saying this.
    > > > >
    > > > > I don't think this should be a MUST; but a SHOULD would be reasonable.
    > > > >
    > > > > I can put in language as well that drivers SHOULD specify the correct
    > > > > length; the virtio-ccw commands do not lend themselves to the scenario
    > > > > I described above, and suppressing a length check would be more of a
    > > > > crutch for not-so-good drivers.
    > > >
    > > > Hmm if it's not a MUST then drivers can't rely on it.
    > > > So why is it useful?
    > >
    > > It obviously must be either two MUSTs or two SHOULDs. It probably
    > > should not be MUST, as I don't remember another device failing on a too
    > > large buffer. SHOULD is more like a 'best practice' to me.
    > >
    > > Remember that an incorrect length without length check disabled will
    > > always yield a check; this is mandated by the architecture.
    > >
    > > >
    > > > I guess I'm kind of confused as to why this is useful - on the one hand
    > > > you prefer failing on easy to handle errors such as reserved field
    > > > != 0 (device could simply ignore it).
    > >
    > > Well, we _can_ ignore it, if we specify it that way :) A
    > > reserved/ignored or reserved/must be zero field are both fine for this
    > > case.
    > >
    > > > I kind of see the point - this makes sure drivers initialize everything.
    > > > On the other hand you want this flexibility to pass large
    > > > lengths. I thought the point is to make drivers simpler:
    > > > they can always use large length and not worry that device
    > > > will be confused. But if it's a SHOULD then drivers can't rely
    > > > on it being there, so I guess that's not the prupose?
    > >
    > > No, the purpose is not to be too different from other devices
    > > implementing channel architecture. A driver will usually only suppress
    > > length checking in special cases (like the variable data length case);
    > > the normal mode of operation is to specify the correct length and leave
    > > the length check on.
    >
    > I don't know too much about this. I was going by your text:
    >
    > Otherwise, the normal conditions for handling incorrect data lenghts apply.
    >
    > which makes one think we are making some kind of exception here.

    That was referring to the type of error status posted, but I'll ditch
    this.

    >
    > In any case, I think if it's a SHOULD that's fine, but it seems
    > a separate issue from ring layout.
    > Maybe a separate chapter explaining the virtio-ccw specific
    > length handling rules will make sense?

    Maybe in the general remarks for virtio-ccw?

    ---

    For the virtio-ccw specific channel commands, the general mechanism for
    channel command data length checking applies, as detailed in the
    z/Architecture Principles of Operation: I/O Interruptions -> Subchannel
    Status Word.

    If a driver did not suppress length checks for a channel command, the
    device MUST present a subchannel status as detailed in the architecture
    when the actual length did not match the expected length.

    If a driver did suppress length checks for a channel command, the
    device MUST present a check condition if the transmitted data does not
    contain enough data to process the command. If the driver submitted a
    buffer that was too long, it SHOULD accept the command. The driver
    SHOULD attempt to provide the correct length even if it suppresses
    length checks.




  • 23.  Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-10-2013 12:31
    On Thu, 10 Oct 2013 14:10:39 +0300 "Michael S. Tsirkin" <mst@redhat.com> wrote: > On Thu, Oct 10, 2013 at 12:56:56PM +0200, Cornelia Huck wrote: > > On Thu, 10 Oct 2013 12:29:59 +0300 > > "Michael S. Tsirkin" <mst@redhat.com> wrote: > > > > > On Thu, Oct 10, 2013 at 11:04:39AM +0200, Cornelia Huck wrote: > > > > On Thu, 10 Oct 2013 11:46:05 +0300 > > > > "Michael S. Tsirkin" <mst@redhat.com> wrote: > > > > > > > > > On Thu, Oct 10, 2013 at 10:16:35AM +0200, Cornelia Huck wrote: > > > > > > On Thu, 10 Oct 2013 08:43:44 +0300 > > > > > > "Michael S. Tsirkin" <mst@redhat.com> wrote: > > > > > > > > > > > > > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote: > > > > > > > > Extend vq_info_block so that the addresses for descriptor table, > > > > > > > > available ring and used ring may be transmitted independently. > > > > > > > > > > > > > > > > Depending upon the selected revision, post a command reject instead > > > > > > > > of a channel program check if the driver uses the legacy format > > > > > > > > and length checks are suppressed. > > > > > > > > > > > > > > > > VIRTIO-23 > > > > > > > > > > > > > > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> > > > > > > > > > > > > > > > > --- > > > > > > > > > > > > > > > > This is an alternate approach, extending the exiting structure instead > > > > > > > > of creating a different layout. I'm not 100% sure whether doing a > > > > > > > > command reject instead of a channel program check in case of a short > > > > > > > > buffer is the right approach, though. Doing a channel program check > > > > > > > > would probably cover that error just as well, and we could resolve > > > > > > > > VIRTIO-23 independently of VIRTIO-42. > > > > > > > > --- > > > > > > > > virtio-v1.0-wd01-part1-specification.txt 32 +++++++++++++++++++++++++++--- > > > > > > > > 1 file changed, 29 insertions(+), 3 deletions(-) > > > > > > > > > > > > > > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt > > > > > > > > index ae646db..baff12f 100644 > > > > > > > > --- a/virtio-v1.0-wd01-part1-specification.txt > > > > > > > > +++ b/virtio-v1.0-wd01-part1-specification.txt > > > > > > > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted > > > > > > > > structure is > > > > > > > > > > > > > > > > struct vq_info_block { > > > > > > > > + __u64 desc; > > > > > > > > + __u32 res0; > > > > > > > > + __u16 index; > > > > > > > > + __u16 num; > > > > > > > > + __u64 avail; > > > > > > > > + __u64 used; > > > > > > > > +} __attribute__ ((packed)); > > > > > > > > + > > > > > > > > +desc, avail and used contain the guest addresses for the descriptor table, > > > > > > > > +available ring and used ring for queue index, respectively. The actual > > > > > > > > +virtqueue size (number of allocated buffers) is transmitted in num. > > > > > > > > +res0 is reserved and must contain 0; otherwise, the device MUST post a > > > > > > > > +unit check with command reject. > > > > > > > > + > > > > > > > > +If the revision selected by the driver is at least 1, the device MUST > > > > > > > > +post a unit check with command reject if the transmitted data is between > > > > > > > > +16 and 31 bytes if the driver suppressed incorrect length indication > > > > > > > > +for the channel command. Otherwise, the normal conditions for handling > > > > > > > > +incorrect data lenghts apply. > > > > > > > > > > > > > > Also I don't understand the following: is there any > > > > > > > flexibility for drivers wrt the transmitted data length? > > > > > > > Above structure is 32 bytes in size. > > > > > > > So any other length is a driver bug. > > > > > > > > > > > > Not really. The driver may transmit a larger buffer then is needed, and > > > > > > suppress length checking via a ccw flag. The device can then process > > > > > > the data it needs, and disregard the rest. This is used sometimes for > > > > > > variable-length responses where a driver can just supply the largest > > > > > > possible buffer and check afterwards how much data it got. Depending on > > > > > > the command, this may work with short buffers as well. > > > > > > > > > > > > (In the virtio-ccw code so far, I required a minimum length and allowed > > > > > > a larger length when length checks have been turned off.) > > > > > > > > > > If drivers rely on this, this probably should be documented in the spec. > > > > > Specifically if I read the spec today it says command legth is X, > > > > > it seems quite reasonable to just stick > > > > > assert(length == X) in code, and people will interpret it > > > > > like this - was saw it with message framing. > > > > > > > > > > If you think devices should assept longer lengths, > > > > > please put a MUST in text saying this. > > > > > > > > I don't think this should be a MUST; but a SHOULD would be reasonable. > > > > > > > > I can put in language as well that drivers SHOULD specify the correct > > > > length; the virtio-ccw commands do not lend themselves to the scenario > > > > I described above, and suppressing a length check would be more of a > > > > crutch for not-so-good drivers. > > > > > > Hmm if it's not a MUST then drivers can't rely on it. > > > So why is it useful? > > > > It obviously must be either two MUSTs or two SHOULDs. It probably > > should not be MUST, as I don't remember another device failing on a too > > large buffer. SHOULD is more like a 'best practice' to me. > > > > Remember that an incorrect length without length check disabled will > > always yield a check; this is mandated by the architecture. > > > > > > > > I guess I'm kind of confused as to why this is useful - on the one hand > > > you prefer failing on easy to handle errors such as reserved field > > > != 0 (device could simply ignore it). > > > > Well, we _can_ ignore it, if we specify it that way :) A > > reserved/ignored or reserved/must be zero field are both fine for this > > case. > > > > > I kind of see the point - this makes sure drivers initialize everything. > > > On the other hand you want this flexibility to pass large > > > lengths. I thought the point is to make drivers simpler: > > > they can always use large length and not worry that device > > > will be confused. But if it's a SHOULD then drivers can't rely > > > on it being there, so I guess that's not the prupose? > > > > No, the purpose is not to be too different from other devices > > implementing channel architecture. A driver will usually only suppress > > length checking in special cases (like the variable data length case); > > the normal mode of operation is to specify the correct length and leave > > the length check on. > > I don't know too much about this. I was going by your text: > > Otherwise, the normal conditions for handling incorrect data lenghts apply. > > which makes one think we are making some kind of exception here. That was referring to the type of error status posted, but I'll ditch this. > > In any case, I think if it's a SHOULD that's fine, but it seems > a separate issue from ring layout. > Maybe a separate chapter explaining the virtio-ccw specific > length handling rules will make sense? Maybe in the general remarks for virtio-ccw? --- For the virtio-ccw specific channel commands, the general mechanism for channel command data length checking applies, as detailed in the z/Architecture Principles of Operation: I/O Interruptions -> Subchannel Status Word. If a driver did not suppress length checks for a channel command, the device MUST present a subchannel status as detailed in the architecture when the actual length did not match the expected length. If a driver did suppress length checks for a channel command, the device MUST present a check condition if the transmitted data does not contain enough data to process the command. If the driver submitted a buffer that was too long, it SHOULD accept the command. The driver SHOULD attempt to provide the correct length even if it suppresses length checks.


  • 24.  Re: [virtio-dev] Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-15-2013 03:40
    Cornelia Huck <cornelia.huck@de.ibm.com> writes:
    > On Thu, 10 Oct 2013 14:10:39 +0300
    > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    >
    >> On Thu, Oct 10, 2013 at 12:56:56PM +0200, Cornelia Huck wrote:
    >> > On Thu, 10 Oct 2013 12:29:59 +0300
    >> > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    >> >
    >> > > On Thu, Oct 10, 2013 at 11:04:39AM +0200, Cornelia Huck wrote:
    >> > > > On Thu, 10 Oct 2013 11:46:05 +0300
    >> > > > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    >> > > >
    >> > > > > On Thu, Oct 10, 2013 at 10:16:35AM +0200, Cornelia Huck wrote:
    >> > > > > > On Thu, 10 Oct 2013 08:43:44 +0300
    >> > > > > > "Michael S. Tsirkin" <mst@redhat.com> wrote:
    >> > > > > >
    >> > > > > > > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote:
    >> > > > > > > > Extend vq_info_block so that the addresses for descriptor table,
    >> > > > > > > > available ring and used ring may be transmitted independently.
    >> > > > > > > >
    >> > > > > > > > Depending upon the selected revision, post a command reject instead
    >> > > > > > > > of a channel program check if the driver uses the legacy format
    >> > > > > > > > and length checks are suppressed.
    >> > > > > > > >
    >> > > > > > > > VIRTIO-23
    >> > > > > > > >
    >> > > > > > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
    >> > > > > > > >
    >> > > > > > > > ---
    >> > > > > > > >
    >> > > > > > > > This is an alternate approach, extending the exiting structure instead
    >> > > > > > > > of creating a different layout. I'm not 100% sure whether doing a
    >> > > > > > > > command reject instead of a channel program check in case of a short
    >> > > > > > > > buffer is the right approach, though. Doing a channel program check
    >> > > > > > > > would probably cover that error just as well, and we could resolve
    >> > > > > > > > VIRTIO-23 independently of VIRTIO-42.
    >> > > > > > > > ---
    >> > > > > > > > virtio-v1.0-wd01-part1-specification.txt | 32 +++++++++++++++++++++++++++---
    >> > > > > > > > 1 file changed, 29 insertions(+), 3 deletions(-)
    >> > > > > > > >
    >> > > > > > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt
    >> > > > > > > > index ae646db..baff12f 100644
    >> > > > > > > > --- a/virtio-v1.0-wd01-part1-specification.txt
    >> > > > > > > > +++ b/virtio-v1.0-wd01-part1-specification.txt
    >> > > > > > > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted
    >> > > > > > > > structure is
    >> > > > > > > >
    >> > > > > > > > struct vq_info_block {
    >> > > > > > > > + __u64 desc;
    >> > > > > > > > + __u32 res0;
    >> > > > > > > > + __u16 index;
    >> > > > > > > > + __u16 num;
    >> > > > > > > > + __u64 avail;
    >> > > > > > > > + __u64 used;
    >> > > > > > > > +} __attribute__ ((packed));
    >> > > > > > > > +
    >> > > > > > > > +desc, avail and used contain the guest addresses for the descriptor table,
    >> > > > > > > > +available ring and used ring for queue index, respectively. The actual
    >> > > > > > > > +virtqueue size (number of allocated buffers) is transmitted in num.
    >> > > > > > > > +res0 is reserved and must contain 0; otherwise, the device MUST post a
    >> > > > > > > > +unit check with command reject.
    >> > > > > > > > +
    >> > > > > > > > +If the revision selected by the driver is at least 1, the device MUST
    >> > > > > > > > +post a unit check with command reject if the transmitted data is between
    >> > > > > > > > +16 and 31 bytes if the driver suppressed incorrect length indication
    >> > > > > > > > +for the channel command. Otherwise, the normal conditions for handling
    >> > > > > > > > +incorrect data lenghts apply.
    >> > > > > > >
    >> > > > > > > Also I don't understand the following: is there any
    >> > > > > > > flexibility for drivers wrt the transmitted data length?
    >> > > > > > > Above structure is 32 bytes in size.
    >> > > > > > > So any other length is a driver bug.
    >> > > > > >
    >> > > > > > Not really. The driver may transmit a larger buffer then is needed, and
    >> > > > > > suppress length checking via a ccw flag. The device can then process
    >> > > > > > the data it needs, and disregard the rest. This is used sometimes for
    >> > > > > > variable-length responses where a driver can just supply the largest
    >> > > > > > possible buffer and check afterwards how much data it got. Depending on
    >> > > > > > the command, this may work with short buffers as well.
    >> > > > > >
    >> > > > > > (In the virtio-ccw code so far, I required a minimum length and allowed
    >> > > > > > a larger length when length checks have been turned off.)
    >> > > > >
    >> > > > > If drivers rely on this, this probably should be documented in the spec.
    >> > > > > Specifically if I read the spec today it says command legth is X,
    >> > > > > it seems quite reasonable to just stick
    >> > > > > assert(length == X) in code, and people will interpret it
    >> > > > > like this - was saw it with message framing.
    >> > > > >
    >> > > > > If you think devices should assept longer lengths,
    >> > > > > please put a MUST in text saying this.
    >> > > >
    >> > > > I don't think this should be a MUST; but a SHOULD would be reasonable.
    >> > > >
    >> > > > I can put in language as well that drivers SHOULD specify the correct
    >> > > > length; the virtio-ccw commands do not lend themselves to the scenario
    >> > > > I described above, and suppressing a length check would be more of a
    >> > > > crutch for not-so-good drivers.
    >> > >
    >> > > Hmm if it's not a MUST then drivers can't rely on it.
    >> > > So why is it useful?
    >> >
    >> > It obviously must be either two MUSTs or two SHOULDs. It probably
    >> > should not be MUST, as I don't remember another device failing on a too
    >> > large buffer. SHOULD is more like a 'best practice' to me.
    >> >
    >> > Remember that an incorrect length without length check disabled will
    >> > always yield a check; this is mandated by the architecture.
    >> >
    >> > >
    >> > > I guess I'm kind of confused as to why this is useful - on the one hand
    >> > > you prefer failing on easy to handle errors such as reserved field
    >> > > != 0 (device could simply ignore it).
    >> >
    >> > Well, we _can_ ignore it, if we specify it that way :) A
    >> > reserved/ignored or reserved/must be zero field are both fine for this
    >> > case.
    >> >
    >> > > I kind of see the point - this makes sure drivers initialize everything.
    >> > > On the other hand you want this flexibility to pass large
    >> > > lengths. I thought the point is to make drivers simpler:
    >> > > they can always use large length and not worry that device
    >> > > will be confused. But if it's a SHOULD then drivers can't rely
    >> > > on it being there, so I guess that's not the prupose?
    >> >
    >> > No, the purpose is not to be too different from other devices
    >> > implementing channel architecture. A driver will usually only suppress
    >> > length checking in special cases (like the variable data length case);
    >> > the normal mode of operation is to specify the correct length and leave
    >> > the length check on.
    >>
    >> I don't know too much about this. I was going by your text:
    >>
    >> Otherwise, the normal conditions for handling incorrect data lenghts apply.
    >>
    >> which makes one think we are making some kind of exception here.
    >
    > That was referring to the type of error status posted, but I'll ditch
    > this.
    >
    >>
    >> In any case, I think if it's a SHOULD that's fine, but it seems
    >> a separate issue from ring layout.
    >> Maybe a separate chapter explaining the virtio-ccw specific
    >> length handling rules will make sense?
    >
    > Maybe in the general remarks for virtio-ccw?
    >
    > ---
    >
    > For the virtio-ccw specific channel commands, the general mechanism for
    > channel command data length checking applies, as detailed in the
    > z/Architecture Principles of Operation: I/O Interruptions -> Subchannel
    > Status Word.

    Please add that (and anything else relevant) to "1.2. Normative
    References" ?

    Cheers,
    Rusty.




  • 25.  Re: [virtio-dev] Re: [PATCH] virtio-ccw: split descriptor/available/used rings (alternate)

    Posted 10-15-2013 06:12
    Cornelia Huck <cornelia.huck@de.ibm.com> writes: > On Thu, 10 Oct 2013 14:10:39 +0300 > "Michael S. Tsirkin" <mst@redhat.com> wrote: > >> On Thu, Oct 10, 2013 at 12:56:56PM +0200, Cornelia Huck wrote: >> > On Thu, 10 Oct 2013 12:29:59 +0300 >> > "Michael S. Tsirkin" <mst@redhat.com> wrote: >> > >> > > On Thu, Oct 10, 2013 at 11:04:39AM +0200, Cornelia Huck wrote: >> > > > On Thu, 10 Oct 2013 11:46:05 +0300 >> > > > "Michael S. Tsirkin" <mst@redhat.com> wrote: >> > > > >> > > > > On Thu, Oct 10, 2013 at 10:16:35AM +0200, Cornelia Huck wrote: >> > > > > > On Thu, 10 Oct 2013 08:43:44 +0300 >> > > > > > "Michael S. Tsirkin" <mst@redhat.com> wrote: >> > > > > > >> > > > > > > On Wed, Oct 09, 2013 at 05:59:36PM +0200, Cornelia Huck wrote: >> > > > > > > > Extend vq_info_block so that the addresses for descriptor table, >> > > > > > > > available ring and used ring may be transmitted independently. >> > > > > > > > >> > > > > > > > Depending upon the selected revision, post a command reject instead >> > > > > > > > of a channel program check if the driver uses the legacy format >> > > > > > > > and length checks are suppressed. >> > > > > > > > >> > > > > > > > VIRTIO-23 >> > > > > > > > >> > > > > > > > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> >> > > > > > > > >> > > > > > > > --- >> > > > > > > > >> > > > > > > > This is an alternate approach, extending the exiting structure instead >> > > > > > > > of creating a different layout. I'm not 100% sure whether doing a >> > > > > > > > command reject instead of a channel program check in case of a short >> > > > > > > > buffer is the right approach, though. Doing a channel program check >> > > > > > > > would probably cover that error just as well, and we could resolve >> > > > > > > > VIRTIO-23 independently of VIRTIO-42. >> > > > > > > > --- >> > > > > > > > virtio-v1.0-wd01-part1-specification.txt 32 +++++++++++++++++++++++++++--- >> > > > > > > > 1 file changed, 29 insertions(+), 3 deletions(-) >> > > > > > > > >> > > > > > > > diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt >> > > > > > > > index ae646db..baff12f 100644 >> > > > > > > > --- a/virtio-v1.0-wd01-part1-specification.txt >> > > > > > > > +++ b/virtio-v1.0-wd01-part1-specification.txt >> > > > > > > > @@ -1642,15 +1642,41 @@ host about the location used for its queue. The transmitted >> > > > > > > > structure is >> > > > > > > > >> > > > > > > > struct vq_info_block { >> > > > > > > > + __u64 desc; >> > > > > > > > + __u32 res0; >> > > > > > > > + __u16 index; >> > > > > > > > + __u16 num; >> > > > > > > > + __u64 avail; >> > > > > > > > + __u64 used; >> > > > > > > > +} __attribute__ ((packed)); >> > > > > > > > + >> > > > > > > > +desc, avail and used contain the guest addresses for the descriptor table, >> > > > > > > > +available ring and used ring for queue index, respectively. The actual >> > > > > > > > +virtqueue size (number of allocated buffers) is transmitted in num. >> > > > > > > > +res0 is reserved and must contain 0; otherwise, the device MUST post a >> > > > > > > > +unit check with command reject. >> > > > > > > > + >> > > > > > > > +If the revision selected by the driver is at least 1, the device MUST >> > > > > > > > +post a unit check with command reject if the transmitted data is between >> > > > > > > > +16 and 31 bytes if the driver suppressed incorrect length indication >> > > > > > > > +for the channel command. Otherwise, the normal conditions for handling >> > > > > > > > +incorrect data lenghts apply. >> > > > > > > >> > > > > > > Also I don't understand the following: is there any >> > > > > > > flexibility for drivers wrt the transmitted data length? >> > > > > > > Above structure is 32 bytes in size. >> > > > > > > So any other length is a driver bug. >> > > > > > >> > > > > > Not really. The driver may transmit a larger buffer then is needed, and >> > > > > > suppress length checking via a ccw flag. The device can then process >> > > > > > the data it needs, and disregard the rest. This is used sometimes for >> > > > > > variable-length responses where a driver can just supply the largest >> > > > > > possible buffer and check afterwards how much data it got. Depending on >> > > > > > the command, this may work with short buffers as well. >> > > > > > >> > > > > > (In the virtio-ccw code so far, I required a minimum length and allowed >> > > > > > a larger length when length checks have been turned off.) >> > > > > >> > > > > If drivers rely on this, this probably should be documented in the spec. >> > > > > Specifically if I read the spec today it says command legth is X, >> > > > > it seems quite reasonable to just stick >> > > > > assert(length == X) in code, and people will interpret it >> > > > > like this - was saw it with message framing. >> > > > > >> > > > > If you think devices should assept longer lengths, >> > > > > please put a MUST in text saying this. >> > > > >> > > > I don't think this should be a MUST; but a SHOULD would be reasonable. >> > > > >> > > > I can put in language as well that drivers SHOULD specify the correct >> > > > length; the virtio-ccw commands do not lend themselves to the scenario >> > > > I described above, and suppressing a length check would be more of a >> > > > crutch for not-so-good drivers. >> > > >> > > Hmm if it's not a MUST then drivers can't rely on it. >> > > So why is it useful? >> > >> > It obviously must be either two MUSTs or two SHOULDs. It probably >> > should not be MUST, as I don't remember another device failing on a too >> > large buffer. SHOULD is more like a 'best practice' to me. >> > >> > Remember that an incorrect length without length check disabled will >> > always yield a check; this is mandated by the architecture. >> > >> > > >> > > I guess I'm kind of confused as to why this is useful - on the one hand >> > > you prefer failing on easy to handle errors such as reserved field >> > > != 0 (device could simply ignore it). >> > >> > Well, we _can_ ignore it, if we specify it that way :) A >> > reserved/ignored or reserved/must be zero field are both fine for this >> > case. >> > >> > > I kind of see the point - this makes sure drivers initialize everything. >> > > On the other hand you want this flexibility to pass large >> > > lengths. I thought the point is to make drivers simpler: >> > > they can always use large length and not worry that device >> > > will be confused. But if it's a SHOULD then drivers can't rely >> > > on it being there, so I guess that's not the prupose? >> > >> > No, the purpose is not to be too different from other devices >> > implementing channel architecture. A driver will usually only suppress >> > length checking in special cases (like the variable data length case); >> > the normal mode of operation is to specify the correct length and leave >> > the length check on. >> >> I don't know too much about this. I was going by your text: >> >> Otherwise, the normal conditions for handling incorrect data lenghts apply. >> >> which makes one think we are making some kind of exception here. > > That was referring to the type of error status posted, but I'll ditch > this. > >> >> In any case, I think if it's a SHOULD that's fine, but it seems >> a separate issue from ring layout. >> Maybe a separate chapter explaining the virtio-ccw specific >> length handling rules will make sense? > > Maybe in the general remarks for virtio-ccw? > > --- > > For the virtio-ccw specific channel commands, the general mechanism for > channel command data length checking applies, as detailed in the > z/Architecture Principles of Operation: I/O Interruptions -> Subchannel > Status Word. Please add that (and anything else relevant) to "1.2. Normative References" ? Cheers, Rusty.


  • 26.  [PATCH] virtio-ccw: clarify some channel I/O concepts

    Posted 10-15-2013 10:38
    Add the documents where channel I/O is generally described to the
    normative references and add some further words on command rejects
    and length checks.

    Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>

    ---

    These should hopefully specify clear enough what devices/drivers are
    supposed to do with different commands. Any comments?
    ---
    virtio-v1.0-wd01-part1-specification.txt | 21 +++++++++++++++++++++
    1 file changed, 21 insertions(+)

    diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt
    index 66d3bab..b7af1f9 100644
    --- a/virtio-v1.0-wd01-part1-specification.txt
    +++ b/virtio-v1.0-wd01-part1-specification.txt
    @@ -67,6 +67,10 @@ Driver

    [RFC 2119] S. Bradner, Key words for use in RFCs to Indicate Requirement Levels, http://www.ietf.org/rfc/rfc2119.txt IETF (Internet Engineering Task Force) RFC 2119, March 1997.

    +[S390 PoP] z/Architecture Principles of Operation, IBM Publication SA22-7832
    +
    +[S390 Common I/O] ESA/390 Common I/O-Device and Self-Description, IBM Publication SA22-7204
    +
    1.3. Non-Normative References
    =========================

    @@ -1581,6 +1585,23 @@ virtio:
    #define CCW_CMD_WRITE_STATUS 0x31
    #define CCW_CMD_READ_VQ_CONF 0x32

    +The virtio-ccw device acts like a normal channel device, as specified
    +in [S390 PoP] and [S390 Common I/O]. In particular:
    +
    +- A device must post a unit check with command reject for any command
    + it does not support.
    +
    +- If a driver did not suppress length checks for a channel command,
    + the device must present a subchannel status as detailed in the
    + architecture when the actual length did not match the expected length.
    +
    +- If a driver did suppress length checks for a channel command, the
    + device must present a check condition if the transmitted data does
    + not contain enough data to process the command. If the driver submitted
    + a buffer that was too long, the device should accept the command.
    + The driver should attempt to provide the correct length even if it
    + suppresses length checks.
    +
    2.3.3.2. Device Initialization
    ------------------------------

    --
    1.7.9.5




  • 27.  [PATCH] virtio-ccw: clarify some channel I/O concepts

    Posted 10-15-2013 10:39
    Add the documents where channel I/O is generally described to the normative references and add some further words on command rejects and length checks. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> --- These should hopefully specify clear enough what devices/drivers are supposed to do with different commands. Any comments? --- virtio-v1.0-wd01-part1-specification.txt 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt index 66d3bab..b7af1f9 100644 --- a/virtio-v1.0-wd01-part1-specification.txt +++ b/virtio-v1.0-wd01-part1-specification.txt @@ -67,6 +67,10 @@ Driver [RFC 2119] S. Bradner, Key words for use in RFCs to Indicate Requirement Levels, http://www.ietf.org/rfc/rfc2119.txt IETF (Internet Engineering Task Force) RFC 2119, March 1997. +[S390 PoP] z/Architecture Principles of Operation, IBM Publication SA22-7832 + +[S390 Common I/O] ESA/390 Common I/O-Device and Self-Description, IBM Publication SA22-7204 + 1.3. Non-Normative References ========================= @@ -1581,6 +1585,23 @@ virtio: #define CCW_CMD_WRITE_STATUS 0x31 #define CCW_CMD_READ_VQ_CONF 0x32 +The virtio-ccw device acts like a normal channel device, as specified +in [S390 PoP] and [S390 Common I/O]. In particular: + +- A device must post a unit check with command reject for any command + it does not support. + +- If a driver did not suppress length checks for a channel command, + the device must present a subchannel status as detailed in the + architecture when the actual length did not match the expected length. + +- If a driver did suppress length checks for a channel command, the + device must present a check condition if the transmitted data does + not contain enough data to process the command. If the driver submitted + a buffer that was too long, the device should accept the command. + The driver should attempt to provide the correct length even if it + suppresses length checks. + 2.3.3.2. Device Initialization ------------------------------ -- 1.7.9.5