linux-brain/drivers/nvdimm
Oliver O'Halloran 6426aaa60c 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 14:35:18 +01:00
..
blk.c libnvdimm, {btt, blk}: do integrity setup before add_disk() 2018-03-28 18:24:41 +02:00
btt_devs.c libnvdimm: rename nd_sector_size_{show,store} to nd_size_select_{show,store} 2017-08-11 17:36:54 -07:00
btt.c libnvdimm, {btt, blk}: do integrity setup before add_disk() 2018-03-28 18:24:41 +02:00
btt.h libnvdimm, btt: Fix an incompatibility in the log layout 2017-12-29 17:53:49 +01:00
bus.c libnvdimm: Hold reference on parent while scheduling async init 2018-11-13 11:15:05 -08:00
claim.c libnvdimm, btt: rework error clearing 2017-08-31 15:05:10 -07:00
core.c libnvdimm: rename nd_sector_size_{show,store} to nd_size_select_{show,store} 2017-08-11 17:36:54 -07:00
dax_devs.c Merge branch 'for-4.13/dax' into libnvdimm-for-next 2017-07-03 16:54:58 -07:00
dimm_devs.c libnvdimm, dimm: clear 'locked' status on successful DIMM enable 2017-11-30 08:40:54 +00:00
dimm.c libnvdimm, dimm: fix dpa reservation vs uninitialized label area 2018-04-24 09:36:32 +02:00
e820.c libnvdimm, e820: use module_platform_driver 2016-12-05 08:52:21 -08:00
Kconfig pmem: add dax_operations support 2017-04-19 15:14:35 -07:00
label.c libnvdimm/label: Clear 'updating' flag after label-set update 2019-03-23 14:35:17 +01:00
label.h libnvdimm, btt: BTT updates for UEFI 2.7 format 2017-06-29 13:50:38 -07:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
namespace_devs.c libnvdimm/pmem: Honor force_raw for legacy pmem regions 2019-03-23 14:35:17 +01:00
nd-core.h libnvdimm, pfn: Pad pfn namespaces relative to other regions 2018-12-13 09:18:54 +01:00
nd.h libnvdimm, dimm: clear 'locked' status on successful DIMM enable 2017-11-30 08:40:54 +00:00
pfn_devs.c libnvdimm: Fix altmap reservation size calculation 2019-03-23 14:35:18 +01:00
pfn.h libnvdimm, dax: autodetect support 2016-05-20 22:02:57 -07:00
pmem.c - Some request-based DM core and DM multipath fixes and cleanups 2017-09-14 13:43:16 -07:00
pmem.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
region_devs.c libnvdimm, pfn: Pad pfn namespaces relative to other regions 2018-12-13 09:18:54 +01:00
region.c libnvdimm, region, pmem: fix 'badblocks' sysfs_get_dirent() reference lifetime 2017-06-30 18:56:03 -07:00