linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen-blkback: only attach blkback if the required features are met
@ 2014-04-04 14:41 Roger Pau Monne
  2014-04-04 15:01 ` David Vrabel
  2014-04-04 16:58 ` Konrad Rzeszutek Wilk
  0 siblings, 2 replies; 5+ messages in thread
From: Roger Pau Monne @ 2014-04-04 14:41 UTC (permalink / raw)
  To: xen-devel, linux-kernel
  Cc: Roger Pau Monne, Konrad Rzeszutek Wilk, David Vrabel,
	Boris Ostrovsky

Blkback cannot work properly on auto-translated guests if Xen doesn't
update the IOMMU when performing grant maps/unmaps, so only attach if
the newly introduced XENFEAT_hvm_gntmap_supports_iommu is found.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
 drivers/block/xen-blkback/blkback.c |   12 ++++++++++++
 include/xen/interface/features.h    |    6 ++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 64c60ed..4c23ddd 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -1381,6 +1381,18 @@ static int __init xen_blkif_init(void)
 	if (!xen_domain())
 		return -ENODEV;
 
+#ifdef CONFIG_X86
+	if (xen_feature(XENFEAT_auto_translated_physmap) &&
+	    !xen_feature(XENFEAT_hvm_gntmap_supports_iommu)) {
+		/*
+		 * blkback cannot work properly on auto-translated guests
+		 * if grant table mappings don't update the IOMMU entries.
+		 */
+		pr_debug(DRV_PFX "Disabling blkback because Xen is missing feature XENFEAT_hvm_gntmap_supports_iommu\n");
+		return -ENODEV;
+	}
+#endif /* CONFIG_X86 */
+
 	rc = xen_blkif_interface_init();
 	if (rc)
 		goto failed_init;
diff --git a/include/xen/interface/features.h b/include/xen/interface/features.h
index 131a6cc..d1e0f23 100644
--- a/include/xen/interface/features.h
+++ b/include/xen/interface/features.h
@@ -53,6 +53,12 @@
 /* operation as Dom0 is supported */
 #define XENFEAT_dom0                      11
 
+/*
+ * If set, GNTTABOP_map_grant_ref sets the proper IOMMU mappings so the
+ * resulting mapped page can be used for IO with hardware devices.
+ */
+#define XENFEAT_hvm_gntmap_supports_iommu 12
+
 #define XENFEAT_NR_SUBMAPS 1
 
 #endif /* __XEN_PUBLIC_FEATURES_H__ */
-- 
1.7.7.5 (Apple Git-26)


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] xen-blkback: only attach blkback if the required features are met
  2014-04-04 14:41 [PATCH] xen-blkback: only attach blkback if the required features are met Roger Pau Monne
@ 2014-04-04 15:01 ` David Vrabel
  2014-04-04 15:13   ` Roger Pau Monné
  2014-04-04 16:58 ` Konrad Rzeszutek Wilk
  1 sibling, 1 reply; 5+ messages in thread
From: David Vrabel @ 2014-04-04 15:01 UTC (permalink / raw)
  To: Roger Pau Monne
  Cc: xen-devel, linux-kernel, Konrad Rzeszutek Wilk, Boris Ostrovsky

On 04/04/14 15:41, Roger Pau Monne wrote:
> Blkback cannot work properly on auto-translated guests if Xen doesn't
> update the IOMMU when performing grant maps/unmaps, so only attach if
> the newly introduced XENFEAT_hvm_gntmap_supports_iommu is found.

Can you explain the problem in more detail and which guest
configurations are affected?

This isn't a problem that is specific to blkback, but any backend that
grant maps and passes the foreign pages to a device so there needs to be
a generic solution.

Why can't this be fixed by having the swiotlb bounce foreign pages?

> --- a/drivers/block/xen-blkback/blkback.c
> +++ b/drivers/block/xen-blkback/blkback.c
> @@ -1381,6 +1381,18 @@ static int __init xen_blkif_init(void)
>  	if (!xen_domain())
>  		return -ENODEV;
>  
> +#ifdef CONFIG_X86
> +	if (xen_feature(XENFEAT_auto_translated_physmap) &&
> +	    !xen_feature(XENFEAT_hvm_gntmap_supports_iommu)) {
> +		/*
> +		 * blkback cannot work properly on auto-translated guests
> +		 * if grant table mappings don't update the IOMMU entries.
> +		 */
> +		pr_debug(DRV_PFX "Disabling blkback because Xen is missing feature XENFEAT_hvm_gntmap_supports_iommu\n");
> +		return -ENODEV;
> +	}
> +#endif /* CONFIG_X86 */

Why CONFIG_X86?

David

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] xen-blkback: only attach blkback if the required features are met
  2014-04-04 15:01 ` David Vrabel
