[v3,3/3] vhost: prevent zero copy mode if iommu is on

Message ID 20190927183759.18816-4-amorenoz@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series vhost: add support for IOVA_VA mode |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Adrian Moreno Sept. 27, 2019, 6:37 p.m. UTC
The simltaneous use of dequeue_zero_copy and IOMMU is problematic.
Not only because IOVA_VA mode is not supported but also because the
potential invalidation of guest pages while the buffers are in use,
is not handled.

Prevent these two features to be enabled simultaneosly.

Fixes: 69c90e98f483 ("vhost: enable IOMMU support")
Cc: maxime.coquelin@redhat.com
Cc: stable@dpdk.org

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
---
 lib/librte_vhost/socket.c | 8 ++++++++
 1 file changed, 8 insertions(+)
  

Comments

Tiwei Bie Oct. 8, 2019, 6:23 a.m. UTC | #1
On Fri, Sep 27, 2019 at 08:37:59PM +0200, Adrian Moreno wrote:
> The simltaneous use of dequeue_zero_copy and IOMMU is problematic.
> Not only because IOVA_VA mode is not supported but also because the
> potential invalidation of guest pages while the buffers are in use,
> is not handled.
> 
> Prevent these two features to be enabled simultaneosly.
> 
> Fixes: 69c90e98f483 ("vhost: enable IOMMU support")
> Cc: maxime.coquelin@redhat.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
> ---
>  lib/librte_vhost/socket.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>

> 
> diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c
> index 274988c4d..534a7ffe3 100644
> --- a/lib/librte_vhost/socket.c
> +++ b/lib/librte_vhost/socket.c
> @@ -871,6 +871,14 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
>  	}
>  	vsocket->dequeue_zero_copy = flags & RTE_VHOST_USER_DEQUEUE_ZERO_COPY;
>  
> +	if (vsocket->dequeue_zero_copy &&
> +	   (flags & RTE_VHOST_USER_IOMMU_SUPPORT)) {

It's better to add one more space before '(flags ...'

> +		RTE_LOG(ERR, VHOST_CONFIG,
> +			"error: enabling dequeue zero copy and IOMMU features "
> +			"simultaneously is not supported\n");
> +		goto out_mutex;
> +	}
> +
>  	/*
>  	 * Set the supported features correctly for the builtin vhost-user
>  	 * net driver.
> -- 
> 2.21.0
>
  
Adrian Moreno Oct. 8, 2019, 7:40 a.m. UTC | #2
On 10/8/19 8:23 AM, Tiwei Bie wrote:
> On Fri, Sep 27, 2019 at 08:37:59PM +0200, Adrian Moreno wrote:
>> The simltaneous use of dequeue_zero_copy and IOMMU is problematic.
>> Not only because IOVA_VA mode is not supported but also because the
>> potential invalidation of guest pages while the buffers are in use,
>> is not handled.
>>
>> Prevent these two features to be enabled simultaneosly.
>>
>> Fixes: 69c90e98f483 ("vhost: enable IOMMU support")
>> Cc: maxime.coquelin@redhat.com
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
>> ---
>>  lib/librte_vhost/socket.c | 8 ++++++++
>>  1 file changed, 8 insertions(+)
> 
> Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
> 
>>
>> diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c
>> index 274988c4d..534a7ffe3 100644
>> --- a/lib/librte_vhost/socket.c
>> +++ b/lib/librte_vhost/socket.c
>> @@ -871,6 +871,14 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
>>  	}
>>  	vsocket->dequeue_zero_copy = flags & RTE_VHOST_USER_DEQUEUE_ZERO_COPY;
>>  
>> +	if (vsocket->dequeue_zero_copy &&
>> +	   (flags & RTE_VHOST_USER_IOMMU_SUPPORT)) {
> 
> It's better to add one more space before '(flags ...'
OK. I'll add it in the next version.
> 
>> +		RTE_LOG(ERR, VHOST_CONFIG,
>> +			"error: enabling dequeue zero copy and IOMMU features "
>> +			"simultaneously is not supported\n");
>> +		goto out_mutex;
>> +	}
>> +
>>  	/*
>>  	 * Set the supported features correctly for the builtin vhost-user
>>  	 * net driver.
>> -- 
>> 2.21.0
>>

Thanks.
-Adrián
  

Patch

diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c
index 274988c4d..534a7ffe3 100644
--- a/lib/librte_vhost/socket.c
+++ b/lib/librte_vhost/socket.c
@@ -871,6 +871,14 @@  rte_vhost_driver_register(const char *path, uint64_t flags)
 	}
 	vsocket->dequeue_zero_copy = flags & RTE_VHOST_USER_DEQUEUE_ZERO_COPY;
 
+	if (vsocket->dequeue_zero_copy &&
+	   (flags & RTE_VHOST_USER_IOMMU_SUPPORT)) {
+		RTE_LOG(ERR, VHOST_CONFIG,
+			"error: enabling dequeue zero copy and IOMMU features "
+			"simultaneously is not supported\n");
+		goto out_mutex;
+	}
+
 	/*
 	 * Set the supported features correctly for the builtin vhost-user
 	 * net driver.