From: "Laszlo Ersek" <lersek@redhat.com>
To: edk2-devel-groups-io <devel@edk2.groups.io>
Cc: "Ard Biesheuvel" <ard.biesheuvel@arm.com>,
"Jordan Justen" <jordan.l.justen@intel.com>,
"Per Sundstrom" <per_sundstrom@yahoo.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH 2/7] OvmfPkg/PlatformPei: parse "X-PciMmio64Mb" with QemuFwCfgSimpleParserLib
Date: Fri, 24 Apr 2020 09:53:48 +0200 [thread overview]
Message-ID: <20200424075353.8489-3-lersek@redhat.com> (raw)
In-Reply-To: <20200424075353.8489-1-lersek@redhat.com>
Replace the
- QemuFwCfgFindFile(),
- QemuFwCfgSelectItem(),
- QemuFwCfgReadBytes(),
- AsciiStrDecimalToUint64()
sequence in the GetFirstNonAddress() function with a call to
QemuFwCfgSimpleParserLib.
This change is compatible with valid strings accepted previously.
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Per Sundstrom <per_sundstrom@yahoo.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2681
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/PlatformPei/PlatformPei.inf | 1 +
OvmfPkg/PlatformPei/MemDetect.c | 36 ++++++++++++--------
2 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
index 19f2424981bc..e72ef7963d97 100644
--- a/OvmfPkg/PlatformPei/PlatformPei.inf
+++ b/OvmfPkg/PlatformPei/PlatformPei.inf
@@ -60,6 +60,7 @@ [LibraryClasses]
PeimEntryPoint
QemuFwCfgLib
QemuFwCfgS3Lib
+ QemuFwCfgSimpleParserLib
MtrrLib
MemEncryptSevLib
PcdLib
diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c
index 47dc9c543719..f32df937f9ba 100644
--- a/OvmfPkg/PlatformPei/MemDetect.c
+++ b/OvmfPkg/PlatformPei/MemDetect.c
@@ -33,6 +33,7 @@ Module Name:
#include <Library/ResourcePublicationLib.h>
#include <Library/MtrrLib.h>
#include <Library/QemuFwCfgLib.h>
+#include <Library/QemuFwCfgSimpleParserLib.h>
#include "Platform.h"
#include "Cmos.h"
@@ -336,7 +337,7 @@ GetFirstNonAddress (
{
UINT64 FirstNonAddress;
UINT64 Pci64Base, Pci64Size;
- CHAR8 MbString[7 + 1];
+ UINT32 FwCfgPciMmio64Mb;
EFI_STATUS Status;
FIRMWARE_CONFIG_ITEM FwCfgItem;
UINTN FwCfgSize;
@@ -379,25 +380,30 @@ GetFirstNonAddress (
//
// See if the user specified the number of megabytes for the 64-bit PCI host
- // aperture. The number of non-NUL characters in MbString allows for
- // 9,999,999 MB, which is approximately 10 TB.
+ // aperture. Accept an aperture size up to 16TB.
//
// As signaled by the "X-" prefix, this knob is experimental, and might go
// away at any time.
//
- Status = QemuFwCfgFindFile ("opt/ovmf/X-PciMmio64Mb", &FwCfgItem,
- &FwCfgSize);
- if (!EFI_ERROR (Status)) {
- if (FwCfgSize >= sizeof MbString) {
- DEBUG ((EFI_D_WARN,
- "%a: ignoring malformed 64-bit PCI host aperture size from fw_cfg\n",
- __FUNCTION__));
- } else {
- QemuFwCfgSelectItem (FwCfgItem);
- QemuFwCfgReadBytes (FwCfgSize, MbString);
- MbString[FwCfgSize] = '\0';
- Pci64Size = LShiftU64 (AsciiStrDecimalToUint64 (MbString), 20);
+ Status = QemuFwCfgParseUint32 ("opt/ovmf/X-PciMmio64Mb", FALSE,
+ &FwCfgPciMmio64Mb);
+ switch (Status) {
+ case EFI_UNSUPPORTED:
+ case EFI_NOT_FOUND:
+ break;
+ case EFI_SUCCESS:
+ if (FwCfgPciMmio64Mb <= 0x1000000) {
+ Pci64Size = LShiftU64 (FwCfgPciMmio64Mb, 20);
+ break;
}
+ //
+ // fall through
+ //
+ default:
+ DEBUG ((DEBUG_WARN,
+ "%a: ignoring malformed 64-bit PCI host aperture size from fw_cfg\n",
+ __FUNCTION__));
+ break;
}
if (Pci64Size == 0) {
--
2.19.1.3.g30247aa5d201
next prev parent reply other threads:[~2020-04-24 7:54 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-24 7:53 [PATCH 0/7] OvmfPkg, ArmVirtPkg: control PXE v4/v6 boot support from the QEMU cmdline Laszlo Ersek
2020-04-24 7:53 ` [PATCH 1/7] OvmfPkg: introduce QemuFwCfgSimpleParserLib Laszlo Ersek
2020-04-24 9:13 ` Philippe Mathieu-Daudé
2020-04-28 11:47 ` Laszlo Ersek
2020-04-24 7:53 ` Laszlo Ersek [this message]
2020-04-24 8:51 ` [PATCH 2/7] OvmfPkg/PlatformPei: parse "X-PciMmio64Mb" with QemuFwCfgSimpleParserLib Philippe Mathieu-Daudé
2020-04-24 7:53 ` [PATCH 3/7] OvmfPkg/PlatformPei: use QemuFwCfgParseBool in UPDATE_BOOLEAN_PCD_FROM_ Laszlo Ersek
2020-04-24 8:55 ` Philippe Mathieu-Daudé
2020-04-28 11:40 ` Laszlo Ersek
2020-04-24 7:53 ` [PATCH 4/7] OvmfPkg/QemuFwCfgDxeLib: allow UEFI_DRIVER modules Laszlo Ersek
2020-04-28 12:48 ` Philippe Mathieu-Daudé
2020-04-24 7:53 ` [PATCH 5/7] OvmfPkg: control PXEv4 / PXEv6 boot support from the QEMU command line Laszlo Ersek
2020-04-28 12:45 ` Philippe Mathieu-Daudé
2020-04-24 7:53 ` [PATCH 6/7] ArmVirtPkg/QemuFwCfgLib: allow UEFI_DRIVER modules Laszlo Ersek
2020-04-28 12:48 ` Philippe Mathieu-Daudé
2020-04-24 7:53 ` [PATCH 7/7] ArmVirtPkg: control PXEv4 / PXEv6 boot support from the QEMU command line Laszlo Ersek
2020-04-28 12:47 ` Philippe Mathieu-Daudé
2020-04-24 9:00 ` [PATCH 0/7] OvmfPkg, ArmVirtPkg: control PXE v4/v6 boot support from the QEMU cmdline Ard Biesheuvel
2020-04-28 22:39 ` [edk2-devel] " Laszlo Ersek
2020-04-29 7:21 ` Philippe Mathieu-Daudé
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=20200424075353.8489-3-lersek@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