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


Groups > linux.kernel > #1271305

[PATCH 2/4] iommu/amd: Correctly set flags for handle_mm_fault call

From Joerg Roedel <joro@8bytes.org>
Newsgroups linux.kernel
Subject [PATCH 2/4] iommu/amd: Correctly set flags for handle_mm_fault call
Date 2015-11-17 16:20 +0100
Message-ID <qvQd3-6JK-7@gated-at.bofh.it> (permalink)
References <qvQd3-6JK-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Joerg Roedel <jroedel@suse.de>

Instead of just checking for a write access, calculate the
flags that are passed to handle_mm_fault() more precisly and
use the pre-defined macros.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/iommu/amd_iommu_v2.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c
index 7caf2fa..a7edbd6 100644
--- a/drivers/iommu/amd_iommu_v2.c
+++ b/drivers/iommu/amd_iommu_v2.c
@@ -513,16 +513,20 @@ static bool access_error(struct vm_area_struct *vma, struct fault *fault)
 static void do_fault(struct work_struct *work)
 {
 	struct fault *fault = container_of(work, struct fault, work);
-	struct mm_struct *mm;
 	struct vm_area_struct *vma;
+	unsigned int flags = 0;
+	struct mm_struct *mm;
 	u64 address;
-	int ret, write;
-
-	write = !!(fault->flags & PPR_FAULT_WRITE);
+	int ret;
 
 	mm = fault->state->mm;
 	address = fault->address;
 
+	if (fault->flags & PPR_FAULT_USER)
+		flags |= FAULT_FLAG_USER;
+	if (fault->flags & PPR_FAULT_WRITE)
+		flags |= FAULT_FLAG_WRITE;
+
 	down_read(&mm->mmap_sem);
 	vma = find_extend_vma(mm, address);
 	if (!vma || address < vma->vm_start) {
@@ -539,7 +543,7 @@ static void do_fault(struct work_struct *work)
 		goto out;
 	}
 
-	ret = handle_mm_fault(mm, vma, address, write);
+	ret = handle_mm_fault(mm, vma, address, flags);
 	if (ret & VM_FAULT_ERROR) {
 		/* failed to service fault */
 		up_read(&mm->mmap_sem);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/4 v2] Implement access checks in iommu page fault paths Joerg Roedel <joro@8bytes.org> - 2015-11-17 16:20 +0100
  [PATCH 1/4] iommu/amd: Do proper access checking before calling handle_mm_fault() Joerg Roedel <joro@8bytes.org> - 2015-11-17 16:20 +0100
  [PATCH 2/4] iommu/amd: Correctly set flags for handle_mm_fault call Joerg Roedel <joro@8bytes.org> - 2015-11-17 16:20 +0100
  [PATCH 3/4] iommu/amd: Cleanup error handling in do_fault() Joerg Roedel <joro@8bytes.org> - 2015-11-17 16:20 +0100
  [PATCH 4/4] iommu/vt-d: Do access checks before calling handle_mm_fault() Joerg Roedel <joro@8bytes.org> - 2015-11-17 16:20 +0100
    Re: [PATCH 4/4] iommu/vt-d: Do access checks before calling  handle_mm_fault() David Woodhouse <dwmw2@infradead.org> - 2015-11-20 16:40 +0100
  Re: [PATCH 0/4 v2] Implement access checks in iommu page fault paths Oded Gabbay <oded.gabbay@gmail.com> - 2015-11-18 15:10 +0100
  Re: [PATCH 0/4 v2] Implement access checks in iommu page fault paths Jesse Barnes <jbarnes@virtuousgeek.org> - 2015-11-18 17:20 +0100
    Re: [PATCH 0/4 v2] Implement access checks in iommu page fault paths Joerg Roedel <joro@8bytes.org> - 2015-11-27 13:10 +0100

csiph-web