Re: [edk2] [PATCH v2 2/3] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2017-11-13 Thread Ard Biesheuvel
On 13 November 2017 at 12:42, Supreeth Venkatesh
 wrote:
> On Mon, 2017-11-13 at 12:19 +, Ard Biesheuvel wrote:
>> On 13 November 2017 at 12:15, Supreeth Venkatesh
>>  wrote:
>> >
>> > On Mon, 2017-11-13 at 11:48 +, Ard Biesheuvel wrote:
>> > >
>> > > On 13 November 2017 at 11:40, Supreeth Venkatesh
>> > >  wrote:
>> > > >
>> > > >
>> > > > On Mon, 2017-11-13 at 10:30 +, Ard Biesheuvel wrote:
>> > > > >
>> > > > >
>> > > > > On 25 October 2017 at 17:32, Supreeth Venkatesh
>> > > > >  wrote:
>> > > > > >
>> > > > > >
>> > > > > >
>> > > > > > 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
>> > > > > > http://infocenter.arm.com/help/topic/com.arm.doc.den0060a/D
>> > > > > > EN00
>> > > > > > 60A_
>> > > > > > ARM_MM_Interface_Specification.pdf
>> > > > > > to communicate with the standalone MM environment in the
>> > > > > > secure
>> > > > > > world.
>> > > > > >
>> > > > > > Contributed-under: TianoCore Contribution Agreement 1.1
>> > > > > > Signed-off-by: Achin Gupta 
>> > > > > > Signed-off-by: Supreeth Venkatesh > > > > > > om>
>> > > > > > ---
>> > > > > >  .../Drivers/MmCommunicationDxe/MmCommunication.c   | 339
>> > > > > > +
>> > > > > No need to separate the .inf and .c changes, so this patch
>> > > > > can be
>> > > > > merged with the previous one.
>> > > > Thanks for more comments/feedback.
>> > > > Ok. Please wait for v3.
>> > > > >
>> > > > >
>> > > > >
>> > > > > >
>> > > > > >
>> > > > > >
>> > > > > >  1 file changed, 339 insertions(+)
>> > > > > >  create mode 100644
>> > > > > > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
>> > > > > >
>> > > > > > diff --git
>> > > > > > a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
>> > > > > > b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
>> > > > > > new file mode 100644
>> > > > > > index 00..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
>> > > > > > +  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 
>> > > > > > +#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]  ThisThe
>> > > > > > EFI_MM_COMMUNICATION_PROTOCOL instance.
>> > > > > > +  @param[in, out] CommBuffer  A pointer to the
>> > > > > > buffer
>> > > > > > to
>> > > > > > convey into MMRAM.
>> > > > > > +  @param[in, out] CommSizeThe size of the data
>> > > > > > buffer
>> > > > > > being passed in.On exit, the size of data
>> > > > > > +  being returned. Zero
>> > > > > > if
>> > > > > > the
>> > > > > > handler does not wish to reply with any data.
>> > > > > > +
>> > > > > > +  @retval EFI_SUCCESS The message was
>> > > > > > 

