libvmm icon indicating copy to clipboard operation
libvmm copied to clipboard

Virtio-block device implementation bug fixes

Open dreamliner787-9 opened this issue 9 months ago • 0 comments

This PR:

  • Integrated virtio block device implementation changes from #128 that fixes descriptor chain parsing.

  • Fixed an issue that caused the data on the backing storage device to be corrupted if the guest driver issues commands in a certain order or hit certain blocks. This was caused by two bugs: -> Writes to sectors that are not aligned on the sDDF Block transfer window were not handled atomically. This PR added a state machine to each request to keep track of dirty blocks and queues up requests hitting the same block to prevent data races. -> A buffer overrun on the data region when the guest driver issues requests that span >1 sDDF Block transfer window. For example, a write of 8 sectors which starts at sector 4 will span 2 transfer windows (because the transfer windows are aligned on 8 sectors). Previously the device implementation would only allocate 1 transfer window and overrun it.

  • Fixed an issue that caused the guest to hang if the block data region or bookkeeping structures become full. Previously the virtio block device implementation would just drop the requests silently in such cases, now the device will correctly queue up requests and create back-pressure in the guest to prevent the device from overloading.

  • Fixed an issue that caused the guest to hang due to an internal fragmentation issue within the data region. Previously, the device did not implement the VIRTIO_BLK_F_SIZE_MAX and VIRTIO_BLK_F_SEG_MAX feature bits. Which allowed the guest driver to make huge requests (upwards of 100k) that the device would never be able to fulfill due to natural internal fragmentation in the data region. Now, the device restrict the driver to 4K requests at a time, a more reasonable limit that the device will be able to fulfill (eventually) as previous requests complete and resources are freed up.

  • Implemented the VIRTIO_BLK_F_TOPOLOGY feature bit to hint optimal I/O alignment to the guest driver.

  • Added an integration test script for virtio block that was used to catch all the above issues.

  • Mount the third partition on maaxboard instead of the first one.

  • Update sDDF to fee9f97 to fix a cache-coherency issue within the Block subsystem and for the faster imx8 SD driver.

Fixes #150

dreamliner787-9 avatar Mar 27 '25 03:03 dreamliner787-9