diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-01-31 13:01:08 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-01-31 13:01:08 -0500 |
commit | 5a87e37ee0943afe11504299e4b87d2e4d8d88d5 (patch) | |
tree | bd8b5af826eda948190d8ec3d1afd869f834a971 /virt | |
parent | 19e7b5f99474107e8d0b4b3e4652fa19ddb87efc (diff) | |
parent | ce53053ce378c21e7ffc45241fd67d6ee79daa2b (diff) |
Merge branch 'work.get_user_pages_fast' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull get_user_pages_fast updates from Al Viro:
"A bit more get_user_pages work"
* 'work.get_user_pages_fast' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
kvm: switch get_user_page_nowait() to get_user_pages_unlocked()
__get_user_pages_locked(): get rid of notify_drop argument
get_user_pages_unlocked(): pass true to __get_user_pages_locked() notify_drop
cris: switch to get_user_pages_fast()
fold __get_user_pages_unlocked() into its sole remaining caller
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/kvm_main.c | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 210bf820385a..d6b9370806f8 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -1322,17 +1322,6 @@ unsigned long kvm_vcpu_gfn_to_hva_prot(struct kvm_vcpu *vcpu, gfn_t gfn, bool *w | |||
1322 | return gfn_to_hva_memslot_prot(slot, gfn, writable); | 1322 | return gfn_to_hva_memslot_prot(slot, gfn, writable); |
1323 | } | 1323 | } |
1324 | 1324 | ||
1325 | static int get_user_page_nowait(unsigned long start, int write, | ||
1326 | struct page **page) | ||
1327 | { | ||
1328 | int flags = FOLL_NOWAIT | FOLL_HWPOISON; | ||
1329 | |||
1330 | if (write) | ||
1331 | flags |= FOLL_WRITE; | ||
1332 | |||
1333 | return get_user_pages(start, 1, flags, page, NULL); | ||
1334 | } | ||
1335 | |||
1336 | static inline int check_user_page_hwpoison(unsigned long addr) | 1325 | static inline int check_user_page_hwpoison(unsigned long addr) |
1337 | { | 1326 | { |
1338 | int rc, flags = FOLL_HWPOISON | FOLL_WRITE; | 1327 | int rc, flags = FOLL_HWPOISON | FOLL_WRITE; |
@@ -1381,7 +1370,8 @@ static bool hva_to_pfn_fast(unsigned long addr, bool atomic, bool *async, | |||
1381 | static int hva_to_pfn_slow(unsigned long addr, bool *async, bool write_fault, | 1370 | static int hva_to_pfn_slow(unsigned long addr, bool *async, bool write_fault, |
1382 | bool *writable, kvm_pfn_t *pfn) | 1371 | bool *writable, kvm_pfn_t *pfn) |
1383 | { | 1372 | { |
1384 | struct page *page[1]; | 1373 | unsigned int flags = FOLL_HWPOISON; |
1374 | struct page *page; | ||
1385 | int npages = 0; | 1375 | int npages = 0; |
1386 | 1376 | ||
1387 | might_sleep(); | 1377 | might_sleep(); |
@@ -1389,35 +1379,26 @@ static int hva_to_pfn_slow(unsigned long addr, bool *async, bool write_fault, | |||
1389 | if (writable) | 1379 | if (writable) |
1390 | *writable = write_fault; | 1380 | *writable = write_fault; |
1391 | 1381 | ||
1392 | if (async) { | 1382 | if (write_fault) |
1393 | down_read(¤t->mm->mmap_sem); | 1383 | flags |= FOLL_WRITE; |
1394 | npages = get_user_page_nowait(addr, write_fault, page); | 1384 | if (async) |
1395 | up_read(¤t->mm->mmap_sem); | 1385 | flags |= FOLL_NOWAIT; |
1396 | } else { | ||
1397 | unsigned int flags = FOLL_HWPOISON; | ||
1398 | |||
1399 | if (write_fault) | ||
1400 | flags |= FOLL_WRITE; | ||
1401 | 1386 | ||
1402 | npages = get_user_pages_unlocked(addr, 1, page, flags); | 1387 | npages = get_user_pages_unlocked(addr, 1, &page, flags); |
1403 | } | ||
1404 | if (npages != 1) | 1388 | if (npages != 1) |
1405 | return npages; | 1389 | return npages; |
1406 | 1390 | ||
1407 | /* map read fault as writable if possible */ | 1391 | /* map read fault as writable if possible */ |
1408 | if (unlikely(!write_fault) && writable) { | 1392 | if (unlikely(!write_fault) && writable) { |
1409 | struct page *wpage[1]; | 1393 | struct page *wpage; |
1410 | 1394 | ||
1411 | npages = __get_user_pages_fast(addr, 1, 1, wpage); | 1395 | if (__get_user_pages_fast(addr, 1, 1, &wpage) == 1) { |
1412 | if (npages == 1) { | ||
1413 | *writable = true; | 1396 | *writable = true; |
1414 | put_page(page[0]); | 1397 | put_page(page); |
1415 | page[0] = wpage[0]; | 1398 | page = wpage; |
1416 | } | 1399 | } |
1417 | |||
1418 | npages = 1; | ||
1419 | } | 1400 | } |
1420 | *pfn = page_to_pfn(page[0]); | 1401 | *pfn = page_to_pfn(page); |
1421 | return npages; | 1402 | return npages; |
1422 | } | 1403 | } |
1423 | 1404 | ||