forked from oasis-tcs/virtio-spec
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtransport-msg.tex
More file actions
2071 lines (1814 loc) · 105 KB
/
transport-msg.tex
File metadata and controls
2071 lines (1814 loc) · 105 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\section{Virtio Over Messages}\label{sec:Virtio Transport Options / Virtio Over Messages}
\newcommand{\conceptref}[1]{\hyperref[sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / #1]{#1}}
\newcommand{\msgref}[1]{\hyperref[sec:Virtio Transport Options / Virtio Over Messages / Transport Messages / VIRTIO_MSG_#1]{VIRTIO_MSG_#1}}
\newcommand{\busref}[1]{\hyperref[sec:Virtio Transport Options / Virtio Over Messages / Bus Messages / BUS_MSG_#1]{BUS_MSG_#1}}
\newcommand{\msgdef}[1]{\subsubsection{VIRTIO_MSG_#1}\label{sec:Virtio Transport Options / Virtio Over Messages / Transport Messages / VIRTIO_MSG_#1}}
\newcommand{\busdef}[1]{\subsubsection{BUS_MSG_#1}\label{sec:Virtio Transport Options / Virtio Over Messages / Bus Messages / BUS_MSG_#1}}
This section defines \textbf{virtio-msg}, a transport mechanism that encapsulates
virtio operations as discrete message exchanges rather than relying on PCI or
memory-mapped I/O regions. It separates bus-level functionality (e.g., device
enumeration, hotplug events) from device-specific operations (e.g., feature
negotiation, virtqueue setup), ensuring that a single, generic transport layer
can be reused across multiple bus implementations.
virtio-msg addresses several key objectives:
\begin{itemize}
\item \textbf{Support multiple bus implementations:}
Systems can rely on various communication methods such as hypercalls, local
IPC, network channels, or device trees for enumerating devices. virtio-msg
defines a common transport interface suitable for any of these mechanisms.
\item \textbf{Reduce per-bus complexity:}
Buses can implement a fully message-based workflow (including optional
enumeration via \busref{GET_DEVICES} and hotplug via \busref{EVENT_DEVICE})
or they can discover and manage devices through
alternative means such as platform firmware data. In either case, they
forward transport messages to and from each device.
\item \textbf{Preserve virtio semantics:}
The transport leverages standard virtio concepts (features, configuration
space, virtqueues), so existing virtio drivers and device implementations can
integrate smoothly once a device is discovered.
\end{itemize}
\subsection{Basic Concepts}
\label{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts}
The virtio-msg transport relies on a set of foundational concepts to ensure
reusability across different bus implementations and flexibility in device
capabilities. This section defines those concepts and clarifies how they apply,
regardless of whether the bus leverages message-based enumeration or platform
data for device discovery.
\subsubsection{High-Level Architecture}
virtio-msg operates around two layers:
\begin{enumerate}
\item \textbf{Bus Layer}: A \emph{bus instance} exposes zero or more virtio
devices. It discovers available devices through mechanisms such as:
\begin{itemize}
\item Optional message-based queries (\busref{GET_DEVICES}),
\item External data sources (e.g., device tree, ACPI tables, hypervisor
firmware calls),
\item Dynamic hotplug notifications (optionally via \busref{EVENT_DEVICE}).
\end{itemize}
Once a device number is identified, regardless of discovery method, the bus
layer exposes that device number and availability state to the driver side
of the transport.
\item \textbf{Transport Layer}: After the bus knows about a device, the
virtio-msg transport handles all device-specific operations:
\begin{itemize}
\item Retrieving and setting features (\msgref{GET_DEVICE_FEATURES},
\msgref{SET_DRIVER_FEATURES}),
\item Accessing the device configuration space (\msgref{GET_CONFIG},
\msgref{SET_CONFIG}),
\item Setting up virtqueues (\msgref{SET_VQUEUE}, \msgref{RESET_VQUEUE}),
\item Managing status and runtime notifications (\msgref{SET_DEVICE_STATUS},
\msgref{EVENT_USED}, etc.).
\end{itemize}
These transport messages remain the same across different bus instances,
allowing a single virtio-msg driver component to function in multiple
environments.
\end{enumerate}
\subsubsection{Relationship Between Bus and Transport}
\label{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Relationship between bus and transport}
This subsubsection explains the division of responsibilities: the bus layer is
the mandatory carrier that moves messages between driver and device endpoints
(e.g., over IPC, shared memory with signaling or hardware messaging), while
the virtio-msg transport defines the semantics of those messages.
virtio-msg groups messages into two categories:
\begin{description}
\item[\textbf{Bus Messages}:]
Intended for global bus operations such as enumerating device numbers
(\busref{GET_DEVICES}), managing device hotplug events (\busref{EVENT_DEVICE})
or assessing bus-wide health (\busref{PING}).
These messages are \emph{optional} in environments where
device discovery or state changes occur through other means (e.g., device
tree). However, if a bus chooses to handle those tasks via messages,
it implements the appropriate bus message definitions described in this
section.
\item[\textbf{Transport Messages}:]
Used for device-specific operations, such as:
\begin{itemize}
\item Retrieving or setting features (\msgref{GET_DEVICE_FEATURES},
\msgref{SET_DRIVER_FEATURES}),
\item Accessing device configuration (\msgref{GET_CONFIG},
\msgref{SET_CONFIG}),
\item Managing virtqueues (\msgref{SET_VQUEUE}, \msgref{RESET_VQUEUE}),
\item Handling device status and notifications (\msgref{SET_DEVICE_STATUS},
\msgref{EVENT_USED}, etc.).
\end{itemize}
\end{description}
This separation lets a bus remain minimal if it obtains device information from
firmware tables, while still supporting fully message-based enumeration and
hotplug when desired.
\busnormative{\paragraph}{Bus Message Implementation}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Relationship between bus and transport / Bus Messages}
\begin{itemize}
\item A bus implementation MAY support any subset of \busref{GET_DEVICES},
\busref{PING}, and \busref{EVENT_DEVICE}.
\item If a bus implementation supports one of these bus messages, it MUST
conform to the normative definition for that message.
\end{itemize}
\busnormative{\paragraph}{Transport Message Forwarding}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Relationship between bus and transport / Transport Message Forwarding}
\begin{itemize}
\item A bus implementation MUST validate the device number in each transport
message before forwarding it.
\item A bus implementation MUST relay each transport message to the device
number identified in the message header, regardless of how it
discovered or enumerated that device.
\item A bus implementation SHOULD treat transport messages as opaque apart
from enforcing generic transport limits, such as the advertised maximum
message size, and SHOULD NOT modify the transport payload.
\item If a bus implementation cannot validate or route a transport request
that expects a response, it MUST surface a transport-visible failure
for that request.
\item If a bus implementation cannot validate or route a one-way transport
event, it MAY drop the event or handle it according to
message-specific bus requirements.
\end{itemize}
\subsubsection{Known Bus Implementation Examples}
\label{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Known Bus Implementation Examples}
This subsubsection lists informative examples of bus implementations and related
work for virtio-msg.
\begin{itemize}
\item \textbf{Virtio Message Bus over FF-A}: specified by Arm in
\hyperref[intro:FFA-BUS]{[FFA-BUS]}.
\item \textbf{Virtio Message Bus over PCI for AMP}: under development; proof
of concept:
\url{https://github.com/wmamills/hvac-demo}.
\item \textbf{Virtio Message Bus over Xen grant tables and events}: under
discussion.
\end{itemize}
\subsubsection{System Topology}
A virtio-msg system contains the following elements:
\begin{itemize}
\item \textbf{Bus Instances and Devices}: Each bus instance advertises its
capabilities (e.g., transport revision, maximum message size) and
discovers devices via message-based queries or external data sources.
Every discovered device has a unique \emph{device number}.
\item \textbf{Driver}: Communicates with the bus to learn about
available devices. Once a device is recognized, the driver uses the
common transport messages to perform feature negotiation, configuration,
and virtqueue setup.
\item \textbf{Device}: Implements virtio device functionality and
responds to the transport messages. The bus forwards these messages to
the correct device instance based on device number.
\end{itemize}
\subsubsection{Transport Revisions and Maximum Message Size}
\label{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Revisions}
Each \textbf{virtio-msg bus instance} advertises the following to the transport
layer:
\begin{itemize}
\item \textbf{Transport revision}: the protocol version supported by the bus
instance (independent of the overall Virtio specification version).
\item \textbf{Maximum message size}: the largest message size (in bytes) that
can be carried per request or response, including the common header.
\item \textbf{Transport feature bits}: revision-specific optional features
implemented by the bus instance.
\end{itemize}
Transport feature bits are determined per bus instance. When both sides expose
transport feature masks, the bus instance presents only the common subset as
the effective transport feature mask for that bus instance.
The mechanism for obtaining these parameters is implementation-defined and can
vary between bus instances. Common approaches include:
\begin{itemize}
\item Reading firmware or device-tree data that describes each bus instance,
\item Performing a message exchange during bus setup to retrieve the values,
\item Relying on per-bus configuration structures or driver-specific defaults.
\end{itemize}
\busnormative{\paragraph}{Advertising Transport Parameters}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Revisions / Advertising Transport Parameters}
\begin{itemize}
\item Each bus instance MUST make its transport revision, maximum message
size, and transport feature bits available to the virtio-msg transport
before any transport messages are exchanged for that device.
\item A bus instance MUST expose transport feature bits independently of the
device feature blocks exchanged by \msgref{GET_DEVICE_FEATURES} and
\msgref{SET_DRIVER_FEATURES}.
\item A bus instance MUST advertise only the transport feature bits supported
by both sides of that bus instance.
\item A bus instance MUST apply the same limits to both driver-originated and
device-originated transport messages.
\item For an active device, a bus instance MUST treat the advertised
transport revision, maximum message size, and transport feature bits as
stable.
\item If these values change, a bus instance MUST notify the transport layer
and MUST require transport-layer revalidation before accepting
additional transport messages for the affected device.
\end{itemize}
\drivernormative{\paragraph}{Respecting Bus Limits}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Revisions / Driver Limits}
\begin{itemize}
\item A driver MUST NOT send a transport message whose total size exceeds the
maximum message size advertised for the target bus instance.
\item A driver MUST NOT rely on transport features or messages that require a
higher transport revision than the bus instance reports.
\end{itemize}
\devicenormative{\paragraph}{Respecting Bus Limits}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Revisions / Device Limits}
\begin{itemize}
\item A device MUST ensure its responses and device-originated messages do
not exceed the maximum message size advertised by the bus instance that
relays them.
\item A device MUST NOT require transport features or messages beyond the
transport revision reported by the bus instance, and MUST respond with
an error or ignore requests for unsupported features.
\end{itemize}
\paragraph{virtio-msg transport revisions}
The following table lists the currently defined virtio-msg transport revisions
and their protocol-defined maximum message sizes. Transport feature bits are
defined separately in
\ref{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Transport Feature Bits}.
\begin{tabular}{ |l|l|l| }
\hline
\field{revision} & \field{maximum size} & remarks \\
\hline \hline
1 & 52-65535 & Virtio Message Revision 1 \\
\hline
\end{tabular}
The table reflects the protocol-defined maximum size; the recommended
advertised maximum remains 264 bytes for interoperability.
Note that a change in the virtio standard does not necessarily
correspond to a change in the virtio-msg transport revision.
The maximum message size is specified from the transport-layer point of view
and includes the 8-byte common header plus payload. Any extra encapsulation
imposed by the underlying bus (for example, a framing header) does not count
against this limit. Today the largest practical inline configuration payload is
244 bytes: messages such as GET_CONFIG and SET_CONFIG use 12 bytes of
message-specific fields, leaving up to 244 bytes for device configuration data
in one transfer when the recommended 264-byte maximum message size is used.
Larger configuration regions can be accessed through multiple exchanges without
requiring a larger per-message limit.
\busnormative{\paragraph}{Message Size Bounds}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Revisions / Message Size}
\begin{itemize}
\item A bus implementation MUST advertise a maximum message size of at least
52 bytes.
\item A bus implementation SHOULD NOT advertise a maximum message size that
exceeds 264 bytes (256-byte payload plus the common header).
\end{itemize}
\paragraph{Versioning and Forward Compatibility}
A higher transport revision or additional transport feature bits extend the
protocol with new messages or capabilities. Implementations are expected to
remain interoperable across revisions: devices and drivers designed for a newer
revision still implement the mandatory messages and semantics defined in prior
revisions.
\drivernormative{\paragraph}{Revision Compatibility}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Versioning and Forward Compatibility / Driver}
\begin{itemize}
\item A driver that negotiates transport revision $N$ MUST implement all
mandatory driver behavior defined for revisions $1$ through $N$.
\item If a driver receives a device-originated message or feature indication
that requires an unsupported revision or transport feature, it MUST
ignore the message (or treat the request as failed) and MUST NOT act on
partially understood data.
\end{itemize}
\devicenormative{\paragraph}{Revision Compatibility}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Versioning and Forward Compatibility / Device}
\begin{itemize}
\item A device that advertises transport revision $N$ MUST implement all
mandatory device behavior defined for revisions $1$ through $N$.
\item If a device receives a driver request that relies on an unsupported
revision or transport feature, it MUST reject the request using the
message-specific error mechanism (if any) or silently ignore it.
\end{itemize}
\busnormative{\paragraph}{Revision Compatibility}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Versioning and Forward Compatibility / Bus}
\begin{itemize}
\item A bus instance that advertises transport revision $N$ MUST satisfy every
bus requirement defined for revisions $1$ through $N$.
\item If a bus instance cannot forward a message because it requires an
unsupported revision or transport feature, it MUST surface a transport
error or drop the message without forwarding it.
\end{itemize}
\subsubsection{Transport Feature Bits}
\label{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Transport Feature Bits}
Transport feature bits are bus-instance parameters. They are advertised as part
of the transport parameters described in
\ref{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Revisions}
and are not carried in the device feature blocks exchanged by
\msgref{GET_DEVICE_FEATURES} and \msgref{SET_DRIVER_FEATURES}.
The following transport feature bits are defined:
\begin{tabular}{|l|l|l|p{7cm}|}
\hline
Bit & Name & Minimum revision & Meaning \\
\hline
0 & \texttt{VIRTIO\_MSG\_F\_STRICT\_CONFIG\_GENERATION} & 1 &
Select strict configuration semantics profile. When this feature is not
advertised for the bus instance, the baseline profile applies. See
\ref{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Configuration Semantics Profiles}. \\
\hline
\end{tabular}
\subsubsection{Device Numbers and Enumeration}
\label{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts /
Device Numbers}
Each virtio-msg bus instance contains zero or more \emph{devices}, identified
by a 16-bit \textbf{device number}. The device number is a bus-assigned
identifier and is distinct from the virtio device ID (device type) returned by
\msgref{GET_DEVICE_INFO}. Buses discover these device numbers through
mechanisms such as:
\begin{itemize}
\item \textbf{Message-Based Enumeration}: Using \busref{GET_DEVICES} to query
which numbers exist (optional).
\item \textbf{Platform Data}: A device tree, ACPI tables, or hypervisor calls
might inform the bus of available device numbers and their properties.
\end{itemize}
The 16-bit device-number space provides roughly 65k device slots per bus
instance. Deployments that require more devices can instantiate multiple bus
instances and distribute devices across those instances.
Once a bus confirms that a device number is valid, regardless of the discovery
method, it exposes that number to the driver side of the transport. The driver
then issues \msgref{GET_DEVICE_INFO} as the first transport message for that
device number before other transport operations.
\busnormative{\paragraph}{Device Number Assignment}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Device Numbers / Assignment}
\begin{itemize}
\item A bus implementation MUST assign a unique device number to every
device on a given bus instance.
\item A bus implementation SHOULD prevent reuse of a device number
immediately after a device is removed, to reduce race conditions with
delayed messages associated with the removed device.
\item A bus implementation MUST provide the driver with sufficient
information, either via \busref{GET_DEVICES}, \busref{EVENT_DEVICE},
or equivalent platform data, to discover each valid device number.
\end{itemize}
\subsubsection{Configuration Semantics Profiles}
\label{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Configuration Semantics Profiles}
virtio-msg defines two configuration semantics profiles selected by the
transport feature bits advertised for the bus instance:
\begin{itemize}
\item \textbf{Baseline profile}: applies when
\texttt{VIRTIO\_MSG\_F\_STRICT\_CONFIG\_GENERATION} is not advertised for
the bus instance.
\item \textbf{Strict profile}: applies when
\texttt{VIRTIO\_MSG\_F\_STRICT\_CONFIG\_GENERATION} is advertised for the
bus instance.
\end{itemize}
The profiles apply to \msgref{GET_CONFIG}, \msgref{SET_CONFIG}, and
\msgref{EVENT_CONFIG}.
\drivernormative{\paragraph}{Configuration Semantics Profiles}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Configuration Semantics Profiles / Driver}
\begin{itemize}
\item A driver MUST determine the active profile before issuing
\msgref{SET_CONFIG}.
\item A driver MUST determine the active profile from the transport feature
bits advertised for the target bus instance, not from
\msgref{GET_DEVICE_FEATURES}/\msgref{SET_DRIVER_FEATURES}.
\item In any profile, a driver SHOULD use generation values from
\msgref{GET_CONFIG} and \msgref{EVENT_CONFIG} to detect concurrent
configuration changes and SHOULD re-read required configuration until
it observes a stable generation value.
\item In baseline profile, a driver MUST set \field{generation} to 0 in
\msgref{SET_CONFIG} requests.
\item In baseline profile, upon \msgref{EVENT_CONFIG}, a driver SHOULD refresh
required configuration via \msgref{GET_CONFIG} when event data is
omitted or when \field{offset} and \field{length} are zero.
\item In strict profile, a driver MUST track generation values from
\msgref{GET_CONFIG}/\msgref{EVENT_CONFIG} and MUST include its most
recent generation value in \msgref{SET_CONFIG}.
\item In strict profile, if a \msgref{SET_CONFIG} request is rejected due to a
mismatched generation count, a driver SHOULD issue \msgref{GET_CONFIG}
to obtain the latest configuration data and generation count before
retrying.
\item In any profile, a driver MUST NOT assume generation count is monotonic
or preserved across device resets.
\end{itemize}
\devicenormative{\paragraph}{Configuration Semantics Profiles}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Configuration Semantics Profiles / Device}
\begin{itemize}
\item A device MUST apply the configuration semantics profile selected by the
transport feature bits advertised for the bus instance that relays its
messages.
\item In any profile, a device MUST provide its current generation count in
\msgref{GET_CONFIG} responses, \msgref{SET_CONFIG} responses, and
\msgref{EVENT_CONFIG} messages.
\item In any profile, a device MUST change \field{generation} whenever there
is a possibility that two accesses to the device configuration space
can observe different versions of that space, as described in
\ref{sec:Basic Facilities of a Virtio Device / Device Configuration Space}.
\item In baseline profile, a device MUST ignore request \field{generation} in
\msgref{SET_CONFIG}. For requests that are otherwise valid, the device
MUST apply the write regardless of request \field{generation} and MUST
NOT reject \msgref{SET_CONFIG} due solely to generation mismatch.
\item A device MUST NOT send \msgref{EVENT_CONFIG} solely because a
\msgref{SET_CONFIG} request carried a mismatched \field{generation}
value.
\item In any profile, a device MAY send a generic
\msgref{EVENT_CONFIG} notification with \field{offset} and
\field{length} set to 0 and no \field{data} when the affected
configuration change cannot be represented as a bounded range
(for example, when only an equivalent out-of-band notification is
available without affected-range details).
\item A device transport layer implementation MUST originate
\msgref{EVENT_CONFIG} whenever it changes configuration data in a way
that is visible to the driver.
\item A device transport layer implementation MUST originate
\msgref{EVENT_CONFIG} for status only when a device-originated
asynchronous status change requires asynchronous reporting to the
driver.
\item A device MUST NOT send \msgref{EVENT_CONFIG} solely because the driver
wrote status via \msgref{SET_DEVICE_STATUS}; such writes MAY be
followed by \msgref{EVENT_CONFIG} only if a distinct
device-originated asynchronous status change occurs afterward.
\item If \msgref{EVENT_CONFIG} reports only a status change, a device MUST
set \field{offset} and \field{length} to 0.
\item In any profile, a device MAY reset generation count, including when it
resets internal state.
\item In strict profile, if a \msgref{SET_CONFIG} request includes a
\field{generation} count that does not match the device's current
count, the device MUST reject the request.
\item If updated configuration data cannot fit in a single
\msgref{EVENT_CONFIG}, a device SHOULD send an \msgref{EVENT_CONFIG}
without configuration data and MUST make updated data available via
\msgref{GET_CONFIG}. In strict profile, the device SHOULD set
\field{offset}/\field{length} to the affected range.
\end{itemize}
This subsection defines baseline and strict semantics together so that
generation and mismatch behavior remains explicit and consistent across message
definitions.
\subsubsection{Device Feature Blocks}
\label{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Device Feature Blocks}
Device feature bits are organized into 32-bit blocks accessed by
\msgref{GET_DEVICE_FEATURES} and \msgref{SET_DRIVER_FEATURES}. Each block
represents up to 32 feature bits:
\begin{itemize}
\item \textbf{Block Index}: The starting block (e.g., block 0 for
features 0-31, block 1 for features 32-63, etc.).
\item \textbf{Number of Blocks}: How many blocks the driver wishes to retrieve
or modify in a single message.
\item \textbf{Feature Data}: The 32-bit values representing either the
device-offered feature bits or the driver-selected subset for the
selected blocks.
\end{itemize}
Virtio-msg device feature blocks may include core virtio feature bits. They are
distinct from the transport feature bits defined in
\ref{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Transport Feature Bits}.
This transport does not support VIRTIO\_F\_NOTIF\_CONFIG\_DATA; device feature
negotiation requirements are defined in
\ref{sec:Virtio Transport Options / Virtio Over Messages / Device Initialization / Device Features}.
\devicenormative{\paragraph}{Device Feature Blocks}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Device Feature Blocks / Device}
\begin{itemize}
\item When \msgref{GET_DEVICE_FEATURES} covers blocks that extend beyond the
features a device implements, the device MUST return zero for the
feature data in those positions.
\item After processing \msgref{SET_DRIVER_FEATURES}, a device MUST update
only the driver-selected feature blocks addressed by that request and
MUST leave all other driver-selected feature blocks unchanged.
\item A device MUST report the device-offered feature set in
\msgref{GET_DEVICE_FEATURES} responses and MUST NOT reflect the
driver-selected subset in those responses.
\end{itemize}
\subsubsection{Error Signaling}
\label{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Error Signaling}
Transport errors can arise from malformed messages, routing failures inside a
bus implementation, or faults while processing a valid request in the device
transport layer.
Implementations should handle such faults locally where possible. For
request/response messages that use the existing wire format, the completion
contract is deterministic:
\begin{itemize}
\item For a valid, supported request accepted for processing, completion is
exactly one protocol response.
\item If routing, policy, timeout, or completion constraints prevent that
response, completion is a transport-visible failure surfaced by the
bus implementation.
\item One-way events do not define a completion outcome. Unless a
message-specific rule states otherwise, they MAY be dropped without a
protocol error response or transport-visible failure.
\item Malformed or unsupported messages are discarded without protocol error
responses; for request/response messages, the originating side observes
completion according to the bounded transport-visible failure policy.
\end{itemize}
\busnormative{\paragraph}{Error Handling}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Error Signaling / Bus}
\begin{itemize}
\item A bus implementation MUST apply a bounded completion policy for each
valid, supported transport request that expects a response.
\item A bus implementation MUST complete each such request with exactly one
of the following outcomes:
\begin{itemize}
\item one protocol response, or
\item a transport-visible failure when routing, policy, timeout, or
completion constraints prevent response delivery.
\end{itemize}
\item A bus implementation MUST NOT wait indefinitely for response delivery.
\item A bus implementation MUST treat malformed headers or unsupported bus
\field{msg_id} values in bus messages as invalid, MUST discard them
without generating additional protocol traffic, and MAY log the
condition for diagnostics.
\item A bus implementation MUST NOT validate transport \field{msg_id} values;
unsupported transport \field{msg_id} handling is performed by the
transport layer.
\item A bus implementation MUST NOT generate error responses to event
(one-way) messages.
\item Unless a message-specific rule states otherwise, a bus implementation
MAY discard an event without surfacing a completion outcome.
\end{itemize}
\drivernormative{\paragraph}{Error Handling}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Error Signaling / Driver}
\begin{itemize}
\item A driver transport layer implementation receiving a malformed or
unsupported transport message MUST discard it without producing further
protocol traffic.
\item A driver MUST apply a bounded timeout and retry policy when waiting for
transport-request completion, including reset-completion checks.
\item If that bounded policy is exhausted, a driver MUST treat the request as
failed and MUST perform recovery using the reset and status semantics
defined in
\ref{sec:Virtio Transport Options / Virtio Over Messages / Device Operation}.
\end{itemize}
\devicenormative{\paragraph}{Error Handling}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Error Signaling / Device}
\begin{itemize}
\item A device transport layer implementation receiving a malformed or
unsupported transport message MUST discard it without producing further
protocol traffic.
\item Recovery actions taken in response to an error (such as retries,
selective resets, or device removal) MUST follow the normative reset and
status semantics defined in
\ref{sec:Virtio Transport Options / Virtio Over Messages / Device Operation}.
\end{itemize}
This specification does not define a dedicated error-reporting message.
Transport-visible failure is surfaced under the existing wire model as a bus
completion outcome for a request, not as a new protocol message.
Some bus implementations may reject requests that violate their local policy
or that are not valid for the current device state. In such cases, the bus may
return a bus-specific error indication to the transport, which can then surface
that failure to the driver.
\subsubsection{Endianness}
\label{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Endianness}
Unless otherwise stated, all numeric fields defined for virtio-msg messages use
little-endian encoding.
\drivernormative{\paragraph}{Endianness}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Endianness / Driver}
\begin{itemize}
\item A driver MUST encode and decode the common header and payload fields
defined by this transport using little-endian byte order.
\end{itemize}
\devicenormative{\paragraph}{Endianness}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Endianness / Device}
\begin{itemize}
\item A device MUST emit and consume the common header and payload fields
defined by this transport using little-endian byte order.
\end{itemize}
\subsubsection{Common Message Format}
\label{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Common Message Format}
All virtio-msg exchanges, whether \emph{bus messages} or \emph{transport
messages}, begin with an 8-byte header followed by an optional payload. The
fields below describe the wire format for that header.
The header layout is:
\begin{lstlisting}
struct virtio_msg_header {
u8 type; /* request/response + bus/transport */
u8 msg_id; /* message id */
le16 dev_num; /* target device number; bus messages MUST use 0 */
le16 token; /* bus-managed correlation identifier */
le16 msg_size; /* total size: header (8) + payload */
u8 payload[];
};
\end{lstlisting}
Field semantics:
\begin{itemize}
\item \field{type}:
\begin{itemize}
\item Bit[0]: 0=request, 1=response. Messages whose \field{msg_id} identifies
an event MUST use Bit[0]=0 and MUST NOT be sent as responses.
\item Bit[1]: 0=transport message, 1=bus message. This bit selects whether
\field{msg_id} is interpreted in the transport-message namespace or the
bus-message namespace.
\item Bits[2..7]: reserved for future use.
\end{itemize}
\item \field{msg_id}: Message ID identifying the message definition. Ranges
are defined in
\ref{sec:Virtio Transport Options / Virtio Over Messages / Transport Messages}
and
\ref{sec:Virtio Transport Options / Virtio Over Messages / Bus Messages}.
\begin{itemize}
\item Bits[0..5]: message number within the selected range.
\item Bit[6]: 0=request/response message, 1=event.
\item Bit[7]: 0=standardized message ID, 1=implementation-defined message ID.
\end{itemize}
\item \field{dev_num}: For transport messages, the device number that should
receive the message. Device number 0 is not reserved for transport
messages. Bus messages are identified by \field{type} and MUST carry
\field{dev_num}=0.
\item \field{token}: Correlation identifier owned and managed by the bus.
Drivers and devices treat this field as opaque. A bus implementation MAY
transparently insert or overwrite \field{token} values on the request leg,
response leg, or both to correlate concurrent requests and responses or to
compensate for transport-specific reordering. A device copies the request
\field{token} into the matching response before any bus-side rewrite.
\item \field{msg_size}: Total size in bytes of the complete message (header
plus payload).
\item \field{payload}: Operation-specific data. If a bus introduces extra
padding bytes, those bytes are not part of the payload semantics.
\end{itemize}
\drivernormative{\paragraph}{Common Header}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Common Message Format / Driver}
\begin{itemize}
\item A driver MUST set bits 2..7 of \field{type} to zero and MUST treat them
as reserved when parsing received headers.
\item A driver MUST ensure \field{msg_size} reflects the total message length
(header plus payload) and MUST NOT exceed the maximum message size
advertised by the bus instance.
\item When sending a transport message, a driver MUST set \field{dev_num} to
the intended device number.
\item If a driver introduces padding bytes that become part of the transport
payload, it MUST set those bytes to zero.
\item A driver MUST treat the \field{token} field as opaque and MUST NOT rely
on its value when processing received messages.
\end{itemize}
\devicenormative{\paragraph}{Common Header}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Common Message Format / Device}
\begin{itemize}
\item A device MUST set bits 2..7 of \field{type} to zero in transmitted
messages and MUST ignore those bits on receive.
\item A device MUST ensure \field{msg_size} reflects the total message length
(header plus payload) and does not exceed the bus's advertised maximum.
\item When sending a transport message, a device MUST set \field{dev_num} to
its own device number.
\item A device MUST ignore padding bytes that are documented as bus-specific
and MUST zero any such bytes it introduces into the transport payload.
\item A device MUST treat the \field{token} field as opaque and MUST NOT rely
on its value when processing received messages.
\item For each request/response message pair, a device MUST copy the
\field{token} value from the received request into the matching
response.
\end{itemize}
\busnormative{\paragraph}{Common Header}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Common Message Format / Bus}
\begin{itemize}
\item A bus implementation MUST deliver bus messages with \field{dev_num}=0
and MUST NOT alter \field{dev_num} for transport messages beyond the
routing needed to reach the addressed device.
\item A bus implementation MUST set bits 2..7 of \field{type} to zero when
generating bus messages and MUST ignore those bits when forwarding
transport messages.
\item If the bus adds framing or padding bytes around the common header or
payload, it MUST set those bytes to zero before delivering the message
to the opposite side and MUST present the same zero padding when the
opposite side reads a message.
\item A bus implementation owns the \field{token} field; it MAY insert or
overwrite values for correlation purposes and MUST ensure that any such
use is transparent to drivers and devices.
\item A bus implementation MAY rewrite \field{token} values on the request
path, response path, or both, provided this remains transparent to
drivers and devices.
\item A bus implementation MUST ensure that any use of \field{token} for
request/response correlation or to compensate for transport-specific
reordering remains transparent to drivers and devices.
\end{itemize}
A message originator MUST transmit reserved header bits and unspecified header
values as zero, and receivers MUST ignore those bits on receive to preserve
forward compatibility.
Virtqueue descriptors and buffer data are exchanged via shared memory or other
DMA-accessible memory, as with other virtio transports. Transport messages are
used for control operations, configuration, and notifications, not for
virtqueue data transfer.
\subsubsection{Message Ordering}
\label{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Ordering}
Transport messages fall into two classes: requests (which expect responses) and
events (which are one-way). Drivers and devices do not interpret the
\field{token} field directly. A bus implementation MAY have multiple
outstanding requests for the same device number and MAY use the bus-owned
\field{token} field to correlate each response with its originating request.
The device copies the received request token into the matching response, and
the bus may transparently rewrite token values on either leg while preserving
request/response correlation for both endpoints.
Events are asynchronous notifications and MAY be delivered at any time
relative to request/response traffic. Messages for different device numbers MAY
be interleaved by the bus.
Some response payloads repeat request parameters (for example, indices or
offsets). Drivers and devices MAY use these repeated values for validation,
but request/response association is determined by the bus implementation's
correlation state, not by response ordering or by those repeated values.
\busnormative{\paragraph}{Message Ordering}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Ordering / Bus}
\begin{itemize}
\item For each transport request that expects a response, a bus
implementation MUST preserve sufficient correlation state to complete
that request with exactly one protocol response or one
transport-visible failure.
\item A bus implementation MAY forward multiple requests concurrently for the
same device number.
\item For each driver/device pair, a bus implementation MUST preserve request
order when presenting requests to the device-side transport.
\item For concurrently outstanding requests, a bus implementation MAY deliver
responses in an order different from the corresponding request order,
provided it correlates each response with the originating request
before exposing completion to the driver side.
\item A bus implementation MUST NOT delay an event solely to preserve a
request-before-event or response-before-event ordering rule.
\end{itemize}
\devicenormative{\paragraph}{Message Ordering}{Virtio Transport Options / Virtio Over Messages / Basic Concepts / Ordering / Device}
\begin{itemize}
\item A device MUST process requests in receive order for each driver/device
pair.
\item A device MUST send exactly one response for each valid, supported
request it receives and accepts for processing.
\item For malformed or unsupported requests, a device MUST discard the
request without sending a protocol response.
\end{itemize}
\subsection{Device Discovery}\label{sec:Virtio Transport Options / Virtio Over Messages / Device Discovery}
A virtio-msg implementation can learn about devices via bus-level enumeration
(e.g., \busref{GET_DEVICES}), platform data (e.g., device tree, ACPI), or
hypervisor/firmware interfaces. The following informative text describes
typical flows; the normative obligations follow.
Bus implementations discover their devices through a mix of platform data,
hypervisor-provided enumeration, or message-based queries such as
\busref{GET_DEVICES}. This specification defines \busref{GET_DEVICES} for
environments that prefer message-driven enumeration, but it does not require
its use when equivalent information is already known out-of-band.
\busnormative{\paragraph}{Device Discovery}{Virtio Transport Options / Virtio Over Messages / Device Discovery / Bus}
\begin{itemize}
\item A bus implementation MUST ensure that every device number it exposes to
the driver has been validated via either platform data or a successful
query such as \busref{GET_DEVICES}.
\item Once a device number is deemed present, the bus implementation MUST
expose that number to the driver side so the driver can issue
\msgref{GET_DEVICE_INFO}.
\item If a bus implementation provides an alternative enumeration mechanism
(e.g., ACPI, device tree), it MAY omit \busref{GET_DEVICES} provided the
alternative delivers equivalent information to the driver.
\end{itemize}
\subsection{Device Initialization}
\label{sec:Virtio Transport Options / Virtio Over Messages / Device Initialization}
After a bus has identified a virtio-msg device (whether by message-based
enumeration or platform-specific discovery), the driver undertakes a series of
steps to configure and ready the device for normal operation. This section
details the recommended order of operations and the associated messages.
\subsubsection{Initialization Flow Overview}
\label{sec:Virtio Transport Options / Virtio Over Messages / Device Initialization / Overview}
A typical device initialization flow includes:
\begin{enumerate}
\item \textbf{Early Discovery Exception:}
Query static parameters with \msgref{GET_DEVICE_INFO}. This is the only
transport message exception allowed before normal initialization sequencing.
\item \textbf{Reset And Baseline Status:}
Reset the device and transition status through ACKNOWLEDGE then DRIVER via
\msgref{SET_DEVICE_STATUS}.
\item \textbf{Negotiate Device Features:}
Read device feature blocks via \msgref{GET_DEVICE_FEATURES}, decide which
to enable, and send the selected subset via one or more
\msgref{SET_DRIVER_FEATURES} requests. Verify FEATURES\_OK via
\msgref{SET_DEVICE_STATUS}. Transport feature bits are bus-instance
parameters and are determined separately from this per-device exchange.
\item \textbf{Device-Specific Setup:}
Read or write configuration data with
\msgref{GET_CONFIG}/\msgref{SET_CONFIG} using the active configuration
semantics profile defined in
\ref{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Configuration Semantics Profiles},
then configure each virtqueue via \msgref{SET_VQUEUE} and verify settings
with \msgref{GET_VQUEUE}.
\item \textbf{Finalize Initialization:}
Use \msgref{SET_DEVICE_STATUS} to transition to DRIVER\_OK.
\end{enumerate}
After \msgref{GET_DEVICE_INFO}, a driver MUST follow the core virtio status
progression for initialization: reset, ACKNOWLEDGE, DRIVER, feature
negotiation and FEATURES\_OK verification, device-specific setup, then
DRIVER\_OK.
\drivernormative{\paragraph}{Initialization Flow}{Virtio Transport Options / Virtio Over Messages / Device Initialization / Overview / Driver}
\begin{itemize}
\item A driver MUST issue \msgref{GET_DEVICE_INFO} before attempting feature
negotiation or queue setup.
\item A driver MUST complete device feature negotiation via
\msgref{GET_DEVICE_FEATURES}/\msgref{SET_DRIVER_FEATURES}
and confirm the FEATURES\_OK state via \msgref{SET_DEVICE_STATUS} before
enabling virtqueues.
\item A driver MUST configure each virtqueue via \msgref{SET_VQUEUE} and
confirm its parameters (e.g., with \msgref{GET_VQUEUE}) before marking
the queue ready for I/O.
\item A driver MUST drive the device status transitions using
\msgref{SET_DEVICE_STATUS}, ensuring the device reaches DRIVER\_OK
before issuing normal I/O.
\end{itemize}
\subsubsection{Device Information}
\label{sec:Virtio Transport Options / Virtio Over Messages / Device Initialization / Device Information}
Once a device number is confirmed, the driver uses \msgref{GET_DEVICE_INFO} to
retrieve static identification data (device ID, vendor ID), the number of
feature blocks, configuration space size, maximum virtqueues, and any admin
virtqueue details. This information determines which virtio driver should bind
to the device, how many feature blocks to query, and how much configuration
space is valid.
\drivernormative{\paragraph}{Device Information}{Virtio Transport Options / Virtio Over Messages / Device Initialization / Device Information / Driver}
\begin{itemize}
\item A driver MUST use the configuration size reported via
\msgref{GET_DEVICE_INFO} to bound any offsets and lengths supplied in
\msgref{GET_CONFIG} and \msgref{SET_CONFIG} requests.
\end{itemize}
\subsubsection{Feature Negotiation}
\label{sec:Virtio Transport Options / Virtio Over Messages / Device Initialization / Device Features}
Drivers read available device feature bits in 32-bit blocks using
\msgref{GET_DEVICE_FEATURES}; the device returns the requested bitfields,
padding with zeros for any out-of-range blocks. To enable selected device
features, the driver sends the desired subset with one or more
\msgref{SET_DRIVER_FEATURES} requests and then updates the device status via
\msgref{SET_DEVICE_STATUS}, checking whether the FEATURES\_OK bit remains set.
Transport feature bits are bus-instance
parameters and are not part of this message exchange. Zero-padding and
block-scoped update semantics are defined in
\ref{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Device Feature Blocks}.
\drivernormative{\paragraph}{Feature Negotiation}{Virtio Transport Options / Virtio Over Messages / Device Initialization / Device Features / Driver}
\begin{itemize}
\item A driver MUST use \msgref{GET_DEVICE_FEATURES} to discover the feature
bits offered by the device and MUST write back only the features it
intends to enable via \msgref{SET_DRIVER_FEATURES}.
\item A driver MUST NOT negotiate VIRTIO\_F\_NOTIF\_CONFIG\_DATA.
\item After writing the desired features, the driver MUST attempt to set the
FEATURES\_OK bit using \msgref{SET_DEVICE_STATUS} and MUST check the
returned status to ensure the device accepted the set.
\end{itemize}
\devicenormative{\paragraph}{Feature Negotiation}{Virtio Transport Options / Virtio Over Messages / Device Initialization / Device Features / Device}
\begin{itemize}
\item A device MUST NOT offer VIRTIO\_F\_NOTIF\_CONFIG\_DATA.
\item If the device cannot support the driver-selected feature set presented
before FEATURES\_OK is processed, it MUST clear the FEATURES\_OK bit in
the status returned by \msgref{SET_DEVICE_STATUS}.
\end{itemize}
\subsubsection{Device Configuration}
\label{sec:Virtio Transport Options / Virtio Over Messages / Device Initialization / Device Configuration}
Drivers use \msgref{GET_CONFIG} to read portions of the configuration space by
supplying \field{offset} and \field{length}; the device returns the requested
data plus the configuration generation field. Writing is performed via
\msgref{SET_CONFIG}, which carries the same \field{offset}/\field{length} plus
generation and new data.
Generation-field handling follows the active profile defined in
\ref{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Configuration Semantics Profiles},
with strict profile defining generation-mismatch rejection for \msgref{SET_CONFIG}.
The message definitions for \msgref{GET_CONFIG} and \msgref{SET_CONFIG}
define request validation and completion behavior, while
\ref{sec:Virtio Transport Options / Virtio Over Messages / Basic Concepts / Configuration Semantics Profiles}
defines generation handling and \msgref{EVENT_CONFIG} semantics throughout
initialization and operation.
Configuration space is intended for device control and configuration data.
When a device can instead expose data through a virtqueue, that mechanism is
preferred; configuration reads and writes are asynchronous in virtio-msg and
may require the driver to wait for a response.
\subsubsection{Virtqueue Configuration}
\label{sec:Virtio Transport Options / Virtio Over Messages / Device Initialization / Virtqueue Configuration}
Drivers query virtqueue parameters with \msgref{GET_VQUEUE}, configure them via
\msgref{SET_VQUEUE}, and optionally reset them using \msgref{RESET_VQUEUE} (if
VIRTIO\_F\_RING\_RESET is negotiated). Each queue is typically configured by
reading its maximum size, provisioning descriptor/available/used buffers, and
then calling \msgref{SET_VQUEUE} with the chosen size, physical addresses, and
queue-state operation in \field{flags}. A \msgref{GET_VQUEUE} response with
\field{max_size}=0 indicates that the requested queue is not available for
configuration. The message definitions for \msgref{GET_VQUEUE},
\msgref{SET_VQUEUE}, and \msgref{RESET_VQUEUE} define the normative
queue-availability, reconfiguration, and reset rules; this subsection
describes the usual sequencing.
\subsubsection{Status Information}
\label{sec:Virtio Transport Options / Virtio Over Messages / Device Initialization / Status Information}
Drivers query the device status via \msgref{GET_DEVICE_STATUS} to observe
progress or detect errors, and they drive the Virtio status transitions via
\msgref{SET_DEVICE_STATUS}. Writing zero to the status field requests a device
reset, which can complete synchronously or asynchronously. The normative
status-reporting and reset-completion rules are defined by
\msgref{GET_DEVICE_STATUS} and \msgref{SET_DEVICE_STATUS}.
\subsubsection{Finalizing Initialization}
After configuring virtqueues and agreeing on features, the driver transitions
the device to DRIVER\_OK (and any other required status bits) via
\msgref{SET_DEVICE_STATUS}. At that point, the device is considered ready for
normal virtqueue I/O.
\drivernormative{\paragraph}{Final Status}{Virtio Transport Options / Virtio Over Messages / Device Initialization / Finalizing Initialization / Driver}
\begin{itemize}
\item A driver MUST set DRIVER\_OK via \msgref{SET_DEVICE_STATUS} only after
it has completed feature negotiation and initialized all required
virtqueues.
\item A driver MUST NOT queue normal I/O until the device reports a status
that includes DRIVER\_OK.
\item A driver MUST NOT supply buffers or send driver notifications for a
virtqueue until that queue has been configured via \msgref{SET_VQUEUE}.
\end{itemize}
\devicenormative{\paragraph}{Final Status}{Virtio Transport Options / Virtio Over Messages / Device Initialization / Finalizing Initialization / Device}
\begin{itemize}
\item A device MUST NOT process normal virtqueue I/O until the driver has set
DRIVER\_OK.
\item Once DRIVER\_OK is set, the device MUST begin processing virtqueue
requests subject to the negotiated features and queue configurations.
\end{itemize}
\subsection{Device Operation}
\label{sec:Virtio Transport Options / Virtio Over Messages / Device Operation}
Once a virtio-msg device is fully initialized (see
\ref{sec:Virtio Transport Options / Virtio Over Messages / Device Initialization}),
the driver and device exchange messages to perform I/O and respond to
configuration changes. This section details the primary messaging paths for
\emph{driver notifications}, \emph{device notifications}, and the handling of
runtime resets or shutdown sequences.
\subsubsection{Driver Notifications}
\label{sec:Virtio Transport Options / Virtio Over Messages / Device Operation / Driver Notifications}
Drivers and devices MAY select polling-only operation for virtqueue
availability/completion handling. In polling-only mode, \msgref{EVENT_AVAIL}
and \msgref{EVENT_USED} are not semantic requirements. When endpoints use
event-driven notifications, drivers use \msgref{EVENT_AVAIL} to notify the
device of available buffers. A driver-side bus implementation may forward
\msgref{EVENT_AVAIL} in-band or translate it into an out-of-band notification