Re: [edk2] [PATCH v2 2/3] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2017-11-13 Thread Supreeth Venkatesh
On Mon, 2017-11-13 at 12:19 +, Ard Biesheuvel wrote:
> On 13 November 2017 at 12:15, Supreeth Venkatesh
>  wrote:
> > 
> > On Mon, 2017-11-13 at 11:48 +, Ard Biesheuvel wrote:
> > > 
> > > On 13 November 2017 at 11:40, Supreeth Venkatesh
> > >  wrote:
> > > > 
> > > > 
> > > > On Mon, 2017-11-13 at 10:30 +, Ard Biesheuvel wrote:
> > > > > 
> > > > > 
> > > > > On 25 October 2017 at 17:32, Supreeth Venkatesh
> > > > >  wrote:
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 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
> > > > > > http://infocenter.arm.com/help/topic/com.arm.doc.den0060a/D
> > > > > > EN00
> > > > > > 60A_
> > > > > > ARM_MM_Interface_Specification.pdf
> > > > > > to communicate with the standalone MM environment in the
> > > > > > secure
> > > > > > world.
> > > > > > 
> > > > > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > > > > Signed-off-by: Achin Gupta 
> > > > > > Signed-off-by: Supreeth Venkatesh  > > > > > om>
> > > > > > ---
> > > > > >  .../Drivers/MmCommunicationDxe/MmCommunication.c   | 339
> > > > > > +
> > > > > No need to separate the .inf and .c changes, so this patch
> > > > > can be
> > > > > merged with the previous one.
> > > > Thanks for more comments/feedback.
> > > > Ok. Please wait for v3.
> > > > > 
> > > > > 
> > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > >  1 file changed, 339 insertions(+)
> > > > > >  create mode 100644
> > > > > > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > > > > > 
> > > > > > diff --git
> > > > > > a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > > > > > b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > > > > > new file mode 100644
> > > > > > index 00..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
> > > > > > +  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 
> > > > > > +#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]  ThisThe
> > > > > > EFI_MM_COMMUNICATION_PROTOCOL instance.
> > > > > > +  @param[in, out] CommBuffer  A pointer to the
> > > > > > buffer
> > > > > > to
> > > > > > convey into MMRAM.
> > > > > > +  @param[in, out] CommSizeThe size of the data
> > > > > > buffer
> > > > > > being passed in.On exit, the size of data
> > > > > > +  being returned. Zero
> > > > > > if
> > > > > > the
> > > > > > handler does not wish to reply with any data.
> > > > > > +
> > > > > > +  @retval EFI_SUCCESS The message was
> > > > > > successfully
> > > > > > posted.
> > > > > > +  @retval EFI_INVALID_PARAMETER   The CommBuffer was
> > > > > > NULL.
> > > > > > +  @retval EFI_BAD_BUFFER_SIZE The buffer is too
> > > > > > large
> > > 

Re: [edk2] [PATCH v2 2/3] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2017-11-13 Thread Ard Biesheuvel
On 13 November 2017 at 12:15, Supreeth Venkatesh
 wrote:
> On Mon, 2017-11-13 at 11:48 +, Ard Biesheuvel wrote:
>> On 13 November 2017 at 11:40, Supreeth Venkatesh
>>  wrote:
>> >
>> > On Mon, 2017-11-13 at 10:30 +, Ard Biesheuvel wrote:
>> > >
>> > > On 25 October 2017 at 17:32, Supreeth Venkatesh
>> > >  wrote:
>> > > >
>> > > >
>> > > > 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
>> > > > http://infocenter.arm.com/help/topic/com.arm.doc.den0060a/DEN00
>> > > > 60A_
>> > > > ARM_MM_Interface_Specification.pdf
>> > > > to communicate with the standalone MM environment in the secure
>> > > > world.
>> > > >
>> > > > Contributed-under: TianoCore Contribution Agreement 1.1
>> > > > Signed-off-by: Achin Gupta 
>> > > > Signed-off-by: Supreeth Venkatesh 
>> > > > ---
>> > > >  .../Drivers/MmCommunicationDxe/MmCommunication.c   | 339
>> > > > +
>> > > No need to separate the .inf and .c changes, so this patch can be
>> > > merged with the previous one.
>> > Thanks for more comments/feedback.
>> > Ok. Please wait for v3.
>> > >
>> > >
>> > > >
>> > > >
>> > > >  1 file changed, 339 insertions(+)
>> > > >  create mode 100644
>> > > > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
>> > > >
>> > > > diff --git
>> > > > a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
>> > > > b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
>> > > > new file mode 100644
>> > > > index 00..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
>> > > > +  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 
>> > > > +#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]  ThisThe
>> > > > EFI_MM_COMMUNICATION_PROTOCOL instance.
>> > > > +  @param[in, out] CommBuffer  A pointer to the buffer
>> > > > to
>> > > > convey into MMRAM.
>> > > > +  @param[in, out] CommSizeThe size of the data
>> > > > buffer
>> > > > being passed in.On exit, the size of data
>> > > > +  being returned. Zero if
>> > > > the
>> > > > handler does not wish to reply with any data.
>> > > > +
>> > > > +  @retval EFI_SUCCESS The message was
>> > > > successfully
>> > > > posted.
>> > > > +  @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

