linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] omap iommu: Reject unaligned physical address at setting page table entry
@ 2010-05-07  6:56 Hiroshi DOYU
  2010-05-07  6:56 ` [PATCH 2/5] omap iommu: Fix superpage unalignment at allocation of iovm areas Hiroshi DOYU
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Hiroshi DOYU @ 2010-05-07  6:56 UTC (permalink / raw)
  To: linux-omap
  Cc: h-kanigeri2, vimarsh.zutshi, Sakari.Ailus, david.cohen,
	Hiroshi DOYU

From: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>

This rejects unaligned physical address at setting page table entry
and informs error to caller. Otherwise, a wrong address may be used by
IO device.

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---
 arch/arm/plat-omap/iommu.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/arch/arm/plat-omap/iommu.c b/arch/arm/plat-omap/iommu.c
index 0e13766..b3591ee 100644
--- a/arch/arm/plat-omap/iommu.c
+++ b/arch/arm/plat-omap/iommu.c
@@ -503,6 +503,12 @@ static int iopgd_alloc_section(struct iommu *obj, u32 da, u32 pa, u32 prot)
 {
 	u32 *iopgd = iopgd_offset(obj, da);
 
+	if (pa & ~IOSECTION_MASK) {
+		dev_err(obj->dev, "%s: pa:%08x should aligned on %08lx\n",
+			__func__, pa, IOSECTION_SIZE);
+		return -EINVAL;
+	}
+
 	*iopgd = (pa & IOSECTION_MASK) | prot | IOPGD_SECTION;
 	flush_iopgd_range(iopgd, iopgd);
 	return 0;
@@ -513,6 +519,12 @@ static int iopgd_alloc_super(struct iommu *obj, u32 da, u32 pa, u32 prot)
 	u32 *iopgd = iopgd_offset(obj, da);
 	int i;
 
+	if (pa & ~IOSUPER_MASK) {
+		dev_err(obj->dev, "%s: pa:%08x should aligned on %08lx\n",
+			__func__, pa, IOSUPER_SIZE);
+		return -EINVAL;
+	}
+
 	for (i = 0; i < 16; i++)
 		*(iopgd + i) = (pa & IOSUPER_MASK) | prot | IOPGD_SUPER;
 	flush_iopgd_range(iopgd, iopgd + 15);
@@ -542,6 +554,12 @@ static int iopte_alloc_large(struct iommu *obj, u32 da, u32 pa, u32 prot)
 	u32 *iopte = iopte_alloc(obj, iopgd, da);
 	int i;
 
+	if (pa & ~IOLARGE_MASK) {
+		dev_err(obj->dev, "%s: pa:%08x should aligned on %08lx\n",
+			__func__, pa, IOLARGE_SIZE);
+		return -EINVAL;
+	}
+
 	if (IS_ERR(iopte))
 		return PTR_ERR(iopte);
 
-- 
1.7.1.rc1


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

end of thread, other threads:[~2010-05-07 11:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-07  6:56 [PATCH 1/5] omap iommu: Reject unaligned physical address at setting page table entry Hiroshi DOYU
2010-05-07  6:56 ` [PATCH 2/5] omap iommu: Fix superpage unalignment at allocation of iovm areas Hiroshi DOYU
2010-05-07  7:19   ` Felipe Contreras
2010-05-07  6:56 ` [PATCH 3/5] omap iommu: Make CONFIG_OMAP_IOMMU_DEBUG selectable Hiroshi DOYU
2010-05-07  6:56 ` [PATCH 4/5] omap iommu: Insert a gap page between IOVMAs against override Hiroshi DOYU
2010-05-07  6:56 ` [PATCH 5/5] omap iommu: Exit iteration if no possibility of available area Hiroshi DOYU
2010-05-07 11:45 ` [PATCH 1/5] omap iommu: Reject unaligned physical address at setting page table entry Kanigeri, Hari

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).