Skip to content

Commit b813197

Browse files
virtio-msg: guarantee GET_DEVICES forward progress
Define count=0 as a valid GET_DEVICES request and response case, clarify empty-bitmap handling for reduced windows, and require next_offset to be 0 for terminal responses or strictly greater than the request offset for nonterminal responses. This removes zero-progress enumeration loops while preserving the existing sparse-window response model. Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
1 parent 3e2bd01 commit b813197

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

transport-msg.tex

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,49 +1943,59 @@ \subsubsection{Overview}
19431943
\end{lstlisting}
19441944

19451945
The (\field{offset}, \field{count}) tuple defines a window of \field{count}
1946-
consecutive device numbers beginning at \field{offset}. The number of present
1946+
consecutive device numbers beginning at \field{offset}. A request with
1947+
\field{count}=0 is valid and requests an empty window. The number of present
19471948
devices equals the number of set bits in the first \field{count} positions of
19481949
\field{bitmap}. The \field{bitmap} size in bytes is
19491950
\textbf{(\field{count} + 7) / 8}. The response \field{count} MUST NOT exceed
19501951
the request \field{count}. Responders SHOULD return the requested
19511952
\field{count} unless constrained
19521953
(e.g., by maximum message size) or when trailing parts of the requested window
19531954
contain no present device numbers; in those cases they MAY return a smaller
1954-
value, and the \field{bitmap} covers the reduced window. If no devices are
1955-
present in the requested window, returning \field{count}=0 and an empty
1956-
\field{bitmap} is valid.
1955+
value, and the \field{bitmap} covers the reduced window. A response with
1956+
\field{count}=0 returns an empty \field{bitmap}; this is valid for a request
1957+
with \field{count}=0 and also when no devices are present in the returned
1958+
window.
19571959

19581960
Example: a request with \field{offset}=0, \field{count}=16 might produce
19591961
\field{bitmap}=0b00100101 00000000 and \field{next_offset}=16. That indicates
19601962
devices 0, 2, and 5 are present within the 0-15 window and suggests continuing
19611963
at device number 16.
19621964

1963-
\paragraph{Intended usage}
1964-
Drivers MAY use this message to enumerate device numbers. Treat each window as
1965-
a snapshot, advance using \field{next_offset}, and confirm candidates via
1966-
\msgref{GET_DEVICE_INFO} before issuing other transport messages.
1965+
Drivers can use this message to enumerate device numbers. Each window can be
1966+
treated as a snapshot, advanced using \field{next_offset}, and validated with
1967+
\msgref{GET_DEVICE_INFO} before other transport messages are issued. A response
1968+
with \field{next_offset}=0 is terminal. Otherwise, \field{next_offset}
1969+
recommends a later starting device number and advances enumeration beyond the
1970+
request \field{offset}.
19671971

19681972
\busnormative{\paragraph}{GET\_DEVICES}{Virtio Transport Options / Virtio Over Messages / Bus Messages / GET_DEVICES / Bus}
19691973
\begin{itemize}
19701974
\item The bus-side responder MUST interpret \field{count} as a number of
19711975
device-number slots and MUST return a \field{bitmap} of
19721976
\textbf{(\field{count} + 7) / 8} bytes, packed least-significant-bit
19731977
first.
1974-
\item The bus-side responder MUST NOT return a \field{count} value greater
1978+
\item A request with \field{count}=0 is valid. In response to such a request,
1979+
the responding bus implementation MUST return \field{count}=0 and an
1980+
empty \field{bitmap}.
1981+
\item The responding bus implementation MUST NOT return a \field{count} value
1982+
greater
19751983
than the \field{count} value from the request.
19761984
\item If \field{count} is not a multiple of 8, the responder MUST set unused
19771985
bits in the last \field{bitmap} byte (positions at or above
19781986
\field{count}) to zero.
1979-
\item \field{next\_offset} MUST be 0 (indicating no further windows) or an
1980-
value $\ge \field{offset} + \field{count}$ recommending where the
1981-
driver should query next.
1987+
\item For a terminal response, the responding bus implementation MUST set
1988+
\field{next\_offset} to 0.
1989+
\item For a nonterminal response, the responding bus implementation MUST set
1990+
\field{next\_offset} to a value strictly greater than the request
1991+
\field{offset}.
19821992
\item Responders SHOULD return the requested \field{count} unless constrained
19831993
(e.g., by maximum message size) or when trailing parts of the requested
19841994
window contain no present device numbers; if a smaller \field{count} is
19851995
returned, the \field{bitmap} MUST still represent the window defined by
19861996
the echoed \field{offset} and \field{count}.
19871997
\item If no devices are present in the requested window, a responder MAY
1988-
return \field{count}=0 with a zero-\field{length} \field{bitmap}.
1998+
return \field{count}=0 with an empty \field{bitmap}.
19891999
\end{itemize}
19902000

19912001
\busdef{PING}

0 commit comments

Comments
 (0)