* [PATCH] device-dax: fix pmd/pte fault fallback handling
@ 2017-03-27 17:54 Dave Jiang
2017-03-28 0:55 ` Dan Williams
2017-03-28 11:26 ` Greg KH
0 siblings, 2 replies; 3+ messages in thread
From: Dave Jiang @ 2017-03-27 17:54 UTC (permalink / raw)
To: stable; +Cc: dan.j.williams, jmoyer
commit: 0134ed4fb9e7 upstream.
Backported for 4.9-stable and 4.10-stable.
Jeff Moyer reports:
With a device dax alignment of 4KB or 2MB, I get sigbus when running
the attached fio job file for the current kernel (4.11.0-rc1+). If
I specify an alignment of 1GB, it works.
I turned on debug output, and saw that it was failing in the huge
fault code.
dax dax1.0: dax_open
dax dax1.0: dax_mmap
dax dax1.0: dax_dev_huge_fault: fio: write (0x7f08f0a00000 -
dax dax1.0: __dax_dev_pud_fault: phys_to_pgoff(0xffffffffcf60
dax dax1.0: dax_release
fio config for reproduce:
[global]
ioengine=dev-dax
direct=0
filename=/dev/dax0.0
bs=2m
[write]
rw=write
[read]
stonewall
rw=read
The driver fails to fallback when taking a fault that is larger than
the device alignment, or handling a larger fault when a smaller
mapping is already established. While we could support larger
mappings for a device with a smaller alignment, that change is
too large for the immediate fix. The simplest change is to force
fallback until the fault size matches the alignment.
Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap")
Cc: <stable@vger.kernel.org>
Reported-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
drivers/dax/dax.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c
index ed758b7..20ab6bf 100644
--- a/drivers/dax/dax.c
+++ b/drivers/dax/dax.c
@@ -427,6 +427,7 @@ static int __dax_dev_fault(struct dax_dev *dax_dev, struct vm_area_struct *vma,
int rc = VM_FAULT_SIGBUS;
phys_addr_t phys;
pfn_t pfn;
+ unsigned int fault_size = PAGE_SIZE;
if (check_vma(dax_dev, vma, __func__))
return VM_FAULT_SIGBUS;
@@ -437,6 +438,9 @@ static int __dax_dev_fault(struct dax_dev *dax_dev, struct vm_area_struct *vma,
return VM_FAULT_SIGBUS;
}
+ if (fault_size != dax_region->align)
+ return VM_FAULT_SIGBUS;
+
phys = pgoff_to_phys(dax_dev, vmf->pgoff, PAGE_SIZE);
if (phys == -1) {
dev_dbg(dev, "%s: phys_to_pgoff(%#lx) failed\n", __func__,
@@ -482,6 +486,7 @@ static int __dax_dev_pmd_fault(struct dax_dev *dax_dev,
phys_addr_t phys;
pgoff_t pgoff;
pfn_t pfn;
+ unsigned int fault_size = PMD_SIZE;
if (check_vma(dax_dev, vma, __func__))
return VM_FAULT_SIGBUS;
@@ -498,6 +503,16 @@ static int __dax_dev_pmd_fault(struct dax_dev *dax_dev,
return VM_FAULT_SIGBUS;
}
+ if (fault_size < dax_region->align)
+ return VM_FAULT_SIGBUS;
+ else if (fault_size > dax_region->align)
+ return VM_FAULT_FALLBACK;
+
+ /* if we are outside of the VMA */
+ if (pmd_addr < vma->vm_start ||
+ (pmd_addr + PMD_SIZE) > vma->vm_end)
+ return VM_FAULT_SIGBUS;
+
pgoff = linear_page_index(vma, pmd_addr);
phys = pgoff_to_phys(dax_dev, pgoff, PMD_SIZE);
if (phys == -1) {
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] device-dax: fix pmd/pte fault fallback handling
2017-03-27 17:54 [PATCH] device-dax: fix pmd/pte fault fallback handling Dave Jiang
@ 2017-03-28 0:55 ` Dan Williams
2017-03-28 11:26 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Dan Williams @ 2017-03-28 0:55 UTC (permalink / raw)
To: Dave Jiang; +Cc: stable, jmoyer
On Mon, Mar 27, 2017 at 10:54 AM, Dave Jiang <dave.jiang@intel.com> wrote:
> commit: 0134ed4fb9e7 upstream.
I would include the full sha just like other stable commits.
> Backported for 4.9-stable and 4.10-stable.
Next time I would put this info in the subject, something like:
"[PATCH -stable 4.9, 4.10] device-dax: fix pmd/pte fault fallback handling"
Other than that this looks good and passes my testing, so this backport:
Acked-by: Dan Williams <dan.j.williams@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] device-dax: fix pmd/pte fault fallback handling
2017-03-27 17:54 [PATCH] device-dax: fix pmd/pte fault fallback handling Dave Jiang
2017-03-28 0:55 ` Dan Williams
@ 2017-03-28 11:26 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2017-03-28 11:26 UTC (permalink / raw)
To: Dave Jiang; +Cc: stable, dan.j.williams, jmoyer
On Mon, Mar 27, 2017 at 10:54:01AM -0700, Dave Jiang wrote:
> commit: 0134ed4fb9e7 upstream.
> Backported for 4.9-stable and 4.10-stable.
Thanks for this, now queued up.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-28 11:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-27 17:54 [PATCH] device-dax: fix pmd/pte fault fallback handling Dave Jiang
2017-03-28 0:55 ` Dan Williams
2017-03-28 11:26 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.