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.web11.74536.1669986637972626002 for ; Fri, 02 Dec 2022 05:10:38 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=S79k0aJQ; 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=1669986637; 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=HKpy06yQKoLEb1VggIEkLt5kfIdDnYKEKk+akwI5jAs=; b=S79k0aJQ1nDr7WvKuunc9WYaF/K9evvSh2g4kFhL7wYrDJCovNqZx0276HpE/1msSluTj1 sI+m2CP55jtInxfFsXG9katyQHypPnIDgBAwuxEygTL4x49vRp8WZ+YVkl9GCRM10vhXLu M/EiWrgeLhG6boFJU8HVM24fX7CGkcE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-MsmtmOWBNRCUnmdwqvBdVA-1; Fri, 02 Dec 2022 08:10:32 -0500 X-MC-Unique: MsmtmOWBNRCUnmdwqvBdVA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 81146800159; Fri, 2 Dec 2022 13:10:31 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.79]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2639840C94AA; Fri, 2 Dec 2022 13:10:31 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id F15A41801560; 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 10/14] OvmfPkg/PlatformPei: remove mPlatformInfoHob Date: Fri, 2 Dec 2022 14:10:05 +0100 Message-Id: <20221202131009.3190040-11-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.2 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. Let BuildPlatformInfoHob() allocate and return PlatformInfoHob instead. Signed-off-by: Gerd Hoffmann --- OvmfPkg/PlatformPei/Platform.h | 4 +- OvmfPkg/PlatformPei/Platform.c | 71 ++++++++++++++++++---------------- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h index 0c0558f0626c..86f603ff649c 100644 --- a/OvmfPkg/PlatformPei/Platform.h +++ b/OvmfPkg/PlatformPei/Platform.h @@ -13,8 +13,6 @@ #include #include -extern EFI_HOB_PLATFORM_INFO mPlatformInfoHob; - VOID AddressWidthInitialization ( IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob @@ -98,7 +96,7 @@ IntelTdxInitialize ( /** * @brief Builds PlatformInfo Hob */ -VOID +EFI_HOB_PLATFORM_INFO * BuildPlatformInfoHob ( VOID ); diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index d8c4499804fb..ebce2ba1290e 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -41,8 +41,6 @@ #include "Platform.h" -EFI_HOB_PLATFORM_INFO mPlatformInfoHob = { 0 }; - EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = { { EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, @@ -305,12 +303,18 @@ MaxCpuCountInitialization ( /** * @brief Builds PlatformInfo Hob */ -VOID +EFI_HOB_PLATFORM_INFO * BuildPlatformInfoHob ( VOID ) { - BuildGuidDataHob (&gUefiOvmfPkgPlatformInfoGuid, &mPlatformInfoHob, sizeof (EFI_HOB_PLATFORM_INFO)); + EFI_HOB_PLATFORM_INFO PlatformInfoHob; + EFI_HOB_GUID_TYPE *GuidHob; + + ZeroMem (&PlatformInfoHob, sizeof PlatformInfoHob); + BuildGuidDataHob (&gUefiOvmfPkgPlatformInfoGuid, &PlatformInfoHob, sizeof (EFI_HOB_PLATFORM_INFO)); + GuidHob = GetFirstGuidHob (&gUefiOvmfPkgPlatformInfoGuid); + return (EFI_HOB_PLATFORM_INFO *)GET_GUID_HOB_DATA (GuidHob); } /** @@ -329,69 +333,70 @@ InitializePlatform ( IN CONST EFI_PEI_SERVICES **PeiServices ) { - EFI_STATUS Status; + EFI_HOB_PLATFORM_INFO *PlatformInfoHob; + EFI_STATUS Status; DEBUG ((DEBUG_INFO, "Platform PEIM Loaded\n")); + PlatformInfoHob = BuildPlatformInfoHob (); - mPlatformInfoHob.SmmSmramRequire = FeaturePcdGet (PcdSmmSmramRequire); - mPlatformInfoHob.SevEsIsEnabled = MemEncryptSevEsIsEnabled (); - mPlatformInfoHob.PcdPciMmio64Size = PcdGet64 (PcdPciMmio64Size); - mPlatformInfoHob.DefaultMaxCpuNumber = PcdGet32 (PcdCpuMaxLogicalProcessorNumber); + PlatformInfoHob->SmmSmramRequire = FeaturePcdGet (PcdSmmSmramRequire); + PlatformInfoHob->SevEsIsEnabled = MemEncryptSevEsIsEnabled (); + PlatformInfoHob->PcdPciMmio64Size = PcdGet64 (PcdPciMmio64Size); + PlatformInfoHob->DefaultMaxCpuNumber = PcdGet32 (PcdCpuMaxLogicalProcessorNumber); PlatformDebugDumpCmos (); if (QemuFwCfgS3Enabled ()) { DEBUG ((DEBUG_INFO, "S3 support was detected on QEMU\n")); - mPlatformInfoHob.S3Supported = TRUE; + PlatformInfoHob->S3Supported = TRUE; Status = PcdSetBoolS (PcdAcpiS3Enable, TRUE); ASSERT_EFI_ERROR (Status); } - S3Verification (&mPlatformInfoHob); - BootModeInitialization (&mPlatformInfoHob); + S3Verification (PlatformInfoHob); + BootModeInitialization (PlatformInfoHob); // // Query Host Bridge DID // - mPlatformInfoHob.HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID); - AddressWidthInitialization (&mPlatformInfoHob); + PlatformInfoHob->HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID); + AddressWidthInitialization (PlatformInfoHob); - MaxCpuCountInitialization (&mPlatformInfoHob); + MaxCpuCountInitialization (PlatformInfoHob); - if (mPlatformInfoHob.SmmSmramRequire) { - Q35BoardVerification (&mPlatformInfoHob); - Q35TsegMbytesInitialization (&mPlatformInfoHob); - Q35SmramAtDefaultSmbaseInitialization (&mPlatformInfoHob); + if (PlatformInfoHob->SmmSmramRequire) { + Q35BoardVerification (PlatformInfoHob); + Q35TsegMbytesInitialization (PlatformInfoHob); + Q35SmramAtDefaultSmbaseInitialization (PlatformInfoHob); } - PublishPeiMemory (&mPlatformInfoHob); + PublishPeiMemory (PlatformInfoHob); - PlatformQemuUc32BaseInitialization (&mPlatformInfoHob); + PlatformQemuUc32BaseInitialization (PlatformInfoHob); - InitializeRamRegions (&mPlatformInfoHob); + InitializeRamRegions (PlatformInfoHob); - if (mPlatformInfoHob.BootMode != BOOT_ON_S3_RESUME) { - if (!mPlatformInfoHob.SmmSmramRequire) { + if (PlatformInfoHob->BootMode != BOOT_ON_S3_RESUME) { + if (!PlatformInfoHob->SmmSmramRequire) { ReserveEmuVariableNvStore (); } - PeiFvInitialization (&mPlatformInfoHob); - MemTypeInfoInitialization (&mPlatformInfoHob); - MemMapInitialization (&mPlatformInfoHob); - NoexecDxeInitialization (&mPlatformInfoHob); + PeiFvInitialization (PlatformInfoHob); + MemTypeInfoInitialization (PlatformInfoHob); + MemMapInitialization (PlatformInfoHob); + NoexecDxeInitialization (PlatformInfoHob); } InstallClearCacheCallback (); - AmdSevInitialize (&mPlatformInfoHob); - if (mPlatformInfoHob.HostBridgeDevId == 0xffff) { - MiscInitializationForMicrovm (&mPlatformInfoHob); + AmdSevInitialize (PlatformInfoHob); + if (PlatformInfoHob->HostBridgeDevId == 0xffff) { + MiscInitializationForMicrovm (PlatformInfoHob); } else { - MiscInitialization (&mPlatformInfoHob); + MiscInitialization (PlatformInfoHob); } IntelTdxInitialize (); InstallFeatureControlCallback (); - BuildPlatformInfoHob (); return EFI_SUCCESS; } -- 2.38.1