-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
virtio-blk storage via mmio using virtio-drivers [v3] #635
Draft
osteffenrh
wants to merge
10
commits into
coconut-svsm:main
Choose a base branch
from
osteffenrh:virtio-pr-3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7e5fb2c
to
3b13c29
Compare
Use the latest version of the zerocopy crate, to match the one used by the virtio-drivers crate. Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Add mmio read and write functions. ToDo: Improve read_buffer() to be similar to write_buffer(). Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Import a minimized version of the rcore-os/virtio-drivers crate into the codebase, as a sub-crate. See https://github.com/osteffenrh/virtio-drivers/tree/minimize for changes made to the upstream branch. Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Implement a Hal for Coconut that uses the ghcb mmio functions and manages bounce-buffers in host-shared memory. The buffers use SharedBox and are currently limited to 1 page in size. The SharedBoxes need to be kept around between the share() and unshare() calls, thus a global manager was added that holds them. ToDo: Allow arbitrary buffer sizes. Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Add a simple block layer api trait. Co-developed-by: Oliver Steffen <osteffen@redhat.com> Signed-off-by: Oliver Steffen <osteffen@redhat.com> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Add command line option to add a virtio-blk MMIO device to the CVM. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Make use of the fw_cfg file "etc/hardware-info" to obtain the MMIO base addresses for virtio devices. This mechanism was/is being added to OVMF [1] and Qemu [2] to pass information about hardware devices to the firmware, which can not be communicated in other ways. We introduce a new device type for SVSM for use in that file which specifies a MMIO address. [1] https://edk2.groups.io/g/devel/message/86051 [2] https://lists.nongnu.org/archive/html/qemu-devel/2025-02/msg03923.html Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Add a block device driver that uses the virito-blk via mmio transport. ToDo: Return proper error codes. Co-developed-by: Oliver Steffen <osteffen@redhat.com> Signed-off-by: Oliver Steffen <osteffen@redhat.com> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Add simple write+readback tests for the VirtioBlkDriver. Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Add a virtio-blk device to the in-svsm test setup to allow the VirtioBlkDriver tests to run. Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for virtio-blk storage devices using the virtio-mmio transport.
MMIO accesses are done via explicit vmgexits. Interrupts are not used (-> polling).
A minimized version of the rcore-os/virtio-drivers crate (MIT License) is added
to the codebase as a sub-crate. Most of the unused code was removed (PCI support, unused device types,
example programs,...), resulting in about 3800 lines of code, see osteffenrh/virtio-drivers#3
This PR requires a patched version of Qemu (coconut-svsm/qemu#13), which features virtio-mmio slots in the Q35 machine model (thanks @kraxel).
Qemu communicates the MMIO base address via the fw_cfg interface, making use of OVMF's
HardwareInfoLib. Work is already ongoing to add this to upstream Qemu.
Device information are stored in the
etc/hardware-info
fw_cfg file in a simple binary format.Building on top of that, the PR introduces a new device type to store MMIO addresses for use by the SVSM.
How to test:
Fixes since V2 (#542):
Things for future PRs: