-
Notifications
You must be signed in to change notification settings - Fork 2
Description
In virtio-1.3, support for device advertised shared memory segments was added.
A device can share a memory with the driver.
We should support this feature.
As I understand things, these memory areas are device owned and allocated. It is up to the specific device type to decide how these shared memory areas will be used and addressed in buffers. One known (theoretical) user is virtio-fs. The device side (file-system provider) can put requested data blocks in the shared memory and the driver side can read and write those blocks directly. Alex believes that there was a proof of concept virtio-fs device side implementation for this but he believes the current production virtio-fs (from rust-vmm) does not use shared memory segments.
The transport level of this is pretty simple in concept. (Look at virtio-mmio for an example.) The driver can query the size and location of N shared memory segments. Knowing the max N would be good to know up front (GET_DEVICE_INFO).
Implementing this is less clear. It is unclear to me who's job it is to map those segments on the driver side. To me this seems like it would need transport level operations to make the memory appear at a driver side PA. It is probably the transport that knows what type of mapping is required (cached non-cached etc). It can certainly be the device type driver that does the mapping into VA but that seems like the easy part.
It is also unclear when the transport level should do the work to make the memory area accessible. Is querying for the existence of a memory area a trigger to make it accessible? Or can this work be delayed until the device type driver really decides to use it?
Does the Linux kernel support this today? If so we should look at how it is structured between the device type driver and the DMA layer (our transport level hooks would go here). If not in the kernel today, is there sample code somewhere?
This level of shared memory is different than the memory sharing we need to do at the transport level for virtqueues and buffers. In fact the virtio-1.3 spec prohibits virtqueues and buffers being put into this shared memory area. (At the bus level some of the same operations may be required but this is irrelevant to the device level protocol.)