Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1700908 > unrolled thread

[PATCH v9 12/13] iommu/amd: Clear out the GV flag when handle deferred domain attach

Started byBaoquan He <bhe@redhat.com>
First post2017-08-01 13:40 +0200
Last post2017-08-04 15:20 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v9 12/13] iommu/amd: Clear out the GV flag when handle deferred domain attach Baoquan He <bhe@redhat.com> - 2017-08-01 13:40 +0200
    Re: [PATCH v9 12/13] iommu/amd: Clear out the GV flag when handle  deferred domain attach Joerg Roedel <jroedel@suse.de> - 2017-08-04 14:40 +0200
      Re: [PATCH v9 12/13] iommu/amd: Clear out the GV flag when handle  deferred domain attach Joerg Roedel <jroedel@suse.de> - 2017-08-04 15:20 +0200
      Re: [PATCH v9 12/13] iommu/amd: Clear out the GV flag when handle  deferred domain attach Baoquan He <bhe@redhat.com> - 2017-08-04 15:20 +0200

#1700908 — [PATCH v9 12/13] iommu/amd: Clear out the GV flag when handle deferred domain attach

FromBaoquan He <bhe@redhat.com>
Date2017-08-01 13:40 +0200
Subject[PATCH v9 12/13] iommu/amd: Clear out the GV flag when handle deferred domain attach
Message-ID<u9DGQ-3pR-55@gated-at.bofh.it>
When handle deferred domain attach, we need check if the domain is
v2. If not, should try to clear out the GV flag which could be
copied from the old device table entry.

Signed-off-by: Baoquan He <bhe@redhat.com>
---
 drivers/iommu/amd_iommu.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 46d077784da0..98aaccecbb76 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -2085,6 +2085,11 @@ static void clear_dte_entry(u16 devid)
 	amd_iommu_apply_erratum_63(devid);
 }
 