@ 2014-04-04 15:13   ` Roger Pau Monné
  2014-04-07 17:11     ` David Vrabel
  0 siblings, 1 reply; 5+ messages in thread
From: Roger Pau Monné @ 2014-04-04 15:13 UTC (permalink / raw)
  To: David Vrabel
  Cc: xen-devel, linux-kernel, Konrad Rzeszutek Wilk, Boris Ostrovsky

On 04/04/14 17:01, David Vrabel wrote:
> On 04/04/14 15:41, Roger Pau Monne wrote:
>> Blkback cannot work properly on auto-translated guests if Xen doesn't
>> update the IOMMU when performing grant maps/unmaps, so only attach if
>> the newly introduced XENFEAT_hvm_gntmap_supports_iommu is found.
> 
> Can you explain the problem in more detail and which guest
> configurations are affected?
> 
> This isn't a problem that is specific to blkback, but any backend that
> grant maps and passes the foreign pages to a device so there needs to be
> a generic solution.
> 
> Why can't this be fixed by having the swiotlb bounce foreign pages?

Yes, it could be fixed with that, FreeBSD has been doing it for a long time.

But since nobody has complained about this, and the issue has been there
for a long time, I'm not sure it's worth adding all the bounce buffer
code for what seems to be an unused configuration.

Also, since Linux also supports PV, I would just say that if you want to
use driver domains you are forced to use PV guests (or have a recent Xen
version that properly updates the IOMMU on grant map/unmap).

>> --- a/drivers/block/xen-blkback/blkback.c
>> +++ b/drivers/block/xen-blkback/blkback.c
>> @@ -1381,6 +1381,18 @@ static int __init xen_blkif_init(void)
>>  	if (!xen_domain())
>>  		return -ENODEV;
>>  
>> +#ifdef CONFIG_X86
>> +	if (xen_feature(XENFEAT_auto_translated_physmap) &&
>> +	    !xen_feature(XENFEAT_hvm_gntmap_supports_iommu)) {
>> +		/*
>> +		 * blkback cannot work properly on auto-translated guests
>> +		 * if grant table mappings don't update the IOMMU entries.
>> +		 */
>> +		pr_debug(DRV_PFX "Disabling blkback because Xen is missing feature XENFEAT_hvm_gntmap_supports_iommu\n");
>> +		return -ENODEV;
>> +	}
>> +#endif /* CONFIG_X86 */
> 
> Why CONFIG_X86?

ARM has a bounce buffer for foreign pages, so this is not needed.

> 
> David
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] xen-blkback: only attach blkback if the required features are met
  2014-04-04 14:41 [PATCH] xen-blkback: only attach blkback if the required features are met Roger Pau Monne
  2014-04-04 15:01 ` David Vrabel
@ 2014-04-04 16:58 ` Konrad Rzeszutek Wilk
  1 sibling, 0 replies; 5+ messages in thread
From: Konrad Rzeszutek Wilk @ 2014-04-04 16:58 UTC (permalink / raw)
  To: Roger Pau Monne; +Cc: xen-devel, linux-kernel, David Vrabel, Boris Ostrovsky

On Fri, Apr 04, 2014 at 04:41:11PM +0200, Roger Pau Monne wrote:
> Blkback cannot work properly on auto-translated guests if Xen doesn't
> update the IOMMU when performing grant maps/unmaps, so only attach if
> the newly introduced XENFEAT_hvm_gntmap_supports_iommu is found.

Could you point to the git commit that introduces it in the patch please?
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: David Vrabel <david.vrabel@citrix.com>
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> ---
>  drivers/block/xen-blkback/blkback.c |   12 ++++++++++++
>  include/xen/interface/features.h    |    6 ++++++
>  2 files changed, 18 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
> index 64c60ed..4c23ddd 100644
> --- a/drivers/block/xen-blkback/blkback.c
> +++ b/drivers/block/xen-blkback/blkback.c
> @@ -1381,6 +1381,18 @@ static int __init xen_blkif_init(void)
>  	if (!xen_domain())
>  		return -ENODEV;
>  
> +#ifdef CONFIG_X86
> +	if (xen_feature(XENFEAT_auto_translated_physmap) &&
> +	    !xen_feature(XENFEAT_hvm_gntmap_supports_iommu)) {
> +		/*
> +		 * blkback cannot work properly on auto-translated guests
> +		 * if grant table mappings don't update the IOMMU entries.
> +		 */
> +		pr_debug(DRV_PFX "Disabling blkback because Xen is missing feature XENFEAT_hvm_gntmap_supports_iommu\n");
> +		return -ENODEV;
> +	}
> +#endif /* CONFIG_X86 */
> +
>  	rc = xen_blkif_interface_init();
>  	if (rc)
>  		goto failed_init;
> diff --git a/include/xen/interface/features.h b/include/xen/interface/features.h
> index 131a6cc..d1e0f23 100644
> --- a/include/xen/interface/features.h
> +++ b/include/xen/interface/features.h
> @@ -53,6 +53,12 @@
>  /* operation as Dom0 is supported */
>  #define XENFEAT_dom0                      11
>  
> +/*
> + * If set, GNTTABOP_map_grant_ref sets the proper IOMMU mappings so the
> + * resulting mapped page can be used for IO with hardware devices.
> + */
> +#define XENFEAT_hvm_gntmap_supports_iommu 12
> +
>  #define XENFEAT_NR_SUBMAPS 1
>  
>  #endif /* __XEN_PUBLIC_FEATURES_H__ */
> -- 
> 1.7.7.5 (Apple Git-26)
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] xen-blkback: only attach blkback if the required features are met
  2014-04-04 15:13   ` Roger Pau Monné
@ 2014-04-07 17:11     ` David Vrabel
  0 siblings, 0 replies; 5+ messages in thread
From: David Vrabel @ 2014-04-07 17:11 UTC (permalink / raw)
  To: Roger Pau Monné
  Cc: xen-devel, linux-kernel, Konrad Rzeszutek Wilk, Boris Ostrovsky

On 04/04/14 16:13, Roger Pau Monné wrote:
> On 04/04/14 17:01, David Vrabel wrote:
>> On 04/04/14 15:41, Roger Pau Monne wrote:
>>> Blkback cannot work properly on auto-translated guests if Xen doesn't
>>> update the IOMMU when performing grant maps/unmaps, so only attach if
>>> the newly introduced XENFEAT_hvm_gntmap_supports_iommu is found.
>>
>> Can you explain the problem in more detail and which guest
>> configurations are affected?
>>
>> This isn't a problem that is specific to blkback, but any backend that
>> grant maps and passes the foreign pages to a device so there needs to be
>> a generic solution.
>>
>> Why can't this be fixed by having the swiotlb bounce foreign pages?
> 
> Yes, it could be fixed with that, FreeBSD has been doing it for a long time.
> 
> But since nobody has complained about this, and the issue has been there
> for a long time, I'm not sure it's worth adding all the bounce buffer
> code for what seems to be an unused configuration.

Ok.  Now that netback also grant maps.  Can you make this a generic
function and call from netback and blkback?

David

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-04-07 17:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-04 14:41 [PATCH] xen-blkback: only attach blkback if the required features are met Roger Pau Monne
2014-04-04 15:01 ` David Vrabel
2014-04-04 15:13   ` Roger Pau Monné
2014-04-07 17:11     ` David Vrabel
2014-04-04 16:58 ` Konrad Rzeszutek Wilk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).