Re: [PATCH v2 00/12] x86: major paravirt cleanup

2020-12-15 Thread Jürgen Groß via Virtualization
Peter, On 23.11.20 14:43, Peter Zijlstra wrote: On Fri, Nov 20, 2020 at 01:53:42PM +0100, Peter Zijlstra wrote: On Fri, Nov 20, 2020 at 12:46:18PM +0100, Juergen Gross wrote: 30 files changed, 325 insertions(+), 598 deletions(-) Much awesome ! I'll try and get that objtool thing sorted.

Re: [PATCH v3 13/19] vdpa_sim: add get_config callback in vdpasim_dev_attr

2020-12-15 Thread Stefano Garzarella
On Wed, Dec 9, 2020 at 12:07 PM Stefano Garzarella wrote: > On Mon, Dec 07, 2020 at 01:29:17PM +0800, Jason Wang wrote: > > > >On 2020/12/4 上午1:05, Stefano Garzarella wrote: > >>The get_config callback can be used by the device to fill the > >>config structure. > >>The callback will be invoked in

Re: [PATCH v2 00/12] x86: major paravirt cleanup

2020-12-15 Thread Peter Zijlstra
On Tue, Dec 15, 2020 at 12:42:45PM +0100, Jürgen Groß wrote: > Peter, > > On 23.11.20 14:43, Peter Zijlstra wrote: > > On Fri, Nov 20, 2020 at 01:53:42PM +0100, Peter Zijlstra wrote: > > > On Fri, Nov 20, 2020 at 12:46:18PM +0100, Juergen Gross wrote: > > > > 30 files changed, 325 insertions(+),

Re: swiotlb/virtio: unchecked device dma address and length

2020-12-15 Thread Konrad Rzeszutek Wilk
.snip. > > > This raises two issues: > > > 1) swiotlb_tlb_unmap_single fails to check whether the index generated > > > from the dma_addr is in range of the io_tlb_orig_addr array. > > That is fairly simple to implement I would think. That is it can check > > that the dma_addr is from the PA in the

Re: swiotlb/virtio: unchecked device dma address and length

2020-12-15 Thread Konrad Rzeszutek Wilk
On Tue, Dec 15, 2020 at 11:54:08AM +0100, Felicitas Hetzelt wrote: > Hello, > thank you all for looking into this! To answer some of the questions: > - Did you have already some PoC fixes for this: >We don't have a full PoC or fix currently. Thought we have a PoC >with which were able to o

[PATCH v4 00/18] vdpa: generalize vdpa simulator

2020-12-15 Thread Stefano Garzarella
This series moves the network device simulator in a new module (vdpa_sim_net) and leaves the generic functions in the vdpa_sim core module, allowing the possibility to add new vDPA device simulators. For now I removed the vdpa-blk simulator patches, since I'm still working on them and debugging th

[PATCH v4 01/18] vdpa: remove unnecessary 'default n' in Kconfig entries

2020-12-15 Thread Stefano Garzarella
'default n' is not necessary since it is already the default when nothing is specified. Suggested-by: Jason Wang Acked-by: Jason Wang Signed-off-by: Stefano Garzarella --- drivers/vdpa/Kconfig | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/vdpa/Kconfig b/drivers/vdpa/Kconfig ind

[PATCH v4 02/18] vdpa_sim: remove unnecessary headers inclusion

2020-12-15 Thread Stefano Garzarella
Some headers are not necessary, so let's remove them to do some cleaning. Signed-off-by: Stefano Garzarella --- v4: - checked better which headers are not directly used [Randy] v3: - avoided to remove some headers with structures and functions directly used (device.h, slab.h, virtio_byteorder.

[PATCH v4 03/18] vdpa_sim: remove hard-coded virtq count

2020-12-15 Thread Stefano Garzarella
From: Max Gurtovoy Add a new attribute that will define the number of virt queues to be created for the vdpasim device. Signed-off-by: Max Gurtovoy [sgarzare: replace kmalloc_array() with kcalloc()] Acked-by: Jason Wang Signed-off-by: Stefano Garzarella --- v1: - use kcalloc() instead of kmal

[PATCH v4 04/18] vdpa_sim: make IOTLB entries limit configurable

