From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.107.5.42; helo=eur03-ve1-obe.outbound.protection.outlook.com; envelope-from=udit.kumar@nxp.com; receiver=edk2-devel@lists.01.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50042.outbound.protection.outlook.com [40.107.5.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 13F622034A7C9 for ; Wed, 25 Oct 2017 22:01:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/eOwKdKRnKRZQcUWWQPtrJnpKBKPwEhPWY5HvOp4DFM=; b=KeoT8anFKd8yTw4dTbqqHUozsgieQqWmIV2kVChLP5ieZnu4VY3HfZCU5HctiH7spIEqV++wjEwqf8evDBByoaByQHwPeejdQC4WWemxrkio+3BFGCgw68tG9hZmO4v53YRnPNffLD0VBEmCOxMfLgCjpVGe98YKps2cTlUNKJU= Received: from AM6PR0402MB3334.eurprd04.prod.outlook.com (52.133.18.151) by AM6PR0402MB3336.eurprd04.prod.outlook.com (52.133.18.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.156.4; Thu, 26 Oct 2017 05:05:20 +0000 Received: from AM6PR0402MB3334.eurprd04.prod.outlook.com ([fe80::4823:25e5:43de:60ba]) by AM6PR0402MB3334.eurprd04.prod.outlook.com ([fe80::4823:25e5:43de:60ba%13]) with mapi id 15.20.0156.007; Thu, 26 Oct 2017 05:05:20 +0000 From: Udit Kumar To: Supreeth Venkatesh , "edk2-devel@lists.01.org" CC: "leif.lindholm@linaro.org" , "ard.biesheuvel@linaro.org" Thread-Topic: [edk2] [PATCH v2 2/3] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver. Thread-Index: AQHTTa746TJ40YVTb0+5CLuQeTScMqL1k7iQ Date: Thu, 26 Oct 2017 05:05:20 +0000 Message-ID: References: <20171025163258.47961-1-supreeth.venkatesh@arm.com> <20171025163258.47961-3-supreeth.venkatesh@arm.com> In-Reply-To: <20171025163258.47961-3-supreeth.venkatesh@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=udit.kumar@nxp.com; x-originating-ip: [192.88.169.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM6PR0402MB3336; 6:Jc5LUZrGLziKZjlf2gOhKVsBhc0QpZRafUI0ZybqPDdCb6SmJL/PFGXZelvqqlLZM8FCwpGav3AG+tQ0ft3x9lKIpSjztLFLv31+ZvKxCItEAHK7+ziV++BNk+1fqcE7JcNmCG6Vk9Bed2aWV3aMn4fOiTCBu3rtP2eyMqdGAyi3ZravWNxhQ0B8GiyhczFzvxvq70ZslgYjpH/CNrDcyVTF9B2NwTvUi527vYPVP/WVE3TCKQZoLvY2+RW6MP+9+Jx4APHf2MtUiklDDBTWtHjphJRg1534Vt+RznHSJmC8ueyCMo3vkn+bT+DNysb9xi7MfzXo1qKmdbE2u1do4A==; 5:qOf16s9D+lcEHxseG1w4aN2JN5gCT8b+/nsvSqg9MoPc2r6ovT6HYaJ1iCo1GuTGHNHDcQpHB1Bo8yr5Og8E8Ugt6gftvAisNMfRkK7cKpltNV24xKwnd5x9aORUu9/GWVxurnw83h1lw+drE9EpOQ==; 24:f8ls5e3i/JcZDh+zUuvixFiOIgo9G+51yy80Zio9RVUxzi7LW2A8A1Z4SGRbLC8tC8yeVCCygirkTwD3s/lK5/7TojpyhoZT9/ivkOFOWqQ=; 7:LND1ix9GVnQ4G0tz2AWReLW8qqbFQ1Xobh3qV6v4y3SE3wge45lkZRvecvGHb4qvhoozUxUwq2VVJU7h8w6cgjs7d7yQIEemQWZVShgHHZGvZaSkYQ/rZXTpIQcfAtq0civH2nc0Z+hLdcsijzb6tXxYVUNuNGvSHY1j2AN8yLv0HDlYhpEwk4m9S12aqjmwjX2PxGZdB/0oTVM3knqghsmVKLhZ36oG17jIfNMPg3I= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 1db035fc-f6e5-48ed-a919-08d51c2f2851 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(4534020)(4602075)(4627075)(201703031133081)(201702281549075)(2017052603199); SRVR:AM6PR0402MB3336; x-ms-traffictypediagnostic: AM6PR0402MB3336: x-exchange-antispam-report-test: UriScan:(180628864354917)(189930954265078)(162533806227266)(45079756050767)(17755550239193); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(3002001)(3231020)(10201501046)(100000703101)(100105400095)(93006095)(93001095)(6055026)(6041248)(20161123564025)(20161123555025)(20161123558100)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM6PR0402MB3336; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM6PR0402MB3336; x-forefront-prvs: 04724A515E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(376002)(39860400002)(346002)(199003)(13464003)(189002)(189998001)(2900100001)(8676002)(6246003)(16799955002)(6506006)(2501003)(3660700001)(106356001)(54906003)(33656002)(54356999)(9686003)(55016002)(316002)(6306002)(101416001)(50986999)(99286003)(5250100002)(25786009)(6436002)(76176999)(2906002)(14454004)(3280700002)(53936002)(97736004)(110136005)(68736007)(105586002)(53946003)(81156014)(3846002)(478600001)(66066001)(86362001)(229853002)(81166006)(74316002)(7736002)(4326008)(6116002)(53546010)(8936002)(102836003)(45080400002)(966005)(2950100002)(7696004)(5660300001)(305945005)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR0402MB3336; H:AM6PR0402MB3334.eurprd04.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1db035fc-f6e5-48ed-a919-08d51c2f2851 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Oct 2017 05:05:20.7180 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0402MB3336 Subject: Re: [PATCH v2 2/3] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Oct 2017 05:01:38 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi=20 > + Status =3D gBS->AllocatePages (AllocateAddress, > + EfiRuntimeServicesData, > + EFI_SIZE_TO_PAGES (mNsCommBuffMemRegion.L= ength), > + &mNsCommBuffMemRegion.PhysicalBase); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "MmCommunicateInitialize: Failed to allocate MM= - > NS Buffer Memory Space\n")); > + return EFI_INVALID_PARAMETER; > + } > + > + // Install the communication protocol Status =3D > + gBS->InstallProtocolInterface (&mMmCommunicateHandle, > + &gEfiMmCommunicationProtocolGu= id, > + EFI_NATIVE_INTERFACE, > + &mMmCommunication); if > + (EFI_ERROR(Status)) { > + DEBUG ((DEBUG_ERROR, "MmCommunicationInitialize: Failed to install M= M > communication protocol\n")); In case of error, you could free the above allocated memory=20 > + return EFI_INVALID_PARAMETER; > + =20 Regards Udit=20 > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Supreeth Venkatesh > Sent: Wednesday, October 25, 2017 10:03 PM > To: edk2-devel@lists.01.org > Cc: leif.lindholm@linaro.org; ard.biesheuvel@linaro.org > Subject: [edk2] [PATCH v2 2/3] ArmPkg/Drivers: Add > EFI_MM_COMMUNICATION_PROTOCOL DXE driver. >=20 > PI v1.5 Specification Volume 4 defines Management Mode Core Interface and > defines EFI_MM_COMMUNICATION_PROTOCOL. This protocol provides a > means of communicating between drivers outside of MM and MMI handlers > inside of MM. >=20 > This patch implements the EFI_MM_COMMUNICATION_PROTOCOL DXE > runtime driver for AARCH64 platforms. It uses SMCs allocated from the sta= ndard > SMC range defined in > https://emea01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Finfoc= en > ter.arm.com%2Fhelp%2Ftopic%2Fcom.arm.doc.den0060a%2FDEN0060A_ARM_ > MM_Interface_Specification.pdf&data=3D02%7C01%7Cudit.kumar%40nxp.com%7 > C43194cfd48f84756da6908d51bc6185b%7C686ea1d3bc2b4c6fa92cd99c5c3016 > 35%7C0%7C1%7C636445460008712743&sdata=3DNk9bnFSzqB4zxCcyd4C2HyqZ2a > Iluu%2FWKXOVho4a6g8%3D&reserved=3D0 > to communicate with the standalone MM environment in the secure world. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Achin Gupta > Signed-off-by: Supreeth Venkatesh > --- > .../Drivers/MmCommunicationDxe/MmCommunication.c | 339 > +++++++++++++++++++++ > 1 file changed, 339 insertions(+) > create mode 100644 > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c >=20 > diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c > b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c > new file mode 100644 > index 0000000000..ecf70e666c > --- /dev/null > +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c > @@ -0,0 +1,339 @@ > +/** @file > + > + Copyright (c) 2016-2017, 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 > + > + https://emea01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fope= n > + source.org%2Flicenses%2Fbsd- > license.php&data=3D02%7C01%7Cudit.kumar%40nx > + > p.com%7C43194cfd48f84756da6908d51bc6185b%7C686ea1d3bc2b4c6fa92cd9 > 9c5c3 > + > 01635%7C0%7C0%7C636445460008712743&sdata=3D%2Fw7nb5B%2Bw3NKLV4v > 5LwcaQ0%2 > + F6gh2Cva%2FEyDsb69NEAM%3D&reserved=3D0 > + > + 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 > +#include #include > +#include #include > + > +#include > + > +#include > + > +#include > + > +/** > + Communicates with a registered handler. > + > + This function provides an interface to send and receive messages to > + the Standalone MM environment on behalf of UEFI services. This > + function is part of the MM Communication Protocol that may be called > + in physical mode prior to > + SetVirtualAddressMap() and in virtual mode after SetVirtualAddressMap(= ). > + > + @param[in] This The EFI_MM_COMMUNICATION_PROTOCOL > instance. > + @param[in, out] CommBuffer A pointer to the buffer to convey = into > MMRAM. > + @param[in, out] CommSize The size of the data buffer being = passed > in.On exit, the size of data > + being returned. Zero if the handle= r does not wish to reply > with any data. > + > + @retval EFI_SUCCESS The message was successfully poste= d. > + @retval EFI_INVALID_PARAMETER The CommBuffer was NULL. > + @retval EFI_BAD_BUFFER_SIZE The buffer is too large for the MM > implementation. If this error is > + returned, the MessageLength field = in the CommBuffer > header or the integer > + pointed by CommSize are updated to= reflect the maximum > payload size the > + implementation can accommodate. > + @retval EFI_ACCESS_DENIED The CommunicateBuffer parameter or > CommSize parameter, if not omitted, > + are in address range that cannot > +be accessed by the MM environment **/ EFI_STATUS EFIAPI > +MmCommunicationCommunicate ( > + IN CONST EFI_MM_COMMUNICATION_PROTOCOL *This, > + IN OUT VOID *CommBuffer, > + IN OUT UINTN *CommSize OPTIONAL > + ); > + > +// > +// Address, Length of the pre-allocated buffer for communication with > +the secure // world. > +// > +STATIC ARM_MEMORY_REGION_DESCRIPTOR mNsCommBuffMemRegion; > + > +// Notification event when virtual address map is set. > +STATIC EFI_EVENT mSetVirtualAddressMapEvent; > + > +// > +// Handle to install the MM Communication Protocol // STATIC EFI_HANDLE > +mMmCommunicateHandle; > + > +// > +// MM Communication Protocol instance > +// > +EFI_MM_COMMUNICATION_PROTOCOL mMmCommunication =3D { > + MmCommunicationCommunicate > +}; > + > +/** > + Communicates with a registered handler. > + > + This function provides an interface to send and receive messages to > + the Standalone MM environment on behalf of UEFI services. This > + function is part of the MM Communication Protocol that may be called > + in physical mode prior to > + SetVirtualAddressMap() and in virtual mode after SetVirtualAddressMap(= ). > + > + @param[in] This The EFI_MM_COMMUNICATION_PROTOCOL > instance. > + @param[in, out] CommBuffer A pointer to the buffer to convey = into > SMRAM. > + @param[in, out] CommSize The size of the data buffer being = passed > in.On exit, the size of data > + being returned. Zero if the handle= r does not wish to reply > with any data. > + > + @retval EFI_SUCCESS The message was successfully poste= d. > + @retval EFI_INVALID_PARAMETER The CommBuffer was NULL. > + @retval EFI_BAD_BUFFER_SIZE The buffer is too large for the MM > implementation. If this error is > + returned, the MessageLength field = in the CommBuffer > header or the integer > + pointed by CommSize are updated to= reflect the maximum > payload size the > + implementation can accommodate. > + @retval EFI_ACCESS_DENIED The CommunicateBuffer parameter or > CommSize parameter, if not omitted, > + are in address range that cannot > +be accessed by the MM environment **/ EFI_STATUS EFIAPI > +MmCommunicationCommunicate ( > + IN CONST EFI_MM_COMMUNICATION_PROTOCOL *This, > + IN OUT VOID *CommBuffer, > + IN OUT UINTN *CommSize > + ) > +{ > + EFI_MM_COMMUNICATE_HEADER *CommunicateHeader; > + ARM_SMC_ARGS CommunicateSmcArgs; > + EFI_STATUS Status; > + UINTN BufferSize; > + > + CommunicateHeader =3D CommBuffer; > + Status =3D EFI_SUCCESS; > + BufferSize =3D 0; > + > + ZeroMem (&CommunicateSmcArgs, sizeof (ARM_SMC_ARGS)); > + > + // > + // Check parameters > + // > + if (CommBuffer =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + // If the length of the CommBuffer is 0 then return the expected lengt= h. > + if (CommSize) { > + if (*CommSize =3D=3D 0) { > + *CommSize =3D mNsCommBuffMemRegion.Length; > + return EFI_BAD_BUFFER_SIZE; > + } > + // > + // CommSize must hold HeaderGuid and MessageLength > + // > + if (*CommSize < sizeof (EFI_MM_COMMUNICATE_HEADER)) { > + return EFI_INVALID_PARAMETER; > + } > + BufferSize =3D *CommSize; > + } else { > + BufferSize =3D CommunicateHeader->MessageLength + > + sizeof (CommunicateHeader->HeaderGuid) + > + sizeof (CommunicateHeader->MessageLength); > + } > + > + // > + // If the buffer size is 0 or greater than what can be tolerated by > + the MM // environment then return the expected size. > + // > + if ((BufferSize =3D=3D 0) || > + (BufferSize > mNsCommBuffMemRegion.Length)) { > + CommunicateHeader->MessageLength =3D mNsCommBuffMemRegion.Length > - > + sizeof (CommunicateHeader->Header= Guid) - > + sizeof (CommunicateHeader->Messag= eLength); > + return EFI_BAD_BUFFER_SIZE; > + } > + > + // SMC Function ID > + CommunicateSmcArgs.Arg0 =3D > ARM_SMC_ID_MM_COMMUNICATE_AARCH64; > + > + // Reserved for Future. Must be Zero. > + CommunicateSmcArgs.Arg1 =3D 0; > + > + if (mNsCommBuffMemRegion.VirtualBase) { > + CopyMem ((VOID *)mNsCommBuffMemRegion.VirtualBase, CommBuffer, > + BufferSize); } > + > + // For the SMC64 version, this parameter is a 64-bit Physical Address > + (PA) // or Intermediate Physical Address (IPA). > + // For the SMC32 version, this parameter is a 32-bit PA or IPA. > + CommunicateSmcArgs.Arg2 =3D > (UINTN)mNsCommBuffMemRegion.PhysicalBase; > + > + // comm_size_address is a PA or an IPA that holds the size of the // > + communication buffer being passed in. This parameter is optional // > + and can be omitted by passing a zero. > + // ARM does not recommend using it since this might require the // > + implementation to create a separate memory mapping for the parameter. > + // ARM recommends storing the buffer size in the buffer itself. > + CommunicateSmcArgs.Arg3 =3D 0; > + > + // Call the Standalone MM environment. > + ArmCallSmc (&CommunicateSmcArgs); > + > + Status =3D CommunicateSmcArgs.Arg0; > + switch (Status) { > + case ARM_SMC_MM_RET_SUCCESS: > + // On exit, the size of data being returned is inferred from > + // CommSize or MessageLength + Header. > + CopyMem (CommBuffer, (const VOID > *)mNsCommBuffMemRegion.VirtualBase, BufferSize); > + break; > + > + case ARM_SMC_MM_RET_NOT_SUPPORTED: > + case ARM_SMC_MM_RET_INVALID_PARAMS: > + Status =3D EFI_INVALID_PARAMETER; > + break; > + > + case ARM_SMC_MM_RET_DENIED: > + Status =3D EFI_ACCESS_DENIED; > + break; > + > + case ARM_SMC_MM_RET_NO_MEMORY: > + // Unexpected error since the CommSize was checked for zero length > + // prior to issuing the SMC > + default: > + Status =3D EFI_ACCESS_DENIED; > + ASSERT (0); > + } > + > + return Status; > +} > + > +/** > + Notification callback on SetVirtualAddressMap event. > + > + This function notifies the MM communication protocol interface on > + SetVirtualAddressMap event and converts pointers used in this driver > + from physical to virtual address. > + > + @param Event SetVirtualAddressMap event. > + @param Context A context when the SetVirtualAddressMap trigger= ed. > + > + @retval EFI_SUCCESS The function executed successfully. > + @retval Other Some error occurred when executing this functio= n. > + > +**/ > +STATIC > +VOID > +EFIAPI > +NotifySetVirtualAddressMap ( > + IN EFI_EVENT Event, > + IN VOID *Context > + ) > +{ > + EFI_STATUS Status; > + > + Status =3D gRT->ConvertPointer (EFI_OPTIONAL_PTR, > + (VOID **)&mNsCommBuffMemRegion.VirtualBa= se > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "NotifySetVirtualAddressMap(): Unable to > + convert MM runtime pointer. Status:0x%x\n", Status)); } > + > +} > + > +/** > + The Entry Point for MM Communication > + > + This function installs the MM communication protocol interface and > + finds out what type of buffer management will be required prior to > + invoking the communication SMC. > + > + @param ImageHandle The firmware allocated handle for the EFI image= . > + @param SystemTable A pointer to the EFI System Table. > + > + @retval EFI_SUCCESS The entry point is executed successfully. > + @retval Other Some error occurred when executing this entry p= oint. > + > +**/ > +EFI_STATUS > +EFIAPI > +MmCommunicationInitialize ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + > + mNsCommBuffMemRegion.PhysicalBase =3D 0; > + mNsCommBuffMemRegion.VirtualBase =3D 0; > mNsCommBuffMemRegion.Length =3D > + 0; > + > + mNsCommBuffMemRegion.PhysicalBase =3D PcdGet64 (PcdMmBufferBase); // > + During boot , Virtual and Physical are same > + mNsCommBuffMemRegion.VirtualBase =3D > mNsCommBuffMemRegion.PhysicalBase; > + mNsCommBuffMemRegion.Length =3D PcdGet64 (PcdMmBufferSize); > + > + if (mNsCommBuffMemRegion.PhysicalBase =3D=3D 0) { > + DEBUG ((DEBUG_ERROR, "MmCommunicateInitialize: Invalid MM Buffer > Base Address.\n")); > + return EFI_INVALID_PARAMETER; > + } > + > + if (mNsCommBuffMemRegion.Length =3D=3D 0) { > + DEBUG ((DEBUG_ERROR, "MmCommunicateInitialize: Maximum Buffer Size > is zero.\n")); > + return EFI_INVALID_PARAMETER; > + } > + > + Status =3D gDS->AddMemorySpace (EfiGcdMemoryTypeSystemMemory, > + mNsCommBuffMemRegion.PhysicalBase, > + mNsCommBuffMemRegion.Length, > + EFI_MEMORY_WB | > + EFI_MEMORY_XP | > + EFI_MEMORY_RUNTIME); if (EFI_ERROR > + (Status)) { > + DEBUG ((DEBUG_ERROR, "MmCommunicateInitialize: Failed to add MM-NS > Buffer Memory Space\n")); > + return EFI_INVALID_PARAMETER; > + } > + > + Status =3D gDS- > >SetMemorySpaceAttributes(mNsCommBuffMemRegion.PhysicalBase, > + mNsCommBuffMemRegion.Length, > + EFI_MEMORY_WB | > + EFI_MEMORY_XP); if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "MmCommunicateInitialize: Failed to set MM-NS > Buffer Memory attributes\n")); > + return EFI_INVALID_PARAMETER; > + } > + > + Status =3D gBS->AllocatePages (AllocateAddress, > + EfiRuntimeServicesData, > + EFI_SIZE_TO_PAGES (mNsCommBuffMemRegion.L= ength), > + &mNsCommBuffMemRegion.PhysicalBase); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "MmCommunicateInitialize: Failed to allocate MM= - > NS Buffer Memory Space\n")); > + return EFI_INVALID_PARAMETER; > + } > + > + // Install the communication protocol Status =3D > + gBS->InstallProtocolInterface (&mMmCommunicateHandle, > + &gEfiMmCommunicationProtocolGu= id, > + EFI_NATIVE_INTERFACE, > + &mMmCommunication); if > + (EFI_ERROR(Status)) { > + DEBUG ((DEBUG_ERROR, "MmCommunicationInitialize: Failed to install M= M > communication protocol\n")); > + return EFI_INVALID_PARAMETER; > + } > + > + // Register notification callback when virtual address is associated > + // with the physical address. > + // Create a Set Virtual Address Map event. > + // > + Status =3D gBS->CreateEvent (EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, // > Type > + TPL_NOTIFY, // Noti= fyTpl > + NotifySetVirtualAddressMap, // Noti= fyFunction > + NULL, // Noti= fyContext > + &mSetVirtualAddressMapEvent // Even= t > + ); > + ASSERT_EFI_ERROR (Status); > + > + return Status; > +} > -- > 2.14.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://emea01.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Flist= s.01 > .org%2Fmailman%2Flistinfo%2Fedk2- > devel&data=3D02%7C01%7Cudit.kumar%40nxp.com%7C43194cfd48f84756da690 > 8d51bc6185b%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6364454 > 60008712743&sdata=3D3DNXnOuo8%2FVFL6Sha%2FeidNhuh4JoILCVQs1HcGAhvr > Y%3D&reserved=3D0