From nobody Tue Feb 10 06:25:11 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+103612+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+103612+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1682489775; cv=none; d=zohomail.com; s=zohoarc; b=IkmS+8MI+br/fMGSfxiYPBz4oYlfXr+Vr7XA3/HuTIJZPoM2t9K05xKmOFkzTeXGIMC/zGKeU7Q7msPJFHSdXLKm/lSi9Ti1GKvAsFrHUe2xEQ3ID6mzYnAlSBgsNKoVPhAziDctJvT/B3Z/6mrL0ogWKhndB/8Pn7XVPRgpQ/k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682489775; 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=ayyRyEfZU0/fPVpS6UXZcQUNxs27bVPlNLbU2w++PWs=; b=QRrPOpcE3/2VOdhPh+5F+cGpvkowpCIzULLsjlPfS1FIrtBHQjMgAR+ZULsYytP4v+wDEY7MjzYuDvhIQ68uUcQoDJI4b0JMSIDy/YEbZFVvGavj7X7QNjQK1+TD9JaKOzmRVRc4T2lQcZMmuPIGkLITHEFWGWYS+uK8gYt8/18= 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+103612+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 1682489775461144.7983842730315; Tue, 25 Apr 2023 23:16:15 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id XD6KYY1788612xvADZCqTubk; Tue, 25 Apr 2023 23:16:15 -0700 X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web10.1740.1682489774480026272 for ; Tue, 25 Apr 2023 23:16:14 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10691"; a="331235150" X-IronPort-AV: E=Sophos;i="5.99,227,1677571200"; d="scan'208";a="331235150" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2023 23:16:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10691"; a="644125184" X-IronPort-AV: E=Sophos;i="5.99,227,1677571200"; d="scan'208";a="644125184" X-Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.151]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2023 23:16:12 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Zhiguang Liu , Nate DeSimone , Ray Ni Subject: [edk2-devel] [PATCH v2 1/5] SimicsOpenBoardPkg: Build gEfiSmmSmramMemoryGuid Hob in S3 path Date: Wed, 26 Apr 2023 14:15:45 +0800 Message-Id: <20230426061549.1254-2-zhiguang.liu@intel.com> In-Reply-To: <20230426061549.1254-1-zhiguang.liu@intel.com> References: <20230426061549.1254-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: CnM0rHb04MeT9iS1zHz1AZHzx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682489775; bh=0r54NQK5Req6q33Q7L8EndL5FJW/kmeA4GuGiENkQjo=; h=Cc:Date:From:Reply-To:Subject:To; b=wP02fHDJZPGTiAMRDPJ8WcaTxX8E6oA7KCqXm5OmcKaDQyY4iGdHt7+1fJ2ziPTCYG1 9+H4U+IUtWKh+EPEXeHKOGGkFxp8jB4ArFDcu5UUlkLcPDxt2p8La4SpaX3XaefixUEb0 bDPR0KKTRqjH5jjxu0papZY4Dqn+/BlqRfI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682489776784100001 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 | 119 ++++++++---------- 1 file changed, 53 insertions(+), 66 deletions(-) diff --git a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c b/Plat= form/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c index 127afffc00..b79e8eb73a 100644 --- a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c +++ b/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c @@ -1,7 +1,7 @@ /** @file Memory Detection for Virtual Machines. =20 - Copyright (c) 2006 - 2019 Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2023 Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -405,79 +405,66 @@ 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); + // + // CpuMpPei saves the original contents of the borrowed area in permanent + // PEI RAM, in a backup buffer allocated with the normal PEI services. + // CpuMpPei restores the original contents ("returns" the borrowed area)= 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 CpuMpPei = 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 when + // looking for an area to borrow. + // + 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 (#103612): https://edk2.groups.io/g/devel/message/103612 Mute This Topic: https://groups.io/mt/98509463/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-