Re: [edk2] [PATCH v2 2/3] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2017-11-13 Thread Supreeth Venkatesh
On Mon, 2017-11-13 at 11:48 +, Ard Biesheuvel wrote:
> On 13 November 2017 at 11:40, Supreeth Venkatesh
>  wrote:
> > 
> > On Mon, 2017-11-13 at 10:30 +, Ard Biesheuvel wrote:
> > > 
> > > On 25 October 2017 at 17:32, Supreeth Venkatesh
> > >  wrote:
> > > > 
> > > > 
> > > > 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
> > > > http://infocenter.arm.com/help/topic/com.arm.doc.den0060a/DEN00
> > > > 60A_
> > > > ARM_MM_Interface_Specification.pdf
> > > > to communicate with the standalone MM environment in the secure
> > > > world.
> > > > 
> > > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > > Signed-off-by: Achin Gupta 
> > > > Signed-off-by: Supreeth Venkatesh 
> > > > ---
> > > >  .../Drivers/MmCommunicationDxe/MmCommunication.c   | 339
> > > > +
> > > No need to separate the .inf and .c changes, so this patch can be
> > > merged with the previous one.
> > Thanks for more comments/feedback.
> > Ok. Please wait for v3.
> > > 
> > > 
> > > > 
> > > > 
> > > >  1 file changed, 339 insertions(+)
> > > >  create mode 100644
> > > > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > > > 
> > > > diff --git
> > > > a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > > > b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > > > new file mode 100644
> > > > index 00..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
> > > > +  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 
> > > > +#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]  ThisThe
> > > > EFI_MM_COMMUNICATION_PROTOCOL instance.
> > > > +  @param[in, out] CommBuffer  A pointer to the buffer
> > > > to
> > > > convey into MMRAM.
> > > > +  @param[in, out] CommSizeThe size of the data
> > > > buffer
> > > > being passed in.On exit, the size of data
> > > > +  being returned. Zero if
> > > > the
> > > > handler does not wish to reply with any data.
> > > > +
> > > > +  @retval EFI_SUCCESS The message was
> > > > successfully
> > > > posted.
> > > > +  @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
> > > > +**/
> > > Please don't use lines > 80 characters.
> > Ok.
> > > 
> > > 
> > > > 
> > > > 
> > > > +EFI_STATUS
> > > > +EFIAPI
> > > > +MmCommunicationCommunicate (
> > > > +  IN CONST 

Re: [edk2] [PATCH v2 2/3] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2017-11-13 Thread Ard Biesheuvel
On 13 November 2017 at 11:40, Supreeth Venkatesh
 wrote:
> On Mon, 2017-11-13 at 10:30 +, Ard Biesheuvel wrote:
>> On 25 October 2017 at 17:32, Supreeth Venkatesh
>>  wrote:
>> >
>> > 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
>> > http://infocenter.arm.com/help/topic/com.arm.doc.den0060a/DEN0060A_
>> > ARM_MM_Interface_Specification.pdf
>> > to communicate with the standalone MM environment in the secure
>> > world.
>> >
>> > Contributed-under: TianoCore Contribution Agreement 1.1
>> > Signed-off-by: Achin Gupta 
>> > Signed-off-by: Supreeth Venkatesh 
>> > ---
>> >  .../Drivers/MmCommunicationDxe/MmCommunication.c   | 339
>> > +
>> No need to separate the .inf and .c changes, so this patch can be
>> merged with the previous one.
> Thanks for more comments/feedback.
> Ok. Please wait for v3.
>>
>> >
>> >  1 file changed, 339 insertions(+)
>> >  create mode 100644
>> > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
>> >
>> > diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
>> > b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
>> > new file mode 100644
>> > index 00..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
>> > +  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 
>> > +#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]  ThisThe
>> > EFI_MM_COMMUNICATION_PROTOCOL instance.
>> > +  @param[in, out] CommBuffer  A pointer to the buffer to
>> > convey into MMRAM.
>> > +  @param[in, out] CommSizeThe size of the data buffer
>> > being passed in.On exit, the size of data
>> > +  being returned. Zero if the
>> > handler does not wish to reply with any data.
>> > +
>> > +  @retval EFI_SUCCESS The message was successfully
>> > posted.
>> > +  @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
>> > +**/
>> Please don't use lines > 80 characters.
> Ok.
>>
>> >
>> > +EFI_STATUS
>> > +EFIAPI
>> > +MmCommunicationCommunicate (
>> > +  IN CONST EFI_MM_COMMUNICATION_PROTOCOL  *This,
>> > +  IN OUT VOID *CommBuffer,
>> > +  IN OUT UINTN*CommSizeOPTIONAL
>> > +  );
>> > +
>> > +//
>> > +// 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  

Re: [edk2] [PATCH v2 2/3] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2017-11-13 Thread Supreeth Venkatesh
On Mon, 2017-11-13 at 10:30 +, Ard Biesheuvel wrote:
> On 25 October 2017 at 17:32, Supreeth Venkatesh
>  wrote:
> > 
> > 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
> > http://infocenter.arm.com/help/topic/com.arm.doc.den0060a/DEN0060A_
> > ARM_MM_Interface_Specification.pdf
> > to communicate with the standalone MM environment in the secure
> > world.
> > 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Achin Gupta 
> > Signed-off-by: Supreeth Venkatesh 
> > ---
> >  .../Drivers/MmCommunicationDxe/MmCommunication.c   | 339
> > +
> No need to separate the .inf and .c changes, so this patch can be
> merged with the previous one.
Thanks for more comments/feedback.
Ok. Please wait for v3.
> 
> > 
> >  1 file changed, 339 insertions(+)
> >  create mode 100644
> > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > 
> > diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > new file mode 100644
> > index 00..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
> > +  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 
> > +#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]  ThisThe
> > EFI_MM_COMMUNICATION_PROTOCOL instance.
> > +  @param[in, out] CommBuffer  A pointer to the buffer to
> > convey into MMRAM.
> > +  @param[in, out] CommSizeThe size of the data buffer
> > being passed in.On exit, the size of data
> > +  being returned. Zero if the
> > handler does not wish to reply with any data.
> > +
> > +  @retval EFI_SUCCESS The message was successfully
> > posted.
> > +  @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
> > +**/
> Please don't use lines > 80 characters.
Ok.
> 
> > 
> > +EFI_STATUS
> > +EFIAPI
> > +MmCommunicationCommunicate (
> > +  IN CONST EFI_MM_COMMUNICATION_PROTOCOL  *This,
> > +  IN OUT VOID *CommBuffer,
> > +  IN OUT UINTN*CommSizeOPTIONAL
> > +  );
> > +
> > +//
> > +// 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 = {
> > +  MmCommunicationCommunicate
> > +};
> > +
> Please move this below the 

Re: [edk2] [PATCH v2 2/3] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2017-11-13 Thread Ard Biesheuvel
On 25 October 2017 at 17:32, Supreeth Venkatesh
 wrote:
> 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
> http://infocenter.arm.com/help/topic/com.arm.doc.den0060a/DEN0060A_ARM_MM_Interface_Specification.pdf
> to communicate with the standalone MM environment in the secure world.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Achin Gupta 
> Signed-off-by: Supreeth Venkatesh 
> ---
>  .../Drivers/MmCommunicationDxe/MmCommunication.c   | 339 
> +

No need to separate the .inf and .c changes, so this patch can be
merged with the previous one.

>  1 file changed, 339 insertions(+)
>  create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
>
> diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c 
> b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> new file mode 100644
> index 00..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
> +  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 
> +#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]  ThisThe EFI_MM_COMMUNICATION_PROTOCOL 
> instance.
> +  @param[in, out] CommBuffer  A pointer to the buffer to convey into 
> MMRAM.
> +  @param[in, out] CommSizeThe size of the data buffer being 
> passed in.On exit, the size of data
> +  being returned. Zero if the handler 
> does not wish to reply with any data.
> +
> +  @retval EFI_SUCCESS The message was successfully posted.
> +  @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
> +**/

Please don't use lines > 80 characters.

