audk/OvmfPkg/Library
Laszlo Ersek 8bc951a264 OvmfPkg: VirtioFlush(): return the number of bytes written by the host
VirtioLib provides an API for simple, synchronous (request/response-style)
virtio communication. The guest driver builds one descriptor chain, link
for link, with VirtioPrepare() and VirtioAppendDesc(), then submits the
chain, and awaits the processing, with VirtioFlush().

The descriptor chain is always built at the beginning of the descriptor
area, with the head descriptor having descriptor index 0.

In order to submit the descriptor chain to the host, the guest always
pushes a new "available element" to the Available Ring, in genuine
queue-like fashion, with the new element referencing the head descriptor
(which always has index 0, see above).

In turn, after processing, the host always pushes a new "used element" to
the Used Ring, in genuine queue-like fashion, with the new element
referencing the head descriptor of the chain that was just processed. The
same element also reports the number of bytes that the host wrote,
consecutively across the host-writeable buffers that were linked by the
descriptors.

(See "OvmfPkg/VirtioNetDxe/TechNotes.txt" for a diagram about the
descriptor area and the rings.)

Because at most one descriptor chain can be in flight with VirtioLib at
any time,

- the Available Ring and the Used Ring proceed in lock-step,

- and the head descriptor that the new "available" and "used" elements can
  ever reference has index 0.

Based on the above, we can modify VirtioFlush() to return the number of
bytes written by the host across the descriptor chain. The virtio-block
and virtio-scsi drivers don't care (they have other ways to parse the data
produced by the host), while the virtio-net driver doesn't use
VirtioFlush() at all (it employs VirtioLib only to set up its rings).

However, the virtio entropy device,  to be covered in the upcoming
patches, reports the amount of randomness produced by the host only
through this quantity.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2016-02-24 12:07:32 +01:00
..
AcpiTimerLib OvmfPkg: extract some bits and port offsets common to Q35 and I440FX 2015-05-13 09:31:53 +00:00
EmuVariableFvbLib OvmfPkg EMU FVB: Add 2 functions to PlatformFvbLib 2011-01-09 03:51:16 +00:00
LoadLinuxLib OvmfPkg: fix conversion specifiers in DEBUG format strings 2015-07-28 18:33:23 +00:00
LockBoxLib OvmfPkg: LockBoxLib: -D SMM_REQUIRE excludes our fake lockbox 2015-11-30 18:42:05 +00:00
NvVarsFileLib OvmfPkg: fix conversion specifiers in DEBUG format strings 2015-07-28 18:33:23 +00:00
PlatformBdsLib OvmfPkg: install DxeSmmReadyToLock in PlatformBdsLib 2015-07-26 08:02:24 +00:00
PlatformDebugLibIoPort OvmfPkg: PlatformDebugLibIoPort: fix AsciiSPrint() format string 2015-08-06 10:13:33 +00:00
PlatformFvbLibNull OvmfPkg EMU FVB: Add 2 functions to PlatformFvbLib 2011-01-09 03:51:16 +00:00
PlatformSecureLib OvmfPkg: Add custom mode setup if the Secure Boot build option is specified. 2012-04-04 17:35:06 +00:00
QemuBootOrderLib OvmfPkg: QemuBootOrderLib: recognize NVMe devices 2016-02-02 15:30:27 +00:00
QemuFwCfgLib OvmfPkg: QemuFwCfgLib: avoid "variable set but not used" warning from GCC 2015-07-10 06:46:57 +00:00
ResetSystemLib OvmfPkg ResetSystemLib: Fix VS build error 2013-08-19 04:15:26 +00:00
SerializeVariablesLib OvmfPkg: fix conversion specifiers in DEBUG format strings 2015-07-28 18:33:23 +00:00
SmbiosVersionLib OvmfPkg: SmbiosVersionLib: recognize SMBIOS 3.x entry point 2015-08-06 10:14:12 +00:00
SmmCpuFeaturesLib OvmfPkg: SmmCpuFeaturesLib: customize state save map format 2015-11-30 18:46:42 +00:00
VirtioLib OvmfPkg: VirtioFlush(): return the number of bytes written by the host 2016-02-24 12:07:32 +01:00
VirtioMmioDeviceLib OvmfPkg/VirtioMmioDeviceLib: Implement VIRTIO_DEVICE_PROTOCOL for VirtIo Devices over MMIO 2013-12-11 16:57:59 +00:00
XenConsoleSerialPortLib OvmfPkg XenConsoleSerialPortLib: Implement Get(Set)Control/SetAttributes 2015-11-26 08:51:34 +00:00
XenHypercallLib OvfmPkg/XenHypercallLib: add missing GCC_ASM_EXPORT to XenHypercall2 2015-12-17 17:10:59 +00:00
XenIoMmioLib ArmVirtualizationPkg: add XenIoMmioLib 2015-02-28 20:34:16 +00:00