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 <[email protected]> wrote:
> >
> > From: Achin Gupta <[email protected]>
> >
> > 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 <[email protected]>
> > ---
> >  ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf |  56 +++
> >  ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h     |  28 ++
> >  ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c   | 378 
> > ++++++++++++++++++++
> >  3 files changed, 462 insertions(+)


<snip>


> > +/**
> > +  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

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to