+static void clear_dte_flag_gv(u16 devid)
+{
+	amd_iommu_dev_table[devid].data[0] &= (~DTE_FLAG_GV);
+}
+
 static void do_attach(struct iommu_dev_data *dev_data,
 		      struct protection_domain *domain)
 {
@@ -2459,6 +2464,7 @@ static struct iommu_group *amd_iommu_device_group(struct device *dev)
  */
 static struct protection_domain *get_domain(struct device *dev)
 {
+	struct iommu_dev_data *dev_data = get_dev_data(dev);
 	struct protection_domain *domain;
 	struct iommu_domain *io_domain;
 
@@ -2466,11 +2472,21 @@ static struct protection_domain *get_domain(struct device *dev)
 		return ERR_PTR(-EINVAL);
 
 	domain = get_dev_data(dev)->domain;
-	if (domain == NULL && get_dev_data(dev)->defer_attach) {
+	if (domain == NULL && dev_data->defer_attach) {
+		u16 alias = amd_iommu_alias_table[dev_data->devid];
 		get_dev_data(dev)->defer_attach = false;
 		io_domain = iommu_get_domain_for_dev(dev);
 		domain = to_pdomain(io_domain);
 		attach_device(dev, domain);
+		/*
+		 * If the deferred attached domain is not v2, should clear out
+		 * the old GV flag.
+		 */
+		if (!(domain->flags & PD_IOMMUV2_MASK)) {
+			clear_dte_flag_gv(dev_data->devid);
+			if (alias != dev_data->devid)
+				clear_dte_flag_gv(dev_data->devid);
+		}
 	}
 	if (!dma_ops_domain(domain))
 		return ERR_PTR(-EBUSY);
-- 
2.5.5

[toc] | [next] | [standalone]


#1703939 — Re: [PATCH v9 12/13] iommu/amd: Clear out the GV flag when handle deferred domain attach

FromJoerg Roedel <jroedel@suse.de>
Date2017-08-04 14:40 +0200
SubjectRe: [PATCH v9 12/13] iommu/amd: Clear out the GV flag when handle deferred domain attach
Message-ID<uaK3v-6XA-17@gated-at.bofh.it>
In reply to#1700908
On Tue, Aug 01, 2017 at 07:37:28PM +0800, Baoquan He wrote:
> @@ -2466,11 +2472,21 @@ static struct protection_domain *get_domain(struct device *dev)
>  		return ERR_PTR(-EINVAL);
>  
>  	domain = get_dev_data(dev)->domain;
> -	if (domain == NULL && get_dev_data(dev)->defer_attach) {
> +	if (domain == NULL && dev_data->defer_attach) {
> +		u16 alias = amd_iommu_alias_table[dev_data->devid];
>  		get_dev_data(dev)->defer_attach = false;
>  		io_domain = iommu_get_domain_for_dev(dev);
>  		domain = to_pdomain(io_domain);
>  		attach_device(dev, domain);
> +		/*
> +		 * If the deferred attached domain is not v2, should clear out
> +		 * the old GV flag.
> +		 */
> +		if (!(domain->flags & PD_IOMMUV2_MASK)) {
> +			clear_dte_flag_gv(dev_data->devid);
> +			if (alias != dev_data->devid)
> +				clear_dte_flag_gv(dev_data->devid);

Hmm, thinking more about it, I am not sure what the IOMMU responds to
PRI/PASID prefixes if the GV flag is 0.

But until we know it causes problems we should just disable the bit
while doing the copy in the previous patch and avoid any special
handling like done here.

[toc] | [prev] | [next] | [standalone]


#1703965 — Re: [PATCH v9 12/13] iommu/amd: Clear out the GV flag when handle deferred domain attach

FromJoerg Roedel <jroedel@suse.de>
Date2017-08-04 15:20 +0200
SubjectRe: [PATCH v9 12/13] iommu/amd: Clear out the GV flag when handle deferred domain attach
Message-ID<uaKGe-7th-25@gated-at.bofh.it>
In reply to#1703939
On Fri, Aug 04, 2017 at 09:13:20PM +0800, Baoquan He wrote:
> On 08/04/17 at 02:30pm, Joerg Roedel wrote:
> > On Tue, Aug 01, 2017 at 07:37:28PM +0800, Baoquan He wrote:
> > > @@ -2466,11 +2472,21 @@ static struct protection_domain *get_domain(struct device *dev)
> > >  		return ERR_PTR(-EINVAL);
> > >  
> > >  	domain = get_dev_data(dev)->domain;
> > > -	if (domain == NULL && get_dev_data(dev)->defer_attach) {
> > > +	if (domain == NULL && dev_data->defer_attach) {
> > > +		u16 alias = amd_iommu_alias_table[dev_data->devid];
> > >  		get_dev_data(dev)->defer_attach = false;
> > >  		io_domain = iommu_get_domain_for_dev(dev);
> > >  		domain = to_pdomain(io_domain);
> > >  		attach_device(dev, domain);
> > > +		/*
> > > +		 * If the deferred attached domain is not v2, should clear out
> > > +		 * the old GV flag.
> > > +		 */
> > > +		if (!(domain->flags & PD_IOMMUV2_MASK)) {
> > > +			clear_dte_flag_gv(dev_data->devid);
> > > +			if (alias != dev_data->devid)
> > > +				clear_dte_flag_gv(dev_data->devid);
> > 
> > Hmm, thinking more about it, I am not sure what the IOMMU responds to
> > PRI/PASID prefixes if the GV flag is 0.
> > 
> > But until we know it causes problems we should just disable the bit
> > while doing the copy in the previous patch and avoid any special
> > handling like done here.
> 
> So just drop this patch, right? Will do if I got it right. Thanks.

Yes, and clear the GV flag in the previous patch too.

[toc] | [prev] | [next] | [standalone]


#1703969 — Re: [PATCH v9 12/13] iommu/amd: Clear out the GV flag when handle deferred domain attach

FromBaoquan He <bhe@redhat.com>
Date2017-08-04 15:20 +0200
SubjectRe: [PATCH v9 12/13] iommu/amd: Clear out the GV flag when handle deferred domain attach
Message-ID<uaKGe-7th-27@gated-at.bofh.it>
In reply to#1703939
On 08/04/17 at 02:30pm, Joerg Roedel wrote:
> On Tue, Aug 01, 2017 at 07:37:28PM +0800, Baoquan He wrote:
> > @@ -2466,11 +2472,21 @@ static struct protection_domain *get_domain(struct device *dev)
> >  		return ERR_PTR(-EINVAL);
> >  
> >  	domain = get_dev_data(dev)->domain;
> > -	if (domain == NULL && get_dev_data(dev)->defer_attach) {
> > +	if (domain == NULL && dev_data->defer_attach) {
> > +		u16 alias = amd_iommu_alias_table[dev_data->devid];
> >  		get_dev_data(dev)->defer_attach = false;
> >  		io_domain = iommu_get_domain_for_dev(dev);
> >  		domain = to_pdomain(io_domain);
> >  		attach_device(dev, domain);
> > +		/*
> > +		 * If the deferred attached domain is not v2, should clear out
> > +		 * the old GV flag.
> > +		 */
> > +		if (!(domain->flags & PD_IOMMUV2_MASK)) {
> > +			clear_dte_flag_gv(dev_data->devid);
> > +			if (alias != dev_data->devid)
> > +				clear_dte_flag_gv(dev_data->devid);
> 
> Hmm, thinking more about it, I am not sure what the IOMMU responds to
> PRI/PASID prefixes if the GV flag is 0.
> 
> But until we know it causes problems we should just disable the bit
> while doing the copy in the previous patch and avoid any special
> handling like done here.

So just drop this patch, right? Will do if I got it right. Thanks.

> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web