History log of /src/sys/dev/virtio/
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 thorpej-ifq-base thorpej-altq-separation-base netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base
1.5 12-Aug-2022 riastradh

viocon(4): New virtio tty driver imported from OpenBSD.

viocon* at virtio?

/dev/ttyVI??

Tested under qemu with:

qemu-system-aarch64 ... \
-device virtio-serial \
-chardev socket,path=/tmp/ttyVI00,server=on,wait=off,id=ttyVI00 \
-device virtconsole,chardev=ttyVI00,name=org.NetBSD.dev.ttyVI00 \
...

I updated MAKEDEV.conf to create /dev/ttyVI?? on all ports where it
looks likely to work based on:
(a) having pci or a non-pci virtio attachment,
(b) `qemu-system-$ARCH -M ?' mentioned something resembling the port,
and
(c) `qemu-system-$ARCH -device virtio-serial' launched without
complaining about the virtio-serial device.

(Criterion (c) excluded sparc and sparc64.)


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728
1.4 12-Jul-2018 jakllsch

revert previous, unintended, commit


1.3 12-Jul-2018 jakllsch

<sys/pmc.h> is gone; dont


Revision tags: phil-wifi-base pgoyette-compat-0625
1.2 06-Jun-2018 jakllsch

branches: 1.2.2; 1.2.4;
Add Virtio MMIO transport.

Adapted in part from OpenBSD.


1.1 06-Jun-2018 jakllsch

shuffle mechanics of files.virtio config(5) include location,
without actually moving the contents thereof from dev/pci yet


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.10 05-Aug-2024 riastradh

viocon(4): Defer viocon_rx_fill til after virtio_child_attach_finish.

Since virtio.c 1.66, virtqueue_enqueue* can't be used until after
virtio_child_attach_finish completes.

https://mail-index.netbsd.org/source-changes/2023/03/23/msg143799.html

PR kern/58555: Kernel panic during boot when using viocon with PCIe


Revision tags: perseant-exfatfs-base-20240630 perseant-exfatfs-base thorpej-ifq-base thorpej-altq-separation-base
1.9 16-Apr-2023 riastradh

branches: 1.9.6;
viocon(4): Show error in assertion failure.


1.8 23-Mar-2023 yamaguchi

Added functions to set interrupt handler and index into virtqueue


1.7 23-Mar-2023 yamaguchi

viocon(4): fix not to allocate unused virtqueue

viocon(4) allocates 4 virtqueues but it only uses 2 (0 and 1) queues.


1.6 23-Mar-2023 yamaguchi

Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.


Revision tags: netbsd-10-base bouyer-sunxi-drm-base
1.5 13-Aug-2022 riastradh

branches: 1.5.4;
viocon(4): Omit unused sc_dmamap.


1.4 13-Aug-2022 riastradh

viocon(4): Fix bus_dmamap_sync after tx: POSTWRITE, not POSTREAD.


1.3 13-Aug-2022 riastradh

viocon(4): Fix $NetBSD$ rcsid.


1.2 13-Aug-2022 riastradh

viocon(4): Fix tty device number.


1.1 12-Aug-2022 riastradh

viocon(4): New virtio tty driver imported from OpenBSD.

viocon* at virtio?

/dev/ttyVI??

Tested under qemu with:

qemu-system-aarch64 ... \
-device virtio-serial \
-chardev socket,path=/tmp/ttyVI00,server=on,wait=off,id=ttyVI00 \
-device virtconsole,chardev=ttyVI00,name=org.NetBSD.dev.ttyVI00 \
...

I updated MAKEDEV.conf to create /dev/ttyVI?? on all ports where it
looks likely to work based on:
(a) having pci or a non-pci virtio attachment,
(b) `qemu-system-$ARCH -M ?' mentioned something resembling the port,
and
(c) `qemu-system-$ARCH -device virtio-serial' launched without
complaining about the virtio-serial device.

(Criterion (c) excluded sparc and sparc64.)


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.2 26-Jul-2025 martin

branches: 1.2.4;
PR 58681: add a port of the OpenBSD viogpu(4) driver written by
Joshua Stein <jcs@openbsd.org>.
Port by George Matsumura with help from Jiaxun Yang.


1.1 27-Mar-2025 riastradh

virtio(4): Consolidate kernel configs.

No functional change intended.

Leave `# XXX ?' comments where I don't know why the driver in
question is excluded. (Typical reason is that PAGE_SIZE is not 4096
but I didn't investigate -- if you do investigate, please either
update the comment if you determine a reason, or enable the driver if
you don't.)

PR kern/59211: vio9p(4): missing from various GENERICs and MAKEDEVs


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.15 26-Jul-2025 martin

PR 58681: add a port of the OpenBSD viogpu(4) driver written by
Joshua Stein <jcs@openbsd.org>.
Port by George Matsumura with help from Jiaxun Yang.


Revision tags: perseant-exfatfs-base-20240630 perseant-exfatfs-base
1.14 09-Mar-2024 isaki

branches: 1.14.2;
Fix a null dereference (on attach failure).
During cleanup, setup_queue may be called even before vsc->sc_vqs is assigned.


1.13 06-Jan-2024 thorpej

Perform VirtIO 1.0 feature negotation in the MMIO transport. This is
required for HV's that have MMIO-v2 and don't support transitional devices.


1.12 02-Jan-2024 thorpej

- The VirtIO 1.0 spec says that the MMIO interface uses little-endian
registers. For some VMs, at least, this appears to be independent of
the config/struct byte-order. Detect this and handle it.
- Add support for the "v2" MMIO personality.


Revision tags: thorpej-ifq-base thorpej-altq-separation-base
1.11 07-Jul-2023 rin

virtio(4): Fix byte order of DMA data for armeb in the same manner as
aarch64eb.

Fix comments to explain what is going on for {arm,aarch64}eb on QEMU.
This is not due to QEMU bugs; it correctly configures everything for
little-endian environment, and we forcibly change byte order only for
CPU cores during kernel bootstrap.


1.10 19-Apr-2023 yamaguchi

Use enumeration for state of a child driver instead of flags
and check its detaching by using sc->sc_child in virtio_softc

pointed out by riastradh, thanks.
fixes PR/57357


1.9 31-Mar-2023 yamaguchi

Fix wrong variable names

This fixes build errors in virtio_mmio.c


1.8 31-Mar-2023 yamaguchi

Added flags to store status of attaching a virtio device

This prevents a panic on reboot after a virtio device had called
virtio_child_attach_failed().


Revision tags: netbsd-10-base bouyer-sunxi-drm-base
1.7 22-Oct-2021 yamaguchi

branches: 1.7.4;
rename "setup_interrupts" to "alloc_interrupts"
in virtio_mmio and virtio_acpi

This should fix build failure on evbarm.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
1.6 05-Feb-2021 reinoud

Add virtio mmio probe function


1.5 28-Jan-2021 reinoud

Rewrite and streamline virtio device config read/write and explicitly cater
for the Aarch64-eb bus problem with Qemu. This removes lots of bus_space
`magic' and cleans up the code.


1.4 20-Jan-2021 reinoud

Add VirtIO PCI v1.0 attachments and fix the drivers affected.

The vioif, ld, scsi, viornd and viomb devices were adjusted when needed and
tested both in legacy 0.9 and v1.0 attachments trough PCI on amd64, sparc64,
aarch64 and aarch64-eb. ACPI/FDT attachments also tested on
aarch64/aarch64-eb.

Known issues

* viomb on aarch64 works only with ACPI/FDT attachment but not with PCI
attachment. PCI and ACPI/FDT attachment works on aarch64-eb.

* virtio on sparc64 attaches but is it not functioning though not a
regression.


1.3 03-Oct-2020 jmcneill

branches: 1.3.2;
MMIO configuration space is in guest byte order. AArch64 BE is special,
as the guest starts in LE and we switch to BE after the kernel starts.
For this case, we need to byte swap all config space accesses.


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
1.2 15-Jun-2018 jakllsch

branches: 1.2.2;
Add cfprint_t virtiobusprint() and use it for virtio_mmio.


1.1 06-Jun-2018 jakllsch

Add Virtio MMIO transport.

Adapted in part from OpenBSD.


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base perseant-exfatfs-base-20240630 perseant-exfatfs-base
1.7 06-Jan-2024 thorpej

Perform VirtIO 1.0 feature negotation in the MMIO transport. This is
required for HV's that have MMIO-v2 and don't support transitional devices.


1.6 02-Jan-2024 thorpej

- The VirtIO 1.0 spec says that the MMIO interface uses little-endian
registers. For some VMs, at least, this appears to be independent of
the config/struct byte-order. Detect this and handle it.
- Add support for the "v2" MMIO personality.


Revision tags: netbsd-10-1-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 thorpej-ifq-base thorpej-altq-separation-base netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base
1.5 22-Oct-2021 yamaguchi

rename "setup_interrupts" to "alloc_interrupts"
in virtio_mmio and virtio_acpi

This should fix build failure on evbarm.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
1.4 05-Feb-2021 reinoud

Add virtio mmio probe function


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728
1.3 16-Jul-2018 kre

branches: 1.3.14;

Do the previous in the way it probably should have been in the first place.


1.2 16-Jul-2018 kre

Be consistent with double include guard name (clang actually detects this)


Revision tags: phil-wifi-base pgoyette-compat-0625
1.1 06-Jun-2018 jakllsch

branches: 1.1.2; 1.1.4;
Add Virtio MMIO transport.

Adapted in part from OpenBSD.


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.1 15-Jan-2025 imil

Add support for command line MMIO devices, at least qemu and
Firecracker pass MMIO virtual devices mapping through the kernel
command line.
This driver is based on Colin Percival's FreeBSD virtio_mmio_cmdline.c
https://github.com/freebsd/freebsd-src/blob/main/sys/dev/virtio/mmio/virtio_mmio_cmdline.c

The following kernel options are needed

options MPBIOS
options MPTABLE_LINUX_BUG_COMPAT

As are these drivers

pv* at pvbus?
virtio* at pv?

Exemple qemu usage on a Linux host to boot a NetBSD guest:

qemu-system-x86_64 \
-M microvm,x-option-roms=off,rtc=on,acpi=off,pic=off,accel=kvm \
-m 256 -cpu host -kernel ${KERNEL} \
-append "root=ld0a console=com rw -v" \
-device virtio-blk-device,drive=hd0 \
-drive file=${IMG},format=raw,id=hd0 \
-device virtio-net-device,netdev=net0 \
-netdev user,id=net0,ipv6=off,hostfwd=::2200-:22 \
-global virtio-mmio.force-legacy=false -display none -serial stdio

A lightweight kernel configuration named MICROVM if available for this
use case.