public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>, edk2-devel@lists.01.org
Cc: sigmaepsilon92@gmail.com
Subject: Re: [PATCH 2/2] ArmVirtPkg/HighMemDxe: check new regions against GCD memory space map
Date: Tue, 21 Mar 2017 11:40:16 +0100	[thread overview]
Message-ID: <c17cc539-5ef7-335d-35e4-92c83e7849eb@redhat.com> (raw)
In-Reply-To: <1490088209-8564-3-git-send-email-ard.biesheuvel@linaro.org>

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 <sigmaepsilon92@gmail.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  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 <lersek@redhat.com>


  reply	other threads:[~2017-03-21 10:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-21  9:23 [PATCH 0/2] ArmVirtPkg/HighMemDxe: fix issues reported by Michael Ard Biesheuvel
2017-03-21  9:23 ` [PATCH 1/2] ArmVirtPkg/HighMemDxe: use CPU arch protocol to apply memprotect policy Ard Biesheuvel
2017-03-21 10:36   ` Laszlo Ersek
2017-03-21  9:23 ` [PATCH 2/2] ArmVirtPkg/HighMemDxe: check new regions against GCD memory space map Ard Biesheuvel
2017-03-21 10:40   ` Laszlo Ersek [this message]
2017-03-21 10:42 ` [PATCH 0/2] ArmVirtPkg/HighMemDxe: fix issues reported by Michael Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c17cc539-5ef7-335d-35e4-92c83e7849eb@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox