From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 908A6740045 for ; Fri, 10 Nov 2023 18:07:03 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=G79mwmu7jC+FfW47UoKdfwaSM9rfKHJb5JNIuSpqPO0=; c=relaxed/simple; d=groups.io; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1699639622; v=1; b=kGqpkJh1bpQ6g2gbxGdp6Yl0p49n9Ql7pR/08FBRjixLH+V+NUvThn+yB2A7SI9c7q3iDUVd So7g9/6JVe59/oH1pUk6bQrmySsRQMuIEcBenKys8OrrsOx/RJbxvoMe3jTEKwPjsBdw8a5qjnJ 8LuKZT37c3t58f19B18QqCNY= X-Received: by 127.0.0.2 with SMTP id AOZiYY7687511xN2Fuw8VIFR; Fri, 10 Nov 2023 10:07:02 -0800 X-Received: from smtp.joursoir.net (smtp.joursoir.net [91.192.102.115]) by mx.groups.io with SMTP id smtpd.web11.34713.1699639620674616228 for ; Fri, 10 Nov 2023 10:07:01 -0800 X-Received: from reeva (unknown [185.23.230.46]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.joursoir.net (Postfix) with ESMTPSA id C7D80411D6; Fri, 10 Nov 2023 21:06:53 +0300 (MSK) Date: Fri, 10 Nov 2023 21:06:48 +0300 From: "Joursoir" To: devel@edk2.groups.io Cc: ray.ni@intel.com, guo.dong@intel.com, benjamin.you@intel.com, maurice.ma@intel.com, sean@starlabs.systems, james.lu@intel.com, gua.guo@intel.com Subject: [edk2-devel] [PATCH 1/1] UefiPayloadPkg: Add SMM variable related HOBs support for SBL Message-ID: <20231110210648.3ae8c424@reeva> MIME-Version: 1.0 Precedence: Bulk 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,chat@joursoir.net List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: APdH6njK5NhXsZvhWfmxI6WOx7686176AA= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=kGqpkJh1; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io When UefiPayloadPkg is compiled with SMM_SUPPORT enabled and VARIABLE_SUPPORT set to SPI, the following HOBs must be available: * gSmmRegisterInfoGuid * gEfiSmmSmramMemoryGuid * gSpiFlashInfoGuid * gNvVariableInfoGuid * gS3CommunicationGuid Migrate these HOBs information from the bootloader HOB space to the UEFI payload HOB space. Parse them in misc function, so it won't fail if there would be no HOBs. This patch was tested on Slim Bootloader with latest UEFI payload, and it worked as expected. Signed-off-by: Alexander Goncharov --- .../Library/SblParseLib/SblParseLib.c | 109 ++++++++++++++++-- .../Library/SblParseLib/SblParseLib.inf | 5 + 2 files changed, 107 insertions(+), 7 deletions(-) diff --git a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c b/UefiPayload= Pkg/Library/SblParseLib/SblParseLib.c index d88238bfdc..a4cf90618b 100644 --- a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c +++ b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c @@ -16,6 +16,11 @@ #include #include #include +#include +#include +#include +#include +#include =20 /** This function retrieves the parameter base address from boot loader. @@ -264,6 +269,17 @@ ParseMiscInfo ( RETURN_STATUS Status; UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *BlRootBridgesHob; UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PldRootBridgesHob; + PLD_SMM_REGISTERS *BlSmmRegisterHob; + PLD_SMM_REGISTERS *PldSmmRegisterHob; + EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *BlSmmMemoryHob; + EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *PldSmmMemoryHob; + SPI_FLASH_INFO *BlSpiFlashInfoHob; + SPI_FLASH_INFO *PldSpiFlashInfoHob; + NV_VARIABLE_INFO *BlNvVariableHob; + NV_VARIABLE_INFO *PldNvVariableHob; + PLD_S3_COMMUNICATION *BlS3CommunicationHob; + PLD_S3_COMMUNICATION *PldS3CommunicationHob; + UINT32 Length; =20 Status =3D RETURN_NOT_FOUND; BlRootBridgesHob =3D (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *)GetGuidHobDat= aFromSbl ( @@ -278,13 +294,92 @@ ParseMiscInfo ( BlRootBridgesHob->Header.Length ); ASSERT (PldRootBridgesHob !=3D NULL); - if (PldRootBridgesHob !=3D NULL) { - CopyMem (PldRootBridgesHob, BlRootBridgesHob, BlRootBridgesHob->Head= er.Length); - DEBUG ((DEBUG_INFO, "Create PCI root bridge info guid hob\n")); - Status =3D RETURN_SUCCESS; - } else { - Status =3D RETURN_OUT_OF_RESOURCES; - } + if (PldRootBridgesHob =3D=3D NULL) + return RETURN_OUT_OF_RESOURCES; + + CopyMem (PldRootBridgesHob, BlRootBridgesHob, BlRootBridgesHob->Header= .Length); + DEBUG ((DEBUG_INFO, "Create PCI root bridge info guid hob\n")); + Status =3D RETURN_SUCCESS; + } + + // + // Create SMM info hob. + // + BlSmmRegisterHob =3D (PLD_SMM_REGISTERS *)GetGuidHobDataFromSbl (&gSmmRe= gisterInfoGuid); + if (BlSmmRegisterHob !=3D NULL) { + Length =3D sizeof (PLD_SMM_REGISTERS) + 5 * sizeof (PLD_GENERIC_REGIST= ER); + PldSmmRegisterHob =3D BuildGuidHob (&gSmmRegisterInfoGuid, Length); + ASSERT (PldSmmRegisterHob !=3D NULL); + if (PldSmmRegisterHob =3D=3D NULL) + return RETURN_OUT_OF_RESOURCES; + + CopyMem (PldSmmRegisterHob, BlSmmRegisterHob, Length); + DEBUG ((DEBUG_INFO, "Created SMM info hob\n")); + Status =3D RETURN_SUCCESS; + } + + // + // Create SMM memory hob. + // + BlSmmMemoryHob =3D (EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *)GetGuidHobDataFromS= bl (&gEfiSmmSmramMemoryGuid); + if (BlSmmMemoryHob !=3D NULL) { + Length =3D sizeof (EFI_SMRAM_HOB_DESCRIPTOR_BLOCK) + sizeof (EFI_SMRAM= _DESCRIPTOR); + PldSmmMemoryHob =3D BuildGuidHob (&gEfiSmmSmramMemoryGuid, Length); + ASSERT (PldSmmMemoryHob !=3D NULL); + if (PldSmmMemoryHob =3D=3D NULL) + return RETURN_OUT_OF_RESOURCES; + + CopyMem (PldSmmMemoryHob, BlSmmMemoryHob, Length); + DEBUG ((DEBUG_INFO, "Created SMM memory hob\n")); + Status =3D RETURN_SUCCESS; + } + + // + // Create SPI flash info hob. + // + BlSpiFlashInfoHob =3D (SPI_FLASH_INFO *)GetGuidHobDataFromSbl (&gSpiFlas= hInfoGuid); + if (BlSpiFlashInfoHob !=3D NULL) { + Length =3D sizeof (SPI_FLASH_INFO); + PldSpiFlashInfoHob =3D BuildGuidHob (&gSpiFlashInfoGuid, Length); + ASSERT (PldSpiFlashInfoHob !=3D NULL); + if (PldSpiFlashInfoHob =3D=3D NULL) + return RETURN_OUT_OF_RESOURCES; + + CopyMem (PldSpiFlashInfoHob, BlSpiFlashInfoHob, Length); + DEBUG ((DEBUG_INFO, "Created SPI flash info hob\n")); + Status =3D RETURN_SUCCESS; + } + + // + // Create SPI flash variable info hob. + // + BlNvVariableHob =3D (NV_VARIABLE_INFO *)GetGuidHobDataFromSbl (&gNvVaria= bleInfoGuid); + if (BlNvVariableHob !=3D NULL) { + Length =3D sizeof (NV_VARIABLE_INFO); + PldNvVariableHob =3D BuildGuidHob (&gNvVariableInfoGuid, Length); + ASSERT (PldNvVariableHob !=3D NULL); + if (PldNvVariableHob =3D=3D NULL) + return RETURN_OUT_OF_RESOURCES; + + CopyMem (PldNvVariableHob, BlNvVariableHob, Length); + DEBUG ((DEBUG_INFO, "Created SPI flash variable info hob\n")); + Status =3D RETURN_SUCCESS; + } + + // + // Create SMM S3 communication hob. + // + BlS3CommunicationHob =3D (PLD_S3_COMMUNICATION *)GetGuidHobDataFromSbl (= &gS3CommunicationGuid); + if (BlS3CommunicationHob !=3D NULL) { + Length =3D sizeof (PLD_S3_COMMUNICATION); + PldS3CommunicationHob =3D BuildGuidHob (&gS3CommunicationGuid, Length)= ; + ASSERT (PldS3CommunicationHob !=3D NULL); + if (PldS3CommunicationHob =3D=3D NULL) + return RETURN_OUT_OF_RESOURCES; + + CopyMem (PldS3CommunicationHob, BlS3CommunicationHob, Length); + DEBUG ((DEBUG_INFO, "Created SMM S3 communication hob\n")); + Status =3D RETURN_SUCCESS; } =20 return Status; diff --git a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf b/UefiPaylo= adPkg/Library/SblParseLib/SblParseLib.inf index f83a10ccd8..1c77d86a86 100644 --- a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf +++ b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf @@ -41,6 +41,11 @@ gEfiGraphicsInfoHobGuid gEfiGraphicsDeviceInfoHobGuid gUniversalPayloadPciRootBridgeInfoGuid + gSmmRegisterInfoGuid + gEfiSmmSmramMemoryGuid + gSpiFlashInfoGuid + gNvVariableInfoGuid + gS3CommunicationGuid =20 [Pcd] gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter --=20 2.42.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 (#111051): https://edk2.groups.io/g/devel/message/111051 Mute This Topic: https://groups.io/mt/102512104/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-