From a0ac9b3598fac36907bd1baec28c99656d2ed0b6 Mon Sep 17 00:00:00 2001 From: David Hildenbrand Date: Mon, 5 Dec 2022 20:37:13 +0100 Subject: mm/gup_test: fix PIN_LONGTERM_TEST_READ with highmem Patch series "selftests/vm: fix some tests on 32bit". I finally had the time to run some of the selftests written by me (especially "cow") on x86 PAE. I found some unexpected "surprises" :) With these changes, and with [1] on top of mm-unstable, the "cow" tests and the "ksm_functional_tests" compile and pass as expected (expected failures with hugetlb in the "cow" tests). "madv_populate" has one expected test failure -- x86 does not support softdirty tracking. #1-#3 fix commits with stable commit ids. #4 fixes a test that is not in mm-stable yet. A note that there are many other compile errors/warnings when compiling on 32bit and with older Linux headers ... something for another day. [1] https://lkml.kernel.org/r/20221205150857.167583-1-david@redhat.com This patch (of 4): ... we have to kmap()/kunmap(), otherwise this won't work as expected with highmem. Link: https://lkml.kernel.org/r/20221205193716.276024-1-david@redhat.com Link: https://lkml.kernel.org/r/20221205193716.276024-2-david@redhat.com Fixes: c77369b437f9 ("mm/gup_test: start/stop/read functionality for PIN LONGTERM test") Signed-off-by: David Hildenbrand Cc: Shuah Khan , Cc: Yang Li Signed-off-by: Andrew Morton --- mm/gup_test.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'mm/gup_test.c') diff --git a/mm/gup_test.c b/mm/gup_test.c index 0d76d9b4bb5a..33f431e0da60 100644 --- a/mm/gup_test.c +++ b/mm/gup_test.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "gup_test.h" static void put_back_pages(unsigned int cmd, struct page **pages, @@ -297,10 +298,13 @@ static inline int pin_longterm_test_read(unsigned long arg) return -EFAULT; for (i = 0; i < pin_longterm_test_nr_pages; i++) { - void *addr = page_to_virt(pin_longterm_test_pages[i]); + void *addr = kmap_local_page(pin_longterm_test_pages[i]); + unsigned long ret; - if (copy_to_user((void __user *)(unsigned long)user_addr, addr, - PAGE_SIZE)) + ret = copy_to_user((void __user *)(unsigned long)user_addr, addr, + PAGE_SIZE); + kunmap_local(addr); + if (ret) return -EFAULT; user_addr += PAGE_SIZE; } -- cgit v1.2.3