Effectively the only way to recover from errors in the communication
with pcid is by restarting the driver from scratch possibly after
restarting pcid. As such moving the aborts from individual drivers to
pcid_interface simplifies drivers while at the same time allowing nicer
error messages.
This will make it easier to change the way logging is done for all
drivers. This also fixes the log category for a couple of drivers as
well as makes failing to set the logger a fatal error. Only when a
logger is already set is it impossible to set another logger.
Transitional virtio devices (which have both legacy and virtio 1.0
support) have been the default since QEMU 2.7.0, which was released
8 years ago. Basically every non-commercial Linux distro with an older
QEMU has been EOL already.
The legacy transport is also one of the few places where port I/O is
necessary, which is non-trivial to sandbox even once we have IOMMU
support. As it isn't possible to distinguish legacy and modern virtio
devices for pcid, this would mean that all virtio drivers have to be
started as privileged even if it turns out the modern transport is
supported by the VMM.
error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused
--> virtio-core/src/probe.rs:126:21
|
86 | let capability = unsafe { &*(capability.data.as_ptr() as *const PciCapability) };
| --------------------------------------------------- backing allocation comes from here
...
126 | (&*(capability as *const PciCapability as *const PciCapabilityNotify))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: casting from `transport_pci::PciCapability` (13 bytes) to `transport_pci::PciCapabilityNotify` (17 bytes)
= note: `#[deny(invalid_reference_casting)]` on by default
It isn't used in any driver and even on Linux no driver seems to use it
at all. The only times it seems to be useful are if you were to mask an
interrupt and want to check if the interrupt fired without unmasking or
if you want to make the device itself trigger an interrupt.
Most things are already stored in SubdriverArguments and the couple of
things that aren't may change over time and thus should be read again
each time they are accessed, while fetch_header would receive a fixed
copy from pcid.