> +EFI_STATUS
> +EFIAPI
> +MmCommunicationCommunicate (
> +  IN CONST EFI_MM_COMMUNICATION_PROTOCOL  *This,
> +  IN OUT VOID *CommBuffer,
> +  IN OUT UINTN*CommSizeOPTIONAL
> +  );
> +
> +//
> +// 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 = {
> +  MmCommunicationCommunicate
> +};
> +

Please move this below the definition of MmCommunicationCommunicate(),
and drop the forward declaration.

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

Re: [edk2] [PATCH v2 2/3] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2017-10-26 Thread Supreeth Venkatesh
On Thu, 2017-10-26 at 11:13 +0100, Achin Gupta wrote:
> Hi Supreeth,
> 
> some CIL,
> 
> On Wed, Oct 25, 2017 at 05:32:57PM +0100, Supreeth Venkatesh wrote:
> > 
> > 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
> > http://infocenter.arm.com/help/topic/com.arm.doc.den0060a/DEN0060A_
> > ARM_MM_Interface_Specification.pdf
> > to communicate with the standalone MM environment in the secure
> > world.
> > 
> > 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
> > 
> > diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > new file mode 100644
> > index 00..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
> > +  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 
> > +#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]  ThisThe
> > EFI_MM_COMMUNICATION_PROTOCOL instance.
> > +  @param[in, out] CommBuffer  A pointer to the buffer to
> > convey into MMRAM.
> > +  @param[in, out] CommSizeThe size of the data buffer
> > being passed in.On exit, the size of data
> > +  being returned. Zero if the
> > handler does not wish to reply with any data.
> > +
> > +  @retval EFI_SUCCESS The message was successfully
> > posted.
> > +  @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*CommSizeOPTIONAL
> > +  );
> > +
> > +//
> > +// 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 = {
> > +  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 

