summaryrefslogtreecommitdiffstats
path: root/drivers/virtio (follow)
Commit message (Collapse)AuthorAgeFilesLines
* virtio: don't set VIRTIO_CONFIG_S_DRIVER_OK twice.Rusty Russell2015-02-171-1/+4
| | | | | | | I noticed this with the console device. It's not *wrong*, just a bit weird. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* virtio_pci: use 16-bit accessor for queue_enable.Rusty Russell2015-02-111-2/+2
| | | | | | | | | | | | | | Since PCI is little endian, 8-bit access might work, but the spec section is very clear on this: 4.1.3.1 Driver Requirements: PCI Device Layout The driver MUST access each field using the “natural” access method, i.e. 32-bit accesses for 32-bit fields, 16-bit accesses for 16-bit fields and 8-bit accesses for 8-bit fields. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Acked-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: Avoid possible kernel panic if DEBUG is enabled.Tetsuo Handa2015-02-111-3/+3
| | | | | | | | | | | The virtqueue_add() calls START_USE() upon entry. The virtqueue_kick() is called if vq->num_added == (1 << 16) - 1 before calling END_USE(). The virtqueue_kick_prepare() called via virtqueue_kick() calls START_USE() upon entry, and will call panic() if DEBUG is enabled. Move this virtqueue_kick() call to after END_USE() call. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* virtio-mmio: Update the device to OASIS spec versionPawel Moll2015-01-231-50/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch add a support for second version of the virtio-mmio device, which follows OASIS "Virtual I/O Device (VIRTIO) Version 1.0" specification. Main changes: 1. The control register symbolic names use the new device/driver nomenclature rather than the old guest/host one. 2. The driver detect the device version (version 1 is the pre-OASIS spec, version 2 is compatible with fist revision of the OASIS spec) and drives the device accordingly. 3. New version uses direct addressing (64 bit address split into two low/high register) instead of the guest page size based one, and addresses each part of the queue (descriptors, available, used) separately. 4. The device activity is now explicitly triggered by writing to the "queue ready" register. 5. Whole 64 bit features are properly handled now (both ways). Signed-off-by: Pawel Moll <pawel.moll@arm.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* virtio_pci_modern: drop an unused functionMichael S. Tsirkin2015-01-211-8/+0
| | | | | | | | release function in modern driver is unused: it's a left-over from when each driver had to have its own release. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio_pci: add module param to force legacy modeMichael S. Tsirkin2015-01-211-4/+21
| | | | | | | | If set, try legacy interface first, modern one if that fails. Useful to work around device/driver bugs, and for compatibility testing. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* virtio_pci: add an option to disable legacy driverMichael S. Tsirkin2015-01-213-1/+31
| | | | | | | | | Useful for testing device virtio 1 compatibility. Based on patch by Rusty - couldn't resist putting that flying car joke in there! Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* virtio_pci: drop Kconfig warningsMichael S. Tsirkin2015-01-211-3/+0
| | | | | | | | | The ABI *is* stable, and has been for a while now. Drop Kconfig warning saying that it's not guaranteed to work. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* virtio_pci: Kconfig grammar fixMichael S. Tsirkin2015-01-211-1/+1
| | | | | | | This drivers -> this driver. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* virtio_ring: coding style fixMichael S. Tsirkin2015-01-211-2/+1
| | | | | | | | | | | Most of our code has struct foo { } Fix one instances where ring is inconsistent. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* virtio_balloon: coding style fixesMichael S. Tsirkin2015-01-211-2/+1
| | | | | | | | | | | Most of our code has struct foo { } Fix two instances where balloon is inconsistent. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* virtio_pci_modern: support devices with no configMichael S. Tsirkin2015-01-211-2/+19
| | | | | | | | | Virtio 1.0 spec lists device config as optional. Set get/set callbacks to NULL. Drivers can check that and fail gracefully. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* virtio_pci_modern: reduce number of mappingsMichael S. Tsirkin2015-01-212-8/+52
| | | | | | | | | | | We don't know the # of VQs that drivers are going to use so it's hard to predict how much memory we'll need to map. However, the relevant capability does give us an upper limit. If that's below a page, we can reduce the number of required mappings by mapping it all once ahead of the time. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* virtio_pci: macros for PCI layout offsetsRusty Russell2015-01-211-1/+59
| | | | | | | QEMU wants it, so why not? Trust, but verify. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio_pci: modern driverMichael S. Tsirkin2015-01-214-7/+621
| | | | | | | | | | | | | | | | Lightly tested against qemu. One thing *not* implemented here is separate mappings for descriptor/avail/used rings. That's nice to have, will be done later after we have core support. This also exposes the PCI layout to userspace, and adds macros for PCI layout offsets: QEMU wants it, so why not? Trust, but verify. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio_pci: move probe/remove code to commonMichael S. Tsirkin2015-01-213-72/+77
| | | | | | | | Most of initialization is device-independent. Let's move it to common. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* virtio_pci: drop useless del_vqs callSasha Levin2015-01-211-1/+0
| | | | | | | | | | Device VQs were getting freed twice: once in every device's removal functions, and then again in virtio_pci_legacy_remove(). The ones in devices are called first, so drop the useless second call. Signed-off-by: Sasha Levin <sasha.levin@oracle.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* virtio/balloon: verify device has config spaceMichael S. Tsirkin2015-01-211-0/+6
| | | | | | | | | | Some devices might not implement config space access (e.g. remoteproc used not to - before 3.9). virtio/balloon needs config space access so make it fail gracefully if not there. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* virtio_pci: document why we defer kfreeMichael S. Tsirkin2015-01-061-0/+3
| | | | | | | | | | | | | The reason we defer kfree until release function is because it's a general rule for kobjects: kfree of the reference counter itself is only legal in the release function. Previous patch didn't make this clear, document this in code. Cc: stable@vger.kernel.org Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio_pci: defer kfree until release callbackSasha Levin2015-01-061-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | A struct device which has just been unregistered can live on past the point at which a driver decides to drop it's initial reference to the kobject gained on allocation. This implies that when releasing a virtio device, we can't free a struct virtio_device until the underlying struct device has been released, which might not happen immediately on device_unregister(). Unfortunately, this is exactly what virtio pci does: it has an empty release callback, and frees memory immediately after unregistering the device. This causes an easy to reproduce crash if CONFIG_DEBUG_KOBJECT_RELEASE it enabled. To fix, free the memory only once we know the device is gone in the release callback. Cc: stable@vger.kernel.org Signed-off-by: Sasha Levin <sasha.levin@oracle.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio_pci: device-specific release callbackMichael S. Tsirkin2015-01-063-10/+9
| | | | | | | | | It turns out we need to add device-specific code in release callback. Move it to virtio_pci_legacy.c. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: make del_vqs idempotentMichael S. Tsirkin2015-01-061-0/+1
| | | | | | | | | | | | | | | | | | Our code calls del_vqs multiple times, assuming it's idempotent. commit 3ec7a77bb3089bb01032fdbd958eb5c29da58b49 virtio_pci: free up vq->priv broke this assumption, by adding kfree there, so multiple calls cause double free. Fix it up. Fixes: 3ec7a77bb3089bb01032fdbd958eb5c29da58b49 Reported-by: Sasha Levin <sasha.levin@oracle.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhostLinus Torvalds2014-12-194-41/+66
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pull virtio fixes from Michael S Tsirkin: "virtio 1.0 related fixes Most importantly, this fixes using virtio_pci as a module. Further, the big virtio 1.0 conversion missed a couple of places. This fixes them up. This isn't 100% sparse-clean yet because on many architectures get_user triggers sparse warnings when used with __bitwise tag (when same tag is on both pointer and value read). I posted a patchset to fix it up by adding __force on all arches that don't already have it (many do), when that's merged these warnings will go away" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: virtio_pci: restore module attributes mic/host: fix up virtio 1.0 APIs vringh: update for virtio 1.0 APIs vringh: 64 bit features tools/virtio: add virtio 1.0 in vringh_test tools/virtio: add virtio 1.0 in virtio_test tools/virtio: enable -Werror tools/virtio: 64 bit features tools/virtio: fix vringh test tools/virtio: more stubs virtio: core support for config generation virtio_pci: add VIRTIO_PCI_NO_LEGACY virtio_pci: move probe to common file virtio_pci_common.h: drop VIRTIO_PCI_NO_LEGACY virtio_config: fix virtio_cread_bytes virtio: set VIRTIO_CONFIG_S_FEATURES_OK on restore
| * virtio_pci: restore module attributesHerbert Xu2014-12-161-0/+5
| | | | | | | | | | | | | | | | When the virtio_pci driver was moved into virtio_pci_legacy.c the module licence and other attributes went AWOL. This patch restores them. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
| * virtio_pci: move probe to common fileMichael S. Tsirkin2014-12-143-26/+38
| | | | | | | | | | | | It turns out this make everything easier. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
| * virtio_pci_common.h: drop VIRTIO_PCI_NO_LEGACYMichael S. Tsirkin2014-12-111-1/+0
| | | | | | | | | | | | | | Legacy drivers use virtio_pci_common.h too, we should not define VIRTIO_PCI_NO_LEGACY there. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
| * virtio: set VIRTIO_CONFIG_S_FEATURES_OK on restoreMichael S. Tsirkin2014-12-111-14/+23
| | | | | | | | | | | | | | | | | | virtio 1.0 devices require that drivers set VIRTIO_CONFIG_S_FEATURES_OK after finalizing features. virtio core missed doing this on restore, fix it up. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* | Merge tag 'virtio-next-for-linus' of ↵Linus Torvalds2014-12-171-1/+56
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux Pull virtio updates from Rusty Russell: "A balloon enhancement, and a minor race-on-module-unload theoretical bug which doesn't merit cc: stable. All the exciting stuff went via MST this cycle" * tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux: virtio_balloon: free some memory from balloon on OOM virtio_balloon: return the amount of freed memory from leak_balloon() virtio_blk: fix race at module removal virtio: Fix comment typo 'CONFIG_S_FAILED'
| * | virtio_balloon: free some memory from balloon on OOMRaushaniya Maksudova2014-11-111-0/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Excessive virtio_balloon inflation can cause invocation of OOM-killer, when Linux is under severe memory pressure. Various mechanisms are responsible for correct virtio_balloon memory management. Nevertheless it is often the case that these control tools does not have enough time to react on fast changing memory load. As a result OS runs out of memory and invokes OOM-killer. The balancing of memory by use of the virtio balloon should not cause the termination of processes while there are pages in the balloon. Now there is no way for virtio balloon driver to free some memory at the last moment before some process will be get killed by OOM-killer. This does not provide a security breach as balloon itself is running inside guest OS and is working in the cooperation with the host. Thus some improvements from guest side should be considered as normal. To solve the problem, introduce a virtio_balloon callback which is expected to be called from the oom notifier call chain in out_of_memory() function. If virtio balloon could release some memory, it will make the system to return and retry the allocation that forced the out of memory killer to run. Allocate virtio feature bit for this: it is not set by default, the the guest will not deflate virtio balloon on OOM without explicit permission from host. Signed-off-by: Raushaniya Maksudova <rmaksudova@parallels.com> Signed-off-by: Denis V. Lunev <den@openvz.org> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
| * | virtio_balloon: return the amount of freed memory from leak_balloon()Raushaniya Maksudova2014-11-111-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This value would be useful in the next patch to provide the amount of the freed memory for OOM killer. Signed-off-by: Raushaniya Maksudova <rmaksudova@parallels.com> Signed-off-by: Denis V. Lunev <den@openvz.org> CC: Rusty Russell <rusty@rustcorp.com.au> CC: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* | | Merge tag 'driver-core-3.19-rc1' of ↵Linus Torvalds2014-12-151-1/+0
|\ \ \ | |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core Pull driver core update from Greg KH: "Here's the set of driver core patches for 3.19-rc1. They are dominated by the removal of the .owner field in platform drivers. They touch a lot of files, but they are "simple" changes, just removing a line in a structure. Other than that, a few minor driver core and debugfs changes. There are some ath9k patches coming in through this tree that have been acked by the wireless maintainers as they relied on the debugfs changes. Everything has been in linux-next for a while" * tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (324 commits) Revert "ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries" fs: debugfs: add forward declaration for struct device type firmware class: Deletion of an unnecessary check before the function call "vunmap" firmware loader: fix hung task warning dump devcoredump: provide a one-way disable function device: Add dev_<level>_once variants ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries ath: use seq_file api for ath9k debugfs files debugfs: add helper function to create device related seq_file drivers/base: cacheinfo: remove noisy error boot message Revert "core: platform: add warning if driver has no owner" drivers: base: support cpu cache information interface to userspace via sysfs drivers: base: add cpu_device_create to support per-cpu devices topology: replace custom attribute macros with standard DEVICE_ATTR* cpumask: factor out show_cpumap into separate helper function driver core: Fix unbalanced device reference in drivers_probe driver core: fix race with userland in device_add() sysfs/kernfs: make read requests on pre-alloc files use the buffer. sysfs/kernfs: allow attributes to request write buffer be pre-allocated. fs: sysfs: return EGBIG on write if offset is larger than file size ...
| * | virtio: drop owner assignment from platform_driversWolfram Sang2014-10-201-1/+0
| |/ | | | | | | | | | | | | A platform_driver does not need to set an owner, it will be populated by the driver core. Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* | virtio_pci: rename virtio_pci -> virtio_pci_commonMichael S. Tsirkin2014-12-094-4/+5
| | | | | | | | | | | | | | | | | | kbuild does not seem to like it when we name source files same as the module. Let's rename virtio_pci -> virtio_pci_common, and get rid of #include-ing c files. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | virtio_pci: update file descriptions and copyrightMichael S. Tsirkin2014-12-093-3/+12
| | | | | | | | | | | | | | There's been a lot of changes since 2007. List main authors, add Red Hat copyright. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | virtio_pci: split out legacy device supportMichael S. Tsirkin2014-12-093-408/+468
| | | | | | | | | | | | | | Move everything dealing with legacy devices out to virtio_pci_legacy.c. Expose common code APIs in virtio_pci.h Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | virtio_pci: setup config vector indirectlyMichael S. Tsirkin2014-12-091-6/+13
| | | | | | | | | | | | config vector setup is version specific, do it indirectly. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | virtio_pci: setup vqs indirectlyMichael S. Tsirkin2014-12-091-23/+46
| | | | | | | | | | | | | | VQ setup is mostly version-specific, add another level of indirection to split the version-independent code out. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | virtio_pci: delete vqs indirectlyMichael S. Tsirkin2014-12-091-7/+20
| | | | | | | | | | | | | | VQ deletion is mostly version-specific, add another level of indirection to split the version-independent code out. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | virtio_pci: use priv for vq notificationMichael S. Tsirkin2014-12-091-3/+2
| | | | | | | | | | | | | | slightly reduce the amount of pointer chasing this needs to do. More importantly, this will easily generalize to virtio 1.0. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | virtio_pci: free up vq->privMichael S. Tsirkin2014-12-091-25/+31
| | | | | | | | | | | | | | | | | | | | | | We don't need to go from vq to vq info on data path, so using direct vq->priv pointer for that seems like a waste. Let's build an array of vq infos, then we can use vq->index for that lookup. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | virtio_pci: fix coding style for structsMichael S. Tsirkin2014-12-091-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | should be struct foo { } not struct foo { } Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | virtio_pci: add isr fieldMichael S. Tsirkin2014-12-091-1/+6
| | | | | | | | | | | | | | Use isr field instead of direct access to ioaddr. This way generalizes easily to virtio 1.0. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | virtio: drop legacy_only driver flagMichael S. Tsirkin2014-12-091-4/+0
| | | | | | | | | | | | | | legacy_only flag is now unused, drop it from core. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* | virtio_balloon: drop legacy_only driver flagMichael S. Tsirkin2014-12-091-1/+0
| | | | | | | | | | | | | | | | | | we have blacklisted balloon in core, no need for a driver flag. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* | virtio: allow finalize_features to failMichael S. Tsirkin2014-12-093-9/+20
| | | | | | | | | | | | | | This will make it easy for transports to validate features and return failure. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | virtio: add API to detect legacy devicesMichael S. Tsirkin2014-12-091-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | transports need to be able to detect legacy-only devices (ATM balloon only) to use legacy path to drive them. Add a core API to do just that. The implementation just blacklists balloon: not too pretty, but let's not over-engineer. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* | virtio: make VIRTIO_F_VERSION_1 a transport bitMichael S. Tsirkin2014-12-092-1/+7
| | | | | | | | | | | | | | | | | | | | | | Activate VIRTIO_F_VERSION_1 automatically unless legacy_only is set. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | virtio_balloon: add legacy_only flagMichael S. Tsirkin2014-12-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | We have no plans to support virtio 1.0 in balloon driver. Add an explicit flag to mark it legacy only. This will be used by follow-up patches. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | virtio: add legacy feature table supportMichael S. Tsirkin2014-12-091-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | virtio-blk has some legacy feature bits that modern drivers must not negotiate, but are needed for old legacy hosts (that e.g. don't support virtio-scsi). Allow a separate legacy feature table for such cases. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* | virtio: simplify feature bit handlingMichael S. Tsirkin2014-12-091-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | Now that we use u64 for bits, we can simply & them together. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>