summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalph Campbell <rcampbell@nvidia.com>2018-03-26 14:56:14 -0400
committerJérôme Glisse <jglisse@redhat.com>2018-03-26 15:13:16 -0400
commit3738170a6593b0273a1a75abeb1bdb532f2abab0 (patch)
tree0fbba919ec036fae135a3f9fe52d64bf3aa41acc
parentac531468aac4ef7f95c876620286b7a6b6db4325 (diff)
mm/hmm: fix clarify fault logic for device private memoryhmm-4.17
For device private memory caller of hmm_vma_fault() want to be able to carefully control fault. So update logic to only fault device private entry if explicitly ask. Before this patch a read only device private CPU page table entry would fault if caller asked for write without the device private flag set (in caller flag fault request). After this patch it will only fault if the device private flag is also set. Signed-off-by: Ralph Campbell <rcampbell@nvidia.com> Signed-off-by: Jérôme Glisse <jglisse@redhat.com> Cc: Evgeny Baskakov <ebaskakov@nvidia.com> Cc: Mark Hairgrove <mhairgrove@nvidia.com> Cc: John Hubbard <jhubbard@nvidia.com>
-rw-r--r--mm/hmm.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/mm/hmm.c b/mm/hmm.c
index ba912da1c1a1..34aa0b96ba6e 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -390,18 +390,22 @@ static inline void hmm_pte_need_fault(const struct hmm_vma_walk *hmm_vma_walk,
/* We aren't ask to do anything ... */
if (!(pfns & range->flags[HMM_PFN_VALID]))
return;
+ /* If this is device memory than only fault if explicitly ask */
+ if ((cpu_flags & range->flags[HMM_PFN_DEVICE_PRIVATE])) {
+ /* Do we fault on device memory ? */
+ if (pfns & range->flags[HMM_PFN_DEVICE_PRIVATE]) {
+ *write_fault = pfns & range->flags[HMM_PFN_WRITE];
+ *fault = true;
+ }
+ return;
+ }
+
/* If CPU page table is not valid then we need to fault */
- *fault = cpu_flags & range->flags[HMM_PFN_VALID];
+ *fault = !(cpu_flags & range->flags[HMM_PFN_VALID]);
/* Need to write fault ? */
if ((pfns & range->flags[HMM_PFN_WRITE]) &&
!(cpu_flags & range->flags[HMM_PFN_WRITE])) {
- *fault = *write_fault = false;
- return;
- }
- /* Do we fault on device memory ? */
- if ((pfns & range->flags[HMM_PFN_DEVICE_PRIVATE]) &&
- (cpu_flags & range->flags[HMM_PFN_DEVICE_PRIVATE])) {
- *write_fault = pfns & range->flags[HMM_PFN_WRITE];
+ *write_fault = true;
*fault = true;
}
}