From nobody Sun Feb 8 18:43:52 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+88115+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+88115+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1648455001; cv=none; d=zohomail.com; s=zohoarc; b=D6vHsisQdOJggEZlqizYzFJlHMClq/MvuckKOgbt8UVvJ+V+vLZZzqpyIbF1tT2gGAw9DyFhAlF4sunJWytXLuUKABXxDEavqUePzHKnKTinY9Az+JMhu5hXZI2L4WV1OdT4Viemi3/mkp+l7LcrnkvRQHLVtrAxkPzW25H10SM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648455001; 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=34XFasFmnCEBy4Zt2FPkKfA8R7RcaNjJOdBE580rXIE=; b=muLVcMYfD5LFu8UQlk2puBqrmlDbv27Gr6uwEmbFFW3u8wLPOFUYxAmOzC2mbcU8tnGwWyphdvRGlbB6WjNRnxhYG+PbcXSVtGioNBDKoxaoB8qgye10c34FKYa+jccl0sokw5A9wyni89b2bsYUorHX1awCjGQfAgNH+msgqZo= 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+88115+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 1648455001920718.1891614829196; Mon, 28 Mar 2022 01:10:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 7gK0YY1788612xumRXiRuYJr; Mon, 28 Mar 2022 01:10:01 -0700 X-Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web12.8480.1648454962517853012 for ; Mon, 28 Mar 2022 01:10:00 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="257771120" X-IronPort-AV: E=Sophos;i="5.90,216,1643702400"; d="scan'208";a="257771120" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 01:10:00 -0700 X-IronPort-AV: E=Sophos;i="5.90,216,1643702400"; d="scan'208";a="563427707" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.175.167]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 01:09:57 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Ard Biesheuvel , Jordan Justen , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Gerd Hoffmann , Sebastien Boeuf Subject: [edk2-devel] [PATCH V11 25/47] OvmfPkg/PlatformPei: Refactor InitializeRamRegions Date: Mon, 28 Mar 2022 16:08:04 +0800 Message-Id: In-Reply-To: References: 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,min.m.xu@intel.com X-Gm-Message-State: PeZlXTM4v0tsf0wWf4MHnEKqx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1648455001; bh=V7vZYJ2VZg6s64dfMSzoWHY2M4x3g0r0soKFHklYYNs=; h=Cc:Date:From:Reply-To:Subject:To; b=a/SbgnSHRiASyfExF/d1GnB9FMifXaQZ5kxxlrrRrunMDJUE7C2bh/cO1SKuGIPBQlh E6fagd2JorodNZBOYOXvEhNOnaojmBNM9QcBtkgdtmtjl9d0/eV0vQ2PkKjRAweHi9oO4 kDwUq+DlT0oUXYxu5qMkZjnjcNcbbJoWfwk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1648455003606100015 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3863 InitializeRamRegions is refactored into 3 calls: - PlatformQemuInitializeRam - SevInitializeRam - PlatformQemuInitializeRamForS3 SevInitializeRam is not in PlatformInitLib. Because in the first stage PlatformInitLib only support the basic platform featues. PlatformQemuInitializeRamForS3 wraps the code which was previously in InitializeRamRegions (many code in 2 if-checks). Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Gerd Hoffmann Cc: Sebastien Boeuf Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- OvmfPkg/PlatformPei/MemDetect.c | 40 ++++++++++++++++++++------------- OvmfPkg/PlatformPei/Platform.c | 2 +- OvmfPkg/PlatformPei/Platform.h | 3 ++- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetec= t.c index 45f7eba65d04..23a583ed3386 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -161,7 +161,7 @@ PlatformQemuUc32BaseInitialization ( // variable MTRR suffices by truncating the size to a whole power of two, // while keeping the end affixed to 4GB. This will round the base up. // - LowerMemorySize =3D GetSystemMemorySizeBelow4gb (PlatformInfoH= ob); + LowerMemorySize =3D PlatformGetSystemMemorySizeBelow4gb (Platf= ormInfoHob); PlatformInfoHob->Uc32Size =3D GetPowerOfTwo32 ((UINT32)(SIZE_4GB - Lower= MemorySize)); PlatformInfoHob->Uc32Base =3D (UINT32)(SIZE_4GB - PlatformInfoHob->Uc32S= ize); // @@ -372,7 +372,8 @@ GetHighestSystemMemoryAddressFromPvhMemmap ( } =20 UINT32 -GetSystemMemorySizeBelow4gb ( +EFIAPI +PlatformGetSystemMemorySizeBelow4gb ( IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob ) { @@ -761,7 +762,7 @@ PublishPeiMemory ( UINT32 S3AcpiReservedMemoryBase; UINT32 S3AcpiReservedMemorySize; =20 - LowerMemorySize =3D GetSystemMemorySizeBelow4gb (&mPlatformInfoHob); + LowerMemorySize =3D PlatformGetSystemMemorySizeBelow4gb (&mPlatformInfoH= ob); if (mPlatformInfoHob.SmmSmramRequire) { // // TSEG is chipped from the end of low RAM @@ -871,7 +872,7 @@ QemuInitializeRamBelow1gb ( **/ STATIC VOID -QemuInitializeRam ( +PlatformQemuInitializeRam ( IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob ) { @@ -885,7 +886,7 @@ QemuInitializeRam ( // // Determine total memory size available // - LowerMemorySize =3D GetSystemMemorySizeBelow4gb (PlatformInfoHob); + LowerMemorySize =3D PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob= ); =20 if (PlatformInfoHob->BootMode =3D=3D BOOT_ON_S3_RESUME) { // @@ -995,19 +996,12 @@ QemuInitializeRam ( } } =20 -/** - Publish system RAM and reserve memory regions - -**/ +STATIC VOID -InitializeRamRegions ( +PlatformQemuInitializeRamForS3 ( IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob ) { - QemuInitializeRam (PlatformInfoHob); - - SevInitializeRam (); - if (PlatformInfoHob->S3Supported && (PlatformInfoHob->BootMode !=3D BOOT= _ON_S3_RESUME)) { // // This is the memory range that will be used for PEI on S3 resume @@ -1113,7 +1107,7 @@ InitializeRamRegions ( // TsegSize =3D PlatformInfoHob->Q35TsegMbytes * SIZE_1MB; BuildMemoryAllocationHob ( - GetSystemMemorySizeBelow4gb (PlatformInfoHob) - TsegSize, + PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob) - TsegSize, TsegSize, EfiReservedMemoryType ); @@ -1152,3 +1146,19 @@ InitializeRamRegions ( #endif } } + +/** + Publish system RAM and reserve memory regions + +**/ +VOID +InitializeRamRegions ( + IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob + ) +{ + PlatformQemuInitializeRam (PlatformInfoHob); + + SevInitializeRam (); + + PlatformQemuInitializeRamForS3 (PlatformInfoHob); +} diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index 1275c9187e86..f89d14493ecf 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -79,7 +79,7 @@ MemMapInitialization ( return; } =20 - TopOfLowRam =3D GetSystemMemorySizeBelow4gb (PlatformInfoHob); + TopOfLowRam =3D PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob); PciExBarBase =3D 0; if (PlatformInfoHob->HostBridgeDevId =3D=3D INTEL_Q35_MCH_DEVICE_ID) { // diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h index 038a806a1e1b..635d58379a24 100644 --- a/OvmfPkg/PlatformPei/Platform.h +++ b/OvmfPkg/PlatformPei/Platform.h @@ -35,7 +35,8 @@ PublishPeiMemory ( ); =20 UINT32 -GetSystemMemorySizeBelow4gb ( +EFIAPI +PlatformGetSystemMemorySizeBelow4gb ( IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob ); =20 --=20 2.29.2.windows.2 -=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 (#88115): https://edk2.groups.io/g/devel/message/88115 Mute This Topic: https://groups.io/mt/90080001/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-