linux-brain/drivers/nvdimm
Oliver O'Halloran f45c6c3aff libnvdimm: Fix altmap reservation size calculation
commit 07464e8836 upstream.

Libnvdimm reserves the first 8K of pfn and devicedax namespaces to
store a superblock describing the namespace. This 8K reservation
is contained within the altmap area which the kernel uses for the
vmemmap backing for the pages within the namespace. The altmap
allows for some pages at the start of the altmap area to be reserved
and that mechanism is used to protect the superblock from being
re-used as vmemmap backing.

The number of PFNs to reserve is calculated using:

	PHYS_PFN(SZ_8K)

Which is implemented as:

 #define PHYS_PFN(x) ((unsigned long)((x) >> PAGE_SHIFT))

So on systems where PAGE_SIZE is greater than 8K the reservation
size is truncated to zero and the superblock area is re-used as
vmemmap backing. As a result all the namespace information stored
in the superblock (i.e. if it's a PFN or DAX namespace) is lost
and the namespace needs to be re-created to get access to the
contents.

This patch fixes this by using PFN_UP() rather than PHYS_PFN() to ensure
that at least one page is reserved. On systems with a 4K pages size this
patch should have no effect.

Cc: stable@vger.kernel.org
Cc: Dan Williams <dan.j.williams@intel.com>
Fixes: ac515c084b ("libnvdimm, pmem, pfn: move pfn setup to the core")
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-03-23 13:19:45 +01:00
..
blk.c libnvdimm, {btt, blk}: do integrity setup before add_disk() 2018-03-28 18:39:22 +02:00
btt_devs.c nvdimm, btt: add a size attribute for BTTs 2016-08-08 09:26:14 -07:00
btt.c libnvdimm, {btt, blk}: do integrity setup before add_disk() 2018-03-28 18:39:22 +02:00
btt.h libnvdimm, btt: Fix an incompatibility in the log layout 2018-01-23 19:57:03 +01:00
bus.c libnvdimm: Hold reference on parent while scheduling async init 2018-11-13 11:16:55 -08:00
claim.c libnvdimm, pmem: use nvdimm_flush() for namespace I/O writes 2016-07-12 15:13:48 -07:00
core.c libnvdimm: fix badblock range handling of ARS range 2017-07-27 15:08:02 -07:00
dax_devs.c libnvdimm, dax: autodetect support 2016-05-20 22:02:57 -07:00
dimm_devs.c libnvdimm: fix blk free space accounting 2017-04-21 09:31:21 +02:00
dimm.c libnvdimm: Fix nvdimm_probe error on NVDIMM-N 2016-09-01 18:20:39 -07:00
e820.c libnvdimm: move ->module to struct nvdimm_bus_descriptor 2016-07-21 20:03:19 -07:00
Kconfig nvdimm: make CONFIG_NVDIMM_DAX 'bool' 2016-10-27 16:16:21 -07:00
label.c libnvdimm/label: Clear 'updating' flag after label-set update 2019-03-23 13:19:45 +01:00
label.h libnvdimm: write blk label set 2015-06-24 21:24:10 -04:00
Makefile libnvdimm, dax: introduce device-dax infrastructure 2016-05-09 15:35:42 -07:00
namespace_devs.c libnvdimm/pmem: Honor force_raw for legacy pmem regions 2019-03-23 13:19:45 +01:00
nd-core.h libnvdimm, namespace: allow creation of multiple pmem-namespaces per region 2016-10-07 09:22:53 -07:00
nd.h nfit, libnvdimm: fix interleave set cookie calculation 2017-03-15 10:02:47 +08:00
pfn_devs.c libnvdimm: Fix altmap reservation size calculation 2019-03-23 13:19:45 +01:00
pfn.h libnvdimm, dax: autodetect support 2016-05-20 22:02:57 -07:00
pmem.c pmem: return EIO on read_pmem() failure 2017-07-05 14:40:25 +02:00
pmem.h pmem: kill __pmem address space 2016-07-12 19:25:38 -07:00
region_devs.c libnvdimm, region: fix flush hint detection crash 2017-05-20 14:28:42 +02:00
region.c libnvdimm: keep region data alive over namespace removal 2016-07-11 16:13:41 -07:00