Skip to content

Commit

Permalink
mm: fix pfn_t to page conversion in vm_insert_mixed
Browse files Browse the repository at this point in the history
pfn_t_to_page() honors the flags in the pfn_t value to determine if a
pfn is backed by a page.  However, vm_insert_mixed() was originally
written to use pfn_valid() to make this determination.  To restore the
old/correct behavior, ignore the pfn_t flags in the !pfn_t_devmap() case
and fallback to trusting pfn_valid().

Fixes: 01c8f1c ("mm, dax, gpu: convert vm_insert_mixed to pfn_t")
Cc: Dave Hansen <[email protected]>
Cc: David Airlie <[email protected]>
Reported-by: Tomi Valkeinen <[email protected]>
Tested-by: Tomi Valkeinen <[email protected]>
Signed-off-by: Dan Williams <[email protected]>
  • Loading branch information
djbw committed Jan 31, 2016
1 parent d1a5f2b commit 03fc2da
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1591,10 +1591,15 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
* than insert_pfn). If a zero_pfn were inserted into a VM_MIXEDMAP
* without pte special, it would there be refcounted as a normal page.
*/
if (!HAVE_PTE_SPECIAL && pfn_t_valid(pfn)) {
if (!HAVE_PTE_SPECIAL && !pfn_t_devmap(pfn) && pfn_t_valid(pfn)) {
struct page *page;

page = pfn_t_to_page(pfn);
/*
* At this point we are committed to insert_page()
* regardless of whether the caller specified flags that
* result in pfn_t_has_page() == false.
*/
page = pfn_to_page(pfn_t_to_pfn(pfn));
return insert_page(vma, addr, page, vma->vm_page_prot);
}
return insert_pfn(vma, addr, pfn, vma->vm_page_prot);
Expand Down

0 comments on commit 03fc2da

Please sign in to comment.