From patchwork Thu Jan 5 23:01:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 9499751 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 162E460235 for ; Thu, 5 Jan 2017 23:02:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0250428422 for ; Thu, 5 Jan 2017 23:02:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E806228473; Thu, 5 Jan 2017 23:02:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 733D828422 for ; Thu, 5 Jan 2017 23:02:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cPH2s-00087N-IH; Thu, 05 Jan 2017 23:02:06 +0000 Received: from mail-qk0-f170.google.com ([209.85.220.170]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cPH2Y-0007Yx-74 for linux-arm-kernel@lists.infradead.org; Thu, 05 Jan 2017 23:01:47 +0000 Received: by mail-qk0-f170.google.com with SMTP id s140so35811108qke.0 for ; Thu, 05 Jan 2017 15:01:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4wyvPXIB/GW/E8vpSreKo6iJd/OfoFK4fjY4Km9x+EE=; b=S51qOOoDL434RuUK0Czm/yFIv7XplyJgziGBEPKVQAbAZew3+/Wzo4y4HfGmpxGKOU iOhyVGGRtJGA7BKDKrYxSpwWgCearTHixjuC4Hva/b0t0dMiZT1gKHEyV6QEpvHyjcGH DK2L+w++FghJ42vtcVabKY2SyHgUTQitin77wU3f44LhjBYImOXNvdT+xuzoaSUAMI/w D4h68nlJiTbSY3xuAf6eRV1k5AaP8jqaDfshXjumgI+faExqKT5tXb1jqOtV1g2Oh9eO SlZv6+SoGbTVKRgW9CTCahClv3B7i0ShRD9m8OMPKEPJ1heSp/VXLJ23qsJ6ccmbdEsx r17Q== X-Gm-Message-State: AIkVDXLkIW6G+lf9qMfCvFIpkrVlcf4WuTmed6fXv4PpNOGGRF0P6Z42EHHwyoMAZYaqFcK+ X-Received: by 10.55.15.234 with SMTP id 103mr80351739qkp.282.1483657284825; Thu, 05 Jan 2017 15:01:24 -0800 (PST) Received: from labbott-redhat-machine.redhat.com ([2601:602:9802:a8dc::6b06]) by smtp.gmail.com with ESMTPSA id 33sm49223456qtq.1.2017.01.05.15.01.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jan 2017 15:01:23 -0800 (PST) From: Laura Abbott To: Russell King , Nicolas Pitre , Grygorii Strashko Subject: [PATCHv2 2/2] arm: Adjust memory boundaries after reservations Date: Thu, 5 Jan 2017 15:01:14 -0800 Message-Id: <1483657274-11346-3-git-send-email-labbott@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483657274-11346-1-git-send-email-labbott@redhat.com> References: <1483657274-11346-1-git-send-email-labbott@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170105_150146_334620_3225EEB7 X-CRM114-Status: GOOD ( 15.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lilja.magnus@gmail.com, Laura Abbott , festevam@gmail.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP adjust_lowmem_bounds is responsible for setting up the boundary for lowmem/hihgmme. This needs to be setup before memblock reservations can occur. At the time memblock reservations can occur, memory can also be removed from the system. The lowmem/highmem boundary and end of memory may be affected by this but it is currently not recalculated. On some systems this may be harmless, on o thers this may result in incorrect ranges being passed to the main memory allocator. Correct this by recalculating the lowmem/highmem boundary after all reservations have been made. Signed-off-by: Laura Abbott --- v2: Rebased for changes in sanity_check_meminfo cleanup --- arch/arm/kernel/setup.c | 8 ++++++++ arch/arm/mm/mmu.c | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 8a8051c..4625115 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -1093,8 +1093,16 @@ void __init setup_arch(char **cmdline_p) setup_dma_zone(mdesc); xen_early_init(); efi_init(); + /* + * Make sure the calcualtion for lowmem/highmem is set appropriately + * before reserving/allocating any mmeory + */ adjust_lowmem_bounds(); arm_memblock_init(mdesc); + /* + * Memory may have been removed so recalculate the bounds. + */ + adjust_lowmem_bounds(); early_ioremap_reset(); diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index ce5123b..7ca6910 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -1157,6 +1157,7 @@ void __init adjust_lowmem_bounds(void) phys_addr_t memblock_limit = 0; u64 vmalloc_limit; struct memblock_region *reg; + phys_addr_t lowmem_limit = 0; /* * Let's use our own (unoptimized) equivalent of __pa() that is @@ -1173,14 +1174,14 @@ void __init adjust_lowmem_bounds(void) if (reg->base < vmalloc_limit) { - if (block_end > arm_lowmem_limit) + if (block_end > lowmem_limit) /* * Compare as u64 to ensure vmalloc_limit does * not get truncated. block_end should always * fit in phys_addr_t so there should be no * issue with assignment. */ - arm_lowmem_limit = min_t(u64, + lowmem_limit = min_t(u64, vmalloc_limit, block_end); @@ -1201,12 +1202,14 @@ void __init adjust_lowmem_bounds(void) if (!IS_ALIGNED(block_start, PMD_SIZE)) memblock_limit = block_start; else if (!IS_ALIGNED(block_end, PMD_SIZE)) - memblock_limit = arm_lowmem_limit; + memblock_limit = lowmem_limit; } } } + arm_lowmem_limit = lowmem_limit; + high_memory = __va(arm_lowmem_limit - 1) + 1; /*