| 1 |
#include <linux/mm.h> |
| 2 |
|
| 3 |
// |
| 4 |
// The following kernel commit changed the get_user_pages_remote() |
| 5 |
// function signature and added the inlined get_user_page_vma_remote() |
| 6 |
// |
| 7 |
// commit ca5e863233e8f6acd1792fd85d6bc2729a1b2c10 |
| 8 |
// Author: Lorenzo Stoakes <[email protected]> |
| 9 |
// Date: Wed May 17 20:25:39 2023 +0100 |
| 10 |
// |
| 11 |
// mm/gup: remove vmas parameter from get_user_pages_remote() |
| 12 |
// |
| 13 |
// The only instances of get_user_pages_remote() invocations which used the |
| 14 |
// vmas parameter were for a single page which can instead simply look up the |
| 15 |
// VMA directly. In particular:- |
| 16 |
// |
| 17 |
// - __update_ref_ctr() looked up the VMA but did nothing with it so we simply |
| 18 |
// remove it. |
| 19 |
// |
| 20 |
// - __access_remote_vm() was already using vma_lookup() when the original |
| 21 |
// lookup failed so by doing the lookup directly this also de-duplicates the |
| 22 |
// code. |
| 23 |
// |
| 24 |
// We are able to perform these VMA operations as we already hold the |
| 25 |
// mmap_lock in order to be able to call get_user_pages_remote(). |
| 26 |
// |
| 27 |
// As part of this work we add get_user_page_vma_remote() which abstracts the |
| 28 |
// VMA lookup, error handling and decrementing the page reference count should |
| 29 |
// the VMA lookup fail. |
| 30 |
// |
| 31 |
// This forms part of a broader set of patches intended to eliminate the vmas |
| 32 |
// parameter altogether. |
| 33 |
|
| 34 |
struct page *get_user_page_vma_remote_wrapper(struct mm_struct *mm, |
| 35 |
unsigned long addr, |
| 36 |
unsigned int gup_flags, |
| 37 |
struct vm_area_struct **vmaps); |
| 38 |
|
| 39 |
struct page *get_user_page_vma_remote_wrapper(struct mm_struct *mm, |
| 40 |
unsigned long addr, |
| 41 |
unsigned int gup_flags, |
| 42 |
struct vm_area_struct **vmaps) |
| 43 |
{ |
| 44 |
return get_user_page_vma_remote(mm, addr, gup_flags, vmaps); |
| 45 |
} |