Skip to content
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

Upstream virtio block, refactor libuio, and fix virtio block descriptor chain parsing #128

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

erichchan999
Copy link
Contributor

@erichchan999 erichchan999 commented Oct 3, 2024

This PR upstreams the block virtualiser changes where offsets are converted to io addresses. It also fixes a bug in virtio block to do with descriptor chain parsing.

  • Libuio also has a really annoying restriction: it doesn't allow you to specify more than 5 mappings. Meanwhile this example makes use of 9 mappings. I've added a (arguably hacky) workaround in libuio to allow more than uio device so that we can have more mappings. The interrupts from the extra uio devices are ignored.

  • Libuio used to rely on acking interrupts as a way to both ack+enable and as a point of entry into the VMM, which allowed the VMM to then signal other components. The signalling part has now been decoupled from the ack+enable. uio drivers can signal the virtualiser by writing into a registered memory region which will trap into the VMM. I've introduced uio files into the libvmm source directory to conveniently manage this. But I can see that if we don't wish to couple the libvmm repo with a specific linux module then we can leave this implementation to each example.

  • To upstream the issue with offsets, there needs to be a way to propagate the base physical addresses of data regions into the linux uio driver, so that the driver can convert these physical addresses back to offsets. This is because there doesn't seem to be a way to access memory from linux userspace when only given its physical address. I've added a new memory region for this purpose. It is shared between the VMM and the uio driver via a new mapping. The VMM will contain the elf-patched physical address of the data regions, it will then populate this shared mapping for uio driver to see.

  • Libuio used to be implemented with an event loop that only blocks on the interrupt from the uio device file descriptor. There seems to be a need to wake up the event loop handler based on multiple different events (as is seen in uio_net which needs to wait on a network socket), so the implementation has been changed to make use of epoll. Each individual driver can register a file descriptor to this epoll.

  • Virtio block does not guarantee the header/body/footer sections of the request are in separate descriptors. I've changed the request and response parsing logic to account for this.

libuio changes were made in conjunction with @dreamliner787-9

@erichchan999
Copy link
Contributor Author

nvm haven't tested this on odroidc4 yet, will be drafting it.

@erichchan999 erichchan999 marked this pull request as draft October 3, 2024 02:38
@erichchan999
Copy link
Contributor Author

erichchan999 commented Oct 4, 2024

May need to do elf patching on the uio driver to propagate the data region phys_addr. Ideally this piece of code should interface with microkit somehow so we can specify this patching in the sdf file.
Now done via a shared memory region with VMM and the linux guest

@erichchan999 erichchan999 force-pushed the upstream_blk branch 2 times, most recently from df313d3 to 8bb4870 Compare October 24, 2024 02:24
@erichchan999 erichchan999 changed the title Upstream virtio block and fix descriptor chain parsing Upstream virtio block, refactor libuio, and fix virtio block descriptor chain parsing Nov 1, 2024
@erichchan999 erichchan999 marked this pull request as ready for review November 1, 2024 01:11
@Ivan-Velickovic Ivan-Velickovic force-pushed the upstream_blk branch 3 times, most recently from 7a066c4 to 4435cab Compare November 7, 2024 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant