Page MenuHomeFreeBSD

virtio_mmio: Fix V1 device probing spec conformance (section 4.2.3.1.1)
ClosedPublic

Authored by jrtc27 on Jan 9 2021, 9:35 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 12, 9:20 PM
Unknown Object (File)
Fri, Apr 12, 9:20 PM
Unknown Object (File)
Fri, Apr 12, 8:13 AM
Unknown Object (File)
Dec 22 2023, 11:45 PM
Unknown Object (File)
Dec 20 2023, 5:13 PM
Unknown Object (File)
Apr 9 2023, 7:25 PM
Unknown Object (File)
Feb 14 2023, 1:54 AM
Unknown Object (File)
Dec 13 2022, 1:18 AM
Subscribers
None

Details

Summary

We must check MagicValue not just Version before anything else, and then
we must check DeviceID and immediately abort if zero (and this must not
be an error).

Do all this when probing rather than at the start of attaching as that's
where this belongs, and provides a clear boundary between the device
detection and device initialisation parts of the specified driver
initialisation process. This also means we don't create empty device
instances for placeholder devices, reducing clutter on systems that
pre-allocate a large number, such as QEMU's AArch64 virt machine (which
provides 32).

Test Plan

Tested both ACPI (arm64) and FDT (riscv) on QEMU.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 36069
Build 32958: arc lint + arc unit

Event Timeline

jrtc27 requested review of this revision.Jan 9 2021, 9:35 PM
jrtc27 created this revision.
bryanv added inline comments.
sys/dev/virtio/mmio/virtio_mmio.c
186

Nit: style prefers it, and used elsewhere in this driver: explicitly compare this to NULL

This revision is now accepted and ready to land.Jan 19 2021, 5:24 AM
sys/dev/virtio/mmio/virtio_mmio.c
186

Thanks; blindly copied from vtmmio_attach without thinking. Will fix that at the same time as committing this (though in a separate commit).