From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.9310.1652187135776857658 for ; Tue, 10 May 2022 05:52:16 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=m7mRIc8i; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: sebastien.boeuf@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652187135; x=1683723135; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=24lYnNBitfurZw5XA4TCVkw1rrPOcUu8tVHY8PUrzaU=; b=m7mRIc8iwnciYIKEuakvKd+KX7jOXIa4+cOqYYK66VKvOzLmOBCgWlun 9lz3cW0EEPjPCrfzDM3tQUueJcVhEsfCLw0DdsQ8m0nsmyBLAaG9nfwXw 1kweX8g++41tHsYjGvOC2qv5lmo0Vkp5DUt/QcrtI+O5z/G06WwxMOsob YT7zR4p0X0rI7tNwDnqpahp/Hjqf3lKClucl20lUAHUNR1fQFrNyVNBzH to6SOZ5YhA8Zixr1uA37b5oZzvm10VRMWqSDek0EpSMjiNVnoX7QgJhfY tNSfwmnJCCj9+/+MzfP7mG5zuScefpBtNc8w/51gBMPDDdzUZcDJWc+Q6 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10342"; a="269299212" X-IronPort-AV: E=Sophos;i="5.91,214,1647327600"; d="scan'208";a="269299212" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2022 05:51:22 -0700 X-IronPort-AV: E=Sophos;i="5.91,214,1647327600"; d="scan'208";a="593493510" Received: from amrutaya-mobl1.gar.corp.intel.com (HELO sboeuf-mobl.intel.com) ([10.251.220.13]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2022 05:51:21 -0700 From: "Boeuf, Sebastien" To: devel@edk2.groups.io Cc: jiewen.yao@intel.com, jordan.l.justen@intel.com, kraxel@redhat.com, sebastien.boeuf@intel.com Subject: [PATCH 2/4] OvmfPkg: Check for QemuFwCfg availability before accessing it Date: Tue, 10 May 2022 14:50:44 +0200 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable From: Sebastien Boeuf 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 --- OvmfPkg/Library/PlatformInitLib/Platform.c | 9 ++++++--- OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c | 8 +++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/OvmfPkg/Library/PlatformInitLib/Platform.c b/OvmfPkg/Library/P= latformInitLib/Platform.c index 101074f610..cb1a893aef 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 =3D 0; UINT32 MaxCpuCount; = // // Try to fetch the boot CPU count. // - QemuFwCfgSelectItem (QemuFwCfgItemSmpCpuCount); - BootCpuCount =3D QemuFwCfgRead16 (); + if (QemuFwCfgIsAvailable ()) { + QemuFwCfgSelectItem (QemuFwCfgItemSmpCpuCount); + BootCpuCount =3D QemuFwCfgRead16 (); + } + if (BootCpuCount =3D=3D 0) { // // QEMU doesn't report the boot CPU count. (BootCpuCount =3D=3D 0) wil= l let diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c b/OvmfPkg/= Library/QemuBootOrderLib/QemuBootOrderLib.c index b5768285d8..67d29ac642 100644 --- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c +++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c @@ -2233,6 +2233,11 @@ GetFrontPageTimeoutFromQemu ( { FIRMWARE_CONFIG_ITEM BootMenuWaitItem; UINTN BootMenuWaitSize; + UINT16 Timeout =3D PcdGet16 (PcdPlatformBootTimeOut); + + if (!QemuFwCfgIsAvailable ()) { + return Timeout; + } = QemuFwCfgSelectItem (QemuFwCfgItemBootMenu); if (QemuFwCfgRead16 () =3D=3D 0) { @@ -2257,9 +2262,6 @@ GetFrontPageTimeoutFromQemu ( // return three seconds if the platform default would cause us to skip= the // front page, and return the platform default otherwise. // - UINT16 Timeout; - - Timeout =3D PcdGet16 (PcdPlatformBootTimeOut); if (Timeout =3D=3D 0) { Timeout =3D 3; } -- = 2.32.0 --------------------------------------------------------------------- Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, = 92196 Meudon Cedex, France Registration Number: 302 456 199 R.C.S. NANTERRE Capital: 5 208 026.16 Euros This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.