Skip to content

Commit 17d43fe

Browse files
committed
doc: doc: update HLD Emulated Devices
Transcode, edit, and upload HLD 0.7 section 5 (Emulated Devices), including - 5.1 USB Virtualization (merge with previously edited doc), - 5.2 UART virtualization (merge with previous edited doc), - NOT INCLUDING 5.3 (Automotive) I/O controller virtualization - 5.4 Watchdog virtualization (merge with previously edited doc) - 5.5 GVT-g GPU Virtualization (merge previously edited doc) Tracked-on: #1687 Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
1 parent bf88e24 commit 17d43fe

File tree

10 files changed

+218
-4
lines changed

10 files changed

+218
-4
lines changed

doc/developer-guides/hld/hld-emulated-devices.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
Emulated devices high-level design
44
##################################
55

6+
Full virtualization device models can typically
7+
reuse existing native device drivers to avoid implementing front-end
8+
drivers. ACRN implements several fully virtualized devices, as
9+
documented in this section.
10+
611
.. toctree::
712
:maxdepth: 1
813

9-
GVT-g GPU Virtualization <hld-APL_GVT-g>
14+
usb-virt-hld
1015
UART virtualization <uart-virt-hld>
1116
Watchdoc virtualization <watchdog-hld>
17+
random-virt-hld
18+
GVT-g GPU Virtualization <hld-APL_GVT-g>
85.3 KB
Loading
69 KB
Loading
138 KB
Loading
39 KB
Loading
38.9 KB
Loading
43 KB
Loading
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
.. _random_virtualization:
2+
3+
Random device virtualization
4+
############################
5+
6+
The virtual random device virtio-rnd provides a virtual hardware random
7+
source for UOS, based on virtio user mode framework. It simulates a PCI
8+
device based on virtio specification.
9+
10+
Architecture
11+
************
12+
13+
:numref:`rand-virt-arch` shows the Random Device Virtualization Architecture in ACRN.
14+
The green components are parts of the ACRN solution while the dark
15+
components are parts of Linux software or third party tools.
16+
17+
virtio-rnd is implemented as a virtio legacy device in the ACRN device
18+
model (DM), and is registered as a PCI virtio device to the guest OS
19+
(UOS). Tools such as :command:`od` (dump a file in octal or other format) can
20+
be used to read random values from ``/dev/random``. This device file in
21+
UOS is bound with the frontend virtio-rng driver. (The guest kernel must
22+
be built with ``CONFIG_HW_RANDOM_VIRTIO=y``). The backend
23+
virtio-rnd reads the HW random value from ``/dev/random`` in SOS and sends
24+
them to frontend.
25+
26+
.. figure:: images/rand-virt.png
27+
:align: center
28+
:name: rand-virt-arch
29+
30+
Random Device Virtualization in ACRN
31+
32+
How to Use
33+
**********
34+
35+
Add a pci slot to the device model acrn-dm command line, for example::
36+
37+
-s <slot_number>,virtio-rnd
38+
39+
Check if the frontend virtio_rng driver is available in UOS:
40+
41+
.. code-block:: console
42+
43+
# cat /sys/class/misc/hw_random/rng_available
44+
virtio_rng.0
45+
46+
Check if frontend virtio_rng is currently connected to ``/dev/random``:
47+
48+
.. code-block:: console
49+
50+
# cat /sys/class/misc/hw_random/rng_current
51+
virtio_rng.0
52+
53+
Read random values:
54+
55+
.. code-block:: console
56+
57+
# od /dev/random
58+
0000000 007265 175751 147323 164223 060601 057377 027072 106352
59+
0000020 040765 045645 155773 111724 037572 152033 036001 056073
60+
0000040 057164 065021 024005 031500 156630 026635 022440 000127
61+
0000060 115071 046756 071656 106721 161340 106726 175275 072403
62+
0000100 011265 000420 061137 103723 001107 006430 061151 132766
63+
0000120 166216 015074 100505 015473 057324 102727 005126 051731
64+
0000140 003727 071115 167622 071407 120301 002616 047451 120733
65+
0000160 174117 133164 161231 035076 013700 164114 031627 001202
66+
0000200 011467 055650 016365 140074 060277 150601 043610 006403
67+
0000220 016170 071666 065540 026615 055073 162363 012002 112371
68+
0000240 000767 157121 125007 141671 000327 173741 056415 155463
69+
0000260 105504 066453 152754 136314 175213 063541 001420 053025
70+
0000300 047631 167425 044125 063176 171334 177234 050063 031640
71+
...
72+
73+
74+
.. note:: HW randomness is a precious resource of the system. The
75+
:command:`od` command will block and wait until there is randomness
76+
available.
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
.. _usb_virtualization:
2+
3+
USB Virtualization
4+
##################
5+
6+
Universal Serial Bus (USB) is an industry standard that
7+
establishes specifications for cables, connectors, and protocols for
8+
connection, communication, and power supply between personal computers
9+
and their peripheral devices.
10+
11+
.. figure:: images/usb-image51.png
12+
:align: center
13+
:name: usb-virt-arch
14+
15+
USB architecture overview
16+
17+
18+
The ACRN USB virtualization includes
19+
emulation of three components, described here and shown in
20+
:numref:`usb-virt-arch`:
21+
22+
- **xHCI DM** (Host Controller Interface) provides multiple
23+
instances of virtual xHCI controllers to share among multiple User
24+
OSes, each USB port can be assigned and dedicated to a VM by user
25+
settings.
26+
27+
- **xDCI controller** (Device Controller Interface)
28+
can be passed through to the
29+
specific User OS with I/O MMU assistance.
30+
31+
- **DRD DM** (Dual Role Device) emulates the PHY MUX control
32+
logic. The sysfs interface in UOS is used to trap the switch operation
33+
into DM, and the the sysfs interface in SOS is used to operate on the physical
34+
registers to switch between DCI and HCI role.
35+
36+
On Intel Apollo Lake platform, the sysfs interface path is
37+
``/sys/class/usb_role/intel_xhci_usb_sw/role``. If user echos string
38+
``device`` to role node, the usb phy will be connected with xDCI controller as
39+
device mode. Similarly, by echoing ``host``, the usb phy will be
40+
connected with xHCI controller as host mode.
41+
42+
An xHCI register access from UOS will induce EPT trap from UOS to
43+
DM, and the xHCI DM or DRD DM will emulate hardware behaviors to make
44+
the subsystem run.
45+
46+
USB host virtualization
47+
***********************
48+
49+
USB host virtualization is implemented as shown in
50+
:numref:`xhci-dm-arch`:
51+
52+
.. figure:: images/usb-image10.png
53+
:align: center
54+
:name: xhci-dm-arch
55+
56+
xHCI DM software architecture
57+
58+
The yellow-colored components make up the ACRN USB stack supporting xHCI
59+
DM:
60+
61+
- **xHCI DM** emulates the xHCI controller logic following the xHCI spec;
62+
63+
- **USB core** is a middle abstract layer to isolate the USB controller
64+
emulators and USB device emulators.
65+
66+
- **USB Port Mapper** maps the specific native physical USB
67+
ports to virtual USB ports. It communicate with
68+
native USB ports though libusb.
69+
70+
All the USB data buffers from UOS (User OS) are in the form of TRB
71+
(Transfer Request Blocks), according to xHCI spec. xHCI DM will fetch
72+
these data buffers when the related xHCI doorbell registers are set.
73+
These data will convert to *struct usb_data_xfer* and, through USB core,
74+
forward to the USB port mapper module which will communicate with native USB
75+
stack over libusb.
76+
77+
The device model configuration command syntax for xHCI is as follows::
78+
79+
-s <slot>,xhci,[bus1-port1,bus2-port2]
80+
81+
- *slot*: virtual PCI slot number in DM
82+
- *bus-port*: specify which physical USB ports need to map to UOS.
83+
84+
A simple example::
85+
86+
-s 7,xhci,1-2,2-2
87+
88+
This configuration means the virtual xHCI will appear in PCI slot 7
89+
in UOS, and any physical USB device attached on 1-2 or 2-2 will be
90+
detected by UOS and used as expected.
91+
92+
USB DRD virtualization
93+
**********************
94+
95+
USB DRD (Dual Role Device) emulation works as shown in this figure:
96+
97+
.. figure:: images/usb-image31.png
98+
:align: center
99+
100+
xHCI DRD DM software architecture
101+
102+
ACRN emulates the DRD hardware logic of an Intel Apollo Lake platform to
103+
support the dual role requirement. The DRD feature is implemented as xHCI
104+
vendor extended capability. ACRN emulates
105+
the same way, so the native driver can be reused in UOS. When UOS DRD
106+
driver reads or writes the related xHCI extended registers, these access will
107+
be captured by xHCI DM. xHCI DM uses the native DRD related
108+
sysfs interface to do the Host/Device mode switch operations.
109+
110+
The device model configuration command syntax for xHCI DRD is as
111+
follows::
112+
113+
-s <slot>,xhci,[bus1-port1,bus2-port2],cap=platform
114+
115+
- *cap*: cap means virtual xHCI capability. This parameter
116+
indicates virtual xHCI should emulate the named platform’s xHCI
117+
capabilities.
118+
119+
A simple example::
120+
121+
-s 7,xhci,1-2,2-2,cap=apl
122+
123+
This configuration means the virtual xHCI should emulate xHCI
124+
capabilities for the Intel Apollo Lake platform, which supports DRD
125+
feature.
126+
127+
Interface Specification
128+
***********************
129+
130+
.. note:: reference doxygen-generated API content

doc/developer-guides/hld/watchdog-hld.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ timely kick action, it will call DM API to reboot that UOS.
8888
In the UOS launch script, add: ``-s xx,wdt-i6300esb`` into DM parameters.
8989
(xx is the virtual PCI BDF number as with other PCI devices)
9090

91-
Make sure the UOS kernel has the I6300ESB driver enabled: ``CONFIG_I6300ESB_WDT=y``. After the UOS
92-
boots up, the watchdog device will be created as node ``/dev/watchdog``,
93-
and can be used as a normal device file.
91+
Make sure the UOS kernel has the I6300ESB driver enabled:
92+
``CONFIG_I6300ESB_WDT=y``. After the UOS boots up, the watchdog device
93+
will be created as node ``/dev/watchdog``, and can be used as a normal
94+
device file.
9495

9596
Usually the UOS needs a watchdog service (daemon) to run in userland and
9697
kick the watchdog periodically. If something prevents the daemon from

0 commit comments

Comments
 (0)