Commit 24d2613a authored by Fabio M. De Francesco's avatar Fabio M. De Francesco Committed by Andrew Morton

mm/memory: use kmap_local_page() in __wp_page_copy_user()

kmap_atomic() has been deprecated in favor of kmap_local_{folio,page}.

Therefore, replace kmap_atomic() with kmap_local_page in
__wp_page_copy_user().

kmap_atomic() disables preemption in !PREEMPT_RT kernels and
unconditionally disables also page-faults.  My limited knowledge of the
implementation of __wp_page_copy_user() makes me think that the latter
side effect is still needed here, but kmap_local_page() is implemented not
to disable page-faults.

So, in addition to the conversion to local mapping, add explicit
pagefault_disable() / pagefault_enable() between mapping and un-mapping.

Link: https://lkml.kernel.org/r/20231120142418.6977-1-fmdefrancesco@gmail.comSigned-off-by: default avatarFabio M. De Francesco <fabio.maria.de.francesco@linux.intel.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent b3351989
...@@ -2841,7 +2841,8 @@ static inline int __wp_page_copy_user(struct page *dst, struct page *src, ...@@ -2841,7 +2841,8 @@ static inline int __wp_page_copy_user(struct page *dst, struct page *src,
* just copying from the original user address. If that * just copying from the original user address. If that
* fails, we just zero-fill it. Live with it. * fails, we just zero-fill it. Live with it.
*/ */
kaddr = kmap_atomic(dst); kaddr = kmap_local_page(dst);
pagefault_disable();
uaddr = (void __user *)(addr & PAGE_MASK); uaddr = (void __user *)(addr & PAGE_MASK);
/* /*
...@@ -2909,7 +2910,8 @@ static inline int __wp_page_copy_user(struct page *dst, struct page *src, ...@@ -2909,7 +2910,8 @@ static inline int __wp_page_copy_user(struct page *dst, struct page *src,
pte_unlock: pte_unlock:
if (vmf->pte) if (vmf->pte)
pte_unmap_unlock(vmf->pte, vmf->ptl); pte_unmap_unlock(vmf->pte, vmf->ptl);
kunmap_atomic(kaddr); pagefault_enable();
kunmap_local(kaddr);
flush_dcache_page(dst); flush_dcache_page(dst);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment