[GIT PULL] libnvdimm fixes for 4.8-rc6

Williams, Dan J
2016-09-10T15:45:00Z

Hi Linus, please pull from:

git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

...to receive nvdimm fixes for v4.8, two of them are tagged for
-stable:

- Fix devm_memremap_pages() to use track_pfn_insert(). Otherwise, DAX
pmd mappings end up with an uncached pgprot, and unusable performance
for the device-dax interface.  The device-dax interface appeared in 4.7
so this is tagged for -stable.

- Fix a couple VM_BUG_ON() checks in the show_smaps() path to
understand DAX pmd entries.  This fix is tagged for -stable.

- Fix a mis-merge of the nfit machine-check handler to flip the
polarity of an if() to match the final version of the patch that Vishal
sent for 4.8-rc1.  Without this the nfit machine check handler never
detects / inserts new 'badblocks' entries which applications use to
identify lost portions of files.

- For test purposes, fix the nvdimm_clear_poison() path to operate on
legacy / simulated nvdimm memory ranges.  Without this fix a test can
set badblocks, but never clear them on these ranges.

- Fix the range checking done by dax_dev_pmd_fault().  This is not
tagged for -stable since this problem is mitigated by specifying
aligned resources at device-dax setup time.

These patches have appeared in a next release over the past week.  The
recent rebase you can see in the timestamps was to drop an invalid fix
as identified by the updated device-dax unit tests [1].  The -mm
touches have an ack from Andrew.

[1]: "[ndctl PATCH 0/3] device-dax test for recent kernel bugs"
https://lists.01.org/pipermail/linux-nvdimm/2016-September/006855.html

The following changes since commit 3eab887a55424fc2c27553b7bfe32330df83f7b8:

Linux 4.8-rc4 (2016-08-28 15:04:33 -0700)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

for you to fetch changes up to 1e8b8d9619f9476e94f32eb20cab000d50d236aa:

libnvdimm: allow legacy (e820) pmem region to clear bad blocks (2016-09-09 17:34:46 -0700)

----------------------------------------------------------------
Dan Williams (3):
dax: fix mapping size check
mm: fix show_smap() for zone_device-pmd ranges
mm: fix cache mode of dax pmd mappings

Dave Jiang (1):
libnvdimm: allow legacy (e820) pmem region to clear bad blocks

Vishal Verma (1):
nfit, mce: Fix SPA matching logic in MCE handler

arch/x86/mm/pat.c | 17 ++++++++++-------
drivers/acpi/nfit/mce.c | 2 +-
drivers/dax/dax.c | 2 +-
drivers/nvdimm/bus.c | 6 +++++-
fs/proc/task_mmu.c | 2 ++
kernel/memremap.c | 9 +++++++++
mm/huge_memory.c | 4 ++--
7 files changed, 30 insertions(+), 12 deletions(-)

commit 4c3cb6e9a9d94d1553807854a565cd27ff4c22aa
Author: Dan Williams <dan.j.williams@intel.com>
Date: Sat Sep 3 10:36:00 2016 -0700

dax: fix mapping size check

pgoff_to_phys() validates that both the starting address and the length
of the mapping against the resource list. We need to check for a
mapping size of PMD_SIZE not PAGE_SIZE in the pmd fault path.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>

commit ca120cf688874f4423e579e7cc5ddf7244aeca45
Author: Dan Williams <dan.j.williams@intel.com>
Date: Sat Sep 3 10:38:03 2016 -0700

mm: fix show_smap() for zone_device-pmd ranges

Attempting to dump /proc/<pid>/smaps for a process with pmd dax mappings
currently results in the following VM_BUG_ONs:

kernel BUG at mm/huge_memory.c:1105!
task: ffff88045f16b140 task.stack: ffff88045be14000
RIP: 0010:[<ffffffff81268f9b>] [<ffffffff81268f9b>] follow_trans_huge_pmd+0x2cb/0x340
[..]
Call Trace:
[<ffffffff81306030>] smaps_pte_range+0xa0/0x4b0
[<ffffffff814c2755>] ? vsnprintf+0x255/0x4c0
[<ffffffff8123c46e>] __walk_page_range+0x1fe/0x4d0
[<ffffffff8123c8a2>] walk_page_vma+0x62/0x80
[<ffffffff81307656>] show_smap+0xa6/0x2b0

kernel BUG at fs/proc/task_mmu.c:585!
RIP: 0010:[<ffffffff81306469>] [<ffffffff81306469>] smaps_pte_range+0x499/0x4b0
Call Trace:
[<ffffffff814c2795>] ? vsnprintf+0x255/0x4c0
[<ffffffff8123c46e>] __walk_page_range+0x1fe/0x4d0
[<ffffffff8123c8a2>] walk_page_vma+0x62/0x80
[<ffffffff81307696>] show_smap+0xa6/0x2b0

These locations are sanity checking page flags that must be set for an
anonymous transparent huge page, but are not set for the zone_device
pages associated with dax mappings.

Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

commit 9049771f7d5490a302589976984810064c83ab40
Author: Dan Williams <dan.j.williams@intel.com>
Date: Wed Sep 7 08:51:21 2016 -0700

mm: fix cache mode of dax pmd mappings

track_pfn_insert() in vmf_insert_pfn_pmd() is marking dax mappings as
uncacheable rendering them impractical for application usage. DAX-pte
mappings are cached and the goal of establishing DAX-pmd mappings is to
attain more performance, not dramatically less (3 orders of magnitude).

track_pfn_insert() relies on a previous call to reserve_memtype() to
establish the expected page_cache_mode for the range. While memremap()
arranges for reserve_memtype() to be called, devm_memremap_pages() does
not. So, teach track_pfn_insert() and untrack_pfn() how to handle
tracking without a vma, and arrange for devm_memremap_pages() to
establish the write-back-cache reservation in the memtype tree.

Cc: <stable@vger.kernel.org>
Cc: Matthew Wilcox <mawilcox@microsoft.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Nilesh Choudhury <nilesh.choudhury@oracle.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-by: Toshi Kani <toshi.kani@hpe.com>
Reported-by: Kai Zhang <kai.ka.zhang@oracle.com>
Acked-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

commit 2e21807d4b131dfd4a8e5c82116a85b62f28aeec
Author: Vishal Verma <vishal.l.verma@intel.com>
Date: Fri Sep 2 17:27:30 2016 -0600

nfit, mce: Fix SPA matching logic in MCE handler

The check for a 'pmem' type SPA in the MCE handler was inverted due to a
merge/rebase error.

Fixes: 6839a6d nfit: do an ARS scrub on hitting a latent media error
Cc: linux-acpi@vger.kernel.org
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

commit 1e8b8d9619f9476e94f32eb20cab000d50d236aa
Author: Dave Jiang <dave.jiang@intel.com>
Date: Fri Sep 9 09:10:08 2016 -0700

libnvdimm: allow legacy (e820) pmem region to clear bad blocks

Bad blocks can be injected via /sys/block/pmemN/badblocks. In a situation
where legacy pmem is being used or a pmem region created by using memmap
kernel parameter, the injected bad blocks are not cleared due to
nvdimm_clear_poison() failing from lack of ndctl function pointer. In
this case we need to just return as handled and allow the bad blocks to
be cleared rather than fail.

Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>