From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5869680468 for ; Tue, 21 Mar 2017 03:40:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C827732B600; Tue, 21 Mar 2017 10:40:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C827732B600 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C827732B600 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-42.phx2.redhat.com [10.3.116.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC158C65A5; Tue, 21 Mar 2017 10:40:18 +0000 (UTC) To: Ard Biesheuvel , edk2-devel@lists.01.org References: <1490088209-8564-1-git-send-email-ard.biesheuvel@linaro.org> <1490088209-8564-3-git-send-email-ard.biesheuvel@linaro.org> Cc: sigmaepsilon92@gmail.com From: Laszlo Ersek Message-ID: Date: Tue, 21 Mar 2017 11:40:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1490088209-8564-3-git-send-email-ard.biesheuvel@linaro.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 21 Mar 2017 10:40:19 +0000 (UTC) Subject: Re: [PATCH 2/2] ArmVirtPkg/HighMemDxe: check new regions against GCD memory space map X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Mar 2017 10:40:19 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 03/21/17 10:23, Ard Biesheuvel wrote: > Instead of looking at the PCD gArmTokenSpaceGuid.PcdSystemMemoryBase > to decide which DT node covers the memory we are already using, query > the GCD memory space map, which is the authoritative source for this > kind of information > > This fixes a problem observed by Michael on platforms where this PCD > is of the 'Patchable' type, which means updates to its value do not > propagate to other modules. > > Reported-by: Michael Zimmermann > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ard Biesheuvel > --- > ArmVirtPkg/HighMemDxe/HighMemDxe.c | 30 +++++++++++++------- > ArmVirtPkg/HighMemDxe/HighMemDxe.inf | 1 - > 2 files changed, 19 insertions(+), 12 deletions(-) > > diff --git a/ArmVirtPkg/HighMemDxe/HighMemDxe.c b/ArmVirtPkg/HighMemDxe/HighMemDxe.c > index 4e41120deff3..aa3f5f6d8956 100644 > --- a/ArmVirtPkg/HighMemDxe/HighMemDxe.c > +++ b/ArmVirtPkg/HighMemDxe/HighMemDxe.c > @@ -30,16 +30,17 @@ InitializeHighMemDxe ( > IN EFI_SYSTEM_TABLE *SystemTable > ) > { > - FDT_CLIENT_PROTOCOL *FdtClient; > - EFI_CPU_ARCH_PROTOCOL *Cpu; > - EFI_STATUS Status, FindNodeStatus; > - INT32 Node; > - CONST UINT32 *Reg; > - UINT32 RegSize; > - UINTN AddressCells, SizeCells; > - UINT64 CurBase; > - UINT64 CurSize; > - UINT64 Attributes; > + FDT_CLIENT_PROTOCOL *FdtClient; > + EFI_CPU_ARCH_PROTOCOL *Cpu; > + EFI_STATUS Status, FindNodeStatus; > + INT32 Node; > + CONST UINT32 *Reg; > + UINT32 RegSize; > + UINTN AddressCells, SizeCells; > + UINT64 CurBase; > + UINT64 CurSize; > + UINT64 Attributes; > + EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor; > > Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL, > (VOID **)&FdtClient); > @@ -73,7 +74,14 @@ InitializeHighMemDxe ( > } > RegSize -= (AddressCells + SizeCells) * sizeof (UINT32); > > - if (PcdGet64 (PcdSystemMemoryBase) != CurBase) { > + Status = gDS->GetMemorySpaceDescriptor (CurBase, &GcdDescriptor); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_WARN, > + "%a: Region 0x%lx - 0x%lx not found in the GCD memory space map\n", > + __FUNCTION__, CurBase, CurBase + CurSize - 1)); > + continue; > + } > + if (GcdDescriptor.GcdMemoryType == EfiGcdMemoryTypeNonExistent) { > Status = gDS->AddMemorySpace (EfiGcdMemoryTypeSystemMemory, CurBase, > CurSize, EFI_MEMORY_WB); > > diff --git a/ArmVirtPkg/HighMemDxe/HighMemDxe.inf b/ArmVirtPkg/HighMemDxe/HighMemDxe.inf > index ac1761974f52..a7072e38d09d 100644 > --- a/ArmVirtPkg/HighMemDxe/HighMemDxe.inf > +++ b/ArmVirtPkg/HighMemDxe/HighMemDxe.inf > @@ -45,7 +45,6 @@ [Protocols] > gFdtClientProtocolGuid ## CONSUMES > > [Pcd] > - gArmTokenSpaceGuid.PcdSystemMemoryBase > gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy > > [Depex] > Reviewed-by: Laszlo Ersek