public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: edk2-devel@lists.01.org
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH v3 0/5] Abstract allocation of PEI accessible memory
Date: Mon, 28 May 2018 16:40:19 +0200	[thread overview]
Message-ID: <20180528144024.10809-1-ard.biesheuvel@linaro.org> (raw)

At the moment, FirmwarePerformanceTableDataDxe or DxeCorePerformanceLib
are unusable on systems such as AMD Seattle, because they unconditionally
attempt to allocate memory below 4 GB, and ASSERT() if this fails. On AMD
Seattle, no 32-bit addressable DRAM exists, and so the driver will always
assert, and crash a running DEBUG build.

The reason for this is that some platforms (i.e., X64 builds consisting of
a 32-bit PEI stage and 64-bit remaining stages) require these allocations
to be below 4 GB, and for some reason, open coding this practice throughout
the code without regard for other architectures has been regarded as an
acceptable approach.

Instead, I would like to propose the approach implemented in this series:
- create an abstracted AllocatePeiAccessiblePages() routine in DxeServicesLib
  that simply allocates pages from any region on all architectures except X64,
  and allocate below 4 GB for X64
- update the various call sites with calls to this new function.

The above is implemented in patches #3 - #6. Patches #1 and #2 are fixes
for issues that I observed in ArmVirtPkg and OvmfPkg while working on
these patches.

Code can be found here:
https://github.com/ardbiesheuvel/edk2/tree/allocate-pei-v3

Changes since v2:
- move AllocatePeiAccessiblePages() to a separate .c file, and create a special
  X64 version (#3)
- add back ZeroMem() call to #4
- add Laszlo's ack to #4 - #5 (but not to #3 since it has been updated)

Changes since v1:
- add Laszlo's ack to #1 - #2
- move EfiAllocatePeiPages() to DxeServicesLib and drop Efi prefix
- update implementation to take EfiFreeMemoryTop into account when built
  for X64

Ard Biesheuvel (5):
  OvmfPkg/PlatformBootManagerLib: add missing report status code call
  ArmVirtPkg/PlatformBootManagerLib: add missing report status code call
  MdePkg/DxeServicesLib: introduce AllocatePeiAccessiblePages routine
  MdeModulePkg/DxeCorePerformanceLib: use AllocatePeiAccessiblePages
  MdeModulePkg/FirmwarePerformanceDataTableDxe: use
    AllocatePeiAccessiblePages

 .../PlatformBootManagerLib.inf                |  1 +
 .../PlatformBootManagerLib/QemuKernel.c       |  4 ++
 .../DxeCorePerformanceLib.c                   | 48 ++-----------
 .../FirmwarePerformanceDxe.c                  | 51 +++-----------
 .../FirmwarePerformanceDxe.inf                |  1 +
 MdePkg/Include/Library/DxeServicesLib.h       | 23 ++++++-
 MdePkg/Library/DxeServicesLib/Allocate.c      | 54 +++++++++++++++
 .../Library/DxeServicesLib/DxeServicesLib.inf | 11 ++-
 MdePkg/Library/DxeServicesLib/X64/Allocate.c  | 69 +++++++++++++++++++
 .../PlatformBootManagerLib.inf                |  1 +
 .../PlatformBootManagerLib/QemuKernel.c       |  4 ++
 11 files changed, 182 insertions(+), 85 deletions(-)
 create mode 100644 MdePkg/Library/DxeServicesLib/Allocate.c
 create mode 100644 MdePkg/Library/DxeServicesLib/X64/Allocate.c

-- 
2.17.0



             reply	other threads:[~2018-05-28 14:40 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-28 14:40 Ard Biesheuvel [this message]
2018-05-28 14:40 ` [PATCH v3 1/5] OvmfPkg/PlatformBootManagerLib: add missing report status code call Ard Biesheuvel
2018-05-28 14:40 ` [PATCH v3 2/5] ArmVirtPkg/PlatformBootManagerLib: " Ard Biesheuvel
2018-05-28 14:40 ` [PATCH v3 3/5] MdePkg/DxeServicesLib: introduce AllocatePeiAccessiblePages routine Ard Biesheuvel
2018-05-28 14:59   ` Laszlo Ersek
2018-05-29  3:34     ` Gao, Liming
2018-05-29  1:37   ` Zeng, Star
2018-05-29 15:18     ` Yao, Jiewen
2018-05-29 15:31       ` Kinney, Michael D
2018-05-29 15:36         ` Yao, Jiewen
2018-05-29 16:09           ` Kinney, Michael D
2018-05-29 16:19             ` Ard Biesheuvel
2018-05-29 16:41               ` Yao, Jiewen
2018-05-30  0:58             ` Zeng, Star
2018-05-28 14:40 ` [PATCH v3 4/5] MdeModulePkg/DxeCorePerformanceLib: use AllocatePeiAccessiblePages Ard Biesheuvel
2018-05-29  1:33   ` Zeng, Star
2018-05-28 14:40 ` [PATCH v3 5/5] MdeModulePkg/FirmwarePerformanceDataTableDxe: " Ard Biesheuvel
2018-05-29  1:32   ` Zeng, Star
2018-05-29  8:49 ` [PATCH v3 0/5] Abstract allocation of PEI accessible memory 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=20180528144024.10809-1-ard.biesheuvel@linaro.org \
    --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