Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp635310img; Fri, 22 Mar 2019 05:36:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3DXSsKHE+zDK6q33fduwrDBk9YaXJIr7ZnYT0qH3P51AO5xtpz1MuBM04p0sd85mJJXZA X-Received: by 2002:a63:2c4c:: with SMTP id s73mr8850261pgs.113.1553258212492; Fri, 22 Mar 2019 05:36:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553258212; cv=none; d=google.com; s=arc-20160816; b=eJRzv/ZxdnleLvUR+AeaY+X8EvCKk/RuizqHIZu1rRnXJVxdwcX1/0Qn32oxaIUB6I gLtNY1M5ZLs81GB/r4Cu9M/tRtNED74tZK6t/YzQkGKCqGA4Vo+OVv4hMR/QaIE93NbA YhMlkQVZf3n6WdNcY6UqbctiLQrgwItAk71bOuMd9iFx4UGa0e0qUJpzK1ne2N0QkK7Y gUTN4WWxetk+HtQsw5fP7ijA4ItPMGGF8oHAYFiaASbttgx8wpK4cW6SmujQEiIRDSwJ vhez8B0418r5CZInG99XwDsqXiL7dQ8E7iASyf75Ww45b/AIk6e0xvHYZmZl3lVJh1RJ vP1w== 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=1n6vW6pms+nLSP+/CjrpuZlXttsfhATv1tC2vcvG9ww=; b=Ta4lXzkuVMhhMcy0qLuQ3tqbrB9TRDQt/+FqYO/1G3PZuU1FYFB1AuxSYllD8Q/XD0 MPnh5oSFgAUAAiXFSCIpWzYjTEUYDH38M0t5PaWMTom3ySXXKiLoH5i4zoEAeVisYMXX 9SaS04QjZugB0j+HSVZmqYehtgDqmSvh1RAlSGMYYj6j7JWeEL+gbT85AU4DrlnXongM Hwwh4afBHrc4TDpsyLDZdkZiu4WBaQHp+t8J0UgKeTKe+VLyagQG6z+/xHtq2kfs2O7I KaKTQj3fs4K/n+ALctCN6nGgTUNlORls85R5zmnKYgexwn+T6EuG2GVRqWv76oaF+7Et 1OvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P11E1T5z; 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 59si7222666plb.405.2019.03.22.05.36.37; Fri, 22 Mar 2019 05:36:52 -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=P11E1T5z; 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 S2389353AbfCVMM7 (ORCPT + 99 others); Fri, 22 Mar 2019 08:12:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:51136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389699AbfCVMM5 (ORCPT ); Fri, 22 Mar 2019 08:12:57 -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 D265D2082C; Fri, 22 Mar 2019 12:12:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553256776; bh=WSVnmX+Jf945h4ecCPz5Kivr/SUdz3JbZGyKB8tydq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P11E1T5zzxKXzKuEPUcCxQYw9xtR7SWOa7NmM6mDJOdlRx1LFsMYsJiAsMISbpAcO x6M9n5bZl5XkmE7jMVT5EYHlqTh1ITRfCUhoueM5mqdvvWnyoeg5cxqib3kcZjOkXA rvLninhb8XdLCDxLGa93Hs8qQJ4ZEDF3cpt6e4m8= 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 5.0 034/238] libnvdimm: Fix altmap reservation size calculation Date: Fri, 22 Mar 2019 12:14:13 +0100 Message-Id: <20190322111300.336238268@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111258.383569278@linuxfoundation.org> References: <20190322111258.383569278@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 5.0-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 @@ -593,7 +593,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);