Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp608088img; Fri, 22 Mar 2019 05:05:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqz36kpN5WNDu98nGUJp7SnpDWwLV2WiWrviJ5Z7n+hJp89hUg3Q2wWkxDioa/Vyq5PULkRB X-Received: by 2002:a62:54c5:: with SMTP id i188mr8648315pfb.188.1553256303623; Fri, 22 Mar 2019 05:05:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553256303; cv=none; d=google.com; s=arc-20160816; b=gA1Dh3p/wtw6kh4tKKqjmxjEML/ovn4MWWP8vdbvZnYuAdhv8S1ztaAxGAsJyL8Cx6 KTHC0rZzmJZrHVSEQJyNAoJdxRLBuQKKVM2Kf+fZMnCMJ5V62umJAjvNkia4vWbhQUZR 3GCqE/srNE8aPpLxXmcZ3fwI9192mvDm0anDMZD2fKjZ54d8QWX1AtCwriE1doTBfHDP VqXAwjPwWP4TFdu0ZmX3ZBY1NoDx0Zs4ZIwCBg69M45hcPU9yDY7YbTimqcILQ1Lxcdv +n7h8nS8MAjVP68AP4E4iAEgNPGMElBfxsAcLT8oAMgIQfJy0/o5uNiWrc9SyxglUXa1 bioA== 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=2V3bPQE82vVVC744xmemvbp7u07hN/Ffzzr/Dwl1j88=; b=ZOnxwnQWq5d2TfnR6EOyibhQ0lz3vlTFLK8eXWr6Y9DKTaX/a/U++Xrjr78tleJ2mc gp+3r/C6Kvgmkqa3iseG1k5wStKNI7b5dLt5MWGooiOabvAG86sfiTPEIXSD9v3Ldcqm SGuIEotcr4WW4Shn4s0UjN7pjRwzhMxjJ5ucnkTWoDC7pyUnulBbytaAa5ld6rxIDiRg mTDs/fyZYHZ3CwTN04Ez6CvbZ8d4ORQXRweXAuXQpZE3LDxZPBdtTtaZD/Ppl2qMKBPz hxmGC8+Wo8o7vPIV1OA/zyzvoezslJYebX98OlPRecgJ41ls3CL3nkpT/kXlC8mOev4s fabA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RexdsGcZ; 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 bg1si6758381plb.118.2019.03.22.05.04.47; Fri, 22 Mar 2019 05:05:03 -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=RexdsGcZ; 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 S2388508AbfCVMDV (ORCPT + 99 others); Fri, 22 Mar 2019 08:03:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:41672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388496AbfCVMDT (ORCPT ); Fri, 22 Mar 2019 08:03:19 -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 D1DA42192D; Fri, 22 Mar 2019 12:03:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553256198; bh=QR4vR7aI4ZGfWW8RXhJDeyP8hAU5PLKYLbZmEUeYZ00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RexdsGcZ0gm19VPjmXSqycN9MKeHKz6ffMUAl01TKgUl+FEN6Uxz4moTrUMAbyK5D 7jcpYaY5swRzm3KPIfB3op8gv0a+SGuQI38C8+zD8+c+4TDm+Y4rlqh7w5aVWD2s8R lei0Nk3sZFVu4laksJb/FJwU+EsczUU2VF0xkMMA= 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.19 120/280] libnvdimm: Fix altmap reservation size calculation Date: Fri, 22 Mar 2019 12:14:33 +0100 Message-Id: <20190322111314.936628203@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111306.356185024@linuxfoundation.org> References: <20190322111306.356185024@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.19-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 @@ -534,7 +534,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);