From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::d41; helo=mail-io1-xd41.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 47433211A3227 for ; Thu, 3 Jan 2019 03:03:22 -0800 (PST) Received: by mail-io1-xd41.google.com with SMTP id l14so26715560ioj.5 for ; Thu, 03 Jan 2019 03:03:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eFJ+fTi6ePVVScpZDI5a/q9DO+F9qsFtOBXwxXC+Pow=; b=IeZTu94FLWZX5bhmMQVbkIR7H4rPvD61NiHSA/o8VsyurZXw+cfdjdCaOmuiCDYMs1 dBaF9ADjuT/l/T2YNfHJ5LPaSpBC9HTCpQezywiZ6y5IsXku4XMiWsCNvGErj3/0llu6 OBq4wNEZzA4mGNQYmyQGf5HMbx4kqPPRu/JKc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eFJ+fTi6ePVVScpZDI5a/q9DO+F9qsFtOBXwxXC+Pow=; b=UA2xzm4o8D+dXU2eb6h3nRoD86cErnYcBdybEpBVzGvqPe+NDI86mYZAjpDIoJF94L B0zRMs3hiylxKz2mLG7m4BQeq46zu2G96UoBzU49zWb4ghoCdTWTF6oRKNTkqKXVvnFK +iGAn+POd9jJ6xwm3qlV2o/pdm4XnMvUOgLBB4FtV0S3SLxXhfdP+EirKhWKmuF0EuLa MwWdvFRUxBmshdqH0F4oEyAztHasIxR9gFMJcCsB8uvizikoQN8qq66jYrYjAvhfDlgu k99lK6EZXYgb4id1+JbgZNBcl6Tq/WL8jmvrBJiZJsccDUtjxIKxPlBNKwLIvXJCVm5l Jg8g== X-Gm-Message-State: AJcUukeOUtTY0AK9BsnE10Cl/Ve4n3J1UZls7fjq/PxYIII+a8cIPHeA KDL9yBkw18+iVcxZhTy1PgVR2lyAIsaEeDZBCLyblw== X-Google-Smtp-Source: ALg8bN7bC15d1cd/oQRyPoqhYFTsU/5ZkO73RoNBGs1+KQ99gPF7QTct6IlxJp/xfXXGc0uUGet3fwzNQey4Q7nH2OI= X-Received: by 2002:a5e:c206:: with SMTP id v6mr16511323iop.60.1546513401415; Thu, 03 Jan 2019 03:03:21 -0800 (PST) MIME-Version: 1.0 References: <1546434828-24405-1-git-send-email-jagadeesh.ujja@arm.com> <1546434828-24405-5-git-send-email-jagadeesh.ujja@arm.com> In-Reply-To: <1546434828-24405-5-git-send-email-jagadeesh.ujja@arm.com> From: Ard Biesheuvel Date: Thu, 3 Jan 2019 12:03:10 +0100 Message-ID: To: Jagadeesh Ujja , "Gao, Liming" , "Kinney, Michael D" , Laszlo Ersek Cc: "edk2-devel@lists.01.org" , "Zhang, Chao B" , Leif Lindholm , Achin Gupta , Supreeth Venkatesh , Jian J Wang Subject: Re: [PATCH v2 04/11] MdePkg/Include: Add StandaloneMmServicesTableLib library 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: Thu, 03 Jan 2019 11:03:22 -0000 Content-Type: text/plain; charset="UTF-8" On Wed, 2 Jan 2019 at 14:14, Jagadeesh Ujja wrote: > > Some of the existing DXE drivers can be refactored to execute within > the Standalone MM execution environment as well. Allow such drivers to > get access to the Standalone MM services tables. > > Add a mechanism to determine the execution mode is required. > i.e, in MM or non-MM > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jagadeesh Ujja > --- > MdePkg/Include/Library/StandaloneMmServicesTableLib.h | 43 ++++++++++++++++++++ > MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c | 39 ++++++++++++++++++ > MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf | 36 ++++++++++++++++ > MdePkg/MdePkg.dec | 4 ++ > 4 files changed, 122 insertions(+) > OK, so since the PI spec only refers to MM mode now, this library class should be MmServicesTableLib|Include/Library/MmServicesTableLib.h with an implementation in MdeModulePkg that exposes the deprecated SMM system table as the MM system table. In StandaloneMmPkg, we can add an implementation that exposes the standalone MM system table. (They are binary compatible, so it is just a matter of casting one pointer to the other) With this in place, we can go ahead and update FaultTolerantWrite and Variable SMM driver to switch from SmmServicesTableLib to MmServicesTableLib. This will require existing x86 platforms to define a new library class resolution for MmServicesTableLib, referring to the implementation in MdeModulePkg. This is unfortunate, but it is an unavoidable consequence of the PI spec changes. Remaining question is what to do with InSmm() ... > diff --git a/MdePkg/Include/Library/StandaloneMmServicesTableLib.h b/MdePkg/Include/Library/StandaloneMmServicesTableLib.h > new file mode 100644 > index 0000000..3a27ac4 > --- /dev/null > +++ b/MdePkg/Include/Library/StandaloneMmServicesTableLib.h > @@ -0,0 +1,43 @@ > +/** @file > + Provides a service to retrieve a pointer to the Standalone MM Services Table. > + Provides a InMm implementation for RUNTIME DXE drivers > + > +Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
> +Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
> + > +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. > + > +**/ > + > +#ifndef __MM_SERVICES_TABLE_LIB_H__ > +#define __MM_SERVICES_TABLE_LIB_H__ > + > +#include > +#include > + > +extern EFI_MM_SYSTEM_TABLE *gMmst; > + > +/** > + This function allows the caller to determine if the driver is executing in > + Standalone Management Mode(SMM). > + > + This function returns TRUE if the driver is executing in SMM and FALSE if the > + driver is not executing in SMM. > + > + @retval TRUE The driver is executing in Standalone Management Mode (SMM). > + @retval FALSE The driver is not executing in Standalone Management Mode (SMM). > + > +**/ > +BOOLEAN > +EFIAPI > +InMm ( > + VOID > + ); > + > +#endif > diff --git a/MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c b/MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c > new file mode 100644 > index 0000000..6f37cd8 > --- /dev/null > +++ b/MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c > @@ -0,0 +1,39 @@ > +/** @file > + Standalone MM Services Table Library. > + > + Copyright (c) 2018, ARM Limited. All rights reserved.
> + > + 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 > +#include > + > +EFI_MM_SYSTEM_TABLE *gMmst = NULL; > + > +/** > + This function allows the caller to determine if the driver is executing in > + Standalone Management Mode(SMM). > + > + This function returns TRUE if the driver is executing in SMM and FALSE if the > + driver is not executing in SMM. > + > + @retval TRUE The driver is executing in Standalone Management Mode (SMM). > + @retval FALSE The driver is not executing in Standalone Management Mode (SMM). > + > +**/ > +BOOLEAN > +EFIAPI > +InMm ( > + VOID > + ) > +{ > + return FALSE; > +} > diff --git a/MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf b/MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf > new file mode 100644 > index 0000000..c94b605 > --- /dev/null > +++ b/MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf > @@ -0,0 +1,36 @@ > +## @file > +# Provides StandaloneMmServicesTableLib. > +# > +# Copyright (c) 2018, ARM Limited. All rights reserved.
> +# > +# 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 = 0x00010005 > + BASE_NAME = StandaloneMmServicesTableLib > + FILE_GUID = 8099cfbf-9564-4c9b-9052-e66b1da88930 > + MODULE_TYPE = DXE_RUNTIME_DRIVER > + VERSION_STRING = 1.0 > + LIBRARY_CLASS = StandaloneMmServicesTableLib |DXE_RUNTIME_DRIVER DXE_SMM_DRIVER MM_STANDALONE > + > +# > +# The following information is for reference only and not required by the build tools. > +# > +# VALID_ARCHITECTURES = IA32 X64 AARCH64 > +# > + > +[Sources] > + StandaloneMmServicesTableLib.c > + > +[Packages] > + MdePkg/MdePkg.dec > + > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec > index 712bd46..ec9b266 100644 > --- a/MdePkg/MdePkg.dec > +++ b/MdePkg/MdePkg.dec > @@ -243,6 +243,10 @@ > ## > SafeIntLib|Include/Library/SafeIntLib.h > > + ## @libraryclass Provides a service to retrieve a pointer to the Standalone MM Services Table. > + # Only available to MM_STANDALONE module types. > + MmServicesTableLib|Include/Library/StandaloneMmServicesTableLib.h > + > [LibraryClasses.IA32, LibraryClasses.X64] > ## @libraryclass Abstracts both S/W SMI generation and detection. > ## > -- > 2.7.4 >