From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.101.70; helo=foss.arm.com; envelope-from=sughosh.ganu@arm.com; receiver=edk2-devel@lists.01.org Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by ml01.01.org (Postfix) with ESMTP id 867CF2118EF74 for ; Tue, 27 Nov 2018 00:13:03 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1B68032F4; Tue, 27 Nov 2018 00:13:03 -0800 (PST) Received: from a074948-lin.blr.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C95853F5AF; Tue, 27 Nov 2018 00:13:00 -0800 (PST) Received: by a074948-lin.blr.arm.com (sSMTP sendmail emulation); Tue, 27 Nov 2018 13:42:57 +0530 Date: Tue, 27 Nov 2018 13:42:57 +0530 From: Sughosh Ganu To: Ard Biesheuvel Cc: "edk2-devel@lists.01.org" , Leif Lindholm , Achin Gupta Message-ID: <20181127081257.GA24403@arm.com> References: <1543299564-25266-1-git-send-email-sughosh.ganu@arm.com> <1543299564-25266-3-git-send-email-sughosh.ganu@arm.com> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Subject: Re: [PATCH v4 2/5] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver. 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: Tue, 27 Nov 2018 08:13:03 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline hi Ard, On Tue Nov 27, 2018 at 08:59:30AM +0100, Ard Biesheuvel wrote: > Hi Sughosh, > > On Tue, 27 Nov 2018 at 07:19, Sughosh Ganu wrote: > > > > From: Achin Gupta > > > > 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. > > > > This patch implements the EFI_MM_COMMUNICATION_PROTOCOL DXE runtime > > driver for AARCH64 platforms. It uses SMCs allocated from the standard > > SMC range defined in DEN0060A_ARM_MM_Interface_Specification.pdf > > to communicate with the standalone MM environment in the secure world. > > > > This patch also adds the MM Communication driver (.inf) file to > > define entry point for this driver and other compile > > related information the driver needs. > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Sughosh Ganu > > --- > > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf | 56 +++ > > ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h | 28 ++ > > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 378 ++++++++++++++++++++ > > 3 files changed, 462 insertions(+) > > +/** > > + 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 point. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +MmCommunicationInitialize ( > > + IN EFI_HANDLE ImageHandle, > > + IN EFI_SYSTEM_TABLE *SystemTable > > + ) > > +{ > > + EFI_STATUS Status; > > + > > + // Check if we can make the MM call > > + Status = GetMmCompatibility (); > > + if (EFI_ERROR(Status)) { > > + goto ReturnErrorStatus; > > + } > > + > > + mNsCommBuffMemRegion.PhysicalBase = PcdGet64 (PcdMmBufferBase); > > + // During boot , Virtual and Physical are same > > + mNsCommBuffMemRegion.VirtualBase = mNsCommBuffMemRegion.PhysicalBase; > > + mNsCommBuffMemRegion.Length = PcdGet64 (PcdMmBufferSize); > > + > > + ASSERT (mNsCommBuffMemRegion.PhysicalBase != 0); > > + > > + ASSERT (mNsCommBuffMemRegion.Length != 0); > > + > > + Status = gDS->AddMemorySpace ( > > + EfiGcdMemoryTypeReserved, > > + 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")); > > + goto ReturnErrorStatus; > > + } > > + > > + Status = gDS->SetMemorySpaceAttributes ( > > + mNsCommBuffMemRegion.PhysicalBase, > > + mNsCommBuffMemRegion.Length, > > + EFI_MEMORY_WB | EFI_MEMORY_XP | EFI_MEMORY_RUNTIME > > + ); > > + if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_ERROR, "MmCommunicateInitialize: " > > + "Failed to set MM-NS Buffer Memory attributes\n")); > > + goto CleanAddedMemorySpace; > > + } > > + > > + // Install the communication protocol > > + Status = gBS->InstallProtocolInterface ( > > + &mMmCommunicateHandle, > > + &gEfiMmCommunicationProtocolGuid, > > + EFI_NATIVE_INTERFACE, > > + &mMmCommunication > > + ); > > + if (EFI_ERROR(Status)) { > > + DEBUG ((DEBUG_ERROR, "MmCommunicationInitialize: " > > + "Failed to install MM communication protocol\n")); > > + goto CleanAllocatedPages; > > + } > > + > > + // Register notification callback when virtual address is associated > > + // with the physical address. > > + // Create a Set Virtual Address Map event. > > + Status = gBS->CreateEvent ( > > + EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, > > + TPL_NOTIFY, > > + NotifySetVirtualAddressMap, > > + NULL, > > + &mSetVirtualAddressMapEvent > > + ); > > + if (Status == EFI_SUCCESS) { > > + return Status; > > + } > > + > > + gBS->UninstallProtocolInterface ( > > + mMmCommunicateHandle, > > + &gEfiMmCommunicationProtocolGuid, > > + &mMmCommunication > > + ); > > + > > +CleanAllocatedPages: > > + gBS->FreePages ( > > + mNsCommBuffMemRegion.PhysicalBase, > > + EFI_SIZE_TO_PAGES (mNsCommBuffMemRegion.Length) > > + ); > > + > > Do we still need this? Oops. No this can now be removed. Will post a V6. Thanks. -sughosh