2020-12-15 Thread Stefano Garzarella
Some devices may require a higher limit for the number of IOTLB entries, so let's make it configurable through a module parameter. By default, it's initialized with the current limit (2048). Suggested-by: Jason Wang Signed-off-by: Stefano Garzarella --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 7 +++

[PATCH v4 05/18] vdpa_sim: rename vdpasim_config_ops variables

2020-12-15 Thread Stefano Garzarella
These variables store generic callbacks used by the vDPA simulator core, so we can remove the 'net' word in their names. Co-developed-by: Max Gurtovoy Signed-off-by: Max Gurtovoy Acked-by: Jason Wang Signed-off-by: Stefano Garzarella --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 12 ++-- 1 f

[PATCH v4 06/18] vdpa_sim: add struct vdpasim_dev_attr for device attributes

2020-12-15 Thread Stefano Garzarella
vdpasim_dev_attr will contain device specific attributes. We starting moving the number of virtqueues (i.e. nvqs) to vdpasim_dev_attr. vdpasim_create() creates a new vDPA simulator following the device attributes defined in the vdpasim_dev_attr parameter. Co-developed-by: Max Gurtovoy Signed-off

[PATCH v4 07/18] vdpa_sim: add device id field in vdpasim_dev_attr

2020-12-15 Thread Stefano Garzarella
Remove VDPASIM_DEVICE_ID macro and add 'id' field in vdpasim_dev_attr, that will be returned by vdpasim_get_device_id(). Use VIRTIO_ID_NET for vDPA-net simulator device id. Co-developed-by: Max Gurtovoy Signed-off-by: Max Gurtovoy Acked-by: Jason Wang Signed-off-by: Stefano Garzarella --- dr

[PATCH v4 08/18] vdpa_sim: add supported_features field in vdpasim_dev_attr

2020-12-15 Thread Stefano Garzarella
Introduce a new VDPASIM_FEATURES macro with the generic features supported by the vDPA simulator, and VDPASIM_NET_FEATURES macro with vDPA-net features. Add 'supported_features' field in vdpasim_dev_attr, to allow devices to specify their features. Co-developed-by: Max Gurtovoy Signed-off-by: Ma

[PATCH v4 09/18] vdpa_sim: add work_fn in vdpasim_dev_attr

2020-12-15 Thread Stefano Garzarella
Rename vdpasim_work() in vdpasim_net_work() and add it to the vdpasim_dev_attr structure. Co-developed-by: Max Gurtovoy Signed-off-by: Max Gurtovoy Acked-by: Jason Wang Signed-off-by: Stefano Garzarella --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 7 +-- 1 file changed, 5 insertions(+), 2 delet

[PATCH v4 10/18] vdpa_sim: store parsed MAC address in a buffer

2020-12-15 Thread Stefano Garzarella
As preparation for the next patches, we store the MAC address, parsed during the vdpasim_create(), in a buffer that will be used to fill 'config' together with other configurations. Acked-by: Jason Wang Signed-off-by: Stefano Garzarella --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 10 +++--- 1 fi

[PATCH v4 11/18] vdpa_sim: make 'config' generic and usable for any device type

2020-12-15 Thread Stefano Garzarella
Add new 'config_size' attribute in 'vdpasim_dev_attr' and allocates 'config' dynamically to support any device types. Acked-by: Jason Wang Signed-off-by: Stefano Garzarella --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git

[PATCH v4 14/18] vdpa_sim: set vringh notify callback

2020-12-15 Thread Stefano Garzarella
Instead of calling the vq callback directly, we can leverage the vringh_notify() function, adding vdpasim_vq_notify() and setting it in the vringh notify callback. Suggested-by: Jason Wang Acked-by: Jason Wang Signed-off-by: Stefano Garzarella --- v3: - cleared notify during reset [Jason] ---

[PATCH v4 15/18] vdpa_sim: use kvmalloc to allocate vdpasim->buffer

2020-12-15 Thread Stefano Garzarella
The next patch will make the buffer size configurable from each device. Since the buffer could be larger than a page, we use kvmalloc() instead of kmalloc(). Acked-by: Jason Wang Signed-off-by: Stefano Garzarella --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 4 ++-- 1 file changed, 2 insertions(+), 2

[PATCH v4 12/18] vdpa_sim: add get_config callback in vdpasim_dev_attr

2020-12-15 Thread Stefano Garzarella
The get_config callback can be used by the device to fill the config structure. The callback will be invoked in vdpasim_get_config() before copying bytes into caller buffer. Move vDPA-net config updates from vdpasim_set_features() in the new vdpasim_net_get_config() callback. This is safe since in

[PATCH v4 13/18] vdpa_sim: add set_config callback in vdpasim_dev_attr

2020-12-15 Thread Stefano Garzarella
The set_config callback can be used by the device to parse the config structure modified by the driver. The callback will be invoked, if set, in vdpasim_set_config() after copying bytes from caller buffer into vdpasim->config buffer. Acked-by: Jason Wang Signed-off-by: Stefano Garzarella --- d

[PATCH v4 16/18] vdpa_sim: make vdpasim->buffer size configurable

2020-12-15 Thread Stefano Garzarella
Allow each device to specify the size of the buffer allocated in vdpa_sim. Acked-by: Jason Wang Signed-off-by: Stefano Garzarella --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/

[PATCH v4 17/18] vdpa_sim: split vdpasim_virtqueue's iov field in out_iov and in_iov

2020-12-15 Thread Stefano Garzarella
vringh_getdesc_iotlb() manages 2 iovs for writable and readable descriptors. This is very useful for the block device, where for each request we have both types of descriptor. Let's split the vdpasim_virtqueue's iov field in out_iov and in_iov to use them with vringh_getdesc_iotlb(). We are using

[PATCH v4 18/18] vdpa: split vdpasim to core and net modules

2020-12-15 Thread Stefano Garzarella
From: Max Gurtovoy Introduce new vdpa_sim_net and vdpa_sim (core) drivers. This is a preparation for adding a vdpa simulator module for block devices. Signed-off-by: Max Gurtovoy [sgarzare: various cleanups/fixes] Acked-by: Jason Wang Signed-off-by: Stefano Garzarella --- v4: - Fixed typo (s/

Re: [PATCH v2 00/12] x86: major paravirt cleanup

2020-12-15 Thread Peter Zijlstra
On Tue, Dec 15, 2020 at 03:18:34PM +0100, Peter Zijlstra wrote: > Ah, I was waiting for Josh to have an opinion (and then sorta forgot > about the whole thing again). Let me refresh and provide at least a > Changelog. How's this then? --- Subject: objtool: Alternatives vs ORC, the hard way From:

Re: [PATCH v2 00/12] x86: major paravirt cleanup

2020-12-15 Thread Jürgen Groß via Virtualization
On 15.12.20 15:54, Peter Zijlstra wrote: On Tue, Dec 15, 2020 at 03:18:34PM +0100, Peter Zijlstra wrote: Ah, I was waiting for Josh to have an opinion (and then sorta forgot about the whole thing again). Let me refresh and provide at least a Changelog. How's this then? Thanks, will add it in

Re: [PATCH v2 00/12] x86: major paravirt cleanup

2020-12-15 Thread Josh Poimboeuf
On Tue, Dec 15, 2020 at 03:54:08PM +0100, Peter Zijlstra wrote: > The problem is that a single instance of unwind information (ORC) must > capture and correctly unwind all alternatives. Since the trivially > correct mandate is out, implement the straight forward brute-force > approach: > > 1) gen

Re: swiotlb/virtio: unchecked device dma address and length

2020-12-15 Thread Jason Wang
- Original Message - > .snip. > > > > This raises two issues: > > > > 1) swiotlb_tlb_unmap_single fails to check whether the index generated > > > > from the dma_addr is in range of the io_tlb_orig_addr array. > > > That is fairly simple to implement I would think. That is it can check >

Re: [PATCH net 2/2] vhost_net: fix high cpu load when sendmsg fails

2020-12-15 Thread Jason Wang
- Original Message - > > > > -Original Message- > > From: Jason Wang [mailto:jasow...@redhat.com] > > Sent: Tuesday, December 15, 2020 12:10 PM > > To: wangyunjian ; net...@vger.kernel.org; > > m...@redhat.com; willemdebruijn.ker...@gmail.com > > Cc: virtualization@lists.linux-f

Re: swiotlb/virtio: unchecked device dma address and length

2020-12-15 Thread Jason Wang
- Original Message - > > > - Original Message - > > .snip. > > > > > This raises two issues: > > > > > 1) swiotlb_tlb_unmap_single fails to check whether the index > > > > > generated > > > > > from the dma_addr is in range of the io_tlb_orig_addr array. > > > > That is fairly

[PATCH 00/21] Control VQ support in vDPA

2020-12-15 Thread Jason Wang
Hi All: This series tries to add the support for control virtqueue in vDPA. Control virtqueue is used by networking device for accepting various commands from the driver. It's a must to support multiqueue and other configurations. When used by vhost-vDPA bus driver for VM, the control virtqueue

[PATCH 01/21] vhost: move the backend feature bits to vhost_types.h

2020-12-15 Thread Jason Wang
We should store feature bits in vhost_types.h as what has been done for e.g VHOST_F_LOG_ALL. Signed-off-by: Jason Wang --- include/uapi/linux/vhost.h | 5 - include/uapi/linux/vhost_types.h | 5 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/vho

[PATCH 02/21] virtio-vdpa: don't set callback if virtio doesn't need it

2020-12-15 Thread Jason Wang
There's no need for setting callbacks for the driver that doesn't care about that. Signed-off-by: Jason Wang --- drivers/virtio/virtio_vdpa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c index 4a9ddb44b2a7..af6ee6

[PATCH 03/21] vhost-vdpa: passing iotlb to IOMMU mapping helpers

2020-12-15 Thread Jason Wang
To prepare for the ASID support for vhost-vdpa, try to pass IOTLB object to dma helpers. No functional changes, it's just a preparation for support multiple IOTLBs. Signed-off-by: Jason Wang --- drivers/vhost/vdpa.c | 41 +++-- 1 file changed, 23 insertions(+)

[PATCH 04/21] vhost-vdpa: switch to use vhost-vdpa specific IOTLB

2020-12-15 Thread Jason Wang
To ease the implementation of per group ASID support for vDPA device. This patch switches to use a vhost-vdpa specific IOTLB to avoid the unnecessary refactoring of the vhost core. Signed-off-by: Jason Wang --- drivers/vhost/vdpa.c | 18 ++ 1 file changed, 10 insertions(+), 8 del

[PATCH 05/21] vdpa: add the missing comment for nvqs in struct vdpa_device

2020-12-15 Thread Jason Wang
Signed-off-by: Jason Wang --- include/linux/vdpa.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 30bc7a7223bb..8ab8dcde705d 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -42,6 +42,7 @@ struct vdpa_vq_state { * @config: th

[PATCH 06/21] vdpa: introduce virtqueue groups

2020-12-15 Thread Jason Wang
This patch introduces virtqueue groups to vDPA device. The virtqueue group is the minimal set of virtqueues that must share an address space. And the adddress space identifier could only be attached to a specific virtqueue group. A new mandated bus operation is introduced to get the virtqueue grou

[PATCH 07/21] vdpa: multiple address spaces support

2020-12-15 Thread Jason Wang
This patches introduces the multiple address spaces support for vDPA device. This idea is to identify a specific address space via an dedicated identifier - ASID. During vDPA device allocation, vDPA device driver needs to report the number of address spaces supported by the device then the DMA map

[PATCH 08/21] vdpa: introduce config operations for associating ASID to a virtqueue group

2020-12-15 Thread Jason Wang
This patch introduces a new bus operation to allow the vDPA bus driver to associate an ASID to a virtqueue group. Signed-off-by: Jason Wang --- include/linux/vdpa.h | 10 ++ 1 file changed, 10 insertions(+) diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 0a9a754f8180..2a8

[PATCH 09/21] vhost_iotlb: split out IOTLB initialization

2020-12-15 Thread Jason Wang
This patch splits out IOTLB initialization to make sure it could be reused by external modules. Signed-off-by: Jason Wang --- drivers/vhost/iotlb.c | 23 ++- include/linux/vhost_iotlb.h | 2 ++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/vho

[PATCH 10/21] vhost: support ASID in IOTLB API

2020-12-15 Thread Jason Wang
This patches allows userspace to send ASID based IOTLB message to vhost. This idea is to use the reserved u32 field in the existing V2 IOTLB message. Vhost device should advertise this capability via VHOST_BACKEND_F_IOTLB_ASID backend feature. Signed-off-by: Jason Wang --- drivers/vhost/vdpa.c

[PATCH 11/21] vhost-vdpa: introduce asid based IOTLB

2020-12-15 Thread Jason Wang
This patch converts the vhost-vDPA device to support multiple IOTLBs tagged via ASID via hlist. This will be used for supporting multiple address spaces in the following patches. Signed-off-by: Jason Wang --- drivers/vhost/vdpa.c | 106 --- 1 file changed,

[PATCH 12/21] vhost-vdpa: introduce uAPI to get the number of virtqueue groups

2020-12-15 Thread Jason Wang
Follows the vDPA support for multiple address spaces, this patch introduce uAPI for the userspace to know the number of virtqueue groups supported by the vDPA device. Signed-off-by: Jason Wang --- drivers/vhost/vdpa.c | 4 include/uapi/linux/vhost.h | 3 +++ 2 files changed, 7 inserti

[PATCH 13/21] vhost-vdpa: introduce uAPI to get the number of address spaces

2020-12-15 Thread Jason Wang
This patch introduces the uAPI for getting the number of address spaces supported by this vDPA device. Signed-off-by: Jason Wang --- drivers/vhost/vdpa.c | 3 +++ include/uapi/linux/vhost.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c i

[PATCH 14/21] vhost-vdpa: uAPI to get virtqueue group id

2020-12-15 Thread Jason Wang
Follows the support for virtqueue group in vDPA. This patches introduces uAPI to get the virtqueue group ID for a specific virtqueue in vhost-vdpa. Signed-off-by: Jason Wang --- drivers/vhost/vdpa.c | 8 include/uapi/linux/vhost.h | 8 2 files changed, 16 insertions(+) d

[PATCH 16/21] vhost-vdpa: support ASID based IOTLB API

2020-12-15 Thread Jason Wang
This patch extends the vhost-vdpa to support ASID based IOTLB API. The vhost-vdpa device will allocated multple IOTLBs for vDPA device that supports multiple address spaces. The IOTLBs and vDPA device memory mappings is determined and maintained through ASID. Note that we still don't support vDPA

[PATCH 17/21] vdpa_sim: split vdpasim_virtqueue's iov field in out_iov and in_iov

2020-12-15 Thread Jason Wang
From: Stefano Garzarella vringh_getdesc_iotlb() manages 2 iovs for writable and readable descriptors. This is very useful for the block device, where for each request we have both types of descriptor. Let's split the vdpasim_virtqueue's iov field in out_iov and in_iov to use them with vringh_get

[PATCH 15/21] vhost-vdpa: introduce uAPI to set group ASID

2020-12-15 Thread Jason Wang
Follows the vDPA support for associating ASID to a specific virtqueue group. This patch adds a uAPI to support setting them from userspace. Signed-off-by: Jason Wang --- drivers/vhost/vdpa.c | 8 include/uapi/linux/vhost.h | 7 +++ 2 files changed, 15 insertions(+) diff --git

[PATCH 18/21] vdpa_sim: advertise VIRTIO_NET_F_MTU

2020-12-15 Thread Jason Wang
We've already reported maximum mtu via config space, so let's advertise the feature. Signed-off-by: Jason Wang --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index fe48

[PATCH 19/21] vdpa_sim: factor out buffer completion logic

2020-12-15 Thread Jason Wang
Signed-off-by: Jason Wang --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 33 +--- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index 8d051cf25f0a..e901177c6dfe 100644 --- a/drivers/vdpa/vdpa

[PATCH 20/21] vdpa_sim: filter destination mac address

2020-12-15 Thread Jason Wang
This patch implements a simple unicast filter for vDPA simulator. Signed-off-by: Jason Wang --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 49 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_si

[PATCH 21/21] vdpasim: control virtqueue support

2020-12-15 Thread Jason Wang
This patch introduces the control virtqueue support for vDPA simulator. This is a requirement for supporting advanced features like multiqueue. A requirement for control virtqueue is to isolate its memory access from the rx/tx virtqueues. This is because when using vDPA device for VM, the control

Re: [PATCH net 2/2] vhost_net: fix high cpu load when sendmsg fails

2020-12-15 Thread Jason Wang
- Original Message - > > -Original Message- > > From: Jason Wang [mailto:jasow...@redhat.com] > > Sent: Wednesday, December 16, 2020 1:57 PM > > To: wangyunjian > > Cc: net...@vger.kernel.org; m...@redhat.com; willemdebruijn kernel > > ; > > virtualization@lists.linux-foundation.