[PATCH v3 03/41] virtio: add virtio 1.0 feature bit

2014-11-24 Thread Michael S. Tsirkin
Based on original patches by Rusty Russell, Thomas Huth and Cornelia Huck. Note: at this time, we do not negotiate this feature bit in core, drivers have to declare VERSION_1 support explicitly. After all drivers are converted, we will be able to move VERSION_1 to core and drop it from all

[PATCH v3 05/41] virtio_ring: switch to new memory access APIs

2014-11-24 Thread Michael S. Tsirkin
Use virtioXX_to_cpu and friends for access to all multibyte structures in memory. Note: this is intentionally mechanical. A follow-up patch will split long lines etc. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- drivers/virtio/virtio_ring.c | 89

[PATCH v3 06/41] virtio_config: endian conversion for v1.0

2014-11-24 Thread Michael S. Tsirkin
We (ab)use virtio conversion functions for device-specific config space accesses. Reviewed-by: David Hildenbrand d...@linux.vnet.ibm.com Signed-off-by: Rusty Russell ru...@rustcorp.com.au Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com Signed-off-by: Michael S. Tsirkin m...@redhat.com ---

[PATCH v3 01/41] virtio: use u32, not bitmap for struct virtio_device's features

2014-11-24 Thread Michael S. Tsirkin
From: Rusty Russell ru...@rustcorp.com.au It seemed like a good idea, but it's actually a pain when we get more than 32 feature bits. Just change it to a u32 for now. Cc: Brian Swetland swetl...@google.com Cc: Christian Borntraeger borntrae...@de.ibm.com Signed-off-by: Rusty Russell

[PATCH v3 02/41] virtio: add support for 64 bit features.

2014-11-24 Thread Michael S. Tsirkin
From: Rusty Russell ru...@rustcorp.com.au Change the u32 to a u64, and make sure to use 1ULL everywhere! Cc: Brian Swetland swetl...@google.com Cc: Christian Borntraeger borntrae...@de.ibm.com [Thomas Huth: fix up virtio-ccw get_features] Signed-off-by: Rusty Russell ru...@rustcorp.com.au

[PATCH v3 04/41] virtio: memory access APIs

2014-11-24 Thread Michael S. Tsirkin
virtio 1.0 makes all memory structures LE, so we need APIs to conditionally do a byteswap on BE architectures. To make it easier to check code statically, add virtio specific types for multi-byte integers in memory. Add low level wrappers that do a byteswap conditionally, these will be useful

[PATCH v3 07/41] virtio: allow transports to get avail/used addresses

2014-11-24 Thread Michael S. Tsirkin
From: Cornelia Huck cornelia.h...@de.ibm.com For virtio-1, we can theoretically have a more complex virtqueue layout with avail and used buffers not on a contiguous memory area with the descriptor table. For now, it's fine for a transport driver to stay with the old layout: It needs, however, a

[PATCH v3 10/41] virtio: add legacy feature table support

