From patchwork Wed May 9 22:58:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10390963 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 D571560153 for ; Wed, 9 May 2018 22:57:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5C5428675 for ; Wed, 9 May 2018 22:57:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9FE928678; Wed, 9 May 2018 22:57:29 +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=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3D06728675 for ; Wed, 9 May 2018 22:57:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=ITUoD/zANmsdKWNNWKVUvoo1KqS+UFR6cTaEdDGQZjk=; b=ovx nbPMcFrP1cz5HMFzi1RoYVVfZD1gzaqkhAC+uK4pvUnWcJWy6nmOyGdEHxs8yJBbY5qIDuRK62OVa 4Fjdo3p67biqZ1yHHXDDRUdTOjwB9L+JzM8hENOTKZamP2q7w97Kwi3lBZpJ7KidXisqhr6RBcuKg V4r4CvUACBUJe/KoQBdARNuVvj8RWPNpz6p6i81uAftgQmUewCMxePgoboP436bBVGf7RxbRc2Eyj /Nu5U72M8Fu6v4RwH6QbQdGH6ki2YFH2FJuqvOfLoQU6SC3jP3N475POFi6W+fWBCCHANjRKqEJVr iwtSp2syBWdW5qn3xFWDht4ogGNfVrA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fGY1U-0002u1-KW; Wed, 09 May 2018 22:57:24 +0000 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fGY1P-0002tD-Kf for linux-arm-kernel@lists.infradead.org; Wed, 09 May 2018 22:57:20 +0000 Received: by mail-pf0-x241.google.com with SMTP id e9-v6so91641pfi.4 for ; Wed, 09 May 2018 15:57:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=d7BALUdAM6AVVfQ7pc5av/sQV7zUAmoH0F8l5f1jOtU=; b=U4YP8YFokK4bRa7kYHwqprWZ4FpNbidrjflyHUhjzxh30Wc7R/if0/AKvwB2RlDzz4 EsVfOvjLSiNuLw24zhdCJfOXjFKFCb33yYJEE1EYpOo7rb9Vr/a1PmhMb8Z0OwchnYb3 ouG+4ZfFQ8UFR4sK2AU0/71lSAE3cpz/jRUr6nTzbBduBR40tZDWetFvf57iO7hl/CkR 3eK4rNA6u4efI2ABTidrzeVIsxcfymf3jeztmzaFzY+s0G/BxU4KG4Ofl0gyYierBReH qIvLO2Ic380uTzvTJ6XO0DPR9SzDvPMSF166iqUKazE1yNTzxhcW0C4JEkhRZHrOYM+D Jtbw== 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; bh=d7BALUdAM6AVVfQ7pc5av/sQV7zUAmoH0F8l5f1jOtU=; b=m5GB6AmlTpBbH+SeFqdcZ8W5nW4hYnNf08vVyAdfKsWM9dYyNTLGcXiCn/giM7sYm0 lGJrtlTtgrmUDacwT4hoexYexi2zpdVX3S3qbnXReH6ocjPiOm+aZ3vOn7jfAYDuvIWW oroQxAm0lf8obRt+l7wgDEHwazKNofmlM1OeAgfm6orulRnheMERS53kI4BsnHipcH7V QL7dO6MIPM0HxXJOdaDO+yQZU+rfvqPgXoR+1lUSAqQbxtNppoyEOScgBPjGz5zTQi4J LfhUperZ6pXLHwzdhBZiLqeOX6yHCWVFXFx/21Vet+pwA29G0b490uJbksP6fZ22hIOW 2b9g== X-Gm-Message-State: ALQs6tDvAFckehoH8xtGl38ev+QsEkEqzQUVqGJxJ7H8ot5ceEVPPrNy zVIUAuQ7BPBA3nU7OKapyEs= X-Google-Smtp-Source: AB8JxZoGVnUNzbxhyPk1R8Ceba0iFeScWqwcTwwZBws6QpNPwJm3CoPuhhm47S8E6c/hNFWVyyDQ9g== X-Received: by 2002:a65:4341:: with SMTP id k1-v6mr6541713pgq.10.1525906627828; Wed, 09 May 2018 15:57:07 -0700 (PDT) Received: from Asurada-Nvidia.nvidia.com (thunderhill.nvidia.com. [216.228.112.22]) by smtp.gmail.com with ESMTPSA id z127-v6sm42678606pgb.31.2018.05.09.15.57.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 May 2018 15:57:07 -0700 (PDT) From: Nicolin Chen To: will.deacon@arm.com, catalin.marinas@arm.com Subject: [RFC][PATCH] arm64: update iomem_resource.end Date: Wed, 9 May 2018 15:58:23 -0700 Message-Id: <1525906703-28481-1-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180509_155719_682065_C46890EF X-CRM114-Status: GOOD ( 12.76 ) 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: steve.capper@arm.com, linux-kernel@vger.kernel.org, stefan@agner.ch, jglisse@redhat.com, kristina.martsenko@arm.com, akpm@linux-foundation.org, labbott@redhat.com, robin.murphy@arm.com, 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 The iomem_resource.end is -1 by default and should be updated in arch-level code. ARM64 so far hasn't updated it while core kernel code (mm/hmm.c) started to use iomem_resource.end for boundary check. So it'd be better to assign iomem_resource.end using a valid value, the end of physical address space for example because iomem_resource.end in theory should reflect that. However, VA_BITS might be smaller than PA_BITS in ARM64. So using the end of physical address space doesn't make a lot of sense in this case, or could be even harmful since virtual address cannot reach that memory region. Furthermore, the linear region size of ARM64 only has the half of Virtual Memory size -- "VA_BITS - 1". So this patch updates the iomem_resource.end by using the end of physical address space or the end of linear mapping region when (VA_BITS - 1) is smaller than PA_BITS. Signed-off-by: Nicolin Chen --- arch/arm64/mm/init.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index f48b194..22015af 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -377,6 +377,12 @@ void __init arm64_memblock_init(void) BUILD_BUG_ON(linear_region_size != BIT(VA_BITS - 1)); /* + * Update iomem_resource.end based on size of physical address space, + * or linear region size when (VA_BITS - 1) is smaller than PA_BITS. + */ + iomem_resource.end = BIT(min(PHYS_MASK_SHIFT, VA_BITS - 1)) - 1; + + /* * Select a suitable value for the base of physical memory. */ memstart_addr = round_down(memblock_start_of_DRAM(),