All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: virtio-comment@lists.oasis-open.org,
	virtio-dev@lists.oasis-open.org, cohuck@redhat.com,
	sgarzare@redhat.com, stefanha@redhat.com, nrupal.jani@intel.com,
	Piotr.Uminski@intel.com, hang.yuan@intel.com,
	virtio@lists.oasis-open.org,
	Zhu Lingshan <lingshan.zhu@intel.com>,
	pasic@linux.ibm.com, Shahaf Shuler <shahafs@nvidia.com>,
	Parav Pandit <parav@nvidia.com>,
	Max Gurtovoy <mgurtovoy@nvidia.com>
Subject: Re: [PATCH v9 09/10] admin: conformance clauses
Date: Fri, 25 Nov 2022 06:47:04 -0500	[thread overview]
Message-ID: <20221125064414-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <7d27538d-f185-c1fe-b19d-716930fd3f08@redhat.com>

On Fri, Nov 25, 2022 at 11:50:52AM +0800, Jason Wang wrote:
> 
> 在 2022/11/24 16:36, Michael S. Tsirkin 写道:
> > On Thu, Nov 24, 2022 at 02:51:21PM +0800, Jason Wang wrote:
> > > On Thu, Nov 24, 2022 at 5:08 AM Michael S. Tsirkin <mst@redhat.com> wrote:
> > > > Add conformance clauses for admin commands and admin virtqueues.
> > > > 
> > > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > > > ---
> > > >   admin.tex | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > > >   1 file changed, 158 insertions(+)
> > > > 
> > > > diff --git a/admin.tex b/admin.tex
> > > > index eec12a9..e83a9f5 100644
> > > > --- a/admin.tex
> > > > +++ b/admin.tex
> > > > @@ -222,6 +222,107 @@ \subsection{Group administration commands}\label{sec:Basic Facilities of a Virti
> > > >   It is assumed that all members in a group support and are used
> > > >   with the same list of commands.
> > > > 
> > > > +\devicenormative{\paragraph}{Group administration commands}{Basic Facilities of a Virtio Device / Device groups / Group administration commands}
> > > > +
> > > > +The device MUST validate \field{opcode}, \field{group_type} and
> > > > +\field{group_member_id}, set \field{status} to VIRTIO_ADMIN_STATUS_EINVAL and
> > > > +nd if any of these has an invalid or unsupported value, set
> > > typo
> > thanks!
> > 
> > > > +\field{status_qualifier} accordingly.
> > > > +
> > > > +If a command completes successfully, the device MUST set
> > > > +\field{status} to VIRTIO_ADMIN_STATUS_OK.
> > > > +
> > > > +If a command fails, the device MUST set
> > > > +\field{status} to a value different from VIRTIO_ADMIN_STATUS_OK.
> > > > +
> > > > +If \field{status} is set to VIRTIO_ADMIN_STATUS_EINVAL, the
> > > > +device state MUST NOT change, that is the command MUST NOT have
> > > > +any side effects on the device, in particular the device MUST not
> > > > +enter an error state as a result of this command.
> > > > +
> > > > +If a command fails, the device state generally SHOULD NOT change,
> > > > +as far as possible.
> > > > +
> > > > +The device MAY enforce additional restrictions and dependencies on
> > > > +opcodes used by the driver and MAY fail the command
> > > > +VIRTIO_ADMIN_CMD_LIST_USE with \field{status} set to VIRTIO_ADMIN_STATUS_EINVAL
> > > > +and \field{status_qualifier} set to VIRTIO_ADMIN_STATUS_Q_INVALID_FIELD
> > > > +if the list of commands used violate internal device dependencies.
> > > > +
> > > > +If the device supports multiple group types, commands for each group
> > > > +type MUST operate independently of each other, in particular,
> > > > +the device MAY return different results for VIRTIO_ADMIN_CMD_LIST_QUERY
> > > > +for different group types.
> > > > +
> > > > +After reset, and before receiving VIRTIO_ADMIN_CMD_LIST_USE for a given group type
> > > > +the device MUST assume
> > > > +that the list of legal commands used by the driver consists of
> > > > +the two commands VIRTIO_ADMIN_CMD_LIST_QUERY and VIRTIO_ADMIN_CMD_LIST_USE.
> > > > +
> > > > +After completing VIRTIO_ADMIN_CMD_LIST_USE successfully,
> > > > +the device MUST set the list of legal commands used by the driver
> > > > +to the one supplied in \field{command_specific_data}.
> > > > +
> > > > +The device MUST set the list of legal commands used by the driver
> > > > +to the one supplied in VIRTIO_ADMIN_CMD_LIST_USE.
> > > > +
> > > > +The device MUST validate commands against the list used by
> > > > +the driver and MUST fail any commands not in the list with
> > > > +\field{status} set to VIRTIO_ADMIN_STATUS_EINVAL
> > > > +and \field{status_qualifier} set to
> > > > +VIRTIO_ADMIN_STATUS_Q_INVALID_OPCODE.
> > > > +
> > > > +The list of supported commands MUST NOT shrink (but MAY expand):
> > > > +after reporting a given command as supported through
> > > > +VIRTIO_ADMIN_CMD_LIST_QUERY the device MUST NOT later report it
> > > > +as unsupported.  Further, after a given set of commands has been
> > > > +used (via a successful VIRTIO_ADMIN_CMD_LIST_USE), then after a
> > > > +device or system reset the device SHOULD complete successfully
> > > > +any following calls to VIRTIO_ADMIN_CMD_LIST_USE with the same
> > > > +list of commands; if this command VIRTIO_ADMIN_CMD_LIST_USE fails
> > > > +after a device or system reset, the device MUST not fail it
> > > > +solely because of the command list used.  Failure to do so would
> > > > +interfere with resuming from suspend and error recovery.
> > > > +
> > > > +
> > > > +\drivernormative{\paragraph}{Group administration commands}{Basic Facilities of a Virtio Device / Device groups / Group administration commands}
> > > > +
> > > > +The driver MAY discover whether device supports a specific group type
> > > > +by issuing VIRTIO_ADMIN_CMD_LIST_QUERY with the matching
> > > > +\field{group_type}.
> > > > +
> > > > +The driver MUST issue VIRTIO_ADMIN_CMD_LIST_USE
> > > > +and wait for it to be completed with status
> > > > +VIRTIO_ADMIN_STATUS_OK before issuing any commands
> > > > +(except for the initial VIRTIO_ADMIN_CMD_LIST_QUERY
> > > > +and VIRTIO_ADMIN_CMD_LIST_USE).
> > > > +
> > > > +The driver SHOULD NOT set bits in device_admin_cmds
> > > > +if it is not familiar with how the command opcode
> > > > +is used, as dependencies between command opcodes might exist.
> > > > +
> > > > +The driver MUST NOT request (via VIRTIO_ADMIN_CMD_LIST_USE)
> > > > +the use of any commands not previously reported as
> > > > +supported for the same group type by VIRTIO_ADMIN_CMD_LIST_QUERY.
> > > > +
> > > > +The driver MUST NOT use any commands for a given group type
> > > > +before sending VIRTIO_ADMIN_CMD_LIST_USE with the correct
> > > > +list of command opcodes and group type.
> > > > +
> > > > +The driver MAY block use of VIRTIO_ADMIN_CMD_LIST_QUERY and
> > > > +VIRTIO_ADMIN_CMD_LIST_USE by issuing VIRTIO_ADMIN_CMD_LIST_USE
> > > > +with respective bits cleared in \field{command_specific_data}.
> > > > +
> > > > +The driver MUST handle a command error with a reserved \field{status}
> > > > +value in the same way as \field{status} set to VIRTIO_ADMIN_STATUS_EINVAL
> > > > +(except possibly for different error reporting/diagnostic messages).
> > > > +
> > > > +The driver MUST handle a command error with a reserved
> > > > +\field{status_qualifier} value in the same way as
> > > > +\field{status_qualifier} set to
> > > > +VIRTIO_ADMIN_STATUS_Q_INVALID_COMMAND (except possibly for
> > > > +different error reporting/diagnostic messages).
> > > > +
> > > >   \section{Administration Virtqueues}\label{sec:Basic Facilities of a Virtio Device / Administration Virtqueues}
> > > > 
> > > >   An administration virtqueue of an owner device is used to submit
> > > > @@ -275,3 +376,60 @@ \section{Administration Virtqueues}\label{sec:Basic Facilities of a Virtio Devic
> > > >   new fields can be added to the tail of a structure,
> > > >   with the driver using the full structure without concern
> > > >   for versioning.
> > > > +
> > > > +\devicenormative{\paragraph}{Group administration commands}{Basic Facilities of a Virtio Device / Administration virtqueues}
> > > > +
> > > > +The device MUST support device-readable and device-writeable buffers
> > > > +shorter than described in this specification, by
> > > > +\begin{enumerate}
> > > > +\item assuming that any data that would be read outside the
> > > > +device-readable buffers is set to zero, and
> > > s/"is set"/"are set"
> > thanks
> > 
> > > > +\item discarding data that would be written outside the
> > > > +specified device-writeable buffers.
> > > > +\end{enumerate}
> > > > +
> > > > +The device MUST support device-readable and device-writeable buffers
> > > > +longer than described in this specification, by
> > > > +\begin{enumerate}
> > > > +\item ignoring any data in device-readable buffers outside
> > > > +the expected length, and
> > > > +\item only writing the expected structure to the device-writeable
> > > > +buffers, ignoring any extra buffers, and reporting the
> > > > +actual length of data written, in bytes,
> > > > +as buffer used length.
> > > > +\end{enumerate}
> > > > +
> > > > +The device SHOULD initialize the device-writeable buffer
> > > > +up to the length of the structure described by this specification or
> > > > +the length of the buffer supplied by the driver (even if the buffer is
> > > > +all set to zero), whichever is shorter.
> > > > +
> > > > +The device MUST NOT fail a command solely because the buffers
> > > > +provided are shorter or longer than described in this
> > > > +specification.
> > > I may miss something but how can it work if the buffer is shorter?
> > driver does not care what's there.
> > 
> > this is mostly for forward compatibility - we'll add more fields and
> > I don't want to explain separately that old drivers post
> > short buffers with less fields.
> 
> 
> For example:
> 
> The patch said:
> 
> struct virtio_admin_cmd_list {
>        /* Indicates which of the below fields were returned
>        le32 device_admin_cmds[];
> };
> 
> Does it mean the query can still succeed even if there's no space for
> virtio_admin_cmd_list in the writable buffer?
> 

yes you just skip it. E.g. it's a way to check that query is supported.
And this (truncated buffer) is exactly what will happen when we have
e.g. 1k opcodes.

> > 
> > 
> > > > +
> > > > +The device MUST process commands on a given administration virtqueue
> > > > +in the order in which they are queued.
> > > Is it better to use "complete" than "process" here?
> > I am not sure we need to require they complete in order, unless
> > IN_ORDER is set (unfortunately it is global for all of device).
> 
> 
> So I'm not sure the "process" can help in this case. Consider we have two
> commands X and Y. And Y depends on X.
> 
> If we say device processes the commands in order, driver can't submit Y
> until it see X is completed.
> This seems no changes if we allow the device to
> process the command out of order.
> 
Depends on command.
Consider transport vq, some read following a write. read must not bypass
it but you do not need to wait for write.

> 
> > 
> > > Or we can reuse
> > > part of the in-order description.
> > > 
> > > (Or maybe a flush command)
> > 
> > these can be used if offered.
> > 
> > > > +
> > > > +If multiple administration virtqueues have been configured,
> > > > +device MAY process commands on distinct virtqueues with
> > > > +no order constraints.
> > > > +
> > > > +\drivernormative{\paragraph}{Group administration commands}{Basic Facilities of a Virtio Device / Administration virtqueues}
> > > > +
> > > > +The driver MAY supply device-readable and device-writeable buffers
> > > > +longer than described in this specification.
> > > > +
> > > > +The driver SHOULD supply device-readable buffers at least as
> > > > +large as the structure described by this specification
> > > > +(even if the buffer is all set to zero).
> > > > +
> > > > +The driver MUST NOT assume that the device will initialize the whole
> > > > +structure as described in the specification; instead,
> > > > +the driver MUST assume that the structure
> > > > +outside the part of the buffer used by the device
> > > > +is set to zero.
> > > Won't this have security implications? E.g information leak.
> > > 
> > > Thanks
> > hmm this is not clear enough. it should ignore the contents
> > and behave as if it was set to zero. Will fix.
> 
> 
> Ok.
> 
> Thanks
> 
> 
> > 
> > 
> > > > +
> > > > +If multiple administration virtqueues have been configured,
> > > > +the driver MUST ensure ordering for commands
> > > > +placed on different administration virtqueues.
> > > > --
> > > > MST
> > > > 


  parent reply	other threads:[~2022-11-25 11:47 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23 21:07 [PATCH v9 00/10] Introduce device group and device management Michael S. Tsirkin
2022-11-23 21:08 ` [PATCH v9 01/10] virtio: document forward compatibility guarantees Michael S. Tsirkin
2022-11-24  4:33   ` Jason Wang
2022-11-24  6:59     ` Michael S. Tsirkin
2022-11-24  7:34       ` Jason Wang
2022-11-24  8:15         ` Michael S. Tsirkin
2022-11-24 12:05           ` [virtio-dev] " Cornelia Huck
2022-11-25  3:17             ` Jason Wang
2022-11-25 10:37               ` [virtio-dev] " Cornelia Huck
2022-11-28  6:14                 ` Jason Wang
2022-11-23 21:08 ` [PATCH v9 02/10] admin: introduce device group and related concepts Michael S. Tsirkin
2022-11-24  5:41   ` Jason Wang
2022-11-24  7:08     ` Michael S. Tsirkin
2022-11-24  7:37       ` [virtio-dev] " Jason Wang
2022-11-24  8:18         ` Michael S. Tsirkin
2022-11-24 12:12           ` Cornelia Huck
2022-11-25  3:23             ` Jason Wang
2022-11-25 10:58               ` [virtio] " Cornelia Huck
2022-11-25 12:08               ` Michael S. Tsirkin
2022-11-23 21:08 ` [PATCH v9 03/10] admin: introduce group administration commands Michael S. Tsirkin
2022-11-24  5:52   ` [virtio-dev] " Jason Wang
2022-11-24  7:12     ` Michael S. Tsirkin
2022-11-24  7:42       ` Jason Wang
2022-11-24  8:03         ` Michael S. Tsirkin
2022-11-25  3:24           ` [virtio-comment] " Jason Wang
2022-11-24 12:21     ` [virtio-dev] " Cornelia Huck
2022-11-25  3:54       ` Jason Wang
2022-11-28 13:14   ` [virtio-comment] " Zhu Lingshan
2022-11-23 21:08 ` [PATCH v9 04/10] admin: introduce virtio admin virtqueues Michael S. Tsirkin
2022-11-28 13:12   ` [virtio-comment] " Zhu Lingshan
2022-11-23 21:08 ` [PATCH v9 05/10] pci: add admin vq registers to virtio over pci Michael S. Tsirkin
2022-11-24  6:00   ` Jason Wang
2022-11-24  7:14     ` Michael S. Tsirkin
2022-11-24  7:46       ` Jason Wang
2022-11-24  8:09         ` Michael S. Tsirkin
2022-11-25  3:27           ` Jason Wang
2022-11-23 21:08 ` [PATCH v9 06/10] mmio: document ADMIN_VQ as reserved Michael S. Tsirkin
2022-11-24  6:03   ` Jason Wang
2022-11-24  7:45     ` Michael S. Tsirkin
2022-11-23 21:08 ` [PATCH v9 07/10] ccw: " Michael S. Tsirkin
2022-11-23 21:08 ` [PATCH v9 08/10] admin: command list discovery Michael S. Tsirkin
2022-11-24  6:40   ` Jason Wang
2022-11-24  8:30     ` Michael S. Tsirkin
2022-11-25  3:38       ` [virtio-comment] " Jason Wang
2022-11-25 11:43         ` Michael S. Tsirkin
2022-11-28  4:34           ` Jason Wang
2022-11-28  7:42             ` Michael S. Tsirkin
2022-11-23 21:08 ` [PATCH v9 09/10] admin: conformance clauses Michael S. Tsirkin
2022-11-24  6:51   ` Jason Wang
2022-11-24  8:36     ` Michael S. Tsirkin
2022-11-25  3:50       ` Jason Wang
2022-11-25 11:42         ` [virtio] " Cornelia Huck
2022-11-25 11:56           ` Michael S. Tsirkin
2022-11-25 12:10             ` [virtio] " Cornelia Huck
2022-11-25 11:47         ` Michael S. Tsirkin [this message]
2022-11-28  4:32           ` Jason Wang
2022-11-28  7:39             ` Michael S. Tsirkin
2022-11-24 12:28     ` [virtio] " Cornelia Huck
2022-11-25  3:38       ` Jason Wang
2022-11-23 21:08 ` [PATCH RFC v9 10/10] ccw: document more reserved features Michael S. Tsirkin
2022-11-24  6:53   ` Jason Wang
2022-11-24  8:31     ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221125064414-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=Piotr.Uminski@intel.com \
    --cc=cohuck@redhat.com \
    --cc=hang.yuan@intel.com \
    --cc=jasowang@redhat.com \
    --cc=lingshan.zhu@intel.com \
    --cc=mgurtovoy@nvidia.com \
    --cc=nrupal.jani@intel.com \
    --cc=parav@nvidia.com \
    --cc=pasic@linux.ibm.com \
    --cc=sgarzare@redhat.com \
    --cc=shahafs@nvidia.com \
    --cc=stefanha@redhat.com \
    --cc=virtio-comment@lists.oasis-open.org \
    --cc=virtio-dev@lists.oasis-open.org \
    --cc=virtio@lists.oasis-open.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.