aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/virtio/mmio
Commit message (Collapse)AuthorAgeFilesLines
* virtio/mmio: Remove the unused virtio_mmio_if.mAndrew Turner2025-08-214-192/+3
| | | | | | | | | The only driver I know that implemented this interface was removed 7 months ago. Remove the interface and platform from the softc. Reviewed by: imp Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D51992
* newbus: replace leftover device unit wildcardsAhmad Khalifa2025-06-211-1/+1
| | | | | | Reviewed by: imp, jhb Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D50913
* Use bus_generic_detach to detach and delete child devices during detachJohn Baldwin2025-01-021-7/+3
| | | | | | | This is simpler and more robust than individual calls to device_delete_child. Differential Revision: https://reviews.freebsd.org/D47972
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-273-3/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* virtio: remove virtio_alloc_virtqueues' flags argMina Galić2023-09-181-2/+2
| | | | | | | | | | | | | | | | | Summary: the flags argument is unused. Its initial design idea has been superceded by the addition of virtio_setup_intr and related APIs. Sponsored by: The FreeBSD Foundation Reviewers: bryanv Reviewed By: bryanv Subscribers: cognet, imp Differential Revision: https://reviews.freebsd.org/D41850
* virtio: use bool for boolean functionsMina Galić2023-09-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: these static functions: - vq_ring_use_indirect and these public functions: - virtio_bus_is_modern - virtio_with_feature - virtqueue_empty - virtqueue_full exclusively return a boolean value. Change their return values to bool. Sponsored by: The FreeBSD Foundation Reviewers: bryanv Reviewed By: bryanv Subscribers: cognet, imp Differential Revision: https://reviews.freebsd.org/D41848
* sys: Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-163-6/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-161-2/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* virtio_mmio: Support command-line parametersColin Percival2022-10-181-0/+150
| | | | | | | | | | | | | | | | | | | | The Virtio MMIO bus driver was added in 2014 with support for devices exposed via FDT; in 2018 support was added to discover Virtio MMIO devices via ACPI tables, as in QEMU. The Firecracker VMM eschews both FDT and ACPI, instead presenting device information via kernel command line arguments of the form virtio_mmio.device=<parameters>. These command line parameters get converted into kernel environment variables; this adds support for parsing those variables and attaching virtio_mmio children to nexus. There is a case to be made that it would be cleaner to have a new "cmdlinebus" attached to nexus and virtio_mmio children attached to that. A future commit might do that. Discussed with: imp, jrtc27 Sponsored by: https://patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D36189
* virtio_mmio: Improve V1 spec conformanceBryan Venteicher2022-08-171-9/+78
| | | | | | | | | | Implement the virtio_bus_finalize_features method so the FEATURES_OK status bit is set. Implement the virtio_bus_config_generation method to ensure larger than 4-byte reads are consistent. Reviewed by: cperciva MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D36150
* virtio_mmio: correct offset of VIRTIO_MMIO_CONFIG_GENERATIONBryan Venteicher2022-08-041-1/+1
|
* virtio: Remove unused devclass arguments to DRIVER_MODULE.John Baldwin2022-05-062-8/+3
|
* Add missing const after 6c4f95161d6eAlex Richardson2021-10-111-1/+1
| | | | | | I accidentally didn't include hunk in the committed patch. Fixes: 6c4f95161d6e ("virtio: make the write_config buffer argument const")
* virtio: make the write_config buffer argument constAlex Richardson2021-10-111-7/+7
| | | | | | | | No functional change intended, but noticed that we could add const here while adding linuxkpi support for virtio. Reviewed By: bryanv, imp Differential Revision: https://reviews.freebsd.org/D32370
* newbus: Move from bus_child_{pnpinfo,location}_src to ↵Warner Losh2021-06-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | bus_child_{pnpinfo,location} with sbuf Now that the upper layers all go through a layer to tie into these information functions that translates an sbuf into char * and len. The current interface suffers issues of what to do in cases of truncation, etc. Instead, migrate all these functions to using struct sbuf and these issues go away. The caller is also in charge of any memory allocation and/or expansion that's needed during this process. Create a bus_generic_child_{pnpinfo,location} and make it default. It just returns success. This is for those busses that have no information for these items. Migrate the now-empty routines to using this as appropriate. Document these new interfaces with man pages, and oversight from before. Reviewed by: jhb, bcr Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D29937
* virtio_mmio: Delete a stale #if 0'ed debug printJessica Clarke2021-01-211-4/+1
| | | | | | | | This was blindly moved in r360722 but the variable being printed is not yet initialised. It's of little use and can easily be added back in the right place if needed by someone debugging, so just delete it. Reported by: bryanv
* virtio_mmio: Fix V1 device probing spec conformance (section 4.2.3.1.1)Jessica Clarke2021-01-214-12/+46
| | | | | | | | | | | | | | | | | 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). Reviewed by: bryanv Differential Revision: https://reviews.freebsd.org/D28070
* virtio_mmio: Fix a style(9) issueJessica Clarke2021-01-211-1/+1
|
* virtio: Add VirtIO PCI modern (V1) supportBryan Venteicher2021-01-191-5/+18
| | | | | | | | | | | | | | | | | | | | | | Use the existing legacy PCI driver as the basis for shared code between the legacy and modern PCI drivers. The existing virtio_pci kernel module will contain both the legacy and modern drivers. Changes to the virtqueue and each device driver (network, block, etc) for V1 support come in later commits. Update the MMIO driver to reflect the VirtIO bus method changes, but the modern compliance can be improved on later. Note that the modern PCI driver requires bus_map_resource() to be implemented, which is not the case on all archs. The hw.virtio.pci.transitional tunable default value is zero so transitional devices will continue to be driven via the legacy driver. Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27856
* Stop redefining PAGE_SHIFT in virtio-mmioAndrew Turner2020-12-231-2/+0
| | | | | | | This is alreaady defined by each architecture as that is the only place we can know what the correct page shift should be. Sponsored by: Innovate UK
* virtio_mmio: Fix feature negotiation copy-paste issue in r361943Jessica Clarke2020-12-181-2/+2
| | | | | | | | | | | | | | This caused us to write to the low half of the feature word twice, once with the high bits and once with the low bits. Common legacy device implementations seem to be fairly lenient about being able to write to the feature bits multiple times, but Arm's models use a stricter implementation that will ignore the second write. This fixes using vtnet(4) on those models. Reported by: Jean-Philippe Brucker <jean-philippe@linaro.org> Pointy hat: jrtc27 Notes: svn path=/head/; revision=368761
* Only write to VIRTIO_MMIO_GUEST_PAGE_SIZE with virtio mmio version 1Andrew Turner2020-07-211-4/+8
| | | | | | | | | | This register is only defined for the legacy v1 interface so only write to it when interacting with a legacy device. Sponsored by: Innovate UK Notes: svn path=/head/; revision=363390
* virtio_mmio: Negotiate the upper half of the feature bits tooJessica Clarke2020-06-081-0/+11
| | | | | | | | | | | | | | | | | The feature bits are exposed as a 32-bit register with 2 banks, so we should negotiate both halves. Notably, VIRTIO_F_VERSION_1 is in the upper half, and will be used in an upcoming commit. The PCI bus driver also has this bug, but the legacy BAR layout did not include selector registers and is rather different from the modern layout, so it remains solely as legacy. Reviewed by: br, brooks (mentor), jhb (mentor) Approved by: br, brooks (mentor), jhb (mentor) Differential Revision: https://reviews.freebsd.org/D25131 Notes: svn path=/head/; revision=361943
* virtio_mmio: Add casts missing from r360722Jessica Clarke2020-05-071-3/+3
| | | | | | | | | | This fixes -Wshift-count-overflow warnings/errors on architectures using 32-bit physical addresses. Reported by: lwhsu Notes: svn path=/head/; revision=360789
* virtio_mmio: Support non-transitional version 2 devicesJessica Clarke2020-05-062-22/+146
| | | | | | | | | | | | | | | | | | | The non-legacy virtio MMIO specification drops the use of PFNs and replaces them with physical addresses. Whilst many implementations are so-called transitional devices, also implementing the legacy specification, TinyEMU[1] does not. Device-specific configuration registers have also changed to being little-endian, and must be accessed using a single aligned access for registers up to 32 bits, and two 32-bit aligned accesses for 64-bit registers. [1] https://bellard.org/tinyemu/ Reviewed by: br, brooks (mentor) Approved by: br, brooks (mentor) Differential Revision: https://reviews.freebsd.org/D24681 Notes: svn path=/head/; revision=360722
* virtio: Pass the interrupt type in mmio modeKristof Provost2020-02-201-1/+1
| | | | | | | | | | | | | | When we register an interrupt handler we need to pass the intr_type along in bus_setup_intr(). The interrupt type matters because it is used to decide if we need to enter NET_EPOCH. That meant that vtmmio-based if_vtnet did not, which led to panics with INVARIANTS set. Sponsored by: Axiado Notes: svn path=/head/; revision=358178
* virtio: Fix running on machines with memory above 0xffffffffKristof Provost2019-07-261-1/+1
| | | | | | | | | | | | | | We want to allocate a contiguous memory block anywhere in memory, but expressed this as having to be between 0 and 0xffffffff. This limits us on 64-bit machines, and outright breaks on machines where memory is mapped above that address range. Allow the full address range to be used for this allocation. Sponsored by: Axiado Notes: svn path=/head/; revision=350364
* virtio(4): Expose PNP metadata through newbusConrad Meyer2019-06-041-0/+9
| | | | | | | | | | | | | | | | | | | Expose the same fields and widths from both vtio buses, even though they don't quite line up; several virtio drivers can attach to both buses, and sharing a PNP info table for both seems more convenient. In practice, I doubt any virtio driver really needs to match on anything other than bus and device_type (eliminating the unused entries for vtmmio), and also in practice device_type is << 2^16 (so far, values range from 1 to 20). So it might be fine to only expose a 16-bit device_type for PNP purposes. On the other hand, I don't see much harm in overkill here. Reviewed by: bryanv, markj (earlier version) Differential Revision: https://reviews.freebsd.org/D20406 Notes: svn path=/head/; revision=348598
* Split out the virtio mmio FDT attachment and add an ACPI attachment.Andrew Turner2018-10-214-97/+259
| | | | | | | | | | This allows the memory mapped I/O virtio driver to attach when we boot with ACPI tables, for example in some cases with QEMU emulating arm64. MFC after: 1 month Notes: svn path=/head/; revision=339540
* Make virtio queue re-initialization steps to be similar toRuslan Bukin2018-06-151-3/+14
| | | | | | | | | | | | | | | | original initialization, so we don't miss few registers to configure. This fixes vtnet(4) operation with QEMU's virtio-net-device. Tested in QEMU with FreeBSD/RISC-V. Reviewed by: bryanv Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D15821 Notes: svn path=/head/; revision=335211
* Revert r327828, r327949, r327953, r328016-r328026, r328041:Pedro F. Giffuni2018-01-211-1/+1
| | | | | | | | | | | | | | | | | | Uses of mallocarray(9). The use of mallocarray(9) has rocketed the required swap to build FreeBSD. This is likely caused by the allocation size attributes which put extra pressure on the compiler. Given that most of these checks are superfluous we have to choose better where to use mallocarray(9). We still have more uses of mallocarray(9) but hopefully this is enough to bring swap usage to a reasonable level. Reported by: wosch PR: 225197 Notes: svn path=/head/; revision=328218
* dev: make some use of mallocarray(9).Pedro F. Giffuni2018-01-131-1/+1
| | | | | | | | | | | | | | Focus on code where we are doing multiplications within malloc(9). None of these is likely to overflow, however the change is still useful as some static checkers can benefit from the allocation attributes we use for mallocarray. This initial sweep only covers malloc(9) calls with M_NOWAIT. No good reason but I started doing the changes before r327796 and at that time it was convenient to make sure the sorrounding code could handle NULL values. Notes: svn path=/head/; revision=327949
* Add 'prewrite' method allowing us to run some platform-specificRuslan Bukin2015-07-032-0/+22
| | | | | | | | code before each write happens, e.g. write-back caches. This will help booting in Bluespec simulator of CHERI processor. Notes: svn path=/head/; revision=285091
* Remove duplicate defines.Ruslan Bukin2015-06-181-4/+0
| | | | | | | Sponsored by: HEIF5 Notes: svn path=/head/; revision=284544
* Hide virtio features negotiation messages under bootverbose.Alexander Motin2015-03-151-1/+1
| | | | | | | | | Those messages are noisy, but useless for average user. MFC after: 2 weeks Notes: svn path=/head/; revision=280090
* Set the page size in the virtio-mmio driver. Some backends, e.g QEMU, assumeAndrew Turner2014-12-301-0/+2
| | | | | | | | | a 1 byte page size until told otherwise. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=276409
* Allow virtio_mmio to attach to ofwbus. Qemu places these here on at leastAndrew Turner2014-12-291-0/+1
| | | | | | | | | the AArch64 virtual platform with the Linaro UEFI. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=276358
* Add virtio bus 'poll' method allowing us to inform backend we areRuslan Bukin2014-12-122-0/+20
| | | | | | | | | | | | going to poll virtqueue. Use on BERI soft-core to invalidate cpu caches. Reviewed by: bryanv Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=275728
* o Add BERI Virtio Networking Frontend (if_vtbe)Ruslan Bukin2014-12-092-17/+18
| | | | | | | | | | | o Move similar block/networking methods to common file o Follow r275640 and correct MMIO registers width o Pass value to MMIO platform_note method. Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=275647
* Update the virtio driver to work on the ARM AArch64 Foundation Model.Andrew Turner2014-12-091-28/+68
| | | | | | | | | | | | | | There are two main parts to get it to work, 1) most of the register accesses need to be word sized, other than the config register which needs to be byte aligned, and 2) we don't need the platform driver for this to work on the Foundation Model, allow it to be NULL. Differential Revision: https://reviews.freebsd.org/D1240 Reviewed by: bryanv Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=275640
* Add Virtio MMIO bus driver.Ruslan Bukin2014-11-183-0/+939
Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=274655