Open erichchan999 opened 1 month ago
nvm haven't tested this on odroidc4 yet, will be drafting it.
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
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