rcore-os / virtio-drivers

VirtIO guest drivers in Rust.
MIT License
209 stars 63 forks source link

`VirtIOBlk::read_blocks` returns `IoError` if `buf` is >= 2GiB #135

Closed fmckeogh closed 4 months ago

fmckeogh commented 5 months ago

I'm using the PciTransport on a Rust unikernel. 2047MiB copies work without issue, but any greater and I get an IoError.

qwandor commented 4 months ago

That's a lot to read into a single buffer! I suggest splitting up your reads into smaller chunks, a few MiB at a time would be more reasonable.

That said, I can't see a reason why it should fail at 2 GiB. There is a 4 GiB hard limit as the buffer length in VirtIO descriptors is a 32 bit integer. Maybe the host implementation is treating it as signed for some reason, and giving an error when it sees a negative number? Or maybe your Hal::share or Hal::unshare implementations are doing something weird?

fmckeogh commented 4 months ago

@qwandor haha good point, I'll split up the reads:)

I think the signedness seems most likely, my share implementation just translates the virtual address of the buffer to physical (direction is ignored), and my unshare implementation is empty.

Thanks!