Re: [PATCH 0/3] virtio: Clean up scatterlists and use the DMA API

2014-08-27 Thread Stefan Hajnoczi
On Tue, Aug 26, 2014 at 10:16 PM, Andy Lutomirski l...@amacapital.net wrote: There are two outstanding issues. virtio_net warns if DMA debugging is on because it does DMA from the stack. (The warning is correct.) This also is likely to do something unpleasant to s390. (Maintainers are cc'd

Re: GET_RNG_SEED hypercall ABI? (Re: [PATCH v5 0/5] random,x86,kvm: Rework arch RNG seeds and get some from kvm)

2014-08-27 Thread Paolo Bonzini
Il 27/08/2014 01:58, Andy Lutomirski ha scritto: hpa pointed out that the ABI that I chose (an MSR from the KVM range and a KVM cpuid bit) is unnecessarily KVM-specific. It would be nice to allocate an MSR that everyone involved can agree on and, rather than relying on a cpuid bit, just have

Re: GET_RNG_SEED hypercall ABI? (Re: [PATCH v5 0/5] random,x86,kvm: Rework arch RNG seeds and get some from kvm)

2014-08-27 Thread H. Peter Anvin
On 08/27/2014 12:00 AM, Paolo Bonzini wrote: Il 27/08/2014 01:58, Andy Lutomirski ha scritto: hpa pointed out that the ABI that I chose (an MSR from the KVM range and a KVM cpuid bit) is unnecessarily KVM-specific. It would be nice to allocate an MSR that everyone involved can agree on and,

Re: [PATCH 2/3] virtio_ring: Use DMA APIs

2014-08-27 Thread Christian Borntraeger
On 26/08/14 23:17, Andy Lutomirski wrote: virtio_ring currently sends the device (usually a hypervisor) physical addresses of its I/O buffers. This is okay when DMA addresses and physical addresses are the same thing, but this isn't always the case. For example, this never works on Xen

Re: [PATCH 0/3] virtio: Clean up scatterlists and use the DMA API

2014-08-27 Thread Cornelia Huck
On Tue, 26 Aug 2014 14:16:59 -0700 Andy Lutomirski l...@amacapital.net wrote: This fixes virtio on Xen guests as well as on any other platform on which physical addresses don't match bus addresses. This can be tested with: virtme-run --xen xen --kimg arch/x86/boot/bzImage --console

Re: [3.16 stable PATCH v2 1/2] virtio: rng: delay hwrng_register() till driver is ready

2014-08-27 Thread Amit Shah
Hey Greg, Can you add these two patches to the 3.16 queue? Thanks, On (Tue) 12 Aug 2014 [13:23:45], Amit Shah wrote: Instead of calling hwrng_register() in the probe routing, call it in the scan routine. This ensures that when hwrng_register() is successful, and it requests a few random

Re: virtio DMA API?

2014-08-27 Thread Rusty Russell
Andy Lutomirski l...@amacapital.net writes: Currently, a lot of the virtio code assumes that bus (i.e. hypervisor) addresses are the same as physical address. This is false on Xen, so virtio is completely broken. I wouldn't be surprised if it also becomes a problem the first time that

Re: virtio DMA API?

2014-08-27 Thread Michael S. Tsirkin
On Wed, Aug 27, 2014 at 08:40:51PM +0930, Rusty Russell wrote: Andy Lutomirski l...@amacapital.net writes: Currently, a lot of the virtio code assumes that bus (i.e. hypervisor) addresses are the same as physical address. This is false on Xen, so virtio is completely broken. I wouldn't be

Re: [PATCH 1/1] add selftest for virtio-net

2014-08-27 Thread Michael S. Tsirkin
On Wed, Aug 27, 2014 at 12:57:38PM +0800, Jason Wang wrote: On 08/27/2014 09:45 AM, Hengjinxiao wrote: Selftest is an important part of network driver, this patch adds selftest for virtio-net, including loopback test, negotiate test and reset test. Loopback test checks whether

Re: virtio DMA API?

2014-08-27 Thread Andy Lutomirski
On Aug 27, 2014 4:30 AM, Rusty Russell ru...@rustcorp.com.au wrote: Andy Lutomirski l...@amacapital.net writes: Currently, a lot of the virtio code assumes that bus (i.e. hypervisor) addresses are the same as physical address. This is false on Xen, so virtio is completely broken. I

Re: [PATCH 0/3] virtio: Clean up scatterlists and use the DMA API

2014-08-27 Thread Andy Lutomirski
On Aug 26, 2014 11:46 PM, Stefan Hajnoczi stefa...@gmail.com wrote: On Tue, Aug 26, 2014 at 10:16 PM, Andy Lutomirski l...@amacapital.net wrote: There are two outstanding issues. virtio_net warns if DMA debugging is on because it does DMA from the stack. (The warning is correct.) This

Re: [PATCH 0/3] virtio: Clean up scatterlists and use the DMA API

2014-08-27 Thread Michael S. Tsirkin
On Wed, Aug 27, 2014 at 08:11:15AM -0700, Andy Lutomirski wrote: On Aug 26, 2014 11:46 PM, Stefan Hajnoczi stefa...@gmail.com wrote: On Tue, Aug 26, 2014 at 10:16 PM, Andy Lutomirski l...@amacapital.net wrote: There are two outstanding issues. virtio_net warns if DMA debugging is on

Re: [PATCH 0/3] virtio: Clean up scatterlists and use the DMA API

2014-08-27 Thread Andy Lutomirski
On Wed, Aug 27, 2014 at 8:45 AM, Michael S. Tsirkin m...@redhat.com wrote: On Wed, Aug 27, 2014 at 08:11:15AM -0700, Andy Lutomirski wrote: On Aug 26, 2014 11:46 PM, Stefan Hajnoczi stefa...@gmail.com wrote: On Tue, Aug 26, 2014 at 10:16 PM, Andy Lutomirski l...@amacapital.net wrote:

Re: [PATCH 0/3] virtio: Clean up scatterlists and use the DMA API

2014-08-27 Thread Christopher Covington
On 08/27/2014 11:50 AM, Andy Lutomirski wrote: On Wed, Aug 27, 2014 at 8:45 AM, Michael S. Tsirkin m...@redhat.com wrote: On Wed, Aug 27, 2014 at 08:11:15AM -0700, Andy Lutomirski wrote: On Aug 26, 2014 11:46 PM, Stefan Hajnoczi stefa...@gmail.com wrote: On Tue, Aug 26, 2014 at 10:16 PM, Andy

Re: [PATCH 0/3] virtio: Clean up scatterlists and use the DMA API

2014-08-27 Thread Andy Lutomirski
On Wed, Aug 27, 2014 at 9:13 AM, Christopher Covington c...@codeaurora.org wrote: On 08/27/2014 11:50 AM, Andy Lutomirski wrote: On Wed, Aug 27, 2014 at 8:45 AM, Michael S. Tsirkin m...@redhat.com wrote: On Wed, Aug 27, 2014 at 08:11:15AM -0700, Andy Lutomirski wrote: On Aug 26, 2014 11:46 PM,

[PATCH 1/1] add selftest for virtio-net

2014-08-27 Thread Hengjinxiao
Selftest is an important part of network driver, this patch adds selftest for virtio-net, including loopback test, negotiate test and reset test. Loopback test checks whether virtio-net can send and receive packets normally. Negotiate test executes feature negotiation between virtio-net driver

Re: [PATCH 3/3] virtio_pci: Use the DMA API for virtqueues

2014-08-27 Thread Konrad Rzeszutek Wilk
On Tue, Aug 26, 2014 at 02:17:02PM -0700, Andy Lutomirski wrote: A virtqueue is a coherent DMA mapping. Use the DMA API for it. This fixes virtio_pci on Xen. Signed-off-by: Andy Lutomirski l...@amacapital.net --- drivers/virtio/virtio_pci.c | 25 ++--- 1 file changed,

Re: [PATCH 0/3] virtio: Clean up scatterlists and use the DMA API

2014-08-27 Thread Christopher Covington
On 08/27/2014 12:19 PM, Andy Lutomirski wrote: On Wed, Aug 27, 2014 at 9:13 AM, Christopher Covington c...@codeaurora.org wrote: On 08/27/2014 11:50 AM, Andy Lutomirski wrote: On Wed, Aug 27, 2014 at 8:45 AM, Michael S. Tsirkin m...@redhat.com wrote: On Wed, Aug 27, 2014 at 08:11:15AM -0700,

Re: [PATCH 3/3] virtio_pci: Use the DMA API for virtqueues

2014-08-27 Thread Andy Lutomirski
On Wed, Aug 27, 2014 at 10:32 AM, Konrad Rzeszutek Wilk konrad.w...@oracle.com wrote: On Tue, Aug 26, 2014 at 02:17:02PM -0700, Andy Lutomirski wrote: A virtqueue is a coherent DMA mapping. Use the DMA API for it. This fixes virtio_pci on Xen. Signed-off-by: Andy Lutomirski

Re: [PATCH 2/3] virtio_ring: Use DMA APIs

2014-08-27 Thread Konrad Rzeszutek Wilk
On Wed, Aug 27, 2014 at 09:29:36AM +0200, Christian Borntraeger wrote: On 26/08/14 23:17, Andy Lutomirski wrote: virtio_ring currently sends the device (usually a hypervisor) physical addresses of its I/O buffers. This is okay when DMA addresses and physical addresses are the same thing,

Re: [PATCH 0/3] virtio: Clean up scatterlists and use the DMA API

2014-08-27 Thread Andy Lutomirski
On Wed, Aug 27, 2014 at 10:34 AM, Christopher Covington c...@codeaurora.org wrote: On 08/27/2014 12:19 PM, Andy Lutomirski wrote: On Wed, Aug 27, 2014 at 9:13 AM, Christopher Covington c...@codeaurora.org wrote: Virtme looks interesting. If it's any use, here is my modest QEMU command line

Re: [PATCH 2/3] virtio_ring: Use DMA APIs

2014-08-27 Thread Andy Lutomirski
On Wed, Aug 27, 2014 at 10:35 AM, Konrad Rzeszutek Wilk konrad.w...@oracle.com wrote: On Wed, Aug 27, 2014 at 09:29:36AM +0200, Christian Borntraeger wrote: On 26/08/14 23:17, Andy Lutomirski wrote: virtio_ring currently sends the device (usually a hypervisor) physical addresses of its I/O

Re: [PATCH 0/3] virtio: Clean up scatterlists and use the DMA API

2014-08-27 Thread Stefan Hajnoczi
On Wed, Aug 27, 2014 at 6:27 PM, Konrad Rzeszutek Wilk konrad.w...@oracle.com wrote: On Wed, Aug 27, 2014 at 07:46:46AM +0100, Stefan Hajnoczi wrote: On Tue, Aug 26, 2014 at 10:16 PM, Andy Lutomirski l...@amacapital.net wrote: There are two outstanding issues. virtio_net warns if DMA

Re: [PATCH 3/3] virtio_pci: Use the DMA API for virtqueues

2014-08-27 Thread Konrad Rzeszutek Wilk
On Wed, Aug 27, 2014 at 10:35:10AM -0700, Andy Lutomirski wrote: On Wed, Aug 27, 2014 at 10:32 AM, Konrad Rzeszutek Wilk konrad.w...@oracle.com wrote: On Tue, Aug 26, 2014 at 02:17:02PM -0700, Andy Lutomirski wrote: A virtqueue is a coherent DMA mapping. Use the DMA API for it. This fixes

Re: [PATCH 0/3] virtio: Clean up scatterlists and use the DMA API

2014-08-27 Thread Konrad Rzeszutek Wilk
On Wed, Aug 27, 2014 at 07:10:20PM +0100, Stefan Hajnoczi wrote: On Wed, Aug 27, 2014 at 6:27 PM, Konrad Rzeszutek Wilk konrad.w...@oracle.com wrote: On Wed, Aug 27, 2014 at 07:46:46AM +0100, Stefan Hajnoczi wrote: On Tue, Aug 26, 2014 at 10:16 PM, Andy Lutomirski l...@amacapital.net

Re: virtio DMA API?

2014-08-27 Thread Konrad Rzeszutek Wilk
On Wed, Aug 27, 2014 at 01:52:50PM +0200, Michael S. Tsirkin wrote: On Wed, Aug 27, 2014 at 08:40:51PM +0930, Rusty Russell wrote: Andy Lutomirski l...@amacapital.net writes: Currently, a lot of the virtio code assumes that bus (i.e. hypervisor) addresses are the same as physical address.

Re: [PATCH 0/3] virtio: Clean up scatterlists and use the DMA API

2014-08-27 Thread Christian Borntraeger
On 27/08/14 17:50, Andy Lutomirski wrote: On Wed, Aug 27, 2014 at 8:45 AM, Michael S. Tsirkin m...@redhat.com wrote: On Wed, Aug 27, 2014 at 08:11:15AM -0700, Andy Lutomirski wrote: On Aug 26, 2014 11:46 PM, Stefan Hajnoczi stefa...@gmail.com wrote: On Tue, Aug 26, 2014 at 10:16 PM, Andy

Re: virtio DMA API?

2014-08-27 Thread Benjamin Herrenschmidt
On Wed, 2014-08-27 at 20:40 +0930, Rusty Russell wrote: Hi Andy, This has long been a source of contention. virtio assumes that the hypervisor can decode guest-physical addresses. PowerPC, in particular, doesn't want to pay the cost of IOMMU manipulations, and all

Re: virtio DMA API?

2014-08-27 Thread Benjamin Herrenschmidt
On Wed, 2014-08-27 at 13:52 +0200, Michael S. Tsirkin wrote: For x86 as of QEMU 2.0 there's no iommu. So a reasonable thing to do for that platform might be to always use iommu *if it's there*. My understanding is this isn't the case for powerpc? All 64-bit powerpc have an iommu but not all

[PATCH v2 0/4] virtio: Clean up scatterlists and use the DMA API

2014-08-27 Thread Andy Lutomirski
This fixes virtio on Xen guests as well as on any other platform that uses virtio_pci on which physical addresses don't match bus addresses. This can be tested with: virtme-run --xen xen --kimg arch/x86/boot/bzImage --console using virtme from here:

[PATCH v2 1/4] virtio_ring: Remove sg_next indirection

2014-08-27 Thread Andy Lutomirski
The only unusual thing about virtio's use of scatterlists is that two of the APIs accept scatterlists that might not be terminated. Using function pointers to handle this case is overkill; for_each_sg can do it. There's a small subtlely here: for_each_sg assumes that the provided count is

[PATCH v2 2/4] virtio_ring: Support DMA APIs if requested

2014-08-27 Thread Andy Lutomirski
virtio_ring currently sends the device (usually a hypervisor) physical addresses of its I/O buffers. This is okay when DMA addresses and physical addresses are the same thing, but this isn't always the case. For example, this never works on Xen guests, and it is likely to fail if a physical

[PATCH v2 4/4] virtio_net: Stop doing DMA from the stack

2014-08-27 Thread Andy Lutomirski
Now that virtio supports real DMA, drivers should play by the rules. For virtio_net, that means that DMA should be done to and from dynamically-allocated memory, not the kernel stack. This should have no effect on any performance-critical code paths. Signed-off-by: Andy Lutomirski

[PATCH v2 3/4] virtio_pci: Use the DMA API for virtqueues

2014-08-27 Thread Andy Lutomirski
A virtqueue is a coherent DMA mapping. Use the DMA API for it. This fixes virtio_pci on Xen. Signed-off-by: Andy Lutomirski l...@amacapital.net --- drivers/virtio/virtio_pci.c | 34 +- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git