From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.92.41.55]) by mx.groups.io with SMTP id smtpd.web10.1438.1614715498957057906 for ; Tue, 02 Mar 2021 12:04:59 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=akOWdieM; spf=pass (domain: outlook.com, ip: 40.92.41.55, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HBeM/bI4TyH9+VRBVozmLKzhYXmQ3KnEylFCdck8R4o3r2gFN9W7/2EvGduH3ROEtd5hufAr20QB4/HiiZhJX+JnfuUZsbvZdsVWxEzGr+x+z5wJOSRCmniisio8HF8sprgbHL87drvDiO4D6YwLAOyNM8Lmag24NtXhYlaht8rZjqjZLMPJf63x7RIxDzKdtWBlTW9YBUfebo+2kvTEnz4V/gnfthIdq4sOtVPCfN/OCHywVsmj/qmQL0nQ/IXhCSnPjsuG0EuO7z+mnzEYPy81hTA5gKqoivfcz4dRLgtwkk04a0d25iMuCdZFBYTkrhGlcM97TfcLxY3X5KyqNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RETdGUJgfAlX3ekDhLNMV2p7o3F9Yv2bZpXQhBhVid4=; b=cs3OKIIM2hxl383TbRFaEQPCceLnqmAKZtnsZEfuyOVrN5Qgw+A+zAQq/B+yG8aWW4dyqmVyLCPH9KSyjn+Z5TyFTeBaIhgcFrO1Onbn+oaXtpo+pgLimcu9sp60suSYeKrmN2ei9pem8ZurEUH2rD4mdZjqZxufHDIDHK3wO6htRiRLf6HHjuJZs4P0PRQctLDp8ifdaWtJHhhgYCaFSWSKtv8cRpeEZ5MPKk5y1HPKHFExJ38Kxr1K/tgsY9NKPp4/kYQoWidkkIuPYjNHmBAKbIZqyVwE8STT8MIDlKDSbr8iEj2SUut3odAclNOJ91b+rIctLojSSk6LGCxe+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RETdGUJgfAlX3ekDhLNMV2p7o3F9Yv2bZpXQhBhVid4=; b=akOWdieM+jNivAmtTkKcQKfb7937XcHlBG/UHNnQzxe621fjvpf2lYuYxNJcBciL6dP4o4HBk5d5T/sNHNMYrO3Wo+4PhaEDDx3xLXQ7L06qfPfhqBrkNX0ne/hh6bAwGeYVAzNOeyF4h4g2qLzLtRcrjoFKWPbWkex+iKrJQaJnHn+olFmCPGWYDK8GtOUlbbigOvgbU5uwmVjtIFbUfpjUFvYNYreCENjjg1DMDrBt5PxdhYmi8vus9lywjslHnXcrqduO/o7bVfnrDPn0JPOiohxuxvglxa5moilY83R/QX8rr9sRzqGdQGluD9tY+6MACYdwEp8RZYAhoyaXLA== Received: from BN7NAM10FT040.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::40) by BN7NAM10HT244.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19; Tue, 2 Mar 2021 20:04:57 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:7e8f::49) by BN7NAM10FT040.mail.protection.outlook.com (2a01:111:e400:7e8f::238) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19 via Frontend Transport; Tue, 2 Mar 2021 20:04:57 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:B14E968EB094507835D907C67A5B246B3C722B74F2A89DDEEEED2121DDF2A145;UpperCasedChecksum:D313D71E0FA359F9C774F5D3BABCE06DDF1F4B9BFD36C791F846A686B7BFEA30;SizeAsReceived:7573;Count:47 Received: from MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::d4ee:1260:6f53:3f7b]) by MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::d4ee:1260:6f53:3f7b%7]) with mapi id 15.20.3890.028; Tue, 2 Mar 2021 20:04:57 +0000 From: "Kun Qin" To: devel@edk2.groups.io CC: Michael D Kinney , Liming Gao , Zhiguang Liu , Hao A Wu , Jiewen Yao , Laszlo Ersek Subject: [PATCH v4 1/7] MdePkg: MmUnblockMemoryLib: Added definition and null instance Date: Tue, 2 Mar 2021 12:04:32 -0800 Message-ID: X-Mailer: git-send-email 2.30.0.windows.1 In-Reply-To: <20210302200438.1901-1-kun.q@outlook.com> References: <20210302200438.1901-1-kun.q@outlook.com> X-TMN: [BFXEJyHpdiC6Y1TfAL3mSEGBGgHdJAIB] X-ClientProxiedBy: MWHPR19CA0063.namprd19.prod.outlook.com (2603:10b6:300:94::25) To MWHPR06MB3102.namprd06.prod.outlook.com (2603:10b6:301:3e::35) Return-Path: kun.q@outlook.com X-Microsoft-Original-Message-ID: <20210302200438.1901-2-kun.q@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (50.35.88.161) by MWHPR19CA0063.namprd19.prod.outlook.com (2603:10b6:300:94::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Tue, 2 Mar 2021 20:04:56 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 12700070-d83a-496c-f5e2-08d8ddb67351 X-MS-TrafficTypeDiagnostic: BN7NAM10HT244: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UeDhcOTGSGHzZRbEUiyAcgfVMG3+EbopyoIEFjybpwoz0Km1UjUG+75KJs7LRzg6TZY8HsHjZuD1Kcz27Ukc47oOeCz7vfTCpH6YHHO5UCfSKj4YHkFRvAyRtobQGml+90v9rAHI485kBlqswuZFwxtEPizOzjbjZOiGKR1BbORyBmlx74QhepPF7Ic5V+JvOY2PZNwegW0uF65PcshG/cxzoKqfL6wziCYm6hbsC38XbqC3806u3UupmUBOVSuYR3fxRE45bps+RNV+dhqb4wkK+mFsvDC1kNzCCv7Tw8pqOuvtp0nAbdLaHamRQB4k72GvNS/fUOwyj+wW0poFXSjEgu4oeEDzfVD1QE3ooKpcd9saNFC3iYQVnTDHZNx+9q8naruBwT0mWz8CvEfLNzt+UJ+VyEhNZMv0DDX2jOlM1ePTSh53vmuIt0LuMF8q X-MS-Exchange-AntiSpam-MessageData: bMJqup743jOcU2vdI2URdkaQG8yv45/8y8sP8K6pFE8YtLW0iMja3heWFKZmhJdc6AJHqYy+gzG0/CzzXvVLPOl/CjGWzWj7IfwOyl9sHZST2oTpbe1tAmjLwbSPnnOlOWBhUAcvd1HbuzIIKrU2Xw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 12700070-d83a-496c-f5e2-08d8ddb67351 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2021 20:04:56.4371 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: BN7NAM10FT040.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7NAM10HT244 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3168 This interface provides an abstration layer to allow MM modules to access requested areas that are outside of MMRAM. On MM model that blocks all non-MMRAM accesses, areas requested through this API will be mapped or unblocked for accessibility inside MM environment. For MM modules that need to access regions outside of MMRAMs, the agents that set up these regions are responsible for invoking this API in order for these memory areas to be accessible from inside MM. Example usages: 1. To enable runtime cache feature for variable service, Variable MM module will need to access the allocated runtime buffer. Thus the agent sets up these buffers, VariableSmmRuntimeDxe, will need to invoke this API to make these regions accessible by Variable MM. 2. For TPM ACPI table to communicate to physical presence handler, the corresponding NVS region has to be accessible from inside MM. Once the NVS region are assigned, it needs to be unblocked thourgh this API. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Hao A Wu Cc: Jiewen Yao Cc: Laszlo Ersek Signed-off-by: Kun Qin --- Notes: v4: - Added more commit message [Laszlo] - Added UNI file [Hao] =20 v3: - Move interface to MdePkg [Hao, Liming, Jiewen] - Remove Dxe prefix [Jiewen] =20 v2: - Resend with practical usage. No change [Hao] MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c | 44 ++++++++= ++++++++++++ MdePkg/Include/Library/MmUnblockMemoryLib.h | 44 ++++++++= ++++++++++++ MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf | 34 ++++++++= +++++++ MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.uni | 21 ++++++++= ++ MdePkg/MdePkg.dec | 5 +++ MdePkg/MdePkg.dsc | 1 + 6 files changed, 149 insertions(+) diff --git a/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c b/M= dePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c new file mode 100644 index 000000000000..abdce41f10d1 --- /dev/null +++ b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c @@ -0,0 +1,44 @@ +/** @file + Null instance of MM Unblock Page Library. + + This library provides an interface to request non-MMRAM pages to be mapp= ed/unblocked + from inside MM environment. + + For MM modules that need to access regions outside of MMRAMs, the agents= that set up + these regions are responsible for invoking this API in order for these m= emory areas + to be accessed from inside MM. + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +/** + This API provides a way to unblock certain data pages to be accessible i= nside MM environment. + + @param UnblockAddress The address of buffer caller requests to= unblock, the address + has to be page aligned. + @param NumberOfPages The number of pages requested to be unbl= ocked from MM + environment. + + @return EFI_SUCCESS The request goes through successfully. + @return EFI_NOT_AVAILABLE_YET The requested functionality is not produ= ced yet. + @return EFI_UNSUPPORTED The requested functionality is not suppo= rted on current platform. + @return EFI_SECURITY_VIOLATION The requested address failed to pass sec= urity check for + unblocking. + @return EFI_INVALID_PARAMETER Input address either NULL pointer or not= page aligned. + @return EFI_ACCESS_DENIED The request is rejected due to system ha= s passed certain boot + phase. + +**/ +EFI_STATUS +EFIAPI +MmUnblockMemoryRequest ( + IN EFI_PHYSICAL_ADDRESS UnblockAddress, + IN UINT64 NumberOfPages + ) +{ + return RETURN_UNSUPPORTED; +} diff --git a/MdePkg/Include/Library/MmUnblockMemoryLib.h b/MdePkg/Include/L= ibrary/MmUnblockMemoryLib.h new file mode 100644 index 000000000000..980afe9a5fd3 --- /dev/null +++ b/MdePkg/Include/Library/MmUnblockMemoryLib.h @@ -0,0 +1,44 @@ +/** @file + MM Unblock Memory Library Interface. + + This library provides an interface to request non-MMRAM pages to be mapp= ed/unblocked + from inside MM environment. + + For MM modules that need to access regions outside of MMRAMs, the agents= that set up + these regions are responsible for invoking this API in order for these m= emory areas + to be accessed from inside MM. + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef MM_UNBLOCK_MEMORY_LIB_H_ +#define MM_UNBLOCK_MEMORY_LIB_H_ + +/** + This API provides a way to unblock certain data pages to be accessible i= nside MM environment. + + @param UnblockAddress The address of buffer caller requests to= unblock, the address + has to be page aligned. + @param NumberOfPages The number of pages requested to be unbl= ocked from MM + environment. + + @return EFI_SUCCESS The request goes through successfully. + @return EFI_NOT_AVAILABLE_YET The requested functionality is not produ= ced yet. + @return EFI_UNSUPPORTED The requested functionality is not suppo= rted on current platform. + @return EFI_SECURITY_VIOLATION The requested address failed to pass sec= urity check for + unblocking. + @return EFI_INVALID_PARAMETER Input address either NULL pointer or not= page aligned. + @return EFI_ACCESS_DENIED The request is rejected due to system ha= s passed certain boot + phase. + +**/ +EFI_STATUS +EFIAPI +MmUnblockMemoryRequest ( + IN EFI_PHYSICAL_ADDRESS UnblockAddress, + IN UINT64 NumberOfPages +); + +#endif // MM_UNBLOCK_MEMORY_LIB_H_ diff --git a/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf b= /MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf new file mode 100644 index 000000000000..8ecb767ff7bd --- /dev/null +++ b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf @@ -0,0 +1,34 @@ +## @file +# Null instance of MM Unblock Page Library. +# +# This library provides an interface to request non-MMRAM pages to be map= ped/unblocked +# from inside MM environment. +# +# For MM modules that need to access regions outside of MMRAMs, the agent= s that set up +# these regions are responsible for invoking this API in order for these = memory areas +# to be accessed from inside MM. +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D MmUnblockMemoryLibNull + MODULE_UNI_FILE =3D MmUnblockMemoryLibNull.uni + FILE_GUID =3D 9E890F68-5C95-4C31-95DD-59E6286F85EA + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D MmUnblockMemoryLib + +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + MmUnblockMemoryLibNull.c + +[Packages] + MdePkg/MdePkg.dec diff --git a/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.uni b= /MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.uni new file mode 100644 index 000000000000..d7f2709a3dce --- /dev/null +++ b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.uni @@ -0,0 +1,21 @@ +// /** @file +// Null instance of MM Unblock Page Library. +// +// This library provides an interface to request non-MMRAM pages to be map= ped/unblocked +// from inside MM environment. +// +// For MM modules that need to access regions outside of MMRAMs, the agent= s that set up +// these regions are responsible for invoking this API in order for these = memory areas +// to be accessed from inside MM. +// +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Null instance of = MM Unblock Page Library." + +#string STR_MODULE_DESCRIPTION #language en-US "This library prov= ides an interface to request non-MMRAM pages to be mapped/unblocked from in= side MM environment.\n" + "For MM modules th= at need to access regions outside of MMRAMs, the agents that set up these r= egions are responsible for invoking this API in order for these memory area= s to be accessed from inside MM." + diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 3928db65d188..32a9e009c813 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -257,6 +257,11 @@ [LibraryClasses] # UnitTestHostBaseLib|Test/UnitTest/Include/Library/UnitTestHostBaseLib.h =20 + ## @libraryclass This library provides an interface for DXE drivers to= request MM environment + # to map/unblock a memory region for accessibility inside MM. + # + MmUnblockMemoryLib|Include/Library/MmUnblockMemoryLib.h + [LibraryClasses.IA32, LibraryClasses.X64] ## @libraryclass Abstracts both S/W SMI generation and detection. ## diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index ce009086815f..79629e3f93ba 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -168,6 +168,7 @@ [Components.IA32, Components.X64] MdePkg/Library/SmmPciExpressLib/SmmPciExpressLib.inf MdePkg/Library/SmiHandlerProfileLibNull/SmiHandlerProfileLibNull.inf MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf + MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf =20 [Components.EBC] MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf --=20 2.30.0.windows.1