public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zeng, Star" <star.zeng@intel.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>, edk2-devel@lists.01.org
Cc: Hao Wu <hao.a.wu@intel.com>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Laszlo Ersek <lersek@redhat.com>,
	Liming Gao <liming.gao@intel.com>,
	star.zeng@intel.com
Subject: Re: [PATCH 2/6] MdePkg: implement MmServicesTableLib based on traditional SMM
Date: Thu, 10 Jan 2019 14:54:10 +0800	[thread overview]
Message-ID: <02657425-ab44-07e2-f35a-81cd12379a2b@intel.com> (raw)
In-Reply-To: <9bfb4d7c-3d4e-c05c-49a1-1959ddc902e3@intel.com>

Hi Ard,

Another minor feedback.

On 2019/1/10 14:14, Zeng, Star wrote:
> Hi Ard,
> 
> Some minor feedback added inline.
> 
> On 2019/1/4 2:28, Ard Biesheuvel wrote:
>> The definitions of the rebranded MM protocol stack were chosen such
>> that the existing SMM based core drivers can be reused. So let's
>> implement MmServicesTableLib based on gEfiMmBaseProtocolGuid, which
>> is simply gEfiSmmBase2ProtocolGuid under the hood.
> 
> Good commit log.
> 
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> ---
>>   MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c   | 63 
>> ++++++++++++++++++++
>>   MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf | 45 
>> ++++++++++++++
>>   MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni | 22 +++++++
>>   MdePkg/MdePkg.dsc                                        |  1 +
>>   4 files changed, 131 insertions(+)
>>
>> diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c 
>> b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c
>> new file mode 100644
>> index 000000000000..f41d25e59805
>> --- /dev/null
>> +++ b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c
>> @@ -0,0 +1,63 @@
>> +/** @file
>> +  MM Services Table Library.
>> +
>> +  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
>> +  Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
>> +  This program and the accompanying materials
>> +  are licensed and made available under the terms and conditions of 
>> the BSD License
>> +  which accompanies this distribution.  The full text of the license 
>> may be found at
>> +  http://opensource.org/licenses/bsd-license.php.
>> +
>> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS 
>> OR IMPLIED.
>> +
>> +**/
>> +
>> +#include <PiMm.h>
>> +#include <Protocol/MmBase.h>
>> +#include <Library/MmServicesTableLib.h>
>> +#include <Library/DebugLib.h>
>> +
>> +EFI_MM_SYSTEM_TABLE   *gMmst             = NULL;
>> +
>> +/**
>> +  The constructor function caches the pointer of SMM Services Table.

Use "MM" instead of "SMM" here?

Thanks,
Star

>> +
>> +  @param  ImageHandle   The firmware allocated handle for the EFI image.
>> +  @param  SystemTable   A pointer to the EFI System Table.
>> +
>> +  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.
>> +
>> +**/
>> +EFI_STATUS
>> +EFIAPI
>> +MmServicesTableLibConstructor (
>> +  IN EFI_HANDLE        ImageHandle,
>> +  IN EFI_SYSTEM_TABLE  *SystemTable
>> +  )
>> +{
>> +  EFI_STATUS              Status;
>> +  EFI_MM_BASE_PROTOCOL    *InternalMmBase;
>> +
>> +  InternalMmBase = NULL;
>> +  //
>> +  // Retrieve MM Base Protocol,  Do not use gBS from 
>> UefiBootServicesTableLib on purpose
>> +  // to prevent inclusion of gBS, gST, and gImageHandle from SMM 
>> Drivers unless the
>> +  // MM driver explicity declares that dependency.
>> +  //
>> +  Status = SystemTable->BootServices->LocateProtocol (
>> +                                        &gEfiMmBaseProtocolGuid,
>> +                                        NULL,
>> +                                        (VOID **)&InternalMmBase
>> +                                        );
>> +  ASSERT_EFI_ERROR (Status);
>> +  ASSERT (InternalMmBase != NULL);
>> +
>> +  //
>> +  // We are in MM, retrieve the pointer to MM System Table
>> +  //
>> +  InternalMmBase->GetMmstLocation (InternalMmBase, &gMmst);
>> +  ASSERT (gMmst != NULL);
>> +
>> +  return EFI_SUCCESS;
>> +}
>> diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf 
>> b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
>> new file mode 100644
>> index 000000000000..4418cc2f1464
>> --- /dev/null
>> +++ b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
>> @@ -0,0 +1,45 @@
>> +## @file
>> +# MM Services Table Library.
>> +#
>> +# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
>> +# Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
>> +#
>> +#  This program and the accompanying materials
>> +#  are licensed and made available under the terms and conditions of 
>> the BSD License
>> +#  which accompanies this distribution. The full text of the license 
>> may be found at
>> +#  http://opensource.org/licenses/bsd-license.php.
>> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS 
>> OR IMPLIED.
>> +#
>> +#
>> +##
>> +
>> +[Defines]
>> +  INF_VERSION                    = 0x0001001B
>> +  BASE_NAME                      = MmServicesTableLib
>> +  MODULE_UNI_FILE                = MmServicesTableLib.uni
>> +  FILE_GUID                      = 9508ECFD-66D1-4B4C-9415-F25F0FFF9E93
>> +  MODULE_TYPE                    = DXE_SMM_DRIVER
>> +  VERSION_STRING                 = 1.0
>> +  LIBRARY_CLASS                  = MmServicesTableLib|DXE_SMM_DRIVER
>> +  PI_SPECIFICATION_VERSION       = 0x00010032
>> +  CONSTRUCTOR                    = MmServicesTableLibConstructor
>> +
>> +#
>> +#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64
>> +#
>> +
>> +[Sources]
>> +  MmServicesTableLib.c
>> +
>> +[Packages]
>> +  MdePkg/MdePkg.dec
>> +
>> +[LibraryClasses]
>> +  DebugLib
>> +
>> +[Protocols]
>> +  gEfiMmBaseProtocolGuid                      ## CONSUMES
>> +
>> +[Depex]
>> +  gEfiMmBaseProtocolGuid
>> diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni 
>> b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni
>> new file mode 100644
>> index 000000000000..2b2c7e14024c
>> --- /dev/null
>> +++ b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni
>> @@ -0,0 +1,22 @@
>> +// /** @file
>> +// MM Services Table Library.
>> +//
>> +// MM Services Table Library.
> 
> How about adding "It implements MmServicesTableLib based on 
> gEfiMmBaseProtocolGuid, which is simply gEfiSmmBase2ProtocolGuid under 
> the hood." here to make the implementation more clear?
> 
> With Jian's feedback and this handled, Reviewed-by: Star Zeng 
> <star.zeng@intel.com>.
> 
> Thanks,
> Star
> 
>> +//
>> +// Copyright (c) 2009 - 2014, Intel Corporation. All rights 
>> reserved.<BR>
>> +// Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
>> +//
>> +// This program and the accompanying materials
>> +// are licensed and made available under the terms and conditions of 
>> the BSD License
>> +// which accompanies this distribution. The full text of the license 
>> may be found at
>> +// http://opensource.org/licenses/bsd-license.php.
>> +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS 
>> OR IMPLIED.
>> +//
>> +// **/
>> +
>> +
>> +#string STR_MODULE_ABSTRACT             #language en-US "MM Services 
>> Table Library"
>> +
>> +#string STR_MODULE_DESCRIPTION          #language en-US "MM Services 
>> Table Library."
>> +
>> diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
>> index d43ffe4deb49..428b14e6a4e0 100644
>> --- a/MdePkg/MdePkg.dsc
>> +++ b/MdePkg/MdePkg.dsc
>> @@ -141,6 +141,7 @@ [Components.IA32, Components.X64]
>>     MdePkg/Library/BaseRngLib/BaseRngLib.inf
>>     MdePkg/Library/SmmPciExpressLib/SmmPciExpressLib.inf
>>     MdePkg/Library/SmiHandlerProfileLibNull/SmiHandlerProfileLibNull.inf
>> +  MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
>>   [Components.EBC]
>>     MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
>>



  parent reply	other threads:[~2019-01-10  6:54 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-03 18:28 [PATCH 0/6] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
2019-01-03 18:28 ` [PATCH] BaseTools/GenFds: permit stripped MM_CORE_STANDALONE binaries Ard Biesheuvel
2019-01-04  5:51   ` Feng, Bob C
2019-01-03 18:28 ` [PATCH 1/6] MdePkg/Include: add MmServicesTableLib header file Ard Biesheuvel
2019-01-10  6:06   ` Zeng, Star
2019-01-03 18:28 ` [PATCH 2/6] MdePkg: implement MmServicesTableLib based on traditional SMM Ard Biesheuvel
2019-01-10  1:35   ` Wang, Jian J
     [not found]   ` <9bfb4d7c-3d4e-c05c-49a1-1959ddc902e3@intel.com>
2019-01-10  6:54     ` Zeng, Star [this message]
2019-01-03 18:28 ` [PATCH 3/6] MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses Ard Biesheuvel
2019-01-10  1:36   ` Wang, Jian J
2019-01-10  6:45   ` Zeng, Star
2019-01-03 18:28 ` [PATCH 4/6] MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version Ard Biesheuvel
2019-01-10  1:41   ` Wang, Jian J
2019-01-10  1:48     ` Wang, Jian J
2019-01-10  6:31     ` Zeng, Star
2019-01-10  6:47   ` Zeng, Star
2019-01-10  7:29     ` Zeng, Star
2019-01-10  7:33       ` Ard Biesheuvel
2019-01-10  7:59         ` Zeng, Star
2019-01-10 12:28           ` Wang, Jian J
2019-01-10 13:03           ` Laszlo Ersek
2019-01-10 16:23             ` Ard Biesheuvel
2019-01-11  2:18               ` Zeng, Star
2019-01-03 18:28 ` [PATCH 5/6] MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses Ard Biesheuvel
2019-01-08 15:38   ` Laszlo Ersek
2019-01-10  2:33     ` Wang, Jian J
2019-01-10  7:17       ` Zeng, Star
2019-01-10  7:19   ` Zeng, Star
2019-01-03 18:28 ` [PATCH 6/6] MdeModulePkg/VariableRuntimeDxe: implement standalone MM version Ard Biesheuvel
2019-01-10  1:49   ` Wang, Jian J
2019-01-10  1:50   ` Wang, Jian J
2019-01-10  7:28   ` Zeng, Star
2019-01-03 19:13 ` [PATCH 0/6] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
2019-01-07 12:44 ` Gao, Liming
2019-01-07 13:05   ` Ard Biesheuvel
2019-01-07 19:08     ` Laszlo Ersek
2019-01-09 13:56     ` Gao, Liming
2019-01-09 15:29       ` Ard Biesheuvel
2019-01-14  2:55         ` Gao, Liming
2019-01-14  8:26           ` Ard Biesheuvel
2019-01-14 15:33             ` Gao, Liming
2019-01-09  9:44 ` Laszlo Ersek
2019-01-09 10:28   ` Ard Biesheuvel
2019-01-09 15:04     ` Laszlo Ersek
2019-01-09 21:46       ` Laszlo Ersek
2019-01-09 21:56         ` Ard Biesheuvel
2019-01-10  8:24 ` Zeng, Star
2019-01-13 15:42 ` Zeng, Star

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=02657425-ab44-07e2-f35a-81cd12379a2b@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox