Commit d5168ce3 authored by Dan Williams's avatar Dan Williams Committed by Greg Kroah-Hartman

vfio: disable filesystem-dax page pinning

commit 94db151d upstream.

Filesystem-DAX is incompatible with 'longterm' page pinning. Without
page cache indirection a DAX mapping maps filesystem blocks directly.
This means that the filesystem must not modify a file's block map while
any page in a mapping is pinned. In order to prevent the situation of
userspace holding of filesystem operations indefinitely, disallow
'longterm' Filesystem-DAX mappings.

RDMA has the same conflict and the plan there is to add a 'with lease'
mechanism to allow the kernel to notify userspace that the mapping is
being torn down for block-map maintenance. Perhaps something similar can
be put in place for vfio.

Note that xfs and ext4 still report:

   "DAX enabled. Warning: EXPERIMENTAL, use at your own risk" mount time, and resolving the dax-dma-vs-truncate problem is one
of the last hurdles to remove that designation.
Acked-by: default avatarAlex Williamson <>
Cc: Michal Hocko <>
Cc: <>
Reported-by: default avatarHaozhong Zhang <>
Tested-by: default avatarHaozhong Zhang <>
Fixes: d475c634 ("dax,ext2: replace XIP read and write with DAX I/O")
Reviewed-by: default avatarChristoph Hellwig <>
Signed-off-by: default avatarDan Williams <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 7f43f610
......@@ -338,11 +338,12 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr,
struct page *page[1];
struct vm_area_struct *vma;
struct vm_area_struct *vmas[1];
int ret;
if (mm == current->mm) {
ret = get_user_pages_fast(vaddr, 1, !!(prot & IOMMU_WRITE),
ret = get_user_pages_longterm(vaddr, 1, !!(prot & IOMMU_WRITE),
page, vmas);
} else {
unsigned int flags = 0;
......@@ -351,7 +352,18 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr,
ret = get_user_pages_remote(NULL, mm, vaddr, 1, flags, page,
vmas, NULL);
* The lifetime of a vaddr_get_pfn() page pin is
* userspace-controlled. In the fs-dax case this could
* lead to indefinite stalls in filesystem operations.
* Disallow attempts to pin fs-dax pages via this
* interface.
if (ret > 0 && vma_is_fsdax(vmas[0])) {
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment