From patchwork Wed Jul 29 11:49:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 51655 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id C3A2F214B7 for ; Wed, 29 Jul 2015 11:51:43 +0000 (UTC) Received: by wixh2 with SMTP id h2sf6280889wix.0 for ; Wed, 29 Jul 2015 04:51:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:in-reply-to:references :date:message-id:subject:from:to:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:cc:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=gCTmmbCjl+6rTtrmE5b9eZRIYKbwe9LJT7Nv3QGcE2I=; b=kgGqNVPM4sbN2s/YnpFrau04M9xpwKMeCRtRHB0Tnx1qGL1M3MhHZEwMDuFwjyX7DX lOZ06zC100OFjjlCzb52o7pz0oTnP6IpzZpYxTDj0+dQWP/tSSEsM3Slnrxtjdq2JQeQ pCiaDDHb7CcihlmNl1owrfwlbIBfQk7gof72JgsSEiXXRuUKLY8DMqIwtPud/uADDhp6 2okyh8F/wUSvSuFDh9bMpkxO5Ubt0/EcIr0HOzqgtZVs2MYxEYZoZzMxXxFVRn9c9mg+ f6xBDy/wY/VsJw5QPI9R5kxAk3m1GmGBt6wF6zhuGRXqxP0ElcC0soO0SOUsQ2bM16qx /EAA== X-Gm-Message-State: ALoCoQkA3OxyD7ZYQW+2ImU80R4HtStK+mUs3wUQ4jrG9oMOwN64k4kVWcTuvzzUSqfv1rh45kty X-Received: by 10.180.87.201 with SMTP id ba9mr3044849wib.3.1438170703059; Wed, 29 Jul 2015 04:51:43 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.201 with SMTP id t9ls30555laa.95.gmail; Wed, 29 Jul 2015 04:51:42 -0700 (PDT) X-Received: by 10.152.164.193 with SMTP id ys1mr38413438lab.65.1438170702772; Wed, 29 Jul 2015 04:51:42 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id v8si21294470laj.130.2015.07.29.04.51.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Jul 2015 04:51:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by lbbst4 with SMTP id st4so4882863lbb.1 for ; Wed, 29 Jul 2015 04:51:42 -0700 (PDT) X-Received: by 10.112.198.74 with SMTP id ja10mr38364197lbc.19.1438170702638; Wed, 29 Jul 2015 04:51:42 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp2705770lba; Wed, 29 Jul 2015 04:51:41 -0700 (PDT) X-Received: by 10.70.88.226 with SMTP id bj2mr93863504pdb.84.1438170700638; Wed, 29 Jul 2015 04:51:40 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id q1si15589847pdh.119.2015.07.29.04.51.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Jul 2015 04:51:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZKPsH-0002Jk-FG; Wed, 29 Jul 2015 11:50:17 +0000 Received: from mail-ig0-f173.google.com ([209.85.213.173]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZKPsE-00013a-K6 for linux-arm-kernel@lists.infradead.org; Wed, 29 Jul 2015 11:50:15 +0000 Received: by igbpg9 with SMTP id pg9so10545216igb.0 for ; Wed, 29 Jul 2015 04:49:53 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.40.39 with SMTP id u7mr713815igk.71.1438170593381; Wed, 29 Jul 2015 04:49:53 -0700 (PDT) Received: by 10.36.138.69 with HTTP; Wed, 29 Jul 2015 04:49:53 -0700 (PDT) In-Reply-To: <20150729114258.GK15213@leverpostej> References: <20150729114258.GK15213@leverpostej> Date: Wed, 29 Jul 2015 13:49:53 +0200 Message-ID: Subject: Re: bug in identity map for 4KB pages? From: Ard Biesheuvel To: Mark Rutland X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150729_045014_712402_3D26ED42 X-CRM114-Status: GOOD ( 21.89 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.213.173 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.213.173 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Cc: Marc Zyngier , Catalin Marinas , Will Deacon , Stuart Yoder , Peter Newton , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 On 29 July 2015 at 13:42, Mark Rutland wrote: > On Wed, Jul 29, 2015 at 08:47:10AM +0100, Ard Biesheuvel wrote: >> On 29 July 2015 at 04:37, Stuart Yoder wrote: >> > Our system has RAM at a high address, and previously required using 48-bit VA >> > in order to have an idmap that covered all of RAM. >> > >> > In testing on 4.2-rc4, which now contains support for the increased VA range >> > of the idmap without using 48-bit VA, I'm finding that things work for >> > 64KB pages, but do not for 4KB pages. >> > >> > Is there any known limitation here with 4KB pages? Any ideas? >> > >> >> You probably have memory at 0x8000_0000 and at 0x80_8000_0000, right? >> So the physical arrangement still requires more than the 39 bits of >> virtual address space you get with 3 levels, even if the ID map can >> cope now. That is why you get the 0x40_0000_0000 virtual address: >> __phys_to_virt() just wraps to a positive number. > > Ah, I see. So it's the linear mapping rather than the idmap which is the > problem. > > We cut memory which would fall below the start of the linear map in > early_init_dt_add_memory_arch, by cutting memory below phys_offset. > > It looks like we already have the logic for cutting memory beyond the > end of the linear map, so we should just need to override the limit. > > Stuart, does the below patch prevent the panic you see? > Wouldn't something like this make more sense? """ (taken from my patch 'arm64: override early_init_dt_add_memory_arch()' sent to the list a while ago as part of the linear mapping decoupling series) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 597831bdddf3..64480b65ef17 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -158,6 +158,15 @@ early_param("mem", early_mem); void __init arm64_memblock_init(void) { + /* + * Remove the memory that we will not be able to cover + * with the linear mapping. + */ + const s64 linear_region_size = -(s64)PAGE_OFFSET; + + memblock_remove(0, memstart_addr); + memblock_remove(memstart_addr + linear_region_size, ULLONG_MAX); + memblock_enforce_memory_limit(memory_limit); /*