From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6D0D0211B7F79 for ; Tue, 15 Jan 2019 19:29:53 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jan 2019 19:29:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,484,1539673200"; d="scan'208";a="312166346" Received: from shzintpr03.sh.intel.com (HELO [10.253.24.32]) ([10.239.4.100]) by fmsmga005.fm.intel.com with ESMTP; 15 Jan 2019 19:29:51 -0800 To: Ard Biesheuvel , edk2-devel@lists.01.org Cc: Hao Wu , Liming Gao , Michael D Kinney , Laszlo Ersek , star.zeng@intel.com References: <20190114132758.24054-1-ard.biesheuvel@linaro.org> <20190114132758.24054-6-ard.biesheuvel@linaro.org> From: "Zeng, Star" Message-ID: <8cbf777c-5f28-8c51-461b-cce2413f06a5@intel.com> Date: Wed, 16 Jan 2019 11:29:20 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190114132758.24054-6-ard.biesheuvel@linaro.org> Subject: Re: [PATCH v2 05/17] MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jan 2019 03:29:53 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Some minor comments. With them handled, Reviewed-by: Star Zeng Thanks, Star On 2019/1/14 21:27, Ard Biesheuvel wrote: > In preparation of providing a standalone MM based FTW driver, move > the existing SMM driver to the new MM services table, and factor out > some pieces that are specific to the traditional driver, mainly > related to the use of UEFI boot services, which are not accessible > to standalone MM drivers. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > Reviewed-by: Jian J Wang > Regression-tested-by: Laszlo Ersek > --- > MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf | 5 +- > MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h | 23 ++++- > MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h | 34 +++++++ > MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c | 31 ++++++ > MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c | 53 ++++------ > MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c | 106 ++++++++++++++++++++ > MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c | 10 +- > 7 files changed, 219 insertions(+), 43 deletions(-) > [Trimmed] > > +/** > + Entry point of the module > +**/ The block should be matched with the MmFaultTolerantWriteInitialize implementation in FaultTolerantWriteSmm.c. But not SmmFaultTolerantWriteInitialize implementation in FaultTolerantWriteTraditionalMm.c > +EFI_STATUS > +MmFaultTolerantWriteInitialize ( > + VOID > + ); > + > +/** > + This function checks if the buffer is valid per processor architecture and > + does not overlap with SMRAM. > + > + @param Buffer The buffer start address to be checked. > + @param Length The buffer length to be checked. > + > + @retval TRUE This buffer is valid per processor architecture and does not > + overlap with SMRAM. > + @retval FALSE This buffer is not valid per processor architecture or overlaps > + with SMRAM. > +**/ > +BOOLEAN > +FtwSmmIsBufferOutsideSmmValid ( > + IN EFI_PHYSICAL_ADDRESS Buffer, > + IN UINT64 Length > + ); > + > +/** > + Notify the system that the SMM FTW driver is ready > +**/ > +VOID > +FtwNotifySmmReady ( > + VOID > + ); > + > #endif > diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c > index 094e40f9d86c..24e507104bbe 100644 > --- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c > +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c > @@ -51,6 +51,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. [Trimmed] > > **/ > EFI_STATUS > -EFIAPI > -SmmFaultTolerantWriteInitialize ( > - IN EFI_HANDLE ImageHandle, > - IN EFI_SYSTEM_TABLE *SystemTable The comments block should be also removed for these two parameters. > +MmFaultTolerantWriteInitialize ( > + VOID > ) > { > EFI_STATUS Status; > - VOID *SmmEndOfDxeRegistration; > + VOID *MmEndOfDxeRegistration; > > // > // Allocate private data structure for SMM FTW protocol and do some initialization > @@ -634,17 +623,17 @@ SmmFaultTolerantWriteInitialize ( > // > // Register EFI_SMM_END_OF_DXE_PROTOCOL_GUID notify function. > // > - Status = gSmst->SmmRegisterProtocolNotify ( > - &gEfiSmmEndOfDxeProtocolGuid, > - SmmEndOfDxeCallback, > - &SmmEndOfDxeRegistration > + Status = gMmst->MmRegisterProtocolNotify ( > + &gEfiMmEndOfDxeProtocolGuid, > + MmEndOfDxeCallback, > + &MmEndOfDxeRegistration > ); > ASSERT_EFI_ERROR (Status); > > // > // Register FvbNotificationEvent () notify function. > // > - Status = gSmst->SmmRegisterProtocolNotify ( > + Status = gMmst->MmRegisterProtocolNotify ( > &gEfiSmmFirmwareVolumeBlockProtocolGuid, > FvbNotificationEvent, > &mFvbRegistration > diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c > new file mode 100644 > index 000000000000..78351199d3f1 > --- /dev/null > +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c > @@ -0,0 +1,106 @@ [Trimmed] > + > +/** > + Entry point of the module The comments block should have description for the two parameters. Thanks, Star > +**/ > +EFI_STATUS > +EFIAPI > +SmmFaultTolerantWriteInitialize ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + return MmFaultTolerantWriteInitialize (); > +} > diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c > index 50d3421b88bb..d09e9719cf05 100644 > --- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c > +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c > @@ -29,8 +29,6 @@ InitializeLocalWorkSpaceHeader ( > VOID > ) > { > - EFI_STATUS Status; > - > // > // Check signature with gEdkiiWorkingBlockSignatureGuid. > // > @@ -64,12 +62,8 @@ InitializeLocalWorkSpaceHeader ( > // > // Calculate the Crc of woking block header > // > - Status = gBS->CalculateCrc32 ( > - &mWorkingBlockHeader, > - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER), > - &mWorkingBlockHeader.Crc > - ); > - ASSERT_EFI_ERROR (Status); > + mWorkingBlockHeader.Crc = FtwCalculateCrc32 (&mWorkingBlockHeader, > + sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER)); > > mWorkingBlockHeader.WorkingBlockValid = FTW_VALID_STATE; > mWorkingBlockHeader.WorkingBlockInvalid = FTW_INVALID_STATE; >