Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp596401img; Fri, 22 Mar 2019 04:50:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0/Qgrr9y3ag2ypqdmdOwL5+4aoGDUJPU10Mu2kFHU+BVzO7Jza4Cpi6Wk91D50hWD5PZG X-Received: by 2002:a17:902:8644:: with SMTP id y4mr8782071plt.99.1553255429987; Fri, 22 Mar 2019 04:50:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553255429; cv=none; d=google.com; s=arc-20160816; b=E7zhemy2Z66W85AbG6IlxgmBT1wsidPwZwg+po1/4dNk31RVe/io6tE7HCP60GFxy9 43VS69tH1NUPnsDrOJsZ6vv49mNn7/iTberu2+j1pLoF6hl3ht2urAGhnG2oQLklKS4Y vPURcLDepURycz9+agoJvtgjssSvsQsm5fndtQhaEvgtJp99WKiofGUsC/7U4WVSnLQB EEzjLIY7zb8itCDQgBUCZfg+Q2rWViboRPjfXdpf0kjErglQ5tA3oyATJi2svj15VPh9 UkfSbnrCjbzNvZAStfaSmKzyqhm0nMuQTfUvDtq0fiQdZ8XiLNarZMAVECwDjjykEH// hIUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IO4mPBnJGxWprLFB6j7ThTEQXhXU3b9H8nUQlFrkHu0=; b=jabjTYAYj2W6Rxlt68Ty1QRRxOGKEyWko+3XUtjKNLvskKf2KHh4Lt6x2YqNDXIycj cBEFVOQGltprDEuyJNds2hOmBHUgMuxkLlpVkibUpdbOnDWJtJ2cmjyIIYMCToSMngIz pNVDvPZzOf3qNw6EVth25h3aQmrpzw8GYaqLEmbiOIW8ChZBw1gwLDh/v4DNwY5sTG3x jbR7wJMpJltQeBbpjnY09X0qJzvtuQiJalh4lBQods10iIxQDJNa8zmKm5RMGKs86G5l hbVuV+yMbysbGgMDVx3kfzfP6KIr2fIzxYrHsbxzl2duVkeEQirDoMN5P/kkB2eeyYLg +7hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ftzKmzjg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64si7059181plk.279.2019.03.22.04.50.15; Fri, 22 Mar 2019 04:50:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ftzKmzjg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732492AbfCVLth (ORCPT + 99 others); Fri, 22 Mar 2019 07:49:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:53284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732474AbfCVLtf (ORCPT ); Fri, 22 Mar 2019 07:49:35 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5AACF20693; Fri, 22 Mar 2019 11:49:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553255374; bh=/1Kj00ctmVgmDJN+LOY+AHI0pn8x/tiuf2xRVHMF9do=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ftzKmzjg2bDxo/iSBAoolSN4OVDb9+4CMgyPOHw0rwPQLy6I1sIzdFscda5sPnZ2a XW3ILseRVS/hWqbxF5uUY7PcSsEYJEPB3j3TtKGMRvVgtuBuIe+l2rNzmGod4ttPYQ 0BRlYvpZRGjie49hHZ7+Edhgg45InQIeRgBSNlKM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Williams , Oliver OHalloran , Vishal Verma Subject: [PATCH 4.14 071/183] libnvdimm: Fix altmap reservation size calculation Date: Fri, 22 Mar 2019 12:14:59 +0100 Message-Id: <20190322111246.850417771@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111241.819468003@linuxfoundation.org> References: <20190322111241.819468003@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Oliver O'Halloran commit 07464e88365e9236febaca9ed1a2e2006d8bc952 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 Fixes: ac515c084be9 ("libnvdimm, pmem, pfn: move pfn setup to the core") Signed-off-by: Oliver O'Halloran Reviewed-by: Vishal Verma Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- drivers/nvdimm/pfn_devs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -535,7 +535,7 @@ static unsigned long init_altmap_base(re 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);