Skip to content

Commit a0ac9b3

Browse files
davidhildenbrandakpm00
authored andcommitted
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/[email protected] This patch (of 4): ... we have to kmap()/kunmap(), otherwise this won't work as expected with highmem. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: c77369b ("mm/gup_test: start/stop/read functionality for PIN LONGTERM test") Signed-off-by: David Hildenbrand <[email protected]> Cc: Shuah Khan <[email protected]>, Cc: Yang Li <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 6287b7d commit a0ac9b3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

mm/gup_test.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <linux/uaccess.h>
55
#include <linux/ktime.h>
66
#include <linux/debugfs.h>
7+
#include <linux/highmem.h>
78
#include "gup_test.h"
89

910
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)
297298
return -EFAULT;
298299

299300
for (i = 0; i < pin_longterm_test_nr_pages; i++) {
300-
void *addr = page_to_virt(pin_longterm_test_pages[i]);
301+
void *addr = kmap_local_page(pin_longterm_test_pages[i]);
302+
unsigned long ret;
301303

302-
if (copy_to_user((void __user *)(unsigned long)user_addr, addr,
303-
PAGE_SIZE))
304+
ret = copy_to_user((void __user *)(unsigned long)user_addr, addr,
305+
PAGE_SIZE);
306+
kunmap_local(addr);
307+
if (ret)
304308
return -EFAULT;
305309
user_addr += PAGE_SIZE;
306310
}

0 commit comments

Comments
 (0)