From nobody Sun Feb 8 21:06:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103529+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103529+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1682406198; cv=none; d=zohomail.com; s=zohoarc; b=VhcUy5AbXAdKdLWHHRGVch0wZApFpxo0CSX7Goos0VT3aKdqx/Py4b64axUc2t3j5RcT6TiQiikTf88ZERlT7QhCQ1gZIdnsXoAMgsKJ7xOAUbxzKLdOykd4FluiZzWDqaoporQWViuH7pre3zHdxbjctNRIGWGnzcJkFmn6aTs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682406198; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=nS1DuH6bcFnm4aN/Fn3phDOLJ9w7Ys2hyRH8CYg6lvM=; b=O1ucx0KhhdIa0hmXyVgZLgIUEOluff9SnvB701uoO50GJnb+Rk5nt19i0x1k1jFmdqGLo8DcvuOxen4fg+r5/YkhNoMtH28VRs9XewAEJxKyl+gg4xGfcVUctg1AymqkHZ6yZUTeB0DBU0bNocA1jAFpow9iTzwhhbTUvyRDxGw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103529+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682406198010168.66576119673118; Tue, 25 Apr 2023 00:03:18 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZHq2YY1788612xh8eclPD98J; Tue, 25 Apr 2023 00:03:17 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web10.73794.1682406195842322329 for ; Tue, 25 Apr 2023 00:03:17 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10690"; a="374623045" X-IronPort-AV: E=Sophos;i="5.99,224,1677571200"; d="scan'208";a="374623045" X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2023 00:03:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10690"; a="867781551" X-IronPort-AV: E=Sophos;i="5.99,224,1677571200"; d="scan'208";a="867781551" X-Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.151]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2023 00:03:15 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Zhiguang Liu , Nate DeSimone , Ray Ni Subject: [edk2-devel] [PATCH 1/5] SimicsOpenBoardPkg: Build gEfiSmmSmramMemoryGuid Hob in S3 path Date: Tue, 25 Apr 2023 15:03:00 +0800 Message-Id: <20230425070304.2120-2-zhiguang.liu@intel.com> In-Reply-To: <20230425070304.2120-1-zhiguang.liu@intel.com> References: <20230425070304.2120-1-zhiguang.liu@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zhiguang.liu@intel.com X-Gm-Message-State: GSvaXDzjVQgo0CtVXdmJdNqJx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682406197; bh=caqBUGHcpnSgsyuM1DkWoLD1phSF6NtteM3KVhMrW1k=; h=Cc:Date:From:Reply-To:Subject:To; b=s5LPPMENmcEeIZYUM8oLpljOUdgU9IE8O2yyvbHW0q4Dt8NrXJEfy1H8Fy1mJeKYquq dhJOE7MS+l2Xmq2izTEjBTp15S+rA8d53pCIqfr5TGE5d7GwM8zJfR2TqMDYvUTr/uuSs IuprLG/voIESb8+l0YI/1r65E7MErmXsXL4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682406198405100003 Content-Type: text/plain; charset="utf-8" gEfiSmmSmramMemoryGuid Hob is needed for SmmRelocation feature even for S3 path. So in MemDetect.c, remove specical code path for S3 about creating gEfiSmmSmramMemoryGuid Hob and adding some memory descriptor, which does no harm in S3 path. Cc: Nate DeSimone Cc: Ray Ni Signed-off-by: Zhiguang Liu --- .../SimicsOpenBoardPkg/SimicsPei/MemDetect.c | 107 +++++++----------- 1 file changed, 42 insertions(+), 65 deletions(-) diff --git a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c b/Plat= form/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c index 127afffc00..d80ac1d213 100644 --- a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c +++ b/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c @@ -405,79 +405,56 @@ QemuInitializeRam ( LowerMemorySize =3D GetSystemMemorySizeBelow4gb (); UpperMemorySize =3D GetSystemMemorySizeAbove4gb (); =20 - if (mBootMode =3D=3D BOOT_ON_S3_RESUME) { - // - // Create the following memory HOB as an exception on the S3 boot path. - // - // Normally we'd create memory HOBs only on the normal boot path. Howe= ver, - // CpuMpPei specifically needs such a low-memory HOB on the S3 path as - // well, for "borrowing" a subset of it temporarily, for the AP startup - // vector. - // - // CpuMpPei saves the original contents of the borrowed area in perman= ent - // PEI RAM, in a backup buffer allocated with the normal PEI services. - // CpuMpPei restores the original contents ("returns" the borrowed are= a) at - // End-of-PEI. End-of-PEI in turn is emitted by S3Resume2Pei before - // transferring control to the OS's wakeup vector in the FACS. - // - // We expect any other PEIMs that "borrow" memory similarly to CpuMpPe= i to - // restore the original contents. Furthermore, we expect all such PEIMs - // (CpuMpPei included) to claim the borrowed areas by producing memory - // allocation HOBs, and to honor preexistent memory allocation HOBs wh= en - // looking for an area to borrow. - // - AddMemoryRangeHob (0, BASE_512KB + BASE_128KB); - } else { - // - // Create memory HOBs - // - AddMemoryRangeHob (0, BASE_512KB + BASE_128KB); + // + // Create memory HOBs + // + AddMemoryRangeHob (0, BASE_512KB + BASE_128KB); =20 - if (FeaturePcdGet (PcdSmmSmramRequire)) { - UINT32 TsegSize; + if (FeaturePcdGet (PcdSmmSmramRequire)) { + UINT32 TsegSize; =20 - TsegSize =3D mX58TsegMbytes * SIZE_1MB; - AddMemoryRangeHob (BASE_1MB, LowerMemorySize - TsegSize); - AddReservedMemoryBaseSizeHob (LowerMemorySize - TsegSize, TsegSize, - TRUE); + TsegSize =3D mX58TsegMbytes * SIZE_1MB; + AddMemoryRangeHob (BASE_1MB, LowerMemorySize - TsegSize); + AddReservedMemoryBaseSizeHob (LowerMemorySize - TsegSize, TsegSize, + TRUE); =20 - BufferSize =3D sizeof(EFI_SMRAM_HOB_DESCRIPTOR_BLOCK); - SmramRanges =3D 1; + BufferSize =3D sizeof(EFI_SMRAM_HOB_DESCRIPTOR_BLOCK); + SmramRanges =3D 1; =20 - Hob.Raw =3D BuildGuidHob( - &gEfiSmmSmramMemoryGuid, - BufferSize - ); - ASSERT(Hob.Raw); - - SmramHobDescriptorBlock =3D (EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *)(Hob.R= aw); - SmramHobDescriptorBlock->NumberOfSmmReservedRegions =3D SmramRanges; - - SmramIndex =3D 0; - for (Index =3D 0; Index < SmramRanges; Index++) { - // - // This is an SMRAM range, create an SMRAM descriptor - // - SmramHobDescriptorBlock->Descriptor[SmramIndex].PhysicalStart =3D = LowerMemorySize - TsegSize; - SmramHobDescriptorBlock->Descriptor[SmramIndex].CpuStart =3D Lower= MemorySize - TsegSize; - SmramHobDescriptorBlock->Descriptor[SmramIndex].PhysicalSize =3D T= segSize; - SmramHobDescriptorBlock->Descriptor[SmramIndex].RegionState =3D EF= I_SMRAM_CLOSED | EFI_CACHEABLE; - SmramIndex++; - } + Hob.Raw =3D BuildGuidHob( + &gEfiSmmSmramMemoryGuid, + BufferSize + ); + ASSERT(Hob.Raw); =20 - } else { - AddMemoryRangeHob (BASE_1MB, LowerMemorySize); - } + SmramHobDescriptorBlock =3D (EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *)(Hob.Raw= ); + SmramHobDescriptorBlock->NumberOfSmmReservedRegions =3D SmramRanges; =20 - // - // If QEMU presents an E820 map, then create memory HOBs for the >=3D4= GB RAM - // entries. Otherwise, create a single memory HOB with the flat >=3D4GB - // memory size read from the CMOS. - // - if (UpperMemorySize !=3D 0) { - AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize); + SmramIndex =3D 0; + for (Index =3D 0; Index < SmramRanges; Index++) { + // + // This is an SMRAM range, create an SMRAM descriptor + // + SmramHobDescriptorBlock->Descriptor[SmramIndex].PhysicalStart =3D Lo= werMemorySize - TsegSize; + SmramHobDescriptorBlock->Descriptor[SmramIndex].CpuStart =3D LowerMe= morySize - TsegSize; + SmramHobDescriptorBlock->Descriptor[SmramIndex].PhysicalSize =3D Tse= gSize; + SmramHobDescriptorBlock->Descriptor[SmramIndex].RegionState =3D EFI_= SMRAM_CLOSED | EFI_CACHEABLE; + SmramIndex++; } + + } else { + AddMemoryRangeHob (BASE_1MB, LowerMemorySize); } + + // + // If QEMU presents an E820 map, then create memory HOBs for the >=3D4GB= RAM + // entries. Otherwise, create a single memory HOB with the flat >=3D4GB + // memory size read from the CMOS. + // + if (UpperMemorySize !=3D 0) { + AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize); + } + } =20 /** --=20 2.31.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103529): https://edk2.groups.io/g/devel/message/103529 Mute This Topic: https://groups.io/mt/98488191/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-