lkml.org 
[lkml]   [2018]   [Mar]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] mm/hmm: clarify fault logic for device private memory
Date
From: Ralph Campbell <rcampbell@nvidia.com>

For device private memory caller of hmm_vma_fault() want to be able to
carefully control fault behavior. Update logic to only fault on device
private entry if explicitly requested.

Before this patch a read only device private CPU page table entry would
fault if caller requested write permission without the device private
flag set (in caller's 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>
---
mm/hmm.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/mm/hmm.c b/mm/hmm.c
index ba912da1c1a1..398d0214be66 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 requested */
+ 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;
}
}
--
2.14.3
\
 
 \ /
  Last update: 2018-03-26 23:31    [W:0.027 / U:1.416 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site