From patchwork Thu Jan 3 18:28:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 154738 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp950335ljp; Thu, 3 Jan 2019 10:29:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN6UFjiidsqF1vegbSfrjNIPhJH6HaRDLU2TDw7PVMlBw7kyGTA93KjIeJGzNubv5VW1yRLg X-Received: by 2002:a25:1883:: with SMTP id 125mr18606642yby.161.1546540141916; Thu, 03 Jan 2019 10:29:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546540141; cv=none; d=google.com; s=arc-20160816; b=axCAp6ggzzCQtBTti8GeiMzvDjUcJVEdBiGf9hGaeMHloxIeFaFcz/ELYOsFQ/l6GP 33btXaIdgKs2+vfTnvc03d5IHfpBZmIGehcVlsiA4gIKWfmiXtRCI7/CEvcBP/z8DByw wtWl1xM9jzz5D090DkjqyEQJWk8HHYbWpt0xfCg10MBgpQZ7FOfV8axWzOOjLJ26dtvz f6NDVxvbIjSKQ91cDCxjgsozVeuZj7Hi2TXMds3DGPSXhRuoKe3ZF2t30q1s/2vmsPg/ W7u5yyxwVreW4fxiz4hI7xw53d0w9UmPPXiI44c48zgugAWiTxtcuXzy4K13ZTw+SfVu xsGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=cYusNjckeyTvhB7JY0nPL33utP85Krkgm8s6GpjXBB4=; b=uqqG5TVZHsnUL/7R4s/7hW02Q3m6u+V9CC40g1mflzCHrHBifA3M4NIYnlTg92DRzq 7y5I6BOaOke6rv9gksVg+pcfCjbFFhktQOxtXX9ND+6w1TXAZwyFxUKOnJTWadN/AfbC 9eKm0KIGzXnoafJwQGtd0w4diJoLMH2ds6ZDt6BMSuZVbIORwUHFjjcjBCZZdUEwZTvh kSycbnzUJie4yuDUpf+RvsV27anENO+TjAXkOfx1QSbM2hmkOTg7ex9Nh8iFcrxC7ozC ShF39IYvtwg6dXQ7aWPAoSZWL0mKSWKOiHNE5Y7WWCJCeCcGFtnpkJFetBDFaLFSUerA fWEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YrSLKMJO; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 1si9511009ybd.370.2019.01.03.10.29.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Jan 2019 10:29:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YrSLKMJO; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3BF5B211ADA48; Thu, 3 Jan 2019 10:28:57 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::544; helo=mail-ed1-x544.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) (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 676A4211ADA3B for ; Thu, 3 Jan 2019 10:28:55 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id b3so29889468ede.1 for ; Thu, 03 Jan 2019 10:28:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MBiXcKoD/ZIdpRcJu1r2/wb9917ICJJbHxvZhq7nYhE=; b=YrSLKMJO6nz2nfmu7Ib/wx7AuCDMhOrM1jwaq83OqKQexnmapVuYx0tuTcvCCAUeTZ QviWuIOZ+mP0BBdUqqJ/ZjL7ce8BkajVADvyjqZ6qaJM26BFQJ2pCybjseXrxcAJf7Bo bDkx6DYvWefwmyiRTy5szVFhGFT04BhVdJV6Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MBiXcKoD/ZIdpRcJu1r2/wb9917ICJJbHxvZhq7nYhE=; b=eM9kylTg8TkTczSoaPgSBbLFy5D+sMWE9HsyHj14HJ6Xb6QH9x3IAQ/RYKbGEAl2PZ yzhDIvORVWYmVJXTGIJHOt4Y+7kTCR53DFigD4zVXMyV+X7kgGXDzgLooe1B3C/RSOe5 dV30hAeFs83CAJVzO4Nx5+lYTD3XHqUDoXRfnu9K78vd1uFjiTKRGI9bl+0A5bFza5Hw LTfhKoQx3d4K/0nzpwFQg8kfa2M4qmkfkQSCnk7xATVXVkQSg4cttNoykMNFFuigiG1D hB0sU0MxvqViMkvRXlFBQTeXjxq2KMgXrC/kFwecN/zxGUYHGFfy8gFhLNnMwFr1X/6N qJgQ== X-Gm-Message-State: AA+aEWZHsff2y89Gwvc+T95I8voWohtgyeNa89OWbdrfxMrFSmMOSFCn SeNcSjhuAU04hVwn2j9R1v1z+ELjiyHc5w== X-Received: by 2002:a50:a844:: with SMTP id j62mr45121370edc.2.1546540132452; Thu, 03 Jan 2019 10:28:52 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:704e:c241:dc88:597d]) by smtp.gmail.com with ESMTPSA id a11sm25707206edc.28.2019.01.03.10.28.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Jan 2019 10:28:51 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 3 Jan 2019 19:28:21 +0100 Message-Id: <20190103182825.32231-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190103182825.32231-1-ard.biesheuvel@linaro.org> References: <20190103182825.32231-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 2/6] MdePkg: implement MmServicesTableLib based on traditional SMM 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: , Cc: Hao Wu , Liming Gao , Michael D Kinney , Laszlo Ersek MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- 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(+) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel 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.
+ Copyright (c) 2018, Linaro, Ltd. 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 +#include +#include + +EFI_MM_SYSTEM_TABLE *gMmst = NULL; + +/** + The constructor function caches the pointer of SMM Services Table. + + @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.
+# Copyright (c) 2018, Linaro, Ltd. 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 = 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. +// +// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+// Copyright (c) 2018, Linaro, Ltd. 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. +// +// **/ + + +#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