This project builds on my previous efforts to plumb the Linux Kernel Library (LKL) into USB storage devices. This time I plan on mostly ignoring Android and will instead focus on lklfuse USB support.

lklfuse uses virtio over MMIO to route block device I/O between the host block layer and LKL guest kernel. xHCI emulation appears to be how proper USB traffic routing between host and guest would normally be implemented, but I'm unfamiliar with (and daunted by) the specifications and protocols involved. Given that both guest and host are Linux, I'm considering a simpler approach using USB/IP over virtio, but would need to investigate further to see whether it's viable.

Goals

  • Explore options for USB traffic routing between LKL guest and Linux hosts
    • Learn about and play with the USB/IP and virtio protocols
    • Read about the kernels usbdevice_fs.h APIs
  • Implement lklfuse USB storage support
  • stretch goal: map a LUKS/dm-crypt device
  • stretch goal: benchmark USB against virtio-block devices

Looking for hackers with the skills:

Nothing? Add some keywords!

This project is part of:

Hack Week 24

Activity

  • about 2 months ago: mwilck liked this project.
  • about 2 months ago: mbrugger liked this project.
  • 3 months ago: dmdiss started this project.
  • 3 months ago: dmdiss originated this project.

  • Comments

    • dmdiss
      about 1 month ago by dmdiss | Reply

      post hack-week report:

      I spent plenty of time on research, given that I wasn't very familiar with
      USB or virtio low-level transport and protocol details.
      Read original USB/IP paper:
      - https://www.usenix.org/legacy/events/usenix05/tech/freenix/hirofuchi/hirofuchi.pdf
      - USB Request Block (URB) as underlying USB/IP protocol unit appears to
        suit virtio-mmio transport quite well
        + avoids breakdown into Transfer Descriptor microframes
        + (isochronous) I/O scheduling complications can be initially ignored
      Read kernel documentation on virtio, virtqueue details and test examples
      - https://www.redhat.com/en/blog/virtqueues-and-virtio-ring-how-data-travels
      
      Played with existing kernel / user-space USB/IP network implementation
      - https://github.com/rapido-linux/rapido/commit/9ca2d7a0e27940d59f1eaf7d7e9dc559e77c89ef
      - https://github.com/rapido-linux/rapido/commit/c4e0cff00bfdaea03b960311266db5f59f7c5390
      - wireshark PDU dissection works well
      
      For Linux Kernel Library (LKL) / lklfuse plumbing I revisited my walkley
      project from prior hackweeks, and pushed new WIP branches:
      https://gitlab.com/ceph-walkley/walkley/-/tree/wip_hackweek_2024
      - rebased atop current LKL master
      - added new walkley-usb binary
      - added mostly-stubbed virtio-usb host-side driver
      - started work on guest kernel side virtio-usb driver, reusing as much
        of usbip/vhci-hcd as possible
        + TCP tx/rx threads spawned on sysfs/vhci/attach can be swapped out for
          corresponding virtio transport logic
        + usbipd user-space component can mostly be avoided, as virtio has
          better options for device discovery
      - still quite a bit more work needed to support full USB/IP protocol
        over virtio-mmio
        + QEMU / standalone virtio host implementation would likely also be
          needed, so that mainline inclusion isn't dependent on LKL
      

    Similar Projects

    This project is one of its kind!