summaryrefslogtreecommitdiff
path: root/OvmfPkg/Library/PlatformInitLib
diff options
context:
space:
mode:
authorSebastien Boeuf <sebastien.boeuf@intel.com>2022-05-10 20:50:44 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-06-03 10:51:26 +0000
commit43f3cfce19a713fd05cc5bc400b5bf6b79b19a9b (patch)
tree9fd60d829ff5ca6b6a8306797f86213ec69a8e77 /OvmfPkg/Library/PlatformInitLib
parent5c9f151e0c8c0a881bc374ec52fef07714735a82 (diff)
downloadedk2-43f3cfce19a713fd05cc5bc400b5bf6b79b19a9b.zip
edk2-43f3cfce19a713fd05cc5bc400b5bf6b79b19a9b.tar.gz
edk2-43f3cfce19a713fd05cc5bc400b5bf6b79b19a9b.tar.bz2
OvmfPkg: Check for QemuFwCfg availability before accessing it
There are few places in the codebase assuming QemuFwCfg will be present and supported, which can cause some issues when trying to rely on the QemuFwCfgLibNull implementation of QemuFwCfgLib. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com> Acked-by: Jiewen Yao <jiewen.yao@intel.com>
Diffstat (limited to 'OvmfPkg/Library/PlatformInitLib')
-rw-r--r--OvmfPkg/Library/PlatformInitLib/Platform.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/OvmfPkg/Library/PlatformInitLib/Platform.c b/OvmfPkg/Library/PlatformInitLib/Platform.c
index 60a30a0..ee802fd 100644
--- a/OvmfPkg/Library/PlatformInitLib/Platform.c
+++ b/OvmfPkg/Library/PlatformInitLib/Platform.c
@@ -410,14 +410,17 @@ PlatformMaxCpuCountInitialization (
IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob
)
{
- UINT16 BootCpuCount;
+ UINT16 BootCpuCount = 0;
UINT32 MaxCpuCount;
//
// Try to fetch the boot CPU count.
//
- QemuFwCfgSelectItem (QemuFwCfgItemSmpCpuCount);
- BootCpuCount = QemuFwCfgRead16 ();
+ if (QemuFwCfgIsAvailable ()) {
+ QemuFwCfgSelectItem (QemuFwCfgItemSmpCpuCount);
+ BootCpuCount = QemuFwCfgRead16 ();
+ }
+
if (BootCpuCount == 0) {
//
// QEMU doesn't report the boot CPU count. (BootCpuCount == 0) will let