20 Jul, 2012
1 commit
-
This patch changes virtio-scsi to use a new virtio_driver->scan() callback
so that scsi_scan_host() can be properly invoked once virtio_dev_probe() has
set add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK) to signal active virtio-ring
operation, instead of from within virtscsi_probe().This fixes a bug where SCSI LUN scanning for both virtio-scsi-raw and
virtio-scsi/tcm_vhost setups was happening before VIRTIO_CONFIG_S_DRIVER_OK
had been set, causing VIRTIO_SCSI_S_BAD_TARGET to occur. This fixes a bug
with virtio-scsi/tcm_vhost where LUN scan was not detecting LUNs.Tested with virtio-scsi-raw + virtio-scsi/tcm_vhost w/ IBLOCK on 3.5-rc2 code.
Signed-off-by: Nicholas Bellinger
Acked-by: Paolo Bonzini
Signed-off-by: James Bottomley
09 Jul, 2012
1 commit
-
Since ee7cd8981e15bcb365fc762afe3fc47b8242f630 'virtio: expose added
descriptors immediately.', in virtio balloon virtqueue_get_buf might
now run concurrently with virtqueue_kick. I audited both and this
seems safe in practice but this is not guaranteed by the API.
Additionally, a spurious interrupt might in theory make
virtqueue_get_buf run in parallel with virtqueue_add_buf, which is
racy.While we might try to protect against spurious callbacks it's
easier to fix the driver: balloon seems to be the only one
(mis)using the API like this, so let's just fix balloon.Signed-off-by: Michael S. Tsirkin
Signed-off-by: Rusty Russell (removed unused var)
22 May, 2012
4 commits
-
This patch adds an option to instantiate guest virtio-mmio devices
basing on a kernel command line (or module) parameter, for example:virtio_mmio.devices=0x100@0x100b0000:48
Signed-off-by: Pawel Moll
Signed-off-by: Rusty Russell -
Current index allocation in virtio is based on a monotonically
increasing variable "index". This means we'll run out of numbers
after a while. E.g. someone crazy doing this in host side.while(1) {
hot-plug a virtio device
hot-unplug the virito devcie
}Signed-off-by: Asias He
Signed-off-by: Rusty Russell -
The remove and freeze functions have a lot of shared code; put it into a
common function that gets called by both.Signed-off-by: Amit Shah
Signed-off-by: Rusty Russell -
restore_common() was used when there were different thaw and freeze PM
callbacks implemented. We removed thaw in commit
f38f8387cbdc4138a492ce9f2a5f04fd3cd3cf33.restore_common() can be removed and virtballoon_restore() can itself do
the restore ops.Signed-off-by: Amit Shah
Signed-off-by: Rusty Russell
17 May, 2012
1 commit
-
When the balloon module is removed, we deflate the balloon, reclaiming
all the pages that were given to the host. However, we don't update the
config values for the new balloon size, resulting in the host showing
outdated balloon values.The size update is done after each leak and fill operation, only the
module removal case was left out.Signed-off-by: Amit Shah
Signed-off-by: Michael S. Tsirkin
15 Apr, 2012
2 commits
-
As reported by David Gibson, current code handles PAGE_SIZE != 4k
completely wrong which can lead to guest memory corruption errors:- page_to_balloon_pfn is wrong: e.g. on system with 64K page size
it gives the same pfn value for 16 different pages.- we also need to convert back to linux pfns when we free.
- for each linux page we need to tell host about multiple balloon
pages, but code only adds one pfn to the array.This patch fixes all that, tested with a 64k ppc64 kernel.
Reported-by: David Gibson
Tested-by: David Gibson
Signed-off-by: Michael S. Tsirkin -
Although virtio config space fields are usually in guest-native endian,
the spec for the virtio balloon device explicitly states that both fields
in its config space are little-endian.However, the current virtio_balloon driver does not have a suitable endian
swap for the 'num_pages' field, although it does have one for the 'actual'
field. This patch corrects the bug, adding sparse annotation while we're
at it.Signed-off-by: David Gibson
Signed-off-by: Michael S. Tsirkin
31 Mar, 2012
5 commits
-
Use the SET_SYSTEM_SLEEP_PM_OPS macro to initialise the suspend/resume
functions in the new PM API.Signed-off-by: Amit Shah
-
There's no difference in supporting S3 and S4 for virtio devices: the
vqs have to be re-created as the device has to be assumed to be reset at
restore-time. Since S4 already handles this situation, we can directly
use the same code and callbacks for S3 support.Signed-off-by: Amit Shah
-
restore_common() was shared between restore and thaw callbacks. With
thaw gone, we don't need restore_common() anymore.Signed-off-by: Amit Shah
-
The thaw operation was used by the balloon driver, but after the last
commit there's no reason to have separate thaw and restore callbacks.Signed-off-by: Amit Shah
-
There's no reason stats update after restore can't work. If a host
requested for stats, and before servicing the request, the guest entered
S4, upon restore, the stats request can still be processed and sent off
to the host.Signed-off-by: Amit Shah
29 Mar, 2012
1 commit
-
Remove all #inclusions of asm/system.h preparatory to splitting and killing
it. Performed with the following command:perl -p -i -e 's!^#\s*include\s*.*\n!!' `grep -Irl '^#\s*include\s*' *`
Signed-off-by: David Howells
01 Mar, 2012
1 commit
-
commit e562966dbaf49e7804097cd991e5d3a8934fc148 added support for S4 to
the balloon driver. The freeze function did nothing to free the pages,
since reclaiming the pages from the host to immediately give them back
(if S4 was successful) seemed wasteful. Also, if S4 wasn't successful,
the guest would have to re-fill the balloon. On restore, the pages were
supposed to be marked freed and the free page counters were incremented
to reflect the balloon was totally deflated.However, this wasn't done right. The pages that were earlier taken away
from the guest during a balloon inflation operation were just shown as
used pages after a successful restore from S4. Just a fancy way of
leaking lots of memory.Instead of trying that, just leak the balloon on freeze and fill it on
restore/thaw paths. This works properly now. The optimisation to not
leak can be added later on after a bit of refactoring of the code.Signed-off-by: Amit Shah
Signed-off-by: Rusty Russell
28 Jan, 2012
2 commits
-
Use virtio_mb() to make sure the available index to be exposed before
checking the the avail event. Otherwise we may get stale value of
avail event in guest and never kick the host after.Note: this fixes a bug introduced by ee7cd8981e15bcb365fc762afe3fc47b8242f630.
Signed-off-by: Jason Wang
Acked-by: Michael S. Tsirkin
Signed-off-by: Rusty Russell
Cc: stable@kernel.org -
Note: this fixes a bug introduced recently in
7b21e34fd1c272e3a8c3846168f2f6287a4cd72b.Signed-off-by: Jason Wang
Acked-by: Michael S. Tsirkin
Signed-off-by: Rusty Russell
12 Jan, 2012
12 commits
-
Handling balloon hibernate / restore is tricky. If the balloon was
inflated before going into the hibernation state, upon resume, the host
will not have any memory of that. Any pages that were passed on to the
host earlier would most likely be invalid, and the host will have to
re-balloon to the previous value to get in the pre-hibernate state.So the only sane thing for the guest to do here is to discard all the
pages that were put in the balloon. When to discard the pages is the
next question.One solution is to deflate the balloon just before writing the image to
the disk (in the freeze() PM callback). However, asking for pages from
the host just to discard them immediately after seems wasteful of
resources. Hence, it makes sense to do this by just fudging our
counters soon after wakeup. This means we don't deflate the balloon
before sleep, and also don't put unnecessary pressure on the host.This also helps in the thaw case: if the freeze fails for whatever
reason, the balloon should continue to remain in the inflated state.
This was tested by issuing 'swapoff -a' and trying to go into the S4
state. That fails, and the balloon stays inflated, as expected. Both
the host and the guest are happy.Finally, in the restore() callback, we empty the list of pages that were
previously given off to the host, add the appropriate number of pages to
the totalram_pages counter, reset the num_pages counter to 0, and
all is fine.As a last step, delete the vqs on the freeze callback to prepare for
hibernation, and re-create them in the restore and thaw callbacks to
resume normal operation.The kthread doesn't race with any operations here, since it's frozen
before the freeze() call and is thawed after the thaw() and restore()
callbacks, so we're safe with that.Signed-off-by: Amit Shah
Signed-off-by: Rusty Russell -
The probe and PM restore functions will share this code.
Signed-off-by: Amit Shah
Signed-off-by: Rusty Russell -
Handle thaw, restore and freeze notifications from the PM core. Expose
these to individual virtio drivers that can quiesce and resume vq
operations. For drivers not implementing the thaw() method, use the
restore method instead.These functions also save device-specific data so that the device can be
put in pre-suspend state after resume, and disable and enable the PCI
device in the freeze and resume functions, respectively.Signed-off-by: Amit Shah
Signed-off-by: Rusty Russell -
The older PM API doesn't have a way to get notifications on hibernate
events. Switch to the newer one that gives us those notifications.Signed-off-by: Amit Shah
Signed-off-by: Rusty Russell -
Under the existing #ifdef DEBUG, check that they don't have more than
1/10 of a second between an add_buf() and a
virtqueue_notify()/virtqueue_kick_prepare() call.We could get false positives on a really busy system, but good for
development.Signed-off-by: Rusty Russell
-
A virtio driver does virtqueue_add_buf() multiple times before finally
calling virtqueue_kick(); previously we only exposed the added buffers
in the virtqueue_kick() call. This means we don't need a memory
barrier in virtqueue_add_buf(), but it reduces concurrency as the
device (ie. host) can't see the buffers until the kick.In the unusual (but now possible) case where a driver does add_buf()
and get_buf() without doing a kick, we do need to insert one before
our counter wraps. Otherwise we could wrap num_added, and later on
not realize that we have passed the marker where we should have
kicked.Signed-off-by: Rusty Russell
-
Since we know vq->vring.num is a power of 2, modulus is lazy (it's asserted
in vring_new_virtqueue()).Signed-off-by: Rusty Russell
-
Based on patch by Christoph for virtio_blk speedup:
Split virtqueue_kick to be able to do the actual notification
outside the lock protecting the virtqueue. This patch was
originally done by Stefan Hajnoczi, but I can't find the
original one anymore and had to recreated it from memory.
Pointers to the original or corrections for the commit message
are welcome.Stefan's patch was here:
https://github.com/stefanha/linux/commit/a6d06644e3a58e57a774e77d7dc34c4a5a2e7496
http://www.spinics.net/lists/linux-virtualization/msg14616.htmlThird time's the charm!
Signed-off-by: Rusty Russell
-
Remove wrapper functions. This makes the allocation type explicit in
all callers; I used GPF_KERNEL where it seemed obvious, left it at
GFP_ATOMIC otherwise.Signed-off-by: Rusty Russell
Reviewed-by: Christoph Hellwig -
The old documentation is left over from when we used a structure with
strategy pointers.And move the documentation to the C file as per kernel practice.
Though I disagree...Signed-off-by: Rusty Russell
Reviewed-by: Christoph Hellwig -
Trivial changes to remove forgotten junk, format comments, and correct names.
Cc: Rusty Russell
Cc: "Michael S. Tsirkin"
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: Sasha Levin
Signed-off-by: Rusty Russell -
We were cheating with our barriers; using the smp ones rather than the
real device ones. That was fine, until rpmsg came along, which is
used to talk to a real device (a non-SMP CPU).Unfortunately, just putting back the real barriers (reverting
d57ed95d) causes a performance regression on virtio-pci. In
particular, Amos reports netbench's TCP_RR over virtio_net CPU
utilization increased up to 35% while throughput went down by up to
14%.By comparison, this branch is in the noise.
Reference: https://lkml.org/lkml/2011/12/11/22
Signed-off-by: Rusty Russell
03 Dec, 2011
1 commit
24 Nov, 2011
3 commits
-
virtio pci device reset actually just does an I/O
write, which in PCI is really posted, that is it
can complete on CPU before the device has received it.Further, interrupts might have been pending on
another CPU, so device callback might get invoked after reset.This conflicts with how drivers use reset, which is typically:
reset
unregister
a callback running after reset completed can race with
unregister, potentially leading to use after free bugs.Fix by flushing out the write, and flushing pending interrupts.
This assumes that device is never reset from
its vq/config callbacks, or in parallel with being
added/removed, document this assumption.Signed-off-by: Michael S. Tsirkin
Signed-off-by: Rusty Russell -
Guest features selector spelling mistake.
Cc: Pawel Moll
Cc: Rusty Russell
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: Sasha Levin
Signed-off-by: Rusty Russell -
Fix this compile error on s390:
CC [M] drivers/virtio/virtio_mmio.o
drivers/virtio/virtio_mmio.c: In function 'vm_get_features':
drivers/virtio/virtio_mmio.c:107:2: error: implicit declaration of function 'writel'Cc: Christian Borntraeger
Signed-off-by: Heiko Carstens
Acked-by: Pawel Moll
Signed-off-by: Rusty Russell
22 Nov, 2011
1 commit
-
The forcedeth changes had a conflict with the conversion over
to atomic u64 statistics in net-next.The libertas cfg.c code had a conflict with the bss reference
counting fix by John Linville in net-next.Conflicts:
drivers/net/ethernet/nvidia/forcedeth.c
drivers/net/wireless/libertas/cfg.c
17 Nov, 2011
1 commit
-
Add a new .bus_name to virtio_config_ops then modify virtio_net to
call through to it in an ethtool .get_drvinfo routine to report
bus_info in ethtool -i output which is consistent with other
emulated NICs and the output of lspci.Signed-off-by: Rick Jones
Signed-off-by: David S. Miller
14 Nov, 2011
1 commit
-
Commit 31a3ddda166cda86d2b5111e09ba4bda5239fae6 introduced
a use after free in virtio-pci. The main issue is
that the release method signals removal of the virtio device,
while remove signals removal of the pci device.For example, on driver removal or hot-unplug,
virtio_pci_release_dev is called before virtio_pci_remove.
We then might get a crash as virtio_pci_remove tries to use the
device freed by virtio_pci_release_dev.We allocate/free all resources together with the
pci device, so we can leave the release method empty.Signed-off-by: Michael S. Tsirkin
Acked-by: Amit Shah
Signed-off-by: Rusty Russell
Cc: stable@kernel.org
07 Nov, 2011
1 commit
-
* 'modsplit-Oct31_2011' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux: (230 commits)
Revert "tracing: Include module.h in define_trace.h"
irq: don't put module.h into irq.h for tracking irqgen modules.
bluetooth: macroize two small inlines to avoid module.h
ip_vs.h: fix implicit use of module_get/module_put from module.h
nf_conntrack.h: fix up fallout from implicit moduleparam.h presence
include: replace linux/module.h with "struct module" wherever possible
include: convert various register fcns to macros to avoid include chaining
crypto.h: remove unused crypto_tfm_alg_modname() inline
uwb.h: fix implicit use of asm/page.h for PAGE_SIZE
pm_runtime.h: explicitly requires notifier.h
linux/dmaengine.h: fix implicit use of bitmap.h and asm/page.h
miscdevice.h: fix up implicit use of lists and types
stop_machine.h: fix implicit use of smp.h for smp_processor_id
of: fix implicit use of errno.h in include/linux/of.h
of_platform.h: delete needless include
acpi: remove module.h include from platform/aclinux.h
miscdevice.h: delete unnecessary inclusion of module.h
device_cgroup.h: delete needless include
net: sch_generic remove redundant use of
net: inet_timewait_sock doesnt need
...Fix up trivial conflicts (other header files, and removal of the ab3550 mfd driver) in
- drivers/media/dvb/frontends/dibx000_common.c
- drivers/media/video/{mt9m111.c,ov6650.c}
- drivers/mfd/ab3550-core.c
- include/linux/dmaengine.h
02 Nov, 2011
2 commits
-
This patch, based on virtio PCI driver, adds support for memory
mapped (platform) virtio device. This should allow environments
like qemu to use virtio-based block & network devices even on
platforms without PCI support.One can define and register a platform device which resources
will describe memory mapped control registers and "mailbox"
interrupt. Such device can be also instantiated using the Device
Tree node with compatible property equal "virtio,mmio".Cc: Anthony Liguori
Cc: Michael S.Tsirkin
Signed-off-by: Pawel Moll
Signed-off-by: Rusty Russell -
For the MSI but non-per_vq_vector case, the config/change vq
also gets added to the list of vqs that need to process the
MSI interrupt. This is not needed as config has it's own
handler (vp_config_changed). In any case, vring_interrupt()
finds nothing needs to be done on this vq.I tested this patch by testing the "Fallback:" and "Finally
fall back" cases in vp_find_vqs(). Please review.Signed-off-by: Krishna Kumar
Acked-by: Michael S. Tsirkin
Signed-off-by: Rusty Russell