2014-11-24 Thread Michael S. Tsirkin
virtio blk has some legacy feature bits that modern drivers must not negotiate, but are needed for old legacy hosts (e.g. that dn't support virtio scsi). Allow a separate legacy feature table for such cases. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- include/linux/virtio.h | 4

[PATCH v3 11/41] virtio_net: v1.0 endianness

2014-11-24 Thread Michael S. Tsirkin
Based on patches by Rusty Russell, Cornelia Huck. Note: more code changes are needed for 1.0 support (due to different header size). So we don't advertize support for 1.0 yet. Signed-off-by: Rusty Russell ru...@rustcorp.com.au Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com Signed-off-by:

[PATCH v3 08/41] virtio: set FEATURES_OK

2014-11-24 Thread Michael S. Tsirkin
set FEATURES_OK as per virtio 1.0 spec Signed-off-by: Michael S. Tsirkin m...@redhat.com --- include/uapi/linux/virtio_config.h | 2 ++ drivers/virtio/virtio.c| 29 ++--- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git

[PATCH v3 12/41] virtio_blk: v1.0 support

2014-11-24 Thread Michael S. Tsirkin
Based on patch by Cornelia Huck. Note: for consistency, and to avoid sparse errors, convert all fields, even those no longer in use for virtio v1.0. Reviewed-by: Thomas Huth th...@linux.vnet.ibm.com Reviewed-by: David Hildenbrand d...@linux.vnet.ibm.com Signed-off-by: Cornelia Huck

[PATCH v3 09/41] virtio: simplify feature bit handling

2014-11-24 Thread Michael S. Tsirkin
Now that we use u64 for bits, we can simply them together. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- drivers/virtio/virtio.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index a3df817..0f44cff 100644

[PATCH v3 17/41] virtio_blk: make serial attribute static

2014-11-24 Thread Michael S. Tsirkin
It's never declared so no need to make it extern. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- drivers/block/virtio_blk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index f601f16..055f3df 100644 ---

[PATCH v3 19/41] virtio_net: pass vi around

2014-11-24 Thread Michael S. Tsirkin
Too many places poke at [rs]q-vq-vdev-priv just to get the the vi structure. Let's just pass the pointer around: seems cleaner, and might even be faster. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- drivers/net/virtio_net.c | 38 -- 1 file changed,

[PATCH v3 20/41] virtio_net: get rid of virtio_net_hdr/skb_vnet_hdr

2014-11-24 Thread Michael S. Tsirkin
virtio 1.0 doesn't use virtio_net_hdr anymore, and in fact, it's not really useful since virtio_net_hdr_mrg_rxbuf includes that as the first field anyway. Let's drop it, precalculate header len and store within vi instead. This way we can also remove struct skb_vnet_hdr. Signed-off-by: Michael

[PATCH v3 22/41] virtio_net: bigger header when VERSION_1 is set

2014-11-24 Thread Michael S. Tsirkin
With VERSION_1 virtio_net uses same header size whether mergeable buffers are enabled or not. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- drivers/net/virtio_net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c

[PATCH v3 18/41] virtio_blk: fix race at module removal

2014-11-24 Thread Michael S. Tsirkin
If a device appears while module is being removed, driver will get a callback after we've given up on the major number. In theory this means this major number can get reused by something else, resulting in a conflict. Signed-off-by: Michael S. Tsirkin m...@redhat.com ---

[PATCH v3 21/41] virtio_net: stricter short buffer length checks

2014-11-24 Thread Michael S. Tsirkin
Our buffer length check is not strict enough for mergeable buffers: buffer can still be shorter that header + address by 2 bytes. Fix that up. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git

[PATCH v3 23/41] virtio_net: enable v1.0 support

2014-11-24 Thread Michael S. Tsirkin
Now that we have completed 1.0 support, enable it in our driver. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- drivers/net/virtio_net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index a0e64cf..c6a72d3 100644 ---

[PATCH v3 24/41] vhost: add memory access wrappers

2014-11-24 Thread Michael S. Tsirkin
Signed-off-by: Michael S. Tsirkin m...@redhat.com --- drivers/vhost/vhost.h | 33 - 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 3eda654..b9032e8 100644 --- a/drivers/vhost/vhost.h +++

[PATCH v3 26/41] vhost: virtio 1.0 endian-ness support

2014-11-24 Thread Michael S. Tsirkin
Signed-off-by: Michael S. Tsirkin m...@redhat.com --- drivers/vhost/vhost.c | 93 +++ 1 file changed, 56 insertions(+), 37 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index c90f437..4d379ed 100644 ---

[PATCH v3 25/41] vhost/net: force len for TX to host endian

2014-11-24 Thread Michael S. Tsirkin
We use native endian-ness internally but never expose it to guest. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- drivers/vhost/net.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 8dae2f7..dce5c58 100644 ---

[PATCH v3 28/41] vhost/net: virtio 1.0 byte swap

2014-11-24 Thread Michael S. Tsirkin
Signed-off-by: Michael S. Tsirkin m...@redhat.com --- drivers/vhost/net.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index dce5c58..cae22f9 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -416,7 +416,7

[PATCH v3 37/41] virtio_scsi: v1.0 support

2014-11-24 Thread Michael S. Tsirkin
Note: for consistency, and to avoid sparse errors, convert all fields, even those no longer in use for virtio v1.0. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- include/linux/virtio_scsi.h | 32 +++- drivers/scsi/virtio_scsi.c | 51

[PATCH v3 30/41] vhost/net: enable virtio 1.0

2014-11-24 Thread Michael S. Tsirkin
Signed-off-by: Michael S. Tsirkin m...@redhat.com --- drivers/vhost/net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 1ac58d0..984242e 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -61,7 +61,8 @@

[PATCH v3 39/41] virtio_scsi: export to userspace

2014-11-24 Thread Michael S. Tsirkin
Replace uXX by __uXX and _packed by __attribute((packed)) as seems to be the norm for userspace headers. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- include/uapi/linux/virtio_scsi.h | 74 include/uapi/linux/Kbuild| 1 + 2 files changed,

[PATCH v3 31/41] vhost/net: suppress compiler warning

2014-11-24 Thread Michael S. Tsirkin
len is always initialized since function is called with size 0. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- drivers/vhost/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 984242e..54ffbb0 100644 ---

[PATCH v3 29/41] vhost/net: larger header for virtio 1.0

2014-11-24 Thread Michael S. Tsirkin
Signed-off-by: Michael S. Tsirkin m...@redhat.com --- drivers/vhost/net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index cae22f9..1ac58d0 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -1027,7 +1027,8 @@ static

Re: [PATCH v3 04/41] virtio: memory access APIs

2014-11-24 Thread Geert Uytterhoeven
On Mon, Nov 24, 2014 at 12:52 PM, Michael S. Tsirkin m...@redhat.com wrote: virtio 1.0 makes all memory structures LE, so we need APIs to conditionally do a byteswap on BE architectures. To make it easier to check code statically, add virtio specific types for multi-byte integers in memory.

Re: [PATCH v3 04/41] virtio: memory access APIs

2014-11-24 Thread Michael S. Tsirkin
On Mon, Nov 24, 2014 at 01:03:24PM +0100, Geert Uytterhoeven wrote: On Mon, Nov 24, 2014 at 12:52 PM, Michael S. Tsirkin m...@redhat.com wrote: virtio 1.0 makes all memory structures LE, so we need APIs to conditionally do a byteswap on BE architectures. To make it easier to check code

Re: [PATCH v3 04/41] virtio: memory access APIs

2014-11-24 Thread Geert Uytterhoeven
On Mon, Nov 24, 2014 at 1:15 PM, Michael S. Tsirkin m...@redhat.com wrote: On Mon, Nov 24, 2014 at 01:03:24PM +0100, Geert Uytterhoeven wrote: On Mon, Nov 24, 2014 at 12:52 PM, Michael S. Tsirkin m...@redhat.com wrote: virtio 1.0 makes all memory structures LE, so we need APIs to

Re: [PATCH v4 4/6] hw_random: fix unregister race.

2014-11-24 Thread Amos Kong
On Wed, Nov 12, 2014 at 02:33:00PM +1030, Rusty Russell wrote: Amos Kong ak...@redhat.com writes: From: Rusty Russell ru...@rustcorp.com.au The previous patch added one potential problem: we can still be reading from a hwrng when it's unregistered. Add a wait for zero in the