Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6020732ybn; Sun, 29 Sep 2019 10:35:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOT4RSuwLUvnptS+eNq+seu47ZNzh6PVvCBHL+IFal5EX/9emzB6CLa9W/Pi+SeSiUvnm1 X-Received: by 2002:a17:906:6c8:: with SMTP id v8mr10925336ejb.40.1569778559337; Sun, 29 Sep 2019 10:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569778559; cv=none; d=google.com; s=arc-20160816; b=mtMiIZYG9C9fcaR/fC/edtgy7qez9aTEMvdYXfPGby2YCSyXVukH4B9JDDa6ivnus8 9dEDgj4bMW+pT7LoXMq55tcL7P9GVFqIrOWBXfIaEeA72FZbQBggg4f2QIBp3v8DBK3v sIkKJQufH6IwaJdKkbOwGBs5kTFmk0UPtvxUGe74vlgIwoPiYOhUugn0M5ncxeSCB6gQ 05Vlh5h4kYc3kjI0pR9a9d62shygdwWk1KFjmDZj2gQjPpWFQu6NZF2nXjr1s5/HG/z1 5QKLtvg9Lenr84ehoiMyxnjXrqrxYyNzTYQhXP0X3c0zxsaprAkkVcwDH8f/hx69d2TV n9mw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ub5Qrss1f36x5FEE5M9icwjT65JDBNgFAAUuCjxLxfc=; b=w3CsJcZsk6M215w37cwW5gCiBYEt4fqxEkWDFFhudRUVmCvSA11rwEJu4crRnSVu2W o6B5CQGv5/OGAzn5z4d6NLFO+w4dfrJs84Z762cR1llISCTEhcqiuD1+gGf0AM0jCfIQ UrRBqeUcV458cPKwqlWja7gUq3dSdFtjOie4a3GGB1CS6eqSpnTWdPr8G3XHC+btOBIO nFA0vKuyDBbX6NHUeijSEAXL+IzkNCGwkaO+JY8tqgUVOVgYJupT2GUIj36js/qP/HCN Qq2Om8a0/HorpOBcerzchC5ERD/L1Ibu/7no7Z7NU6HlBF77FU/AVBldpYArzq4gyWAq IjSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="U2/h8/9D"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b11si5879848eja.38.2019.09.29.10.35.35; Sun, 29 Sep 2019 10:35:59 -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="U2/h8/9D"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729667AbfI2RfO (ORCPT + 99 others); Sun, 29 Sep 2019 13:35:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:47224 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729279AbfI2RfE (ORCPT ); Sun, 29 Sep 2019 13:35:04 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 49AA421906; Sun, 29 Sep 2019 17:35:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569778504; bh=1gGCjJia8yEAWiHCMurLorhELpMT7PCKhoCa6fsupq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U2/h8/9D2aZJfVXl6sAannU0ORmuFbsgbyRtxBGrxOYUP0TmFsSfXIJupWYSDAo6Q 6mf5IYwEpzAnqOhjzy39HiUs81MzBw6fI7Oy8wx49aNyVFCGqyJvsYbEvjkZ/hFbm5 XAphVJ7pmv8vTCwp8nGejZbQD6M8dCTUbSE7ITdI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mike Rapoport , Mike Rapoport , Russell King , Sasha Levin Subject: [PATCH AUTOSEL 4.19 22/33] ARM: 8903/1: ensure that usable memory in bank 0 starts from a PMD-aligned address Date: Sun, 29 Sep 2019 13:34:10 -0400 Message-Id: <20190929173424.9361-22-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190929173424.9361-1-sashal@kernel.org> References: <20190929173424.9361-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Rapoport [ Upstream commit 00d2ec1e6bd82c0538e6dd3e4a4040de93ba4fef ] The calculation of memblock_limit in adjust_lowmem_bounds() assumes that bank 0 starts from a PMD-aligned address. However, the beginning of the first bank may be NOMAP memory and the start of usable memory will be not aligned to PMD boundary. In such case the memblock_limit will be set to the end of the NOMAP region, which will prevent any memblock allocations. Mark the region between the end of the NOMAP area and the next PMD-aligned address as NOMAP as well, so that the usable memory will start at PMD-aligned address. Signed-off-by: Mike Rapoport Signed-off-by: Russell King Signed-off-by: Sasha Levin --- arch/arm/mm/mmu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index e46a6a446cdd2..70e560cf8ca03 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -1175,6 +1175,22 @@ void __init adjust_lowmem_bounds(void) */ vmalloc_limit = (u64)(uintptr_t)vmalloc_min - PAGE_OFFSET + PHYS_OFFSET; + /* + * The first usable region must be PMD aligned. Mark its start + * as MEMBLOCK_NOMAP if it isn't + */ + for_each_memblock(memory, reg) { + if (!memblock_is_nomap(reg)) { + if (!IS_ALIGNED(reg->base, PMD_SIZE)) { + phys_addr_t len; + + len = round_up(reg->base, PMD_SIZE) - reg->base; + memblock_mark_nomap(reg->base, len); + } + break; + } + } + for_each_memblock(memory, reg) { phys_addr_t block_start = reg->base; phys_addr_t block_end = reg->base + reg->size; -- 2.20.1