Re: [edk2] [PATCH v2 2/3] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2017-10-26 Thread Supreeth Venkatesh
On Thu, 2017-10-26 at 05:05 +, Udit Kumar wrote:
> Hi 
> 
> > 
> > +  Status = gBS->AllocatePages (AllocateAddress,
> > +   EfiRuntimeServicesData,
> > +   EFI_SIZE_TO_PAGES
> > (mNsCommBuffMemRegion.Length),
> > +   )
> > ;
> > +  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 =
> > + gBS->InstallProtocolInterface (,
> > +  
> > ocolGuid,
> > +  EFI_NATIVE_INTERFACE,
> > +  );  if
> > + (EFI_ERROR(Status)) {
> > +DEBUG ((DEBUG_ERROR, "MmCommunicationInitialize: Failed to
> > install MM
> > communication protocol\n"));
> In case of error, you could free the above allocated memory 
> 
> > 
> > +return EFI_INVALID_PARAMETER;
> > +  

Thanks. Yes. It could be done. I will fix it in next version.

> Regards
> Udit 
> 
> > 
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf
> > Of
> > Supreeth Venkatesh
> > Sent: Wednesday, October 25, 2017 10:03 PM
> > To: edk2-devel@lists.01.org
> > Cc: leif.lindh...@linaro.org; ard.biesheu...@linaro.org
> > Subject: [edk2] [PATCH v2 2/3] ArmPkg/Drivers: Add
> > EFI_MM_COMMUNICATION_PROTOCOL DXE driver.
> > 
> > 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
> > https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fi
> > nfocen
> > ter.arm.com%2Fhelp%2Ftopic%2Fcom.arm.doc.den0060a%2FDEN0060A_ARM_
> > MM_Interface_Specification.pdf=02%7C01%7Cudit.kumar%40nxp.com%
> > 7
> > C43194cfd48f84756da6908d51bc6185b%7C686ea1d3bc2b4c6fa92cd99c5c3016
> > 35%7C0%7C1%7C636445460008712743=Nk9bnFSzqB4zxCcyd4C2HyqZ2a
> > Iluu%2FWKXOVho4a6g8%3D=0
> > to communicate with the standalone MM environment in the secure
> > world.
> > 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Achin Gupta <achin.gu...@arm.com>
> > Signed-off-by: Supreeth Venkatesh <supreeth.venkat...@arm.com>
> > ---
> >  .../Drivers/MmCommunicationDxe/MmCommunication.c   | 339
> > +
> >  1 file changed, 339 insertions(+)
> >  create mode 100644
> > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > 
> > diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > new file mode 100644
> > index 00..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=http%3A%2F%2
> > Fopen
> > + source.org%2Flicenses%2Fbsd-
> > license.php=02%7C01%7Cudit.kumar%40nx
> > +
> > p.com%7C43194cfd48f84756da6908d51bc6185b%7C686ea1d3bc2b4c6fa92cd9
> > 9c5c3
> > +
> > 01635%7C0%7C0%7C636445460008712743=%2Fw7nb5B%2Bw3NKLV4v
> > 5LwcaQ0%2
> > + F6gh2Cva%2FEyDsb69NEAM%3D=0
> > +
> > +  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 
&

Re: [edk2] [PATCH v2 2/3] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2017-10-26 Thread Achin Gupta
Hi Supreeth,

some CIL,

On Wed, Oct 25, 2017 at 05:32:57PM +0100, Supreeth Venkatesh wrote:
> 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
> http://infocenter.arm.com/help/topic/com.arm.doc.den0060a/DEN0060A_ARM_MM_Interface_Specification.pdf
> to communicate with the standalone MM environment in the secure world.
>
> 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
>
> diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c 
> b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> new file mode 100644
> index 00..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
> +  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 
> +#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]  ThisThe EFI_MM_COMMUNICATION_PROTOCOL 
> instance.
> +  @param[in, out] CommBuffer  A pointer to the buffer to convey into 
> MMRAM.
> +  @param[in, out] CommSizeThe size of the data buffer being 
> passed in.On exit, the size of data
> +  being returned. Zero if the handler 
> does not wish to reply with any data.
> +
> +  @retval EFI_SUCCESS The message was successfully posted.
> +  @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*CommSizeOPTIONAL
> +  );
> +
> +//
> +// 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 = {
> +  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]  ThisThe EFI_MM_COMMUNICATION_PROTOCOL 
> instance.
> +  @param[in, out] CommBuffer  A pointer to the buffer to convey into 
> SMRAM.
> +  @param[in, 

Re: [edk2] [PATCH v2 2/3] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2017-10-25 Thread Udit Kumar
Hi 

> +  Status = gBS->AllocatePages (AllocateAddress,
> +   EfiRuntimeServicesData,
> +   EFI_SIZE_TO_PAGES 
> (mNsCommBuffMemRegion.Length),
> +   );
> +  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 =
> + gBS->InstallProtocolInterface (,
> +  ,
> +  EFI_NATIVE_INTERFACE,
> +  );  if
> + (EFI_ERROR(Status)) {
> +DEBUG ((DEBUG_ERROR, "MmCommunicationInitialize: Failed to install MM
> communication protocol\n"));

In case of error, you could free the above allocated memory 

> +return EFI_INVALID_PARAMETER;
> +  

Regards
Udit 

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Supreeth Venkatesh
> Sent: Wednesday, October 25, 2017 10:03 PM
> To: edk2-devel@lists.01.org
> Cc: leif.lindh...@linaro.org; ard.biesheu...@linaro.org
> Subject: [edk2] [PATCH v2 2/3] ArmPkg/Drivers: Add
> EFI_MM_COMMUNICATION_PROTOCOL DXE driver.
> 
> 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
> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Finfocen
> ter.arm.com%2Fhelp%2Ftopic%2Fcom.arm.doc.den0060a%2FDEN0060A_ARM_
> MM_Interface_Specification.pdf=02%7C01%7Cudit.kumar%40nxp.com%7
> C43194cfd48f84756da6908d51bc6185b%7C686ea1d3bc2b4c6fa92cd99c5c3016
> 35%7C0%7C1%7C636445460008712743=Nk9bnFSzqB4zxCcyd4C2HyqZ2a
> Iluu%2FWKXOVho4a6g8%3D=0
> to communicate with the standalone MM environment in the secure world.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Achin Gupta <achin.gu...@arm.com>
> Signed-off-by: Supreeth Venkatesh <supreeth.venkat...@arm.com>
> ---
>  .../Drivers/MmCommunicationDxe/MmCommunication.c   | 339
> +
>  1 file changed, 339 insertions(+)
>  create mode 100644
> ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> 
> diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> new file mode 100644
> index 00..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=http%3A%2F%2Fopen
> + source.org%2Flicenses%2Fbsd-
> license.php=02%7C01%7Cudit.kumar%40nx
> +
> p.com%7C43194cfd48f84756da6908d51bc6185b%7C686ea1d3bc2b4c6fa92cd9
> 9c5c3
> +
> 01635%7C0%7C0%7C636445460008712743=%2Fw7nb5B%2Bw3NKLV4v
> 5LwcaQ0%2
> + F6gh2Cva%2FEyDsb69NEAM%3D=0
> +
> +  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]  ThisThe EFI_MM_COMMUNICATION_PROTOCOL
> instance.
> +  @param[in, out] CommBuffer  A pointer to the buffer to convey into
> MMRAM.
> +  @param[in, out] CommSizeThe size of the data buffer being 
> passed
> in.On exit, the size of data
> +  being returned. Zero if the handler 
> does not wish to reply
> with any data.
> +
> +

[edk2] [PATCH v2 2/3] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2017-10-25 Thread Supreeth Venkatesh
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
http://infocenter.arm.com/help/topic/com.arm.doc.den0060a/DEN0060A_ARM_MM_Interface_Specification.pdf
to communicate with the standalone MM environment in the secure world.

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

diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c 
b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
new file mode 100644
index 00..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
+  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 
+#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]  ThisThe EFI_MM_COMMUNICATION_PROTOCOL 
instance.
+  @param[in, out] CommBuffer  A pointer to the buffer to convey into 
MMRAM.
+  @param[in, out] CommSizeThe size of the data buffer being passed 
in.On exit, the size of data
+  being returned. Zero if the handler does 
not wish to reply with any data.
+
+  @retval EFI_SUCCESS The message was successfully posted.
+  @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*CommSizeOPTIONAL
+  );
+
+//
+// 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 = {
+  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]  ThisThe EFI_MM_COMMUNICATION_PROTOCOL 
instance.
+  @param[in, out] CommBuffer  A pointer to the buffer to convey into 
SMRAM.
+  @param[in, out] CommSizeThe size of the data buffer being passed 
in.On exit, the size of data
+  being returned. Zero if the handler does 
not wish to reply with any data.
+
+  @retval EFI_SUCCESS The message was successfully posted.
+  @retval EFI_INVALID_PARAMETER   The CommBuffer was NULL.
+  @retval