Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>,
	"oohall@gmail.com" <oohall@gmail.com>
Cc: "stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] libnvdimm: Fix altmap reservation size calculation
Date: Wed, 6 Feb 2019 02:15:38 +0000	[thread overview]
Message-ID: <4ccd81b41a48f3226b2fae27e2ef60ecfa4e0e23.camel@intel.com> (raw)
In-Reply-To: <20190206020453.25534-1-oohall@gmail.com>


On Wed, 2019-02-06 at 13:04 +1100, Oliver O'Halloran wrote:
> 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: ac515c084be9 ("libnvdimm, pmem, pfn: move pfn setup to the core")
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
> ---
>  drivers/nvdimm/pfn_devs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Looks good to me,
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>

> 
> diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
> index 6f22272e8d80..9b9be83da0e7 100644
> --- a/drivers/nvdimm/pfn_devs.c
> +++ b/drivers/nvdimm/pfn_devs.c
> @@ -593,7 +593,7 @@ static unsigned long init_altmap_base(resource_size_t base)
>  
>  static unsigned long init_altmap_reserve(resource_size_t base)
>  {
> -	unsigned long reserve = PHYS_PFN(SZ_8K);
> +	unsigned long reserve = PFN_UP(SZ_8K);
>  	unsigned long base_pfn = PHYS_PFN(base);
>  
>  	reserve += base_pfn - PFN_SECTION_ALIGN_DOWN(base_pfn);


  reply	other threads:[~2019-02-06  2:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-06  2:04 [PATCH] libnvdimm: Fix altmap reservation size calculation Oliver O'Halloran
2019-02-06  2:15 ` Verma, Vishal L [this message]
2019-02-06  2:38 ` Dan Williams
2019-02-06  4:06   ` Dan Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ccd81b41a48f3226b2fae27e2ef60ecfa4e0e23.camel@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=oohall@gmail.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox