Skip to content

[Bug]: Cannot use VirtIO in legacy mode #569

@msvoelker

Description

@msvoelker

Version

7.2.6

Host OS Type

macOS

Host OS name + version

macOS 15.7.4

Host Architecture

ARM

Guest OS Type

Linux

Guest Architecture

ARM

Guest OS name + version

Linux Ubuntu 6.17.0-14-generic

Component

Network

What happened?

I added a network adapter of type "paravirtualized Network (virtio-net)" and it works. Ubuntu seems to negotiate to use VirtIO PCI device in modern mode. If I force Ubuntu to use legacy mode by adding the following GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub

virtio_pci.force_legacy=1

like so:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash virtio_pci.force_legacy=1"

Ubuntu is unable to use the VirtIO device. I see the following error message in dmesg

virtio_net virtio0: probe with driver virtio_net failed with error -2

I see the same problem in a FreeBSD VM. FreeBSD uses legacy mode by default. It reads configurations from the VirtIO PCI's first BAR (the one of type I/O Port) but only gets values with all ones (0xFF or 0xFFFF or so) and as a result can't use the network adapter. If I disable the second BAR (the one of type Memory) by setting in /boot/loader.conf

hw.pci.enable_io_modes="0"

FreeBSD can read the configuration from the I/O Port BAR and can use the PCI device (network adapter) in legacy mode.

If I instead switch to modern mode by setting in /boot/loader.conf

hw.virtio.pci.transitional="1"

FreeBSD can read the configuration from the Memory BAR and can use the PCI device (network adapter) in modern mode.

The issue is that the VirtIO PCI device cannot be used in legacy mode (if the Memory BAR is enabled). It might be related to issue #563.

VBox-FreeBSD.log

How can we reproduce this?

Run VirtualBox on macOS with Apple Silicon (arm64). Create a FreeBSD VM. Add a network adapter of type "paravirtualized Network (virtio-net)" and start the FreeBSD VM. FreeBSD is not able to use this network adapter. Set in /boot/loader.conf

hw.virtio.pci.transitional="1"

reboot the FreeBSD VM and FreeBSD is able to use the network adapter.

Did you upload all of your necessary log files, screenshots, etc.?

  • Yes, I've uploaded all pertinent files to this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions