Re: [edk2] [PATCH v1 08/18] StandaloneMmPkg/MemLib: AARCH64 Specific instance of memory check library.

2018-05-04 Thread Supreeth Venkatesh
My response inline.

-Original Message-
From: Achin Gupta
Sent: Monday, April 16, 2018 10:13 AM
To: Supreeth Venkatesh 
Cc: edk2-devel@lists.01.org; michael.d.kin...@intel.com; liming@intel.com; 
jiewen@intel.com; leif.lindh...@linaro.org; ard.biesheu...@linaro.org; nd 

Subject: Re: [PATCH v1 08/18] StandaloneMmPkg/MemLib: AARCH64 Specific instance 
of memory check library.

Hi Supreeth,

On Fri, Apr 06, 2018 at 03:42:13PM +0100, Supreeth Venkatesh wrote:
> MM memory check library library implementation. This library consumes
> MM_ACCESS_PROTOCOL to get MMRAM information. In order to use this
> library instance, the platform should produce all MMRAM range via
> MM_ACCESS_PROTOCOL, including the range for firmware (like MM Core and
> MM driver) and/or specific dedicated hardware.
>
> This patch provides services for MM Memory Operation.
> The management mode Mem Library provides function for checking if
> buffer is outside MMRAM and valid. It also provides functions for copy
> data from MMRAM to non-MMRAM, from non-MMRAM to MMRAM, from non-MMRAM
> to non-MMRAM, or set data in non-MMRAM.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Achin Gupta 
> Signed-off-by: Supreeth Venkatesh 
> ---
>  StandaloneMmPkg/Include/Library/MemLib.h| 140 ++
>  StandaloneMmPkg/Library/MemLib/Arm/MemLib.c | 276
> 

Why is this Library Arm specific. Apart from cosmetics tweaks, it has not 
changed since it was originally contributed?
[Supreeth] Modified it to separate out 
MmMemLibInternalCalculateMaximumSupportAddress() specific to archictecture as 
mentioned by Jiewen. Rest of them are generic.

cheers,
Achin

>  StandaloneMmPkg/Library/MemLib/MemLib.inf   |  47 +
>  3 files changed, 463 insertions(+)
>  create mode 100644 StandaloneMmPkg/Include/Library/MemLib.h
>  create mode 100644 StandaloneMmPkg/Library/MemLib/Arm/MemLib.c
>  create mode 100644 StandaloneMmPkg/Library/MemLib/MemLib.inf
>
> diff --git a/StandaloneMmPkg/Include/Library/MemLib.h
> b/StandaloneMmPkg/Include/Library/MemLib.h
> new file mode 100644
> index 00..3264f10010
> --- /dev/null
> +++ b/StandaloneMmPkg/Include/Library/MemLib.h
> @@ -0,0 +1,140 @@
> +/** @file
> +  Provides services for MM Memory Operation.
> +
> +  The MM Mem Library provides function for checking if buffer is outside 
> MMRAM and valid.
> +  It also provides functions for copy data from MMRAM to non-MMRAM,
> + from non-MMRAM to MMRAM,  from non-MMRAM to non-MMRAM, or set data in 
> non-MMRAM.
> +
> +  Copyright (c) 2015, Intel Corporation. All rights reserved.
> + 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.
> +
> +**/
> +
> +#ifndef _MM_MEM_LIB_H_
> +#define _MM_MEM_LIB_H_
> +
> +/**
> +  This function check if the buffer is valid per processor architecture and 
> not overlap with MMRAM.
> +
> +  @param Buffer  The buffer start address to be checked.
> +  @param Length  The buffer length to be checked.
> +
> +  @retval TRUE  This buffer is valid per processor architecture and not 
> overlap with MMRAM.
> +  @retval FALSE This buffer is not valid per processor architecture or 
> overlap with MMRAM.
> +**/
> +BOOLEAN
> +EFIAPI
> +MmIsBufferOutsideMmValid (
> +  IN EFI_PHYSICAL_ADDRESS  Buffer,
> +  IN UINT64Length
> +  );
> +
> +/**
> +  Copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).
> +
> +  This function copies a source buffer (non-MMRAM) to a destination buffer 
> (MMRAM).
> +  It checks if source buffer is valid per processor architecture and not 
> overlap with MMRAM.
> +  If the check passes, it copies memory and returns EFI_SUCCESS.
> +  If the check fails, it return EFI_SECURITY_VIOLATION.
> +  The implementation must be reentrant.
> +
> +  @param  DestinationBuffer   The pointer to the destination buffer of the 
> memory copy.
> +  @param  SourceBufferThe pointer to the source buffer of the memory 
> copy.
> +  @param  Length  The number of bytes to copy from SourceBuffer 
> to DestinationBuffer.
> +
> +  @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor 
> architecture or overlap with MMRAM.
> +  @retval EFI_SUCCESSMemory is copied.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +MmCopyMemToSmram (
> +  OUT VOID   *DestinationBuffer,
> +  IN CONST VOID  *SourceBuffer,
> +  IN UINTN   Length
> +  );
> +
> +/**
> +  Copies a source buffer (MMRAM) 

Re: [edk2] [PATCH v1 08/18] StandaloneMmPkg/MemLib: AARCH64 Specific instance of memory check library.

2018-04-26 Thread Yao, Jiewen
You are right.

I propose to add Arm and X86 specific folder - just include PA calculation.
We can leave the generic function in common folder.

The final layout can be:
StandaloneMmPkg/Library/MmMemLib/MmMemLib.c
StandaloneMmPkg/Library/MmMemLib/MmMemLib.inf
StandaloneMmPkg/Library/MmMemLib/Arm/ArchSpecific.c
StandaloneMmPkg/Library/MmMemLib/AArch64/ArchSpecific.c 
StandaloneMmPkg/Library/MmMemLib/Ia32/ArchSpecific.c
StandaloneMmPkg/Library/MmMemLib/X64/ArchSpecific.c

Thank you
Yao Jiewen

> -Original Message-
> From: Achin Gupta [mailto:achin.gu...@arm.com]
> Sent: Wednesday, April 25, 2018 3:36 AM
> To: Yao, Jiewen <jiewen@intel.com>
> Cc: Supreeth Venkatesh <supreeth.venkat...@arm.com>;
> ard.biesheu...@linaro.org; edk2-devel@lists.01.org; leif.lindh...@linaro.org;
> Gao, Liming <liming@intel.com>; Kinney, Michael D
> <michael.d.kin...@intel.com>; n...@arm.com
> Subject: Re: [edk2] [PATCH v1 08/18] StandaloneMmPkg/MemLib: AARCH64
> Specific instance of memory check library.
> 
> Hi Jiewen,
> 
> On Mon, Apr 16, 2018 at 10:30:55PM +, Yao, Jiewen wrote:
> > Hi
> > I don't think this lib is generic, because it hardcode the physical address 
> > bits.
> >
> > PhysicalAddressBits = 36;
> >
> > For X86 CPU, we get it from CPUID. :-)
> >
> > As enhancement, we may put most common C-code logic (such as CopyMem,
> or memmap calculation) to StandaloneMmPkg/MemLib, and only include the
> PhysicalAddresBit calculation under StandaloneMmPkg/MemLib/Arm folder.
> >
> > As such, we know clearly on which one is ARM specific.
> 
> My point was that the hardocoded PA bits were not introduced to make this code
> work on Arm. This has been present in the StandaloneMmPkg from the outset. I
> guess for x86 you have moved on to getting this information from the
> CPUID. Afaics, this function is not be used on Arm platforms but Supreeth will
> double check. If that is the case then only the generic library will be 
> required
> minus this function.
> 
> cheers,
> Achin
> 
> >
> > Thank you
> > Yao Jiewen
> >
> > > -Original Message-
> > > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Achin
> > > Gupta
> > > Sent: Monday, April 16, 2018 11:13 PM
> > > To: Supreeth Venkatesh <supreeth.venkat...@arm.com>
> > > Cc: ard.biesheu...@linaro.org; edk2-devel@lists.01.org;
> > > leif.lindh...@linaro.org; Yao, Jiewen <jiewen@intel.com>; Gao, Liming
> > > <liming@intel.com>; Kinney, Michael D <michael.d.kin...@intel.com>;
> > > n...@arm.com
> > > Subject: Re: [edk2] [PATCH v1 08/18] StandaloneMmPkg/MemLib: AARCH64
> > > Specific instance of memory check library.
> > >
> > > Hi Supreeth,
> > >
> > > On Fri, Apr 06, 2018 at 03:42:13PM +0100, Supreeth Venkatesh wrote:
> > > > MM memory check library library implementation. This library consumes
> > > > MM_ACCESS_PROTOCOL to get MMRAM information. In order to use this
> > > > library instance, the platform should produce all MMRAM range via
> > > > MM_ACCESS_PROTOCOL, including the range for firmware (like MM Core
> > > > and MM driver) and/or specific dedicated hardware.
> > > >
> > > > This patch provides services for MM Memory Operation.
> > > > The management mode Mem Library provides function for checking if
> buffer
> > > > is outside MMRAM and valid. It also provides functions for copy data
> > > > from MMRAM to non-MMRAM, from non-MMRAM to MMRAM,
> > > > from non-MMRAM to non-MMRAM, or set data in non-MMRAM.
> > > >
> > > > 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>
> > > > ---
> > > >  StandaloneMmPkg/Include/Library/MemLib.h| 140
> ++
> > > >  StandaloneMmPkg/Library/MemLib/Arm/MemLib.c | 276
> > > 
> > >
> > > Why is this Library Arm specific. Apart from cosmetics tweaks, it has not
> > > changed since it was originally contributed?
> > >
> > > cheers,
> > > Achin
> > >
> > > >  StandaloneMmPkg/Library/MemLib/MemLib.inf   |  47 +
> > > >  3 files changed, 463 insertions(+)
> > > >  create mode 100644 StandaloneMmPkg/Include/Library/MemLib.h
> > > >  create mode 100644 StandaloneMmPkg/Library/MemLib/Arm/MemLib.c
> > >

Re: [edk2] [PATCH v1 08/18] StandaloneMmPkg/MemLib: AARCH64 Specific instance of memory check library.

2018-04-25 Thread Achin Gupta
Hi Jiewen,

On Mon, Apr 16, 2018 at 10:30:55PM +, Yao, Jiewen wrote:
> Hi
> I don't think this lib is generic, because it hardcode the physical address 
> bits.
> 
> PhysicalAddressBits = 36;
> 
> For X86 CPU, we get it from CPUID. :-)
> 
> As enhancement, we may put most common C-code logic (such as CopyMem, or 
> memmap calculation) to StandaloneMmPkg/MemLib, and only include the 
> PhysicalAddresBit calculation under StandaloneMmPkg/MemLib/Arm folder.
> 
> As such, we know clearly on which one is ARM specific.

My point was that the hardocoded PA bits were not introduced to make this code
work on Arm. This has been present in the StandaloneMmPkg from the outset. I
guess for x86 you have moved on to getting this information from the
CPUID. Afaics, this function is not be used on Arm platforms but Supreeth will
double check. If that is the case then only the generic library will be required
minus this function.

cheers,
Achin

> 
> Thank you
> Yao Jiewen
> 
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Achin
> > Gupta
> > Sent: Monday, April 16, 2018 11:13 PM
> > To: Supreeth Venkatesh <supreeth.venkat...@arm.com>
> > Cc: ard.biesheu...@linaro.org; edk2-devel@lists.01.org;
> > leif.lindh...@linaro.org; Yao, Jiewen <jiewen@intel.com>; Gao, Liming
> > <liming....@intel.com>; Kinney, Michael D <michael.d.kin...@intel.com>;
> > n...@arm.com
> > Subject: Re: [edk2] [PATCH v1 08/18] StandaloneMmPkg/MemLib: AARCH64
> > Specific instance of memory check library.
> > 
> > Hi Supreeth,
> > 
> > On Fri, Apr 06, 2018 at 03:42:13PM +0100, Supreeth Venkatesh wrote:
> > > MM memory check library library implementation. This library consumes
> > > MM_ACCESS_PROTOCOL to get MMRAM information. In order to use this
> > > library instance, the platform should produce all MMRAM range via
> > > MM_ACCESS_PROTOCOL, including the range for firmware (like MM Core
> > > and MM driver) and/or specific dedicated hardware.
> > >
> > > This patch provides services for MM Memory Operation.
> > > The management mode Mem Library provides function for checking if buffer
> > > is outside MMRAM and valid. It also provides functions for copy data
> > > from MMRAM to non-MMRAM, from non-MMRAM to MMRAM,
> > > from non-MMRAM to non-MMRAM, or set data in non-MMRAM.
> > >
> > > 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>
> > > ---
> > >  StandaloneMmPkg/Include/Library/MemLib.h| 140 ++
> > >  StandaloneMmPkg/Library/MemLib/Arm/MemLib.c | 276
> > 
> > 
> > Why is this Library Arm specific. Apart from cosmetics tweaks, it has not
> > changed since it was originally contributed?
> > 
> > cheers,
> > Achin
> > 
> > >  StandaloneMmPkg/Library/MemLib/MemLib.inf   |  47 +
> > >  3 files changed, 463 insertions(+)
> > >  create mode 100644 StandaloneMmPkg/Include/Library/MemLib.h
> > >  create mode 100644 StandaloneMmPkg/Library/MemLib/Arm/MemLib.c
> > >  create mode 100644 StandaloneMmPkg/Library/MemLib/MemLib.inf
> > >
> > > diff --git a/StandaloneMmPkg/Include/Library/MemLib.h
> > b/StandaloneMmPkg/Include/Library/MemLib.h
> > > new file mode 100644
> > > index 00..3264f10010
> > > --- /dev/null
> > > +++ b/StandaloneMmPkg/Include/Library/MemLib.h
> > > @@ -0,0 +1,140 @@
> > > +/** @file
> > > +  Provides services for MM Memory Operation.
> > > +
> > > +  The MM Mem Library provides function for checking if buffer is outside
> > MMRAM and valid.
> > > +  It also provides functions for copy data from MMRAM to non-MMRAM,
> > from non-MMRAM to MMRAM,
> > > +  from non-MMRAM to non-MMRAM, or set data in non-MMRAM.
> > > +
> > > +  Copyright (c) 2015, Intel Corporation. All rights reserved.
> > > +  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 T

Re: [edk2] [PATCH v1 08/18] StandaloneMmPkg/MemLib: AARCH64 Specific instance of memory check library.

2018-04-16 Thread Yao, Jiewen
Hi
I don't think this lib is generic, because it hardcode the physical address 
bits.

PhysicalAddressBits = 36;

For X86 CPU, we get it from CPUID. :-)

As enhancement, we may put most common C-code logic (such as CopyMem, or memmap 
calculation) to StandaloneMmPkg/MemLib, and only include the PhysicalAddresBit 
calculation under StandaloneMmPkg/MemLib/Arm folder.

As such, we know clearly on which one is ARM specific.

Thank you
Yao Jiewen

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Achin
> Gupta
> Sent: Monday, April 16, 2018 11:13 PM
> To: Supreeth Venkatesh <supreeth.venkat...@arm.com>
> Cc: ard.biesheu...@linaro.org; edk2-devel@lists.01.org;
> leif.lindh...@linaro.org; Yao, Jiewen <jiewen@intel.com>; Gao, Liming
> <liming@intel.com>; Kinney, Michael D <michael.d.kin...@intel.com>;
> n...@arm.com
> Subject: Re: [edk2] [PATCH v1 08/18] StandaloneMmPkg/MemLib: AARCH64
> Specific instance of memory check library.
> 
> Hi Supreeth,
> 
> On Fri, Apr 06, 2018 at 03:42:13PM +0100, Supreeth Venkatesh wrote:
> > MM memory check library library implementation. This library consumes
> > MM_ACCESS_PROTOCOL to get MMRAM information. In order to use this
> > library instance, the platform should produce all MMRAM range via
> > MM_ACCESS_PROTOCOL, including the range for firmware (like MM Core
> > and MM driver) and/or specific dedicated hardware.
> >
> > This patch provides services for MM Memory Operation.
> > The management mode Mem Library provides function for checking if buffer
> > is outside MMRAM and valid. It also provides functions for copy data
> > from MMRAM to non-MMRAM, from non-MMRAM to MMRAM,
> > from non-MMRAM to non-MMRAM, or set data in non-MMRAM.
> >
> > 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>
> > ---
> >  StandaloneMmPkg/Include/Library/MemLib.h| 140 ++
> >  StandaloneMmPkg/Library/MemLib/Arm/MemLib.c | 276
> 
> 
> Why is this Library Arm specific. Apart from cosmetics tweaks, it has not
> changed since it was originally contributed?
> 
> cheers,
> Achin
> 
> >  StandaloneMmPkg/Library/MemLib/MemLib.inf   |  47 +
> >  3 files changed, 463 insertions(+)
> >  create mode 100644 StandaloneMmPkg/Include/Library/MemLib.h
> >  create mode 100644 StandaloneMmPkg/Library/MemLib/Arm/MemLib.c
> >  create mode 100644 StandaloneMmPkg/Library/MemLib/MemLib.inf
> >
> > diff --git a/StandaloneMmPkg/Include/Library/MemLib.h
> b/StandaloneMmPkg/Include/Library/MemLib.h
> > new file mode 100644
> > index 00..3264f10010
> > --- /dev/null
> > +++ b/StandaloneMmPkg/Include/Library/MemLib.h
> > @@ -0,0 +1,140 @@
> > +/** @file
> > +  Provides services for MM Memory Operation.
> > +
> > +  The MM Mem Library provides function for checking if buffer is outside
> MMRAM and valid.
> > +  It also provides functions for copy data from MMRAM to non-MMRAM,
> from non-MMRAM to MMRAM,
> > +  from non-MMRAM to non-MMRAM, or set data in non-MMRAM.
> > +
> > +  Copyright (c) 2015, Intel Corporation. All rights reserved.
> > +  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.
> > +
> > +**/
> > +
> > +#ifndef _MM_MEM_LIB_H_
> > +#define _MM_MEM_LIB_H_
> > +
> > +/**
> > +  This function check if the buffer is valid per processor architecture 
> > and not
> overlap with MMRAM.
> > +
> > +  @param Buffer  The buffer start address to be checked.
> > +  @param Length  The buffer length to be checked.
> > +
> > +  @retval TRUE  This buffer is valid per processor architecture and not
> overlap with MMRAM.
> > +  @retval FALSE This buffer is not valid per processor architecture or 
> > overlap
> with MMRAM.
> > +**/
> > +BOOLEAN
> > +EFIAPI
> > +MmIsBufferOutsideMmValid (
> > +  IN EFI_PHYSICAL_ADDRESS  Buffer,
> > +  IN UINT64Length
> > +  

Re: [edk2] [PATCH v1 08/18] StandaloneMmPkg/MemLib: AARCH64 Specific instance of memory check library.

2018-04-16 Thread Achin Gupta
Hi Supreeth,

On Fri, Apr 06, 2018 at 03:42:13PM +0100, Supreeth Venkatesh wrote:
> MM memory check library library implementation. This library consumes
> MM_ACCESS_PROTOCOL to get MMRAM information. In order to use this
> library instance, the platform should produce all MMRAM range via
> MM_ACCESS_PROTOCOL, including the range for firmware (like MM Core
> and MM driver) and/or specific dedicated hardware.
> 
> This patch provides services for MM Memory Operation.
> The management mode Mem Library provides function for checking if buffer
> is outside MMRAM and valid. It also provides functions for copy data
> from MMRAM to non-MMRAM, from non-MMRAM to MMRAM,
> from non-MMRAM to non-MMRAM, or set data in non-MMRAM.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Achin Gupta 
> Signed-off-by: Supreeth Venkatesh 
> ---
>  StandaloneMmPkg/Include/Library/MemLib.h| 140 ++
>  StandaloneMmPkg/Library/MemLib/Arm/MemLib.c | 276 
> 

Why is this Library Arm specific. Apart from cosmetics tweaks, it has not
changed since it was originally contributed?

cheers,
Achin

>  StandaloneMmPkg/Library/MemLib/MemLib.inf   |  47 +
>  3 files changed, 463 insertions(+)
>  create mode 100644 StandaloneMmPkg/Include/Library/MemLib.h
>  create mode 100644 StandaloneMmPkg/Library/MemLib/Arm/MemLib.c
>  create mode 100644 StandaloneMmPkg/Library/MemLib/MemLib.inf
> 
> diff --git a/StandaloneMmPkg/Include/Library/MemLib.h 
> b/StandaloneMmPkg/Include/Library/MemLib.h
> new file mode 100644
> index 00..3264f10010
> --- /dev/null
> +++ b/StandaloneMmPkg/Include/Library/MemLib.h
> @@ -0,0 +1,140 @@
> +/** @file
> +  Provides services for MM Memory Operation.
> +
> +  The MM Mem Library provides function for checking if buffer is outside 
> MMRAM and valid.
> +  It also provides functions for copy data from MMRAM to non-MMRAM, from 
> non-MMRAM to MMRAM,
> +  from non-MMRAM to non-MMRAM, or set data in non-MMRAM.
> +
> +  Copyright (c) 2015, Intel Corporation. All rights reserved.
> +  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.
> +
> +**/
> +
> +#ifndef _MM_MEM_LIB_H_
> +#define _MM_MEM_LIB_H_
> +
> +/**
> +  This function check if the buffer is valid per processor architecture and 
> not overlap with MMRAM.
> +
> +  @param Buffer  The buffer start address to be checked.
> +  @param Length  The buffer length to be checked.
> +
> +  @retval TRUE  This buffer is valid per processor architecture and not 
> overlap with MMRAM.
> +  @retval FALSE This buffer is not valid per processor architecture or 
> overlap with MMRAM.
> +**/
> +BOOLEAN
> +EFIAPI
> +MmIsBufferOutsideMmValid (
> +  IN EFI_PHYSICAL_ADDRESS  Buffer,
> +  IN UINT64Length
> +  );
> +
> +/**
> +  Copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).
> +
> +  This function copies a source buffer (non-MMRAM) to a destination buffer 
> (MMRAM).
> +  It checks if source buffer is valid per processor architecture and not 
> overlap with MMRAM.
> +  If the check passes, it copies memory and returns EFI_SUCCESS.
> +  If the check fails, it return EFI_SECURITY_VIOLATION.
> +  The implementation must be reentrant.
> +
> +  @param  DestinationBuffer   The pointer to the destination buffer of the 
> memory copy.
> +  @param  SourceBufferThe pointer to the source buffer of the memory 
> copy.
> +  @param  Length  The number of bytes to copy from SourceBuffer 
> to DestinationBuffer.
> +
> +  @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor 
> architecture or overlap with MMRAM.
> +  @retval EFI_SUCCESSMemory is copied.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +MmCopyMemToSmram (
> +  OUT VOID   *DestinationBuffer,
> +  IN CONST VOID  *SourceBuffer,
> +  IN UINTN   Length
> +  );
> +
> +/**
> +  Copies a source buffer (MMRAM) to a destination buffer (NON-MMRAM).
> +
> +  This function copies a source buffer (non-MMRAM) to a destination buffer 
> (MMRAM).
> +  It checks if destination buffer is valid per processor architecture and 
> not overlap with MMRAM.
> +  If the check passes, it copies memory and returns EFI_SUCCESS.
> +  If the check fails, it returns EFI_SECURITY_VIOLATION.
> +  The implementation must be reentrant.
> +
> +  @param  DestinationBuffer   The pointer to the destination buffer of the 
> memory copy.
> +  @param  SourceBufferThe pointer to the source buffer of the memory 
> copy.