linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/4] iommu/io-pgtable-arm-v7s: Fix attributes when splitting blocks
Date: Thu, 18 Aug 2016 14:05:39 +0100	[thread overview]
Message-ID: <1471525542-14969-2-git-send-email-will.deacon@arm.com> (raw)
In-Reply-To: <1471525542-14969-1-git-send-email-will.deacon@arm.com>

From: Robin Murphy <robin.murphy@arm.com>

Due to the attribute bits being all over the place in the different
types of short-descriptor PTEs, when remapping an existing entry, e.g.
splitting a section into pages, we take the approach of decomposing
the PTE attributes back to the IOMMU API flags to start from scratch.

On inspection, though, the existing code seems to have got the read-only
bit backwards and ignored the XN bit. How embarrassing...

Fortunately the primary user so far, the Mediatek IOMMU, both never
splits blocks (because it only serves non-overlapping DMA API calls) and
also ignores permissions anyway, but let's put things right before any
future users trip up.

Cc: <stable@vger.kernel.org>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 drivers/iommu/io-pgtable-arm-v7s.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c
index 8c6139986d7d..def8ca1c982d 100644
--- a/drivers/iommu/io-pgtable-arm-v7s.c
+++ b/drivers/iommu/io-pgtable-arm-v7s.c
@@ -286,12 +286,14 @@ static int arm_v7s_pte_to_prot(arm_v7s_iopte pte, int lvl)
 	int prot = IOMMU_READ;
 	arm_v7s_iopte attr = pte >> ARM_V7S_ATTR_SHIFT(lvl);
 
-	if (attr & ARM_V7S_PTE_AP_RDONLY)
+	if (!(attr & ARM_V7S_PTE_AP_RDONLY))
 		prot |= IOMMU_WRITE;
 	if ((attr & (ARM_V7S_TEX_MASK << ARM_V7S_TEX_SHIFT)) == 0)
 		prot |= IOMMU_MMIO;
 	else if (pte & ARM_V7S_ATTR_C)
 		prot |= IOMMU_CACHE;
+	if (pte & ARM_V7S_ATTR_XN(lvl))
+		prot |= IOMMU_NOEXEC;
 
 	return prot;
 }
-- 
2.1.4

  reply	other threads:[~2016-08-18 13:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-18 13:05 [PATCH 0/4] iommu/arm-smmu: Fixes for 4.8 Will Deacon
2016-08-18 13:05 ` Will Deacon [this message]
2016-08-18 13:05 ` [PATCH 2/4] iommu/arm-smmu: Fix CMDQ error handling Will Deacon
2016-08-18 13:05 ` [PATCH 3/4] iommu/arm-smmu: Disable stalling faults for all endpoints Will Deacon
2016-12-06 23:30   ` Rob Clark
2016-12-07  0:00     ` Jordan Crouse
2016-12-10 15:44       ` Sricharan
2016-12-16 11:54     ` Will Deacon
2016-12-19  9:03       ` Sricharan
2016-12-20 16:17         ` Will Deacon
2017-09-13 19:31       ` Rob Clark
2017-09-18 17:33         ` Will Deacon
2017-09-18 18:45           ` Rob Clark
2016-08-18 13:05 ` [PATCH 4/4] iommu/arm-smmu: Don't BUG() if we find aborting STEs with disable_bypass Will Deacon
2016-08-18 16:52 ` [PATCH 0/4] iommu/arm-smmu: Fixes for 4.8 Joerg Roedel

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=1471525542-14969-2-git-send-email-will.deacon@arm.com \
    --to=will.deacon@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 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).