Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp803381ybg; Tue, 28 Jul 2020 20:39:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi6ZfC7Q8hI7GHyjutfoQ8gcY/vMsxeUKqTB2aJCz40vA5uS42OOLFrKEROV14fSiSxTH0 X-Received: by 2002:a17:906:c34e:: with SMTP id ci14mr15629423ejb.335.1595993988511; Tue, 28 Jul 2020 20:39:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595993988; cv=none; d=google.com; s=arc-20160816; b=x4aOXS00BCN54uG2duyF1YaxsIJprMKSryFFjxUDLtomP50P+CBm2XvuZs8ufwhU6V gxIeoRqlafK4veVWHmXq7ZeLv50KW/FAji+vlLjNNqd2doIKk2IDe7G+Ltoa/ymCj+Of Pz81e8JC7dTaCO9Ck/Cs6HTjCMnEZZayq3iv2BgHZ21uZ9kCFVrUKNnhny9D7fW0rdnm q/IfZWrkSMdIx/WaWX1VrQkFdOrSgHX1J9ApbiTwQswK2r8cOAe9pMHmKx/tj8lGkv3X fGckMVj+XcnJ1m0ZWQdTDfOKFNWywP1QUDUMhYqNF7cuGqPrKT+OEZjmzSK6Qt6iiTph ZFDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=FsmIWqOGU8/36YSK0oAlzhkIE4DIRQipSB+3zp/r7kM=; b=hHmpyH+dZZHJGdnc+LfLKguH+u6gi6rH7KIQxSWORNNqliGHyiMje5v4vFtZdjix2w 0KvH/dJf1DqkSc5xv4fogny4gioUfoWbQxvs3verAp32m9VN98t8LTozRcKiToCopIz8 6fOjtKO9QyyFWOq/79o+ABOJ0K/YnJDKAyJ+j3JHLpPb8HjcBz95TzX9FIg7bCWmDo/r GfZQ1F8tgwS4/vX6LQ8Ca8nMvAnF6ixgIEsTwo1QNEBs/PpFpYkBAbF6q9YRk793xX9U AldgYVsqhaQWcZq6mJvhGeZckOisrUsIXfnDMP5n+uYFT2c8m1y0nAPfmoUeF/yUoSb7 1XNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si291880eji.301.2020.07.28.20.39.26; Tue, 28 Jul 2020 20:39:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726957AbgG2DgB (ORCPT + 99 others); Tue, 28 Jul 2020 23:36:01 -0400 Received: from foss.arm.com ([217.140.110.172]:44702 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbgG2DgA (ORCPT ); Tue, 28 Jul 2020 23:36:00 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 14AB831B; Tue, 28 Jul 2020 20:36:00 -0700 (PDT) Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com [10.169.212.213]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8D9883F66E; Tue, 28 Jul 2020 20:35:52 -0700 (PDT) From: Jia He To: Dan Williams , Vishal Verma , Mike Rapoport , David Hildenbrand Cc: Catalin Marinas , Will Deacon , Greg Kroah-Hartman , "Rafael J. Wysocki" , Dave Jiang , Andrew Morton , Steve Capper , Mark Rutland , Logan Gunthorpe , Anshuman Khandual , Hsin-Yi Wang , Jason Gunthorpe , Dave Hansen , Kees Cook , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-mm@kvack.org, Wei Yang , Pankaj Gupta , Ira Weiny , Kaly Xin , Jia He Subject: [RFC PATCH 6/6] arm64: fall back to vmemmap_populate_basepages if not aligned with PMD_SIZE Date: Wed, 29 Jul 2020 11:34:24 +0800 Message-Id: <20200729033424.2629-7-justin.he@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200729033424.2629-1-justin.he@arm.com> References: <20200729033424.2629-1-justin.he@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In dax pmem kmem (dax pmem used as RAM device) case, the start address might not be aligned with PMD_SIZE e.g. 240000000-33fdfffff : Persistent Memory 240000000-2421fffff : namespace0.0 242400000-2bfffffff : dax0.0 242400000-2bfffffff : System RAM (kmem) pfn_to_page(0x242400000) is fffffe0007e90000. Without this patch, vmemmap_populate(fffffe0007e90000, ...) will incorrectly create a pmd mapping [fffffe0007e00000, fffffe0008000000] which contains fffffe0007e90000. This adds the check and then falls back to vmemmap_populate_basepages() Signed-off-by: Jia He --- arch/arm64/mm/mmu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index d69feb2cfb84..3b21bd47e801 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1102,6 +1102,10 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, do { next = pmd_addr_end(addr, end); + if (next - addr < PMD_SIZE) { + vmemmap_populate_basepages(start, next, node, altmap); + continue; + } pgdp = vmemmap_pgd_populate(addr, node); if (!pgdp) -- 2.17.1