From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.221.68; helo=mail-wr1-f68.google.com; envelope-from=philmd@redhat.com; receiver=edk2-devel@lists.01.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9E85C21A00AE6 for ; Wed, 28 Nov 2018 06:46:34 -0800 (PST) Received: by mail-wr1-f68.google.com with SMTP id r10so26557213wrs.10 for ; Wed, 28 Nov 2018 06:46:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=x2sbC1thPj1/HWbOvcOFyDkuWHuEJ1hzBrGnp1mSy6Q=; b=YIHCgM0TLVwgtaO/w350jpJUylSYyoergBGjkn20wx8LzzJU1GFBH3HksOMmBT3RsJ MLuQ3hhrPrdiCQwFcOePg0Pgs0np9hQKc4g8LVGqc8fRZJxQOr9Uzvt6h0lacpLy4nU0 iqDf+mHbEPu9lR5TqGXkGz3+76fBAt1u+N/5ngjCQ4iGpDV8iJbJe51yXbbDs8Fq4PyZ lqb8m+OMXHyKTtuk1suSoGsayJ4RIq7oA8cbUy0YAD4BmiAjPxgCKdvJe+IHniMYTd15 lDpTLGdhtVTevGoPDDPTbb77lQgfx1nIq2lXPwglVDspSWkU+ubGuA9Va7qpIPyWB+g8 LE+w== X-Gm-Message-State: AA+aEWZ7GCKTiV4BSHsThF21dSbwqXUave4L50PPxDQ8dzS7pvagvPS5 nGZOgVhwB2EJbPEPN8ny9GYdtw== X-Google-Smtp-Source: AFSGD/Xu9JYt1JcZL583N+7ZjF0uaQixpWzOtRrqMheSaQ2bNeG74aAZOJqa2s2g6NLhWN7CKEQrrQ== X-Received: by 2002:a05:6000:108d:: with SMTP id y13mr28905251wrw.135.1543416393059; Wed, 28 Nov 2018 06:46:33 -0800 (PST) Received: from ?IPv6:2a01:cb1d:8a0a:f500:48c1:8eab:256a:caf9? ([2a01:cb1d:8a0a:f500:48c1:8eab:256a:caf9]) by smtp.gmail.com with ESMTPSA id q125sm2374601wme.33.2018.11.28.06.46.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 06:46:32 -0800 (PST) To: Ard Biesheuvel , edk2-devel@lists.01.org Cc: Laszlo Ersek , Leif Lindholm , Eric Auger , Andrew Jones , Julien Grall References: <20181128143357.991-1-ard.biesheuvel@linaro.org> <20181128143357.991-9-ard.biesheuvel@linaro.org> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Openpgp: id=89C1E78F601EE86C867495CBA2A3FD6EDEADC0DE; url=http://pgp.mit.edu/pks/lookup?op=get&search=0xA2A3FD6EDEADC0DE Message-ID: <8bb4a0e1-6691-4d12-2f64-d3346cb7643a@redhat.com> Date: Wed, 28 Nov 2018 15:46:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20181128143357.991-9-ard.biesheuvel@linaro.org> Subject: Re: [PATCH v3 08/16] ArmPkg/ArmMmuLib: take the CPU supported maximum PA space into account X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Nov 2018 14:46:34 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 28/11/18 15:33, Ard Biesheuvel wrote: > In preparation of dropping PcdPrePiCpuMemorySize entirely, base the > maximum size of the identity map on the capabilities of the CPU. > Since that may exceed what is architecturally permitted when using > 4 KB pages, take MAX_ADDRESS into account as well. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daudé > --- > ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf | 3 --- > ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf | 3 --- > ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 11 +++++++++-- > 3 files changed, 9 insertions(+), 8 deletions(-) > > diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf b/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf > index b9f264de8d26..246963361e45 100644 > --- a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf > +++ b/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf > @@ -40,8 +40,5 @@ [LibraryClasses] > CacheMaintenanceLib > MemoryAllocationLib > > -[Pcd.AARCH64] > - gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize > - > [Pcd.ARM] > gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride > diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf b/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf > index ecf13f790734..f689c193b862 100644 > --- a/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf > +++ b/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf > @@ -35,6 +35,3 @@ [LibraryClasses] > ArmLib > CacheMaintenanceLib > MemoryAllocationLib > - > -[Pcd.AARCH64] > - gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize > diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c > index 4b62ecb6a476..5403b8d4070e 100644 > --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c > +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c > @@ -604,8 +604,15 @@ ArmConfigureMmu ( > return EFI_INVALID_PARAMETER; > } > > - // Cover the entire GCD memory space > - MaxAddress = (1UL << PcdGet8 (PcdPrePiCpuMemorySize)) - 1; > + // > + // Limit the virtual address space to what we can actually use: UEFI > + // mandates a 1:1 mapping, so no point in making the virtual address > + // space larger than the physical address space. We also have to take > + // into account the architectural limitations that result from UEFI's > + // use of 4 KB pages. > + // > + MaxAddress = MIN (LShiftU64 (1ULL, ArmGetPhysicalAddressBits ()) - 1, > + MAX_ADDRESS); > > // Lookup the Table Level to get the information > LookupAddresstoRootTable (MaxAddress, &T0SZ, &RootTableEntryCount); >