Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751390AbcCHWc7 (ORCPT ); Tue, 8 Mar 2016 17:32:59 -0500 Received: from mga11.intel.com ([192.55.52.93]:54493 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751107AbcCHWcw (ORCPT ); Tue, 8 Mar 2016 17:32:52 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,558,1449561600"; d="scan'208";a="919711822" Subject: [PATCH] mm: fix 'size' alignment in devm_memremap_pages() From: Dan Williams To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Toshi Kani Date: Tue, 08 Mar 2016 14:32:25 -0800 Message-ID: <20160308222516.16008.22439.stgit@dwillia2-desk3.jf.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1565 Lines: 39 We need to align the end address, not just the size. Cc: Toshi Kani Signed-off-by: Dan Williams --- Hi Andrew, one more fixup to devm_memremap_pages(). I was discussing patch "mm: fix mixed zone detection in devm_memremap_pages" with Toshi and noticed that it was mishandling the end-of-range alignment. Please apply or fold this into the existing patch. kernel/memremap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/kernel/memremap.c b/kernel/memremap.c index c0f11a498a5a..60baf4d3401e 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -270,14 +270,16 @@ struct dev_pagemap *find_dev_pagemap(resource_size_t phys) void *devm_memremap_pages(struct device *dev, struct resource *res, struct percpu_ref *ref, struct vmem_altmap *altmap) { - resource_size_t align_start = res->start & ~(SECTION_SIZE - 1); - resource_size_t align_size = ALIGN(resource_size(res), SECTION_SIZE); - int is_ram = region_intersects(align_start, align_size, "System RAM"); - resource_size_t key, align_end; + resource_size_t key, align_start, align_size, align_end; struct dev_pagemap *pgmap; struct page_map *page_map; + int error, nid, is_ram; unsigned long pfn; - int error, nid; + + align_start = res->start & ~(SECTION_SIZE - 1); + align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE) + - align_start; + is_ram = region_intersects(align_start, align_size, "System RAM"); if (is_ram == REGION_MIXED) { WARN_ONCE(1, "%s attempted on mixed region %pr\n",