aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-03-17 21:40:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-17 21:40:35 -0400
commitec0afc9311adcfb10b90e547c23250f63939f990 (patch)
tree2093d2668898a8a03f30acbfd5568e65b8c086b9 /mm
parent804f18536984939622ddca60ab6b25743e0ec68d (diff)
parent776e58ea3d3735f85678155398241d2513afa67a (diff)
Merge branch 'kvm-updates/2.6.39' of git://git.kernel.org/pub/scm/virt/kvm/kvm
* 'kvm-updates/2.6.39' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (55 commits) KVM: unbreak userspace that does not sets tss address KVM: MMU: cleanup pte write path KVM: MMU: introduce a common function to get no-dirty-logged slot KVM: fix rcu usage in init_rmode_* functions KVM: fix kvmclock regression due to missing clock update KVM: emulator: Fix permission checking in io permission bitmap KVM: emulator: Fix io permission checking for 64bit guest KVM: SVM: Load %gs earlier if CONFIG_X86_32_LAZY_GS=n KVM: x86: Remove useless regs_page pointer from kvm_lapic KVM: improve comment on rcu use in irqfd_deassign KVM: MMU: remove unused macros KVM: MMU: cleanup page alloc and free KVM: MMU: do not record gfn in kvm_mmu_pte_write KVM: MMU: move mmu pages calculated out of mmu lock KVM: MMU: set spte accessed bit properly KVM: MMU: fix kvm_mmu_slot_remove_write_access dropping intermediate W bits KVM: Start lock documentation KVM: better readability of efer_reserved_bits KVM: Clear async page fault hash after switching to real mode KVM: VMX: Initialize vm86 TSS only once. ...
Diffstat (limited to 'mm')
-rw-r--r--mm/internal.h5
-rw-r--r--mm/memory-failure.c32
-rw-r--r--mm/memory.c63
3 files changed, 60 insertions, 40 deletions
diff --git a/mm/internal.h b/mm/internal.h
index 69488205723d..3438dd43a062 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -245,11 +245,6 @@ static inline void mminit_validate_memmodel_limits(unsigned long *start_pfn,
245} 245}
246#endif /* CONFIG_SPARSEMEM */ 246#endif /* CONFIG_SPARSEMEM */
247 247
248int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
249 unsigned long start, int len, unsigned int foll_flags,
250 struct page **pages, struct vm_area_struct **vmas,
251 int *nonblocking);
252
253#define ZONE_RECLAIM_NOSCAN -2 248#define ZONE_RECLAIM_NOSCAN -2
254#define ZONE_RECLAIM_FULL -1 249#define ZONE_RECLAIM_FULL -1
255#define ZONE_RECLAIM_SOME 0 250#define ZONE_RECLAIM_SOME 0
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 0207c2f6f8bd..99ccb4472623 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1487,35 +1487,3 @@ done:
1487 /* keep elevated page count for bad page */ 1487 /* keep elevated page count for bad page */
1488 return ret; 1488 return ret;
1489} 1489}
1490
1491/*
1492 * The caller must hold current->mm->mmap_sem in read mode.
1493 */
1494int is_hwpoison_address(unsigned long addr)
1495{
1496 pgd_t *pgdp;
1497 pud_t pud, *pudp;
1498 pmd_t pmd, *pmdp;
1499 pte_t pte, *ptep;
1500 swp_entry_t entry;
1501
1502 pgdp = pgd_offset(current->mm, addr);
1503 if (!pgd_present(*pgdp))
1504 return 0;
1505 pudp = pud_offset(pgdp, addr);
1506 pud = *pudp;
1507 if (!pud_present(pud) || pud_large(pud))
1508 return 0;
1509 pmdp = pmd_offset(pudp, addr);
1510 pmd = *pmdp;
1511 if (!pmd_present(pmd) || pmd_large(pmd))
1512 return 0;
1513 ptep = pte_offset_map(pmdp, addr);
1514 pte = *ptep;
1515 pte_unmap(ptep);
1516 if (!is_swap_pte(pte))
1517 return 0;
1518 entry = pte_to_swp_entry(pte);
1519 return is_hwpoison_entry(entry);
1520}
1521EXPORT_SYMBOL_GPL(is_hwpoison_address);
diff --git a/mm/memory.c b/mm/memory.c
index 5823698c2b71..346ee7e041fd 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1410,6 +1410,55 @@ no_page_table:
1410 return page; 1410 return page;
1411} 1411}
1412 1412
1413/**
1414 * __get_user_pages() - pin user pages in memory
1415 * @tsk: task_struct of target task
1416 * @mm: mm_struct of target mm
1417 * @start: starting user address
1418 * @nr_pages: number of pages from start to pin
1419 * @gup_flags: flags modifying pin behaviour
1420 * @pages: array that receives pointers to the pages pinned.
1421 * Should be at least nr_pages long. Or NULL, if caller
1422 * only intends to ensure the pages are faulted in.
1423 * @vmas: array of pointers to vmas corresponding to each page.
1424 * Or NULL if the caller does not require them.
1425 * @nonblocking: whether waiting for disk IO or mmap_sem contention
1426 *
1427 * Returns number of pages pinned. This may be fewer than the number
1428 * requested. If nr_pages is 0 or negative, returns 0. If no pages
1429 * were pinned, returns -errno. Each page returned must be released
1430 * with a put_page() call when it is finished with. vmas will only
1431 * remain valid while mmap_sem is held.
1432 *
1433 * Must be called with mmap_sem held for read or write.
1434 *
1435 * __get_user_pages walks a process's page tables and takes a reference to
1436 * each struct page that each user address corresponds to at a given
1437 * instant. That is, it takes the page that would be accessed if a user
1438 * thread accesses the given user virtual address at that instant.
1439 *
1440 * This does not guarantee that the page exists in the user mappings when
1441 * __get_user_pages returns, and there may even be a completely different
1442 * page there in some cases (eg. if mmapped pagecache has been invalidated
1443 * and subsequently re faulted). However it does guarantee that the page
1444 * won't be freed completely. And mostly callers simply care that the page
1445 * contains data that was valid *at some point in time*. Typically, an IO
1446 * or similar operation cannot guarantee anything stronger anyway because
1447 * locks can't be held over the syscall boundary.
1448 *
1449 * If @gup_flags & FOLL_WRITE == 0, the page must not be written to. If
1450 * the page is written to, set_page_dirty (or set_page_dirty_lock, as
1451 * appropriate) must be called after the page is finished with, and
1452 * before put_page is called.
1453 *
1454 * If @nonblocking != NULL, __get_user_pages will not wait for disk IO
1455 * or mmap_sem contention, and if waiting is needed to pin all pages,
1456 * *@nonblocking will be set to 0.
1457 *
1458 * In most cases, get_user_pages or get_user_pages_fast should be used
1459 * instead of __get_user_pages. __get_user_pages should be used only if
1460 * you need some special @gup_flags.
1461 */
1413int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, 1462int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
1414 unsigned long start, int nr_pages, unsigned int gup_flags, 1463 unsigned long start, int nr_pages, unsigned int gup_flags,
1415 struct page **pages, struct vm_area_struct **vmas, 1464 struct page **pages, struct vm_area_struct **vmas,
@@ -1527,9 +1576,16 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
1527 if (ret & VM_FAULT_ERROR) { 1576 if (ret & VM_FAULT_ERROR) {
1528 if (ret & VM_FAULT_OOM) 1577 if (ret & VM_FAULT_OOM)
1529 return i ? i : -ENOMEM; 1578 return i ? i : -ENOMEM;
1530 if (ret & 1579 if (ret & (VM_FAULT_HWPOISON |
1531 (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE| 1580 VM_FAULT_HWPOISON_LARGE)) {
1532 VM_FAULT_SIGBUS)) 1581 if (i)
1582 return i;
1583 else if (gup_flags & FOLL_HWPOISON)
1584 return -EHWPOISON;
1585 else
1586 return -EFAULT;
1587 }
1588 if (ret & VM_FAULT_SIGBUS)
1533 return i ? i : -EFAULT; 1589 return i ? i : -EFAULT;
1534 BUG(); 1590 BUG();
1535 } 1591 }
@@ -1578,6 +1634,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
1578 } while (nr_pages); 1634 } while (nr_pages);
1579 return i; 1635 return i;
1580} 1636}
1637EXPORT_SYMBOL(__get_user_pages);
1581 1638
1582/** 1639/**
1583 * get_user_pages() - pin user pages in memory 1640 * get_user_pages() - pin user pages in memory