Hi all,
I'm trying to add virtio drivers (just block device at the moment) to my OS, however, I'm running into this issue. Once I set everything up and write 0xF (ACK | DRIVER | FEATURES_OK | DRIVERS_OK) to the status register, I get "qemu-system-x86_64: virtio: zero sized buffers are not allowed" in the terminal. If I don't set the virtual queue, I don't get this error, so I got it pinpointed there.
For the virtqueue setup, the device needs a 256 element queue, and I have the descriptors at 0x7000, available queue at 0x8000 (0x7000 + 256 * 16) and used queue at 0x9000 (aligned to 4096) and I write 0x7 to queue 0's address. All the memory here is zero initialized. I'm using the legacy interface since BAR0 for this device is an IO port.
Could someone assist me with this? Resources on virtio is much thinner than I expected. I checked out the examples at dumais.io and the managarm source, however I didn't notice anything.
Update: when I run the same kernel with `-kernel`, everything works. Running it with `-cdrom` causes this problem on linux and macos, but works on Windows.
Virtio: zero sized buffers are not allowed,cdrom kernel diff
Virtio: zero sized buffers are not allowed,cdrom kernel diff
Last edited by fbkr on Mon Feb 01, 2021 12:42 am, edited 1 time in total.
Re: Virtio error: "zero sized buffers are not allowed"
I just tested this on qemu(v5.1.0-11824-g8699890d91-dirty) on Windows and it actually worked without a problem.
However, both with qemu v4.2.1 and v5.1.0 on linux have this problem.
However, both with qemu v4.2.1 and v5.1.0 on linux have this problem.
-
- Member
- Posts: 5568
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Virtio error: "zero sized buffers are not allowed"
Virtual or physical? How do you set up those descriptors? Did you set the buffer length to a nonzero value? (That's what QEMU is checking when it throws the error you're seeing.)fbkr wrote:I have the descriptors at 0x7000
Re: Virtio error: "zero sized buffers are not allowed"
Octocontrabass wrote:Virtual or physical?fbkr wrote:I have the descriptors at 0x7000
It's physical.
This is happening at initialization, the descriptors are empty, and the whole buffer is zero filled.Octocontrabass wrote:How do you set up those descriptors? Did you set the buffer length to a nonzero value? (That's what QEMU is checking when it throws the error you're seeing.)
-
- Member
- Posts: 5568
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Virtio error: "zero sized buffers are not allowed"
I think I do finish setting up the descriptors. Neither the general initialization nor the block device initialization mention putting anything into the queues during initialization. So I'm just trying to initialize an empty queue. Am I missing something obvious?Octocontrabass wrote:You need to finish setting up the descriptors before you set DRIVER_OK.
Re: Virtio error: "zero sized buffers are not allowed"
One thing I've noticed is that this works correctly even under linux if I boot with `-kernel ...`, but if I boot with `-cdrom ...`, it fails. But the same ELF/ISO works on windows either way.
Qemu 5.2.0 has the same behaviour on macos as well, works with -kernel, fails with -cdrom
The ISO is being generated with `grub-mkrescue` and the elf is a multiboot1 image.
Qemu 5.2.0 has the same behaviour on macos as well, works with -kernel, fails with -cdrom
The ISO is being generated with `grub-mkrescue` and the elf is a multiboot1 image.
Re: Virtio: zero sized buffers are not allowed,cdrom kernel
I seem to have figured this out.
Even though the spec clearly says a device must initialize the status register with 0 (https://docs.oasis-open.org/virtio/virt ... #x1-120002), setting it to 0 before doing any initialization fixed the problem.
Even though the spec clearly says a device must initialize the status register with 0 (https://docs.oasis-open.org/virtio/virt ... #x1-120002), setting it to 0 before doing any initialization fixed the problem.