From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.74424.1669986629170058661 for ; Fri, 02 Dec 2022 05:10:29 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H63K+9c3; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669986628; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GQTtgmDLbV6tNuE9afmVUsVXYF5OS332RiwmntRe7F4=; b=H63K+9c3hZgld8Q4wc/MgbwG5IbYIqSsS/Dq2kFUT9OlS0VUbDYhz+b34bttJP4e0KzAXS WjT589vRtEIe78laaanz4b99SVOzP0DbgCnTlLigQELblH3D6kzDoNqAdYU9nkOu5cjft0 mUumWFnq8InKD/hQO0QcIplKWnIepBo= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-574-MEMAITIRNG2FogkfGc_Qvg-1; Fri, 02 Dec 2022 08:10:25 -0500 X-MC-Unique: MEMAITIRNG2FogkfGc_Qvg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B131E3C025CF; Fri, 2 Dec 2022 13:10:24 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.79]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4ED001402BDC; Fri, 2 Dec 2022 13:10:24 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E13251801546; Fri, 2 Dec 2022 14:10:09 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Bob Feng , Yuwei Chen , Erdem Aktas , Jordan Justen , Peter Grehan , Rebecca Cran , Liming Gao , Ard Biesheuvel , Gerd Hoffmann , Jiewen Yao , Min Xu , Brijesh Singh , Oliver Steffen , Pawel Polawski , Tom Lendacky , James Bottomley Subject: [PATCH 06/14] OvmfPkg/PlatformPei: PeiMemory: stop using mPlatformInfoHob Date: Fri, 2 Dec 2022 14:10:01 +0100 Message-Id: <20221202131009.3190040-7-kraxel@redhat.com> In-Reply-To: <20221202131009.3190040-1-kraxel@redhat.com> References: <20221202131009.3190040-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Stop using the mPlatformInfoHob global variable in PublishPeiMemory() and GetPeiMemoryCap() functions. Pass a pointer to the PlatformInfoHob instead. Signed-off-by: Gerd Hoffmann --- OvmfPkg/PlatformPei/Platform.h | 2 +- OvmfPkg/PlatformPei/MemDetect.c | 36 ++++++++++++++++----------------- OvmfPkg/PlatformPei/Platform.c | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h index 7baa5e1d289f..d0c673c5a346 100644 --- a/OvmfPkg/PlatformPei/Platform.h +++ b/OvmfPkg/PlatformPei/Platform.h @@ -32,7 +32,7 @@ Q35SmramAtDefaultSmbaseInitialization ( EFI_STATUS PublishPeiMemory ( - VOID + IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob ); VOID diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c index b9207107b4d9..3d8375320dcb 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -188,7 +188,7 @@ AddressWidthInitialization ( STATIC UINT32 GetPeiMemoryCap ( - VOID + IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob ) { BOOLEAN Page1GSupport; @@ -225,15 +225,15 @@ GetPeiMemoryCap ( } } - if (mPlatformInfoHob.PhysMemAddressWidth <= 39) { + if (PlatformInfoHob->PhysMemAddressWidth <= 39) { Pml4Entries = 1; - PdpEntries = 1 << (mPlatformInfoHob.PhysMemAddressWidth - 30); + PdpEntries = 1 << (PlatformInfoHob->PhysMemAddressWidth - 30); ASSERT (PdpEntries <= 0x200); } else { - if (mPlatformInfoHob.PhysMemAddressWidth > 48) { + if (PlatformInfoHob->PhysMemAddressWidth > 48) { Pml4Entries = 0x200; } else { - Pml4Entries = 1 << (mPlatformInfoHob.PhysMemAddressWidth - 39); + Pml4Entries = 1 << (PlatformInfoHob->PhysMemAddressWidth - 39); } ASSERT (Pml4Entries <= 0x200); @@ -260,7 +260,7 @@ GetPeiMemoryCap ( **/ EFI_STATUS PublishPeiMemory ( - VOID + IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob ) { EFI_STATUS Status; @@ -271,12 +271,12 @@ PublishPeiMemory ( UINT32 S3AcpiReservedMemoryBase; UINT32 S3AcpiReservedMemorySize; - LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (&mPlatformInfoHob); - if (mPlatformInfoHob.SmmSmramRequire) { + LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob); + if (PlatformInfoHob->SmmSmramRequire) { // // TSEG is chipped from the end of low RAM // - LowerMemorySize -= mPlatformInfoHob.Q35TsegMbytes * SIZE_1MB; + LowerMemorySize -= PlatformInfoHob->Q35TsegMbytes * SIZE_1MB; } S3AcpiReservedMemoryBase = 0; @@ -287,27 +287,27 @@ PublishPeiMemory ( // downwards. Its size is primarily dictated by CpuMpPei. The formula below // is an approximation. // - if (mPlatformInfoHob.S3Supported) { + if (PlatformInfoHob->S3Supported) { S3AcpiReservedMemorySize = SIZE_512KB + - mPlatformInfoHob.PcdCpuMaxLogicalProcessorNumber * + PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber * PcdGet32 (PcdCpuApStackSize); S3AcpiReservedMemoryBase = LowerMemorySize - S3AcpiReservedMemorySize; LowerMemorySize = S3AcpiReservedMemoryBase; } - mPlatformInfoHob.S3AcpiReservedMemoryBase = S3AcpiReservedMemoryBase; - mPlatformInfoHob.S3AcpiReservedMemorySize = S3AcpiReservedMemorySize; + PlatformInfoHob->S3AcpiReservedMemoryBase = S3AcpiReservedMemoryBase; + PlatformInfoHob->S3AcpiReservedMemorySize = S3AcpiReservedMemorySize; - if (mPlatformInfoHob.BootMode == BOOT_ON_S3_RESUME) { + if (PlatformInfoHob->BootMode == BOOT_ON_S3_RESUME) { MemoryBase = S3AcpiReservedMemoryBase; MemorySize = S3AcpiReservedMemorySize; } else { - PeiMemoryCap = GetPeiMemoryCap (); + PeiMemoryCap = GetPeiMemoryCap (PlatformInfoHob); DEBUG (( DEBUG_INFO, "%a: PhysMemAddressWidth=%d PeiMemoryCap=%u KB\n", __FUNCTION__, - mPlatformInfoHob.PhysMemAddressWidth, + PlatformInfoHob->PhysMemAddressWidth, PeiMemoryCap >> 10 )); @@ -321,7 +321,7 @@ PublishPeiMemory ( // allocation HOB, and other allocations served from the permanent PEI RAM // shouldn't overlap with that HOB. // - MemoryBase = mPlatformInfoHob.S3Supported && mPlatformInfoHob.SmmSmramRequire ? + MemoryBase = PlatformInfoHob->S3Supported && PlatformInfoHob->SmmSmramRequire ? PcdGet32 (PcdOvmfDecompressionScratchEnd) : PcdGet32 (PcdOvmfDxeMemFvBase) + PcdGet32 (PcdOvmfDxeMemFvSize); MemorySize = LowerMemorySize - MemoryBase; @@ -336,7 +336,7 @@ PublishPeiMemory ( // normal boot permanent PEI RAM. Regarding the S3 boot path, the S3 // permanent PEI RAM is located even higher. // - if (mPlatformInfoHob.SmmSmramRequire && mPlatformInfoHob.Q35SmramAtDefaultSmbase) { + if (PlatformInfoHob->SmmSmramRequire && PlatformInfoHob->Q35SmramAtDefaultSmbase) { ASSERT (SMM_DEFAULT_SMBASE + MCH_DEFAULT_SMBASE_SIZE <= MemoryBase); } diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index 8b055fb451d7..4cd77fd5f84f 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -361,7 +361,7 @@ InitializePlatform ( Q35SmramAtDefaultSmbaseInitialization (&mPlatformInfoHob); } - PublishPeiMemory (); + PublishPeiMemory (&mPlatformInfoHob); PlatformQemuUc32BaseInitialization (&mPlatformInfoHob); -- 2.38.1