From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web11.4209.1646706992182166839 for ; Mon, 07 Mar 2022 18:37:02 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=JJJysuk9; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646707022; x=1678243022; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B271ZZ6nqneuv6Z0OgSI989uhbUCCDszJbWdPRp4a04=; b=JJJysuk9gcXMD5dt+zcmswxxsm0V+kppVvIW+GyXFgupUnMWjlF8Y5fy vUWYP2UM8mbpHzQgnRowegtybkfbtOZPXrpKlkRt04cddIuXfRn23MXA1 wCA2KIIw7uhysA1PZjMct6QWT1KvpObEJfbzHXsZL7xbuJUK/vNgsD/5D 3ynx1f5GeKu6O6hhUlA6w5DWxVuq0gDeBqnJB2bi8BBK7s0zrAlzAwJBV TJC10rkCafLP5qbCh08ndQCgwHEqgam7GBaqe2kbhj2heNwlnz5yCCla2 FscG9MLz0uViTLSuavrlMtPY9TPnL7HDSRefWEICGne2gvTz3gy31esu8 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10279"; a="317801201" X-IronPort-AV: E=Sophos;i="5.90,163,1643702400"; d="scan'208";a="317801201" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2022 18:37:02 -0800 X-IronPort-AV: E=Sophos;i="5.90,163,1643702400"; d="scan'208";a="553432831" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.238.2.184]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2022 18:36:59 -0800 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: [PATCH 09/14] OvmfPkg/PlatformPei: Refactor InitializeRamRegions Date: Tue, 8 Mar 2022 10:36:10 +0800 Message-Id: <69b1b726e06bb8104a8c69ae2f0b73e6c3c4589a.1646706302.git.min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 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 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/MemDetect.c index 33c39228e448..5709766f86f3 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -163,7 +163,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 = GetSystemMemorySizeBelow4gb (PlatformInfoHob); + LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob); PlatformInfoHob->Uc32Size = GetPowerOfTwo32 ((UINT32)(SIZE_4GB - LowerMemorySize)); PlatformInfoHob->Uc32Base = (UINT32)(SIZE_4GB - PlatformInfoHob->Uc32Size); // @@ -374,7 +374,8 @@ GetHighestSystemMemoryAddressFromPvhMemmap ( } UINT32 -GetSystemMemorySizeBelow4gb ( +EFIAPI +PlatformGetSystemMemorySizeBelow4gb ( IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob ) { @@ -763,7 +764,7 @@ PublishPeiMemory ( UINT32 S3AcpiReservedMemoryBase; UINT32 S3AcpiReservedMemorySize; - LowerMemorySize = GetSystemMemorySizeBelow4gb (&mPlatformInfoHob); + LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (&mPlatformInfoHob); if (mPlatformInfoHob.SmmSmramRequire) { // // TSEG is chipped from the end of low RAM @@ -873,7 +874,7 @@ QemuInitializeRamBelow1gb ( **/ STATIC VOID -QemuInitializeRam ( +PlatformQemuInitializeRam ( IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob ) { @@ -887,7 +888,7 @@ QemuInitializeRam ( // // Determine total memory size available // - LowerMemorySize = GetSystemMemorySizeBelow4gb (PlatformInfoHob); + LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob); if (PlatformInfoHob->BootMode == BOOT_ON_S3_RESUME) { // @@ -997,19 +998,12 @@ QemuInitializeRam ( } } -/** - 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 != BOOT_ON_S3_RESUME)) { // // This is the memory range that will be used for PEI on S3 resume @@ -1115,7 +1109,7 @@ InitializeRamRegions ( // TsegSize = PlatformInfoHob->Q35TsegMbytes * SIZE_1MB; BuildMemoryAllocationHob ( - GetSystemMemorySizeBelow4gb (PlatformInfoHob) - TsegSize, + PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob) - TsegSize, TsegSize, EfiReservedMemoryType ); @@ -1154,3 +1148,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 0bf92e117bee..3e02ba2c9fc4 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -79,7 +79,7 @@ MemMapInitialization ( return; } - TopOfLowRam = GetSystemMemorySizeBelow4gb (PlatformInfoHob); + TopOfLowRam = PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob); PciExBarBase = 0; if (PlatformInfoHob->HostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) { // diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h index b5e831aa68e2..494836c3efe4 100644 --- a/OvmfPkg/PlatformPei/Platform.h +++ b/OvmfPkg/PlatformPei/Platform.h @@ -33,7 +33,8 @@ PublishPeiMemory ( ); UINT32 -GetSystemMemorySizeBelow4gb ( +EFIAPI +PlatformGetSystemMemorySizeBelow4gb ( IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob ); -- 2.29.2.windows.2