All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Fenghua Yu <fenghua.yu@intel.com>
Cc: Tony Luck <tony.luck@intel.com>,
	iommu@lists.linux-foundation.org, linux-ia64@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] Bug Fix drivers/pci/intel-iommu.c: secure
Date: Wed, 05 Aug 2009 08:09:59 +0000	[thread overview]
Message-ID: <1249459799.9324.348.camel@macbook.infradead.org> (raw)
In-Reply-To: <20090804221024.GA21406@linux-os.sc.intel.com>

On Tue, 2009-08-04 at 15:10 -0700, Fenghua Yu wrote:
> sg_next() is called only when sg is not NULL. This solves a kernel panic on
> some platforms (e.g. ia64).

Is this still necessary after we fix the other bugs? When does it
happen? And is this fix sufficient (ignore the first hunk; it's just a
cleanup that the fix allows me to make, which is why I'd prefer to do it
this way):

diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 11b317a..c9bdb0b 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -1675,7 +1675,7 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
 	if (sg)
 		sg_res = 0;
 	else {
-		sg_res = nr_pages + 1;
+		sg_res = nr_pages;
 		pteval = ((phys_addr_t)phys_pfn << VTD_PAGE_SHIFT) | prot;
 	}
 
@@ -1716,7 +1716,7 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
 		iov_pfn++;
 		pteval += VTD_PAGE_SIZE;
 		sg_res--;
-		if (!sg_res)
+		if (nr_pages && !sg_res)
 			sg = sg_next(sg);
 	}
 	return 0;


-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation


WARNING: multiple messages have this Message-ID (diff)
From: David Woodhouse <dwmw2@infradead.org>
To: Fenghua Yu <fenghua.yu@intel.com>
Cc: Tony Luck <tony.luck@intel.com>,
	iommu@lists.linux-foundation.org, linux-ia64@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] Bug Fix drivers/pci/intel-iommu.c: secure sg_next() calling
Date: Wed, 05 Aug 2009 09:09:59 +0100	[thread overview]
Message-ID: <1249459799.9324.348.camel@macbook.infradead.org> (raw)
In-Reply-To: <20090804221024.GA21406@linux-os.sc.intel.com>

On Tue, 2009-08-04 at 15:10 -0700, Fenghua Yu wrote:
> sg_next() is called only when sg is not NULL. This solves a kernel panic on
> some platforms (e.g. ia64).

Is this still necessary after we fix the other bugs? When does it
happen? And is this fix sufficient (ignore the first hunk; it's just a
cleanup that the fix allows me to make, which is why I'd prefer to do it
this way):

diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 11b317a..c9bdb0b 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -1675,7 +1675,7 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
 	if (sg)
 		sg_res = 0;
 	else {
-		sg_res = nr_pages + 1;
+		sg_res = nr_pages;
 		pteval = ((phys_addr_t)phys_pfn << VTD_PAGE_SHIFT) | prot;
 	}
 
@@ -1716,7 +1716,7 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
 		iov_pfn++;
 		pteval += VTD_PAGE_SIZE;
 		sg_res--;
-		if (!sg_res)
+		if (nr_pages && !sg_res)
 			sg = sg_next(sg);
 	}
 	return 0;


-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation


  reply	other threads:[~2009-08-05  8:09 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <BAE9DCEF64577A439B3A37F36F9B691C0339372B@orsmsx418.amr.corp.intel.com>
2007-11-19 23:03 ` [PATCH] More Sanity checks for DMAR Fenghua Yu
2007-11-20 18:58   ` mark gross
     [not found] ` <617E1C2C70743745A92448908E030B2A02AD5AD7@scsmsx411.amr.corp.intel.com>
2008-05-02 22:26   ` [PATCH] Handle invalid ACPI SLIT table Fenghua Yu
2008-05-02 22:26     ` Fenghua Yu
2008-05-02 22:26     ` Fenghua Yu
2008-10-01 16:57   ` [PATCH 1/2]Add Variable Page Size and IA64 Support in Intel IOMMU: Generic Part Fenghua Yu
2008-10-01 16:57     ` Fenghua Yu
2008-10-02  8:29     ` [PATCH 1/2]Add Variable Page Size and IA64 Support in Intel Ingo Molnar
2008-10-02  8:29       ` [PATCH 1/2]Add Variable Page Size and IA64 Support in Intel IOMMU: Generic Part Ingo Molnar
2008-10-02 22:06       ` [PATCH 1/2]Add Variable Page Size and IA64 Support in Intel Yu, Fenghua
2008-10-02 22:06         ` [PATCH 1/2]Add Variable Page Size and IA64 Support in Intel IOMMU: Generic Part Yu, Fenghua
2008-10-03  8:54         ` [PATCH 1/2]Add Variable Page Size and IA64 Support in Intel Ingo Molnar
2008-10-03  8:54           ` [PATCH 1/2]Add Variable Page Size and IA64 Support in Intel IOMMU: Generic Part Ingo Molnar
2008-10-02 15:31     ` Bjorn Helgaas
2008-10-02 15:31       ` Bjorn Helgaas
2008-10-02 21:46       ` [PATCH 1/2]Add Variable Page Size and IA64 Support in Intel Yu, Fenghua
2008-10-02 21:46         ` [PATCH 1/2]Add Variable Page Size and IA64 Support in Intel IOMMU: Generic Part Yu, Fenghua
2008-10-03 15:33         ` Bjorn Helgaas
2008-10-03 15:33           ` Bjorn Helgaas
2008-10-04  0:21           ` [PATCH 1/2]Add Variable Page Size and IA64 Support in Intel Yu, Fenghua
2008-10-04  0:21             ` [PATCH 1/2]Add Variable Page Size and IA64 Support in Intel IOMMU: Generic Part Yu, Fenghua
2008-10-07  0:01     ` [PATCH V2 1/2] Add " Fenghua Yu
2008-10-07  0:01       ` Fenghua Yu
2009-08-04 22:10   ` [PATCH 2/4] Bug Fix drivers/pci/intel-iommu.c: secure sg_next() calling Fenghua Yu
2009-08-04 22:10     ` Fenghua Yu
2009-08-05  8:09     ` David Woodhouse [this message]
2009-08-05  8:09       ` David Woodhouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1249459799.9324.348.camel@macbook.infradead.org \
    --to=dwmw2@infradead.org \
    --cc=fenghua.yu@intel.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.