mm/hmm: fault non-owner device private entries
PATCH 1/1 mm/hmm: fault non-owner device private entries
If hmm_range_fault() is called with the HMM_PFN_REQ_FAULT flag and a device private PTE is found, the hmm_range::dev_private_owner page is used to determine if the device private page should not be faulted in. However, if the device private page is not owned by the caller, hmm_range_fault() returns an error instead of calling migrate_to_ram() to fault in the page.
--- mm/hmm.c | 3 +++ 1 file changed, 3 insertions(+)
mm/hmm.c +3 -0
@@ -273,6 +273,9 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr,if (!non_swap_entry (entry)) goto fault; +if (is_device_private_entry (entry)) + goto fault; +if (is_device_exclusive_entry (entry)) goto fault;
Signature · 1 line
2.35.3
Quoted 7 lines · Ralph Campbell
If
hmm_range_fault()is called with theHMM_PFN_REQ_FAULTflag and a device private PTE is found, thehmm_range::dev_private_ownerpage is used to determine if the device private page should not be faulted in. However, if the device private page is not owned by the caller,hmm_range_fault()returns an error instead of callingmigrate_to_ram()to fault in the page.
Quoted 7 lines
Fixes 76612d6ce4cc ("mm/hmm: reorganize how !pte_present is handled in hmm_vma_handle_pte()")Signed-off-by Ralph Campbell <[email protected]>Reported-by Felix Kuehling <[email protected]>--- mm/hmm.c | 3 +++ 1 file changed, 3 insertions(+)
Should we have a test for this ?
Jason
Quoted 15 lines · Jason Gunthorpe
Quoted 7 lines · Ralph Campbell
If
hmm_range_fault()is called with theHMM_PFN_REQ_FAULTflag and a device private PTE is found, thehmm_range::dev_private_ownerpage is used to determine if the device private page should not be faulted in. However, if the device private page is not owned by the caller,hmm_range_fault()returns an error instead of callingmigrate_to_ram()to fault in the page.Quoted 7 lines
Fixes 76612d6ce4cc ("mm/hmm: reorganize how !pte_present is handled in hmm_vma_handle_pte()")Signed-off-by Ralph Campbell <[email protected]>Reported-by Felix Kuehling <[email protected]>--- mm/hmm.c | 3 +++ 1 file changed, 3 insertions(+)
Quoted 5 lines
Should we have a test for this ?
Reviewed-by Jason Gunthorpe <[email protected]>Jason
Sure, I'll add something to tools/testing/selftests/vm/hmm-tests.c
Quoted 6 lines · Ralph Campbell
If
hmm_range_fault()is called with theHMM_PFN_REQ_FAULTflag and a device private PTE is found, thehmm_range::dev_private_ownerpage is used to determine if the device private page should not be faulted in. However, if the device private page is not owned by the caller,hmm_range_fault()returns an error instead of callingmigrate_to_ram()to fault in the page.
/* * Never fault in device private pages, but just report * the PFN even if not present. */
This comment needs updating because it will be possible to fault in device private pages now.
It also looks a bit strange to be checking for device private entries twice - I think it would be clearer if hmm_is_device_private_entry() is removed and the ownership check done directly in hmm_vma_handle_pte().
- Alistair
Quoted 21 lines
Fixes 76612d6ce4cc ("mm/hmm: reorganize how !pte_present is handled in hmm_vma_handle_pte()")Signed-off-by Ralph Campbell <[email protected]>Reported-by Felix Kuehling <[email protected]>--- mm/hmm.c | 3 +++ 1 file changed, 3 insertions(+)mm/hmm.c +3
-0@@ -273,6 +273,9 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr,if (!non_swap_entry (entry)) goto fault; +if (is_device_private_entry (entry)) + goto fault; +if (is_device_exclusive_entry (entry)) goto fault;
Quoted 13 lines · Alistair Popple
Quoted 6 lines · Ralph Campbell
If
hmm_range_fault()is called with theHMM_PFN_REQ_FAULTflag and a device private PTE is found, thehmm_range::dev_private_ownerpage is used to determine if the device private page should not be faulted in. However, if the device private page is not owned by the caller,hmm_range_fault()returns an error instead of callingmigrate_to_ram()to fault in the page./* * Never fault in device private pages, but just report * the PFN even if not present. */
Quoted 8 lines
This comment needs updating because it will be possible to fault in device private pages now.
It also looks a bit strange to be checking for device private entries twice - I think it would be clearer if
hmm_is_device_private_entry()is removed and the ownership check done directly inhmm_vma_handle_pte().- Alistair
I'll fix this in v2. Thanks for the review.
Am 2022-07-22 um 18:56 schrieb Ralph Campbell:
Quoted 11 lines
If
hmm_range_fault()is called with theHMM_PFN_REQ_FAULTflag and a device private PTE is found, thehmm_range::dev_private_ownerpage is used to determine if the device private page should not be faulted in. However, if the device private page is not owned by the caller,hmm_range_fault()returns an error instead of callingmigrate_to_ram()to fault in the page.Fixes 76612d6ce4cc ("mm/hmm: reorganize how !pte_present is handled in hmm_vma_handle_pte()")Signed-off-by Ralph Campbell <[email protected]>Reported-by Felix Kuehling <[email protected]>
Thank you!
Quoted 18 lines
--- mm/hmm.c | 3 +++ 1 file changed, 3 insertions(+)mm/hmm.c +3
-0@@ -273,6 +273,9 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr,if (!non_swap_entry (entry)) goto fault; +if (is_device_private_entry (entry)) + goto fault; +if (is_device_exclusive_entry (entry)) goto fault;
Andrew Morton
maintainerQuoted 6 lines · On Fri, 22 Jul 2022 15:56:32 -0700 Ralph Campbell <[email protected]> wrote:
If
hmm_range_fault()is called with theHMM_PFN_REQ_FAULTflag and a device private PTE is found, thehmm_range::dev_private_ownerpage is used to determine if the device private page should not be faulted in. However, if the device private page is not owned by the caller,hmm_range_fault()returns an error instead of callingmigrate_to_ram()to fault in the page.
Could we please include here a description of the end-user visible effects of the bug?
Quoted 1 line
Especially when proposing a -stable backport.
Quoted 8 lines · Andrew Morton
Quoted 6 lines · On Fri, 22 Jul 2022 15:56:32 -0700 Ralph Campbell <[email protected]> wrote:
If
hmm_range_fault()is called with theHMM_PFN_REQ_FAULTflag and a device private PTE is found, thehmm_range::dev_private_ownerpage is used to determine if the device private page should not be faulted in. However, if the device private page is not owned by the caller,hmm_range_fault()returns an error instead of callingmigrate_to_ram()to fault in the page.
Quoted 5 lines
Could we please include here a description of the end-user visible effects of the bug?
Quoted 1 line
Especially when proposing a -stable backport.
If I add the following, would that be sufficient?
Should I post a v3?
For example, if a page is migrated to GPU private
memory and a RDMA fault capable NIC tries to read the migrated page, without this patch it will get an error. With this patch, the page will be migrated back to system memory and the NIC will be able to read the data.
Andrew Morton
maintainerQuoted 7 lines · On Mon, 25 Jul 2022 12:07:27 -0700 Ralph Campbell <[email protected]> wrote:
Quoted 6 lines
Quoted 1 line
to fault in the page.
Could we please include here a description of the end-user visible effects of the bug?
Quoted 1 line
Especially when proposing a -stable backport.
Quoted 8 lines
If I add the following, would that be sufficient?
Should I post a v3?For example, if a page is migrated to GPU private
memory and a RDMA fault capable NIC tries to read the migrated page, without this patch it will get an error. With this patch, the page will be migrated back to system memory and the NIC will be able to read the data.
I added it, thanks.