[edk2] [PATCH edk2-platforms v3 3/3] Platform/ARM/SgiPkg: Enable MmCommunication module on the platform

2018-12-26 Thread Sughosh Ganu
The ArmMmCommunication module is used for communication between
non-secure and secure world using Arm's Management Mode
Specification. Enable this module on Sgi platforms. This would be used
subsequently by the RAS and SecureBoot features, support for which
is to be added on the platform.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 Platform/ARM/SgiPkg/SgiPlatform.dsc | 2 ++
 Platform/ARM/SgiPkg/SgiPlatform.fdf | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc 
b/Platform/ARM/SgiPkg/SgiPlatform.dsc
index f9e50f00b121..bdb4ecb06d19 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.dsc
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc
@@ -343,3 +343,5 @@ [Components.common]
   # SATA Controller
   #
   MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
+
+  ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
diff --git a/Platform/ARM/SgiPkg/SgiPlatform.fdf 
b/Platform/ARM/SgiPkg/SgiPlatform.fdf
index 80c3412fd4ad..7916a5246902 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.fdf
+++ b/Platform/ARM/SgiPkg/SgiPlatform.fdf
@@ -169,6 +169,9 @@ [FV.FvMain]
   #
   INF  ShellPkg/Application/Shell/Shell.inf
 
+  # MM Communicate
+  INF ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
+
   #
   # Platform driver
   #
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v3 2/3] Platform/ARM/SgiPkg: Setup memory buffers for MmCommunicate

2018-12-26 Thread Sughosh Ganu
Add memory regions for MmCommuncate buffers into the virtual memory
table.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 Platform/ARM/SgiPkg/SgiPlatform.dsc  | 12 
 Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf  |  4 
 Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c |  8 +++-
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc 
b/Platform/ARM/SgiPkg/SgiPlatform.dsc
index 7995c7d132d6..f9e50f00b121 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.dsc
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc
@@ -197,6 +197,18 @@ [PcdsFixedAtBuild.common]
   gArmSgiTokenSpaceGuid.PcdVirtioNetSize|0x1
   gArmSgiTokenSpaceGuid.PcdVirtioNetInterrupt|204
 
+  #
+  # Set the base address and size of the buffer used
+  # for communication between the Normal world edk2
+  # with StandaloneMm image at S-EL0 through MM_COMMUNICATE.
+  # This buffer gets allocated in ATF and since we do not have
+  # a mechanism currently to communicate the base address and
+  # size of this buffer from ATF, hard-code it here
+  #
+  ## MM Communicate
+  gArmTokenSpaceGuid.PcdMmBufferBase|0xFF60
+  gArmTokenSpaceGuid.PcdMmBufferSize|0x1
+
 

 #
 # Components Section - list of all EDK II Modules needed by this Platform
diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf 
b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
index 260be58fb38c..c0fcc8198201 100644
--- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
+++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
@@ -25,6 +25,7 @@ [Packages]
   MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
   Platform/ARM/SgiPkg/SgiPlatform.dec
+  StandaloneMmPkg/StandaloneMmPkg.dec
 
 [LibraryClasses]
   ArmLib
@@ -62,6 +63,9 @@ [FixedPcd]
   gArmTokenSpaceGuid.PcdPciMmio64Base
   gArmTokenSpaceGuid.PcdPciMmio64Size
 
+  gArmTokenSpaceGuid.PcdMmBufferBase
+  gArmTokenSpaceGuid.PcdMmBufferSize
+
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
 
 [Guids]
diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c 
b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c
index 6ec2e8a7096d..60729e3c7158 100644
--- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c
+++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c
@@ -22,7 +22,7 @@
 #include 
 
 // Total number of descriptors, including the final "end-of-table" descriptor.
-#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS  12
+#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS  13
 
 /**
   Returns the Virtual Memory Map of the platform.
@@ -136,6 +136,12 @@ ArmPlatformGetVirtualMemoryMap (
SIZE_1MB;
   VirtualMemoryTable[Index].Attributes  = 
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
 
+ // MM Memory Space
+  VirtualMemoryTable[++Index].PhysicalBase  = PcdGet64 (PcdMmBufferBase);
+  VirtualMemoryTable[Index].VirtualBase = PcdGet64 (PcdMmBufferBase);
+  VirtualMemoryTable[Index].Length  = PcdGet64 (PcdMmBufferSize);
+  VirtualMemoryTable[Index].Attributes  = 
ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
+
   // End of Table
   VirtualMemoryTable[++Index].PhysicalBase  = 0;
   VirtualMemoryTable[Index].VirtualBase = 0;
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v3 1/3] Platform/ARM/SgiPkg: Build infrastructure for StandaloneMm image

2018-12-26 Thread Sughosh Ganu
Add the build infrastructure for compilation of StandaloneMm image
files and FD file.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc | 128 
 Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf |  99 +++
 2 files changed, 227 insertions(+)

diff --git a/Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc 
b/Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
new file mode 100644
index ..6cdbcd84422c
--- /dev/null
+++ b/Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
@@ -0,0 +1,128 @@
+#
+#  Copyright (c) 2018, 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.
+#
+
+
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+
+[Defines]
+  PLATFORM_NAME  = Sgi_Mm_Standalone
+  PLATFORM_GUID  = 34B78C8F-CFD5-49D5-8360-E91143F6106D
+  PLATFORM_VERSION   = 1.0
+  DSC_SPECIFICATION  = 0x00010011
+  OUTPUT_DIRECTORY   = Build/$(PLATFORM_NAME)
+  SUPPORTED_ARCHITECTURES= AARCH64
+  BUILD_TARGETS  = DEBUG|RELEASE|NOOPT
+  SKUID_IDENTIFIER   = DEFAULT
+  FLASH_DEFINITION   = Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf
+  DEFINE DEBUG_MESSAGE   = TRUE
+
+  # LzmaF86
+  DEFINE COMPRESSION_TOOL_GUID   = D42AE6BD-1352-4bfb-909A-CA72A6EAE889
+
+
+#
+# Library Class section - list of all Library Classes needed by this Platform.
+#
+
+[LibraryClasses]
+  #
+  # Basic
+  #
+  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+  
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
+  FvLib|StandaloneMmPkg/Library/FvLib/FvLib.inf
+  
HobLib|StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf
+  IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
+  MemLib|StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf
+  
MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.inf
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
+  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+  
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
+
+  #
+  # Entry point
+  #
+  
StandaloneMmDriverEntryPoint|StandaloneMmPkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
+
+  ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
+  
StandaloneMmMmuLib|ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
+  ArmSvcLib|ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf
+  
CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
+  
PeCoffExtraActionLib|StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
+
+  # ARM PL011 UART Driver
+  
PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartClockLib.inf
+  PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf
+  
SerialPortLib|ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.inf
+
+  
StandaloneMmCoreEntryPoint|StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
+
+
+#
+# Pcd Section - list of all EDK II PCD Entries defined by this Platform
+#
+
+[PcdsFeatureFlag]
+  gStandaloneMmPkgTokenSpaceGuid.PcdStandaloneMmEnable|TRUE
+
+[PcdsFixedAtBuild]
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80CF
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xff
+  gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x0f
+
+  ## PL011 - Serial Terminal
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x7FF7
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
+
+###
+#
+# Components Section - list of t

[edk2] [PATCH edk2-platforms v3 0/3] Platform/ARM/SgiPkg: Enable StandaloneMm on Sgi platforms

2018-12-26 Thread Sughosh Ganu
Changes since v2: Handle review comments from Ard Biesheuvel

The following patches enable building of StandaloneMm image on Sgi
platforms.

The first patch adds build infra for StandaloneMm image. The second
patch of the series adds memory buffer required for communication
between the non-secure world with StandaloneMm image using MM
Communicate. The third patch of the series enables MmCommunication
module on the platform for it subsequent use by features like
Secure-Boot and Error Injection and Handling for RAS.

Sughosh Ganu (3):
  Platform/ARM/SgiPkg: Build infrastructure for StandaloneMm image
  Platform/ARM/SgiPkg: Setup memory buffers for MmCommunicate
  Platform/ARM/SgiPkg: Enable MmCommunication module on the platform

 Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc | 128 

 Platform/ARM/SgiPkg/SgiPlatform.dsc  |  14 +++
 Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf |  99 +++
 Platform/ARM/SgiPkg/SgiPlatform.fdf  |   3 +
 Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf  |   4 +
 Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c |   8 +-
 6 files changed, 255 insertions(+), 1 deletion(-)
 create mode 100644 Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
 create mode 100644 Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf

-- 
2.7.4


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms v2 1/3] Platform/ARM/SgiPkg: Build infrastructure for StandaloneMm image

2018-12-26 Thread Sughosh Ganu
On Thu Dec 20, 2018 at 09:46:34AM +0100, Ard Biesheuvel wrote:
> On Thu, 20 Dec 2018 at 06:48, Sughosh Ganu  wrote:
> >
> > Add the build infrastructure for compilation of StandaloneMm image
> > files and FD file.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Sughosh Ganu 
> > ---
> >  Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc | 130 
> > +++
> >  Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf | 100 +
> >  2 files changed, 230 insertions(+)
> >  create mode 100644 Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
> >  create mode 100644 Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf




> > diff --git a/Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf 
> > b/Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf
> > new file mode 100644
> > index ..6b9d1e703869
> > --- /dev/null
> > +++ b/Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf
> > @@ -0,0 +1,100 @@
> > +#
> > +#  Copyright (c) 2018, 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.
> > +#
> > +
> > +
> > +#
> > +# FD Section
> > +# The [FD] Section is made up of the definition statements and a
> > +# description of what goes into  the Flash Device Image.  Each FD section
> > +# defines one flash "device" image.  A flash device image may be one of
> > +# the following: Removable media bootable image (like a boot floppy
> > +# image,) an Option ROM image (that would be "flashed" into an add-in
> > +# card,) a System "Flash"  image (that would be burned into a system's
> > +# flash) or an Update ("Capsule") image that will be used to update and
> > +# existing system flash.
> > +#
> > +
> > +
> > +[FD.BL32_AP_MM]
> > +BaseAddress   = 0xff20|gArmTokenSpaceGuid.PcdFdBaseAddress  # UEFI in 
> > DRAM + 128MB.
> > +Size  = 0x00e0|gArmTokenSpaceGuid.PcdFdSize # The size 
> > in bytes of the device (64MiB).
> > +ErasePolarity = 1
> 
> Indent ^^
> 
> > +
> > +# This one is tricky, it must be: BlockSize * NumBlocks = Size
> 
> Please drop the silly line above
> 
> > +BlockSize = 0x1000
> > +NumBlocks = 0x0e00
> > +
> 
> indent ^^^
> 
> > +0x|0x0028
> > +gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize
> > +FV = FVMAIN_COMPACT
> > +
> > +[FV.FVMAIN_COMPACT]
> > +FvAlignment= 16
> > +ERASE_POLARITY = 1
> > +MEMORY_MAPPED  = TRUE
> > +STICKY_WRITE   = TRUE
> > +LOCK_CAP   = TRUE
> > +LOCK_STATUS= TRUE
> > +WRITE_DISABLED_CAP = TRUE
> > +WRITE_ENABLED_CAP  = TRUE
> > +WRITE_STATUS   = TRUE
> > +WRITE_LOCK_CAP = TRUE
> > +WRITE_LOCK_STATUS  = TRUE
> > +READ_DISABLED_CAP  = TRUE
> > +READ_ENABLED_CAP   = TRUE
> > +READ_STATUS= TRUE
> > +READ_LOCK_CAP  = TRUE
> > +READ_LOCK_STATUS   = TRUE
> 
> Indent ^^


Can you tell me what is the correct indentation here. I checked
multiple platforms and they all seem to be using the same
indentation. Or am i missing something here.

-sughosh
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms v2 3/3] Platform/ARM/SgiPkg: Enable MmCommunication module on the platform

2018-12-20 Thread Sughosh Ganu
On Thu Dec 20, 2018 at 09:52:46AM +0100, Ard Biesheuvel wrote:
> On Thu, 20 Dec 2018 at 06:48, Sughosh Ganu  wrote:
> >
> > The ArmMmCommunication module is used for communication between
> > non-secure and secure world using Arm's Management Mode
> > Specification. Enable this module on Sgi platforms. This would be used
> > subsequently by the RAS and SecureBoot features, support for which
> > is to be added on the platform.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Sughosh Ganu 
> > ---
> >  Platform/ARM/SgiPkg/SgiPlatform.dsc | 18 ++
> >  Platform/ARM/SgiPkg/SgiPlatform.fdf |  5 +
> >  2 files changed, 23 insertions(+)
> >
> > diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc 
> > b/Platform/ARM/SgiPkg/SgiPlatform.dsc
> > index 7995c7d132d6..948b75631a00 100644
> > --- a/Platform/ARM/SgiPkg/SgiPlatform.dsc
> > +++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc
> > @@ -197,6 +197,20 @@ [PcdsFixedAtBuild.common]
> >gArmSgiTokenSpaceGuid.PcdVirtioNetSize|0x1
> >gArmSgiTokenSpaceGuid.PcdVirtioNetInterrupt|204
> >
> > +!if $(ARM_STANDALONE_MM_ENABLE) == TRUE
> 
> Why is this inclusion conditional (here and below)? I was under the
> impression that the communicate driver fails gracefully if the secure
> standalone MM is absent. If this is not the case, please propose how
> to fix the core driver so that it does.


I have tried it earlier, and it does fail gracefully -- will test it
once more nonetheless before posting an updated version.

-sughosh
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms v2 1/3] Platform/ARM/SgiPkg: Build infrastructure for StandaloneMm image

2018-12-20 Thread Sughosh Ganu
On Thu Dec 20, 2018 at 09:46:34AM +0100, Ard Biesheuvel wrote:
> On Thu, 20 Dec 2018 at 06:48, Sughosh Ganu  wrote:
> >
> > Add the build infrastructure for compilation of StandaloneMm image
> > files and FD file.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Sughosh Ganu 
> > ---
> >  Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc | 130 
> > +++
> >  Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf | 100 +
> >  2 files changed, 230 insertions(+)
> >  create mode 100644 Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
> >  create mode 100644 Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf
> >
> > diff --git a/Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc 
> > b/Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
> > new file mode 100644
> > index ..4615c383c46a
> > --- /dev/null
> > +++ b/Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
> > @@ -0,0 +1,130 @@
> > +#
> > +#  Copyright (c) 2018, 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.
> > +#
> > +
> > +
> > +#
> > +# Defines Section - statements that will be processed to create a Makefile.
> > +#
> > +
> > +[Defines]
> > +  PLATFORM_NAME  = sgi_mm_standalone
> 
> Please use camel case

Ok

> 
> > +  PLATFORM_GUID  = 34B78C8F-CFD5-49D5-8360-E91143F6106D
> > +  PLATFORM_VERSION   = 1.0
> > +  DSC_SPECIFICATION  = 0x00010011
> > +  OUTPUT_DIRECTORY   = Build/$(PLATFORM_NAME)
> > +  SUPPORTED_ARCHITECTURES= AARCH64|ARM
> 
> Does this actually build for ARM?


I haven't tried it. Will remove.

> 
> > +  BUILD_TARGETS  = DEBUG|RELEASE
> 
> Please include NOOPT

Ok

> 
> > +  SKUID_IDENTIFIER   = DEFAULT
> > +  FLASH_DEFINITION   = 
> > Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf
> > +  DEFINE DEBUG_MESSAGE   = TRUE
> > +
> > +  # LzmaF86
> > +  DEFINE COMPRESSION_TOOL_GUID   = D42AE6BD-1352-4bfb-909A-CA72A6EAE889
> > +
> > +
> > +#
> > +# Library Class section - list of all Library Classes needed by this 
> > Platform.
> > +#
> > +
> > +[LibraryClasses]
> > +  #
> > +  # Basic
> > +  #
> > +  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
> > +  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
> > +  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> > +  
> > DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
> > +  FvLib|StandaloneMmPkg/Library/FvLib/FvLib.inf
> > +  
> > HobLib|StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf
> > +  IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
> > +  MemLib|StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf
> > +  
> > MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.inf
> > +  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
> > +  PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
> > +  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
> > +  
> > ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
> > +
> > +  #
> > +  # Entry point
> > +  #
> > +  
> > StandaloneMmDriverEntryPoint|StandaloneMmPkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
> > +
> > +[LibraryClasses.AARCH64]
> 
> Are the pieces below specific to AARCH64? If not, drop the [] section header

No, these are not specific to AArch64. Will remove the section header.

> 
> > +  ArmLib|ArmPkg/Library/ArmLib/ArmBaseL

[edk2] [PATCH edk2-platforms v2 3/3] Platform/ARM/SgiPkg: Enable MmCommunication module on the platform

2018-12-19 Thread Sughosh Ganu
The ArmMmCommunication module is used for communication between
non-secure and secure world using Arm's Management Mode
Specification. Enable this module on Sgi platforms. This would be used
subsequently by the RAS and SecureBoot features, support for which
is to be added on the platform.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 Platform/ARM/SgiPkg/SgiPlatform.dsc | 18 ++
 Platform/ARM/SgiPkg/SgiPlatform.fdf |  5 +
 2 files changed, 23 insertions(+)

diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc 
b/Platform/ARM/SgiPkg/SgiPlatform.dsc
index 7995c7d132d6..948b75631a00 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.dsc
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc
@@ -197,6 +197,20 @@ [PcdsFixedAtBuild.common]
   gArmSgiTokenSpaceGuid.PcdVirtioNetSize|0x1
   gArmSgiTokenSpaceGuid.PcdVirtioNetInterrupt|204
 
+!if $(ARM_STANDALONE_MM_ENABLE) == TRUE
+  #
+  # Set the base address and size of the buffer used
+  # for communication between the Normal world edk2
+  # with StandaloneMm image at S-EL0 through MM_COMMUNICATE.
+  # This buffer gets allocated in ATF and since we do not have
+  # a mechanism currently to communicate the base address and
+  # size of this buffer from ATF, hard-code it here
+  #
+  ## MM Communicate
+  gArmTokenSpaceGuid.PcdMmBufferBase|0xFF60
+  gArmTokenSpaceGuid.PcdMmBufferSize|0x1
+!endif
+
 

 #
 # Components Section - list of all EDK II Modules needed by this Platform
@@ -331,3 +345,7 @@ [Components.common]
   # SATA Controller
   #
   MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
+
+!if $(ARM_STANDALONE_MM_ENABLE) == TRUE
+  ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
+!endif
diff --git a/Platform/ARM/SgiPkg/SgiPlatform.fdf 
b/Platform/ARM/SgiPkg/SgiPlatform.fdf
index 80c3412fd4ad..01799de8a0c8 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.fdf
+++ b/Platform/ARM/SgiPkg/SgiPlatform.fdf
@@ -169,6 +169,11 @@ [FV.FvMain]
   #
   INF  ShellPkg/Application/Shell/Shell.inf
 
+!if $(ARM_STANDALONE_MM_ENABLE) == TRUE
+  # MM Communicate
+  INF ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
+!endif
+
   #
   # Platform driver
   #
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v2 2/3] Platform/ARM/SgiPkg: Setup memory buffers for MmCommunicate

2018-12-19 Thread Sughosh Ganu
Add memory regions for MmCommuncate buffers into the virtual memory
table.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf  | 4 
 Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c | 8 +++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf 
b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
index 260be58fb38c..c0fcc8198201 100644
--- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
+++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
@@ -25,6 +25,7 @@ [Packages]
   MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
   Platform/ARM/SgiPkg/SgiPlatform.dec
+  StandaloneMmPkg/StandaloneMmPkg.dec
 
 [LibraryClasses]
   ArmLib
@@ -62,6 +63,9 @@ [FixedPcd]
   gArmTokenSpaceGuid.PcdPciMmio64Base
   gArmTokenSpaceGuid.PcdPciMmio64Size
 
+  gArmTokenSpaceGuid.PcdMmBufferBase
+  gArmTokenSpaceGuid.PcdMmBufferSize
+
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
 
 [Guids]
diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c 
b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c
index 6ec2e8a7096d..60729e3c7158 100644
--- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c
+++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c
@@ -22,7 +22,7 @@
 #include 
 
 // Total number of descriptors, including the final "end-of-table" descriptor.
-#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS  12
+#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS  13
 
 /**
   Returns the Virtual Memory Map of the platform.
@@ -136,6 +136,12 @@ ArmPlatformGetVirtualMemoryMap (
SIZE_1MB;
   VirtualMemoryTable[Index].Attributes  = 
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
 
+ // MM Memory Space
+  VirtualMemoryTable[++Index].PhysicalBase  = PcdGet64 (PcdMmBufferBase);
+  VirtualMemoryTable[Index].VirtualBase = PcdGet64 (PcdMmBufferBase);
+  VirtualMemoryTable[Index].Length  = PcdGet64 (PcdMmBufferSize);
+  VirtualMemoryTable[Index].Attributes  = 
ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
+
   // End of Table
   VirtualMemoryTable[++Index].PhysicalBase  = 0;
   VirtualMemoryTable[Index].VirtualBase = 0;
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v2 1/3] Platform/ARM/SgiPkg: Build infrastructure for StandaloneMm image

2018-12-19 Thread Sughosh Ganu
Add the build infrastructure for compilation of StandaloneMm image
files and FD file.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc | 130 +++
 Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf | 100 +
 2 files changed, 230 insertions(+)
 create mode 100644 Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
 create mode 100644 Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf

diff --git a/Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc 
b/Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
new file mode 100644
index ..4615c383c46a
--- /dev/null
+++ b/Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
@@ -0,0 +1,130 @@
+#
+#  Copyright (c) 2018, 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.
+#
+
+
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+
+[Defines]
+  PLATFORM_NAME  = sgi_mm_standalone
+  PLATFORM_GUID  = 34B78C8F-CFD5-49D5-8360-E91143F6106D
+  PLATFORM_VERSION   = 1.0
+  DSC_SPECIFICATION  = 0x00010011
+  OUTPUT_DIRECTORY   = Build/$(PLATFORM_NAME)
+  SUPPORTED_ARCHITECTURES= AARCH64|ARM
+  BUILD_TARGETS  = DEBUG|RELEASE
+  SKUID_IDENTIFIER   = DEFAULT
+  FLASH_DEFINITION   = Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf
+  DEFINE DEBUG_MESSAGE   = TRUE
+
+  # LzmaF86
+  DEFINE COMPRESSION_TOOL_GUID   = D42AE6BD-1352-4bfb-909A-CA72A6EAE889
+
+
+#
+# Library Class section - list of all Library Classes needed by this Platform.
+#
+
+[LibraryClasses]
+  #
+  # Basic
+  #
+  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+  
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
+  FvLib|StandaloneMmPkg/Library/FvLib/FvLib.inf
+  
HobLib|StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf
+  IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
+  MemLib|StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf
+  
MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.inf
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
+  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+  
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
+
+  #
+  # Entry point
+  #
+  
StandaloneMmDriverEntryPoint|StandaloneMmPkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
+
+[LibraryClasses.AARCH64]
+  ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
+  
StandaloneMmMmuLib|ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
+  ArmSvcLib|ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf
+  
CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
+  
PeCoffExtraActionLib|StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
+
+  # ARM PL011 UART Driver
+  
PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartClockLib.inf
+  PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf
+  
SerialPortLib|ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.inf
+
+  
StandaloneMmCoreEntryPoint|StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
+
+
+#
+# Pcd Section - list of all EDK II PCD Entries defined by this Platform
+#
+
+[PcdsFeatureFlag]
+  gStandaloneMmPkgTokenSpaceGuid.PcdStandaloneMmEnable|TRUE
+
+[PcdsFixedAtBuild]
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80CF
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xff
+  gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x0f
+
+[PcdsFixedAtBuild.AARCH64]
+  ## PL011 - Serial Terminal
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|

[edk2] [PATCH edk2-platforms v2 0/3] Platform/ARM/SgiPkg: Enable StandaloneMm on Sgi platforms

2018-12-19 Thread Sughosh Ganu
Changes since v1: Rebased on top of latest edk2-platforms master

The following patches enable building of StandaloneMm image on Sgi
platforms.

The first patch adds build infra for StandaloneMm image. The second
patch of the series adds memory buffer required for communication
between the non-secure world with StandaloneMm image using MM
Communicate. The third patch of the series enables MmCommunication
module on the platform for it subsequent use by features like
Secure-Boot and Error Injection and Handling for RAS.

Sughosh Ganu (3):
  Platform/ARM/SgiPkg: Build infrastructure for StandaloneMm image
  Platform/ARM/SgiPkg: Setup memory buffers for MmCommunicate
  Platform/ARM/SgiPkg: Enable MmCommunication module on the platform

 Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc   | 130 +
 Platform/ARM/SgiPkg/SgiPlatform.dsc|  18 +++
 Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf   | 100 
 Platform/ARM/SgiPkg/SgiPlatform.fdf|   5 +
 .../ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf |   4 +
 .../SgiPkg/Library/PlatformLib/PlatformLibMem.c|   8 +-
 6 files changed, 264 insertions(+), 1 deletion(-)
 create mode 100644 Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
 create mode 100644 Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf

-- 
2.7.4
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms 3/3] Platform/ARM/SgiPkg: Enable MmCommunication module on the platform

2018-12-13 Thread Sughosh Ganu
The ArmMmCommunication module is used for communication between
non-secure and secure world using Arm's Management Mode
Specification. Enable this module on Sgi platforms. This would be used
subsequently by the RAS and SecureBoot features, support for which
is to be added on the platform..

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 Platform/ARM/SgiPkg/SgiPlatform.dsc | 20 
 Platform/ARM/SgiPkg/SgiPlatform.fdf |  5 +
 2 files changed, 25 insertions(+)

diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc 
b/Platform/ARM/SgiPkg/SgiPlatform.dsc
index 19d2ac3a656a..44f769947d53 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.dsc
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc
@@ -185,6 +185,22 @@ [PcdsFixedAtBuild.common]
   # Ethernet
   gEmbeddedTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x1800
 
+!if $(ARM_STANDALONE_MM_ENABLE) == TRUE
+  #
+  # Set the base address and size of the buffer used
+  # for communication between the Normal world edk2
+  # with StandaloneMm image at S-EL0 through MM_COMMUNICATE.
+  # This buffer gets allocated in ATF and since we do not have
+  # a mechanism currently to communicate the base address and
+  # size of this buffer from ATF, hard-code it here
+  #
+
+  ## MM Communicate
+  gArmTokenSpaceGuid.PcdMmBufferBase|0xFF60
+  gArmTokenSpaceGuid.PcdMmBufferSize|0x1
+
+!endif
+
 

 #
 # Components Section - list of all EDK II Modules needed by this Platform
@@ -316,3 +332,7 @@ [Components.common]
   # SATA Controller
   #
   MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
+
+!if $(ARM_STANDALONE_MM_ENABLE) == TRUE
+  ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
+!endif
diff --git a/Platform/ARM/SgiPkg/SgiPlatform.fdf 
b/Platform/ARM/SgiPkg/SgiPlatform.fdf
index 9c0ec1fa43a6..4145bc50ea04 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.fdf
+++ b/Platform/ARM/SgiPkg/SgiPlatform.fdf
@@ -169,6 +169,11 @@ [FV.FvMain]
   #
   INF  ShellPkg/Application/Shell/Shell.inf
 
+!if $(ARM_STANDALONE_MM_ENABLE) == TRUE
+  # MM Communicate
+  INF ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
+!endif
+
   #
   # Platform driver
   #
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms 2/3] Platform/ARM/SgiPkg: Setup memory buffers for MmCommunicate

2018-12-13 Thread Sughosh Ganu
Add memory regions for MmCommuncate buffers into the virtual memory
table.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf  | 4 
 Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c | 6 ++
 2 files changed, 10 insertions(+)

diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf 
b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
index 260be58fb38c..c0fcc8198201 100644
--- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
+++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
@@ -25,6 +25,7 @@ [Packages]
   MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
   Platform/ARM/SgiPkg/SgiPlatform.dec
+  StandaloneMmPkg/StandaloneMmPkg.dec
 
 [LibraryClasses]
   ArmLib
@@ -62,6 +63,9 @@ [FixedPcd]
   gArmTokenSpaceGuid.PcdPciMmio64Base
   gArmTokenSpaceGuid.PcdPciMmio64Size
 
+  gArmTokenSpaceGuid.PcdMmBufferBase
+  gArmTokenSpaceGuid.PcdMmBufferSize
+
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
 
 [Guids]
diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c 
b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c
index 6ec2e8a7096d..11e0811fccc8 100644
--- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c
+++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c
@@ -136,6 +136,12 @@ ArmPlatformGetVirtualMemoryMap (
SIZE_1MB;
   VirtualMemoryTable[Index].Attributes  = 
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
 
+ // MM Memory Space
+  VirtualMemoryTable[++Index].PhysicalBase  = PcdGet64 (PcdMmBufferBase);
+  VirtualMemoryTable[Index].VirtualBase = PcdGet64 (PcdMmBufferBase);
+  VirtualMemoryTable[Index].Length  = PcdGet64 (PcdMmBufferSize);
+  VirtualMemoryTable[Index].Attributes  = 
ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
+
   // End of Table
   VirtualMemoryTable[++Index].PhysicalBase  = 0;
   VirtualMemoryTable[Index].VirtualBase = 0;
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms 1/3] Platform/ARM/SgiPkg: Build infrastructure for StandaloneMm image

2018-12-13 Thread Sughosh Ganu
Add the build infrastructure for compilation of StandaloneMm image
files and FD file.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc | 130 +++
 Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf | 100 +
 2 files changed, 230 insertions(+)
 create mode 100644 Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
 create mode 100644 Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf

diff --git a/Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc 
b/Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
new file mode 100644
index ..4615c383c46a
--- /dev/null
+++ b/Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
@@ -0,0 +1,130 @@
+#
+#  Copyright (c) 2018, 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.
+#
+
+
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+
+[Defines]
+  PLATFORM_NAME  = sgi_mm_standalone
+  PLATFORM_GUID  = 34B78C8F-CFD5-49D5-8360-E91143F6106D
+  PLATFORM_VERSION   = 1.0
+  DSC_SPECIFICATION  = 0x00010011
+  OUTPUT_DIRECTORY   = Build/$(PLATFORM_NAME)
+  SUPPORTED_ARCHITECTURES= AARCH64|ARM
+  BUILD_TARGETS  = DEBUG|RELEASE
+  SKUID_IDENTIFIER   = DEFAULT
+  FLASH_DEFINITION   = Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf
+  DEFINE DEBUG_MESSAGE   = TRUE
+
+  # LzmaF86
+  DEFINE COMPRESSION_TOOL_GUID   = D42AE6BD-1352-4bfb-909A-CA72A6EAE889
+
+
+#
+# Library Class section - list of all Library Classes needed by this Platform.
+#
+
+[LibraryClasses]
+  #
+  # Basic
+  #
+  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+  
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
+  FvLib|StandaloneMmPkg/Library/FvLib/FvLib.inf
+  
HobLib|StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf
+  IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
+  MemLib|StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf
+  
MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.inf
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
+  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+  
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
+
+  #
+  # Entry point
+  #
+  
StandaloneMmDriverEntryPoint|StandaloneMmPkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
+
+[LibraryClasses.AARCH64]
+  ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
+  
StandaloneMmMmuLib|ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
+  ArmSvcLib|ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf
+  
CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
+  
PeCoffExtraActionLib|StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
+
+  # ARM PL011 UART Driver
+  
PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartClockLib.inf
+  PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf
+  
SerialPortLib|ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.inf
+
+  
StandaloneMmCoreEntryPoint|StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
+
+
+#
+# Pcd Section - list of all EDK II PCD Entries defined by this Platform
+#
+
+[PcdsFeatureFlag]
+  gStandaloneMmPkgTokenSpaceGuid.PcdStandaloneMmEnable|TRUE
+
+[PcdsFixedAtBuild]
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80CF
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xff
+  gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x0f
+
+[PcdsFixedAtBuild.AARCH64]
+  ## PL011 - Serial Terminal
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|

[edk2] [PATCH edk2-platforms 0/3] Platform/ARM/SgiPkg: Enable StandaloneMm on Sgi platforms

2018-12-13 Thread Sughosh Ganu
The following patches enable building of StandaloneMm image on Sgi
platforms.

The first patch adds build infra for StandaloneMm image. The second
patch of the series adds memory buffer required for communication
between the non-secure world with StandaloneMm image using MM
Communicate. The third patch of the series enables MmCommunication
module on the platform for it subsequent use by features like
Secure-Boot and Error Injection and Handling for RAS.


Sughosh Ganu (3):
  Platform/ARM/SgiPkg: Build infrastructure for StandaloneMm image
  Platform/ARM/SgiPkg: Setup memory buffers for MmCommunicate
  Platform/ARM/SgiPkg: Enable MmCommunication module on the platform

 Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc   | 130 +
 Platform/ARM/SgiPkg/SgiPlatform.dsc|  20 
 Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf   | 100 
 Platform/ARM/SgiPkg/SgiPlatform.fdf|   5 +
 .../ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf |   4 +
 .../SgiPkg/Library/PlatformLib/PlatformLibMem.c|   6 +
 6 files changed, 265 insertions(+)
 create mode 100644 Platform/ARM/SgiPkg/PlatformStandaloneMm.dsc
 create mode 100644 Platform/ARM/SgiPkg/PlatformStandaloneMm.fdf

-- 
2.7.4


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 5/5] StandaloneMmPkg: Update dependency on PeCoffExtraActionLib

2018-12-03 Thread Sughosh Ganu
From: Achin Gupta 

Replace DebugPeCoffExtraActionLib with StandaloneMmExtraActionLib

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Achin Gupta 
Signed-off-by: Sughosh Ganu 
---
 StandaloneMmPkg/StandaloneMmPkg.dsc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc 
b/StandaloneMmPkg/StandaloneMmPkg.dsc
index 412702272c95..ea4153f567a8 100644
--- a/StandaloneMmPkg/StandaloneMmPkg.dsc
+++ b/StandaloneMmPkg/StandaloneMmPkg.dsc
@@ -65,7 +65,7 @@ [LibraryClasses.AARCH64]
   
StandaloneMmMmuLib|ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
   ArmSvcLib|ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf
   
CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
-  
PeCoffExtraActionLib|ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
+  
PeCoffExtraActionLib|StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
   PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf
   
PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartClockLib.inf
   # ARM PL011 UART Driver
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 4/5] StandaloneMmPkg: Replace dependency on ArmMmuLib

2018-12-03 Thread Sughosh Ganu
From: Achin Gupta 

Use StandaloneMmMmuLib instead of ArmMmuLib in StandaloneMmPkg for AArch64

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Achin Gupta 
Signed-off-by: Sughosh Ganu 
---
 StandaloneMmPkg/StandaloneMmPkg.dsc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc 
b/StandaloneMmPkg/StandaloneMmPkg.dsc
index 3470e1102cc3..412702272c95 100644
--- a/StandaloneMmPkg/StandaloneMmPkg.dsc
+++ b/StandaloneMmPkg/StandaloneMmPkg.dsc
@@ -62,7 +62,7 @@ [LibraryClasses]
 
 [LibraryClasses.AARCH64]
   ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
-  ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuStandaloneMmCoreLib.inf
+  
StandaloneMmMmuLib|ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
   ArmSvcLib|ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf
   
CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
   
PeCoffExtraActionLib|ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 3/5] StandaloneMmPkg: Zero data structure explicitly

2018-12-03 Thread Sughosh Ganu
From: Achin Gupta 

Introduction of the -mstrict-align flag results in GCC attempting
to use memset to zero out the InitMmFoundationSvcArgs structure.
In the absence of this C library function, this patch explicitly
zeroes this data structure prior to use.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Achin Gupta 
Signed-off-by: Sughosh Ganu 
---
 
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c
 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c
 
b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c
index 20fd0d1f34ba..05ed6c8dd0b5 100644
--- 
a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c
+++ 
b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c
@@ -224,7 +224,7 @@ _ModuleEntryPoint (
 {
   PE_COFF_LOADER_IMAGE_CONTEXTImageContext;
   EFI_SECURE_PARTITION_BOOT_INFO  *PayloadBootInfo;
-  ARM_SVC_ARGSInitMmFoundationSvcArgs = {0};
+  ARM_SVC_ARGSInitMmFoundationSvcArgs;
   EFI_STATUS  Status;
   UINT32  SectionHeaderOffset;
   UINT16  NumberOfSections;
@@ -299,6 +299,7 @@ _ModuleEntryPoint (
   DEBUG ((DEBUG_INFO, "Shared Cpu Driver EP 0x%lx\n", (UINT64) 
CpuDriverEntryPoint));
 
 finish:
+  ZeroMem (&InitMmFoundationSvcArgs, sizeof(InitMmFoundationSvcArgs));
   InitMmFoundationSvcArgs.Arg0 = ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64;
   InitMmFoundationSvcArgs.Arg1 = Status;
   DelegatedEventLoop (&InitMmFoundationSvcArgs);
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 2/5] StandaloneMmPkg: Enforce alignment check for AArch64

2018-12-03 Thread Sughosh Ganu
From: Achin Gupta 

On AArch64, Standalone MM during the SEC phase runs in S-EL0 with
SCTLR_EL1.A=1. This patch adds the -mstrict-align compiler flag to
ensure that the generated code is compliant with the runtime
alignment checks.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Achin Gupta 
Signed-off-by: Sughosh Ganu 
---
 StandaloneMmPkg/StandaloneMmPkg.dsc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc 
b/StandaloneMmPkg/StandaloneMmPkg.dsc
index 84de1ab0f13a..3470e1102cc3 100644
--- a/StandaloneMmPkg/StandaloneMmPkg.dsc
+++ b/StandaloneMmPkg/StandaloneMmPkg.dsc
@@ -128,4 +128,5 @@ [Components.AARCH64]
 #
 
###
 [BuildOptions.AARCH64]
-GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 -march=armv8-a+nofp
+GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 -march=armv8-a+nofp 
-mstrict-align
+GCC:*_*_*_CC_FLAGS = -mstrict-align
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 1/5] StandaloneMmPkg: Add missing dependency on PL011UartClockLib

2018-12-03 Thread Sughosh Ganu
From: Achin Gupta 

This patch fixes the dependency PL011UartLib has on PL011UartClockLib by
including its implementation path in the StandaloneMm DSC file.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Achin Gupta 
Signed-off-by: Sughosh Ganu 
---
 StandaloneMmPkg/StandaloneMmPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc 
b/StandaloneMmPkg/StandaloneMmPkg.dsc
index c6ddb35b8993..84de1ab0f13a 100644
--- a/StandaloneMmPkg/StandaloneMmPkg.dsc
+++ b/StandaloneMmPkg/StandaloneMmPkg.dsc
@@ -67,6 +67,7 @@ [LibraryClasses.AARCH64]
   
CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
   
PeCoffExtraActionLib|ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
   PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf
+  
PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartClockLib.inf
   # ARM PL011 UART Driver
   
SerialPortLib|ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.inf
 
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 0/5] StandaloneMmPkg: Miscellaneous fixes

2018-12-02 Thread Sughosh Ganu
Miscellaneous fixes in StandaloneMmPkg code.

This patcheset is to be applied on top of the following patchset
"StandaloneMM: Update permissions for Standalone MM drivers memory area"


Achin Gupta (5):
  StandaloneMmPkg: Add missing dependency on PL011UartClockLib
  StandaloneMmPkg: Enforce alignment check for AArch64
  StandaloneMmPkg: Zero data structure explicitly
  StandaloneMmPkg: Replace dependency on ArmMmuLib
  StandaloneMmPkg: Update dependency on PeCoffExtraActionLib

 StandaloneMmPkg/StandaloneMmPkg.dsc
 | 8 +---
 
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c
 | 3 ++-
 2 files changed, 7 insertions(+), 4 deletions(-)

-- 
2.7.4


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v3 2/2] StandaloneMM: Update permissions for Standalone MM drivers memory area

2018-12-02 Thread Sughosh Ganu
The StandaloneMM image executes in S-EL0 on reference Arm platforms
and is deployed by the trusted firmware as BL32 image. Memory for the
Standalone MM drivers is marked as RW+XN initially, allowing the
drivers to be loaded into the memory. Once loaded, the memory
attributes need to be changed to RO+XN for rodata sections and RO+X
for code sections.

Achieve this through the extra action 'UpdatePeCoffPermissions' to
request the privileged firmware in EL3 to update the permissions.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf => 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
 |  18 +-
 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c
 | 222 

 2 files changed, 233 insertions(+), 7 deletions(-)

diff --git a/ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf 
b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
similarity index 72%
copy from ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf
copy to 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
index 3be0237a3689..eef3d7c6e253 100644
--- a/ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf
+++ 
b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
@@ -16,9 +16,9 @@
 #**/
 
 [Defines]
-  INF_VERSION= 0x00010005
-  BASE_NAME  = RvdUnixPeCoffExtraActionLib
-  FILE_GUID  = 5EDEB7E7-EA55-4E92-8216-335AC98A3B11
+  INF_VERSION= 0x0001000A
+  BASE_NAME  = StandaloneMmPeCoffExtraActionLib
+  FILE_GUID  = 8B40543B-9588-48F8-840C-5A60E6DB1B03
   MODULE_TYPE= BASE
   VERSION_STRING = 1.0
   LIBRARY_CLASS  = PeCoffExtraActionLib
@@ -30,12 +30,16 @@ [Defines]
 #
 
 [Sources.common]
-  RvdPeCoffExtraActionLib.c
+  AArch64/StandaloneMmPeCoffExtraActionLib.c
 
 [Packages]
-  MdePkg/MdePkg.dec
   ArmPkg/ArmPkg.dec
+  MdePkg/MdePkg.dec
+  StandaloneMmPkg/StandaloneMmPkg.dec
+
+[FeaturePcd]
+  gStandaloneMmPkgTokenSpaceGuid.PcdStandaloneMmEnable
 
 [LibraryClasses]
-  DebugLib
-  SemihostLib
+  StandaloneMmMmuLib
+  PcdLib
diff --git 
a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c
 
b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c
new file mode 100644
index ..1c9fec201916
--- /dev/null
+++ 
b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c
@@ -0,0 +1,222 @@
+/**@file
+
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
+Portions copyright (c) 2011 - 2018, ARM Ltd. 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 
+
+typedef RETURN_STATUS (*REGION_PERMISSION_UPDATE_FUNC) (
+  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN  UINT64Length
+  );
+
+STATIC
+RETURN_STATUS
+UpdatePeCoffPermissions (
+  IN  CONST PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,
+  IN  REGION_PERMISSION_UPDATE_FUNC   NoExecUpdater,
+  IN  REGION_PERMISSION_UPDATE_FUNC   ReadOnlyUpdater
+  )
+{
+  RETURN_STATUS Status;
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;
+  EFI_IMAGE_OPTIONAL_HEADER_UNION   HdrData;
+  UINTN Size;
+  UINTN ReadSize;
+  UINT32SectionHeaderOffset;
+  UINTN NumberOfSections;
+  UINTN Index;
+  EFI_IMAGE_SECTION_HEADER  SectionHeader;
+  PE_COFF_LOADER_IMAGE_CONTEXT  TmpContext;
+  EFI_PHYSICAL_ADDRESS  Base;
+
+  //
+  // We need to copy ImageContext since PeCoffLoaderGetImageInfo ()
+  // will mangle the ImageAddress field
+  //
+  CopyMem (&TmpContext, ImageContext, sizeof (TmpContext));
+
+  if (TmpContext.PeCoffHeaderOffset == 0) {
+Status = PeCoffLoaderGetImageInfo (&TmpContext);
+if (RETURN_ERROR (Status

[edk2] [PATCH v3 1/2] StandaloneMM: Include the newly added library class for MMU functions

2018-12-02 Thread Sughosh Ganu
The MMU functions needed for StandaloneMM image are now exported
through a separate library class. Make the corresponding change in the
core's entry point inf file so that it references the correct library
class for modifying the MMU attributes.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
 
b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
index 66184c4a00f3..3222cd359f3e 100644
--- 
a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
+++ 
b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
@@ -45,7 +45,7 @@ [LibraryClasses]
   DebugLib
 
 [LibraryClasses.AARCH64]
-  ArmMmuLib
+  StandaloneMmMmuLib
   ArmSvcLib
 
 [Guids]
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v3 0/2] StandaloneMM: Update permissions for Standalone MM drivers memory area

2018-12-02 Thread Sughosh Ganu
Changes since v2:
Incorporate review comments from Achin to move
StandaloneMmPeCoffExtraActionLib.c under AArch64 directory.

Changes since v1:
A new patch has been added to reflect the library class added for
changing the MMU attributes in StandaloneMM image, based on review
comments from Ard Biesheuvel.

Sughosh Ganu (2):
  StandaloneMM: Include the newly added library class for MMU functions
  StandaloneMM: Update permissions for Standalone MM drivers memory area

 
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf

   |   2 +-
 ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf => 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
 |  18 +-
 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c
 | 222 

 3 files changed, 234 insertions(+), 8 deletions(-)
 copy ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf => 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
 (72%)
 create mode 100644 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c

-- 
2.7.4


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 0/2] StandaloneMM: Update permissions for Standalone MM drivers memory area

2018-12-02 Thread Sughosh Ganu
hi Achin,

On Sun Dec 02, 2018 at 12:15:47AM +0530, Achin Gupta wrote:
> Hi Sughosh,
> 
> On Sat, Dec 01, 2018 at 09:56:52AM +0530, Sughosh Ganu wrote:
> > hi Achin,
> > 
> > On Sat Dec 01, 2018 at 05:08:50AM +0530, Achin Gupta wrote:
> > > Hi Sughosh,
> > > 
> > > +Jiewen
> > > 
> > > I took the patches for a spin and it looks like the FVP port is broken. 
> > > Some
> > > reasons are:
> > > 
> > > 1. The build breaks due to a reference to ArmMmuLib in StandaloneMmPkg.dsc
> > > 2. There is a broken dependency on PL011UartClockLib in 
> > > StandaloneMmPkg.dsc
> > > 3. GCC flags to enforce strict alignment and no fp are required in
> > >StandaloneMmPkg.dsc to avoid a runtime fault
> > > 4. There is a data structre in StandaloneMmCoreEntryPoint.c that needs to 
> > > be
> > >memzeroed due to the alignment checks
> > > 
> > > Even after these fixes, I am unable to boot the MM SP. The SP boots with 
> > > the
> > > previous revision of your patches and the above fixes. Something has 
> > > broken
> > > between the two. I am suspecting the MMU library for S-EL0.
> > 
> > I had tested the patches which i had sent out for ArmPkg changes with
> > the error handling and error reporting feature on sgi575 before
> > posting the patches. In addition to the changes that you mention, i
> > was required to make a couple of more changes in the StandadloneMm
> > description file.
> > 
> > 1) 
> > StandaloneMmMmuLib|ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
> > 
> > This was changed from ArmMmuLib which was used earlier.
> 
> yes! this was the change i was referring to in 1.
> 
> > 
> > 2) 
> > PeCoffExtraActionLib|StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
> > 
> > I had changed this to reflect the change made in the patch
> > StandaloneMM: Update permissions for Standalone MM drivers memory area
> 
> Doh! of course it does not work without this change. Thanks! Could you roll it
> in your patchstack?
> 
> > 
> > Can you please confirm that you tested with these two additional
> > changes made. Meanwhile, I will incorporate your review comments which
> > you make below. Thanks.
> 
> I was able to initialise the SP on the FVP and the MM communication driver
> initialised correctly. I did not test the MM SP further. I have pushed my
> changes on top of your patches here [1]. Could you please check they work for
> you as well and include the relevant changes in the next rev of your 
> patchstack?

Sure. I will post these fixes as well. I will post it as a separate
series, since the contents are pretty different from the other two
patches. Thanks.

-sughosh


> 
> cheers,
> Achin
> 
> [1] https://github.com/achingupta/edk2/commits/ag/stmm_perm_v2
> 
> > 
> > -sughosh
> > 
> > > 
> > > Lets sort this out first. Apart from this, could you move this library 
> > > into
> > > an AArch64 directory as is the case for other Arm specific libraries
> > > e.g. StandaloneMmCoreEntryPoint/AArch64
> > > 
> > > cheers,
> > > Achin
> > > 
> > > On Tue, Nov 27, 2018 at 11:52:53AM +0530, Sughosh Ganu wrote:
> > > > Changes since v1:
> > > > A new patch has been added to reflect the library class added for
> > > > changing the MMU attributes in StandaloneMM image, based on review
> > > > comments from Ard Biesheuvel.
> > > > 
> > > > 
> > > > These patches needs to be applied on top of the following patch series
> > > >  - "ArmPkg related changes for StandaloneMM package".
> > > > 
> > > > 
> > > > Sughosh Ganu (2):
> > > >   StandaloneMM: Include the newly added library class for MMU functions
> > > >   StandaloneMM: Update permissions for Standalone MM drivers memory area
> > > > 
> > > >  .../StandaloneMmCoreEntryPoint.inf |   2 +-
> > > >  .../StandaloneMmPeCoffExtraActionLib.inf   |  18 +-
> > > >  .../StandaloneMmPeCoffExtraActionLib.c | 222 
> > > > +
> > > >  3 files changed, 234 insertions(+), 8 deletions(-)
> > > >  copy 
> > > > ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf => 
> > > > StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
> > > >  (72%)
> > > >  create mode 100644 
> > > > StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.c
> > > > 
> > > > -- 
> > > > 2.7.4
> > > > 
> > 
> > -- 
> > -sughosh

-- 
-sughosh
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 0/2] StandaloneMM: Update permissions for Standalone MM drivers memory area

2018-11-30 Thread Sughosh Ganu
hi Achin,

On Sat Dec 01, 2018 at 05:08:50AM +0530, Achin Gupta wrote:
> Hi Sughosh,
> 
> +Jiewen
> 
> I took the patches for a spin and it looks like the FVP port is broken. Some
> reasons are:
> 
> 1. The build breaks due to a reference to ArmMmuLib in StandaloneMmPkg.dsc
> 2. There is a broken dependency on PL011UartClockLib in StandaloneMmPkg.dsc
> 3. GCC flags to enforce strict alignment and no fp are required in
>StandaloneMmPkg.dsc to avoid a runtime fault
> 4. There is a data structre in StandaloneMmCoreEntryPoint.c that needs to be
>memzeroed due to the alignment checks
> 
> Even after these fixes, I am unable to boot the MM SP. The SP boots with the
> previous revision of your patches and the above fixes. Something has broken
> between the two. I am suspecting the MMU library for S-EL0.

I had tested the patches which i had sent out for ArmPkg changes with
the error handling and error reporting feature on sgi575 before
posting the patches. In addition to the changes that you mention, i
was required to make a couple of more changes in the StandadloneMm
description file.

1) 
StandaloneMmMmuLib|ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf

This was changed from ArmMmuLib which was used earlier.

2) 
PeCoffExtraActionLib|StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf

I had changed this to reflect the change made in the patch
StandaloneMM: Update permissions for Standalone MM drivers memory area

Can you please confirm that you tested with these two additional
changes made. Meanwhile, I will incorporate your review comments which
you make below. Thanks.

-sughosh

> 
> Lets sort this out first. Apart from this, could you move this library into
> an AArch64 directory as is the case for other Arm specific libraries
> e.g. StandaloneMmCoreEntryPoint/AArch64
> 
> cheers,
> Achin
> 
> On Tue, Nov 27, 2018 at 11:52:53AM +0530, Sughosh Ganu wrote:
> > Changes since v1:
> > A new patch has been added to reflect the library class added for
> > changing the MMU attributes in StandaloneMM image, based on review
> > comments from Ard Biesheuvel.
> > 
> > 
> > These patches needs to be applied on top of the following patch series
> >  - "ArmPkg related changes for StandaloneMM package".
> > 
> > 
> > Sughosh Ganu (2):
> >   StandaloneMM: Include the newly added library class for MMU functions
> >   StandaloneMM: Update permissions for Standalone MM drivers memory area
> > 
> >  .../StandaloneMmCoreEntryPoint.inf |   2 +-
> >  .../StandaloneMmPeCoffExtraActionLib.inf   |  18 +-
> >  .../StandaloneMmPeCoffExtraActionLib.c | 222 
> > +
> >  3 files changed, 234 insertions(+), 8 deletions(-)
> >  copy ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf => 
> > StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
> >  (72%)
> >  create mode 100644 
> > StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.c
> > 
> > -- 
> > 2.7.4
> > 

-- 
-sughosh
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v5 0/5] ArmPkg related changes for StandaloneMM package

2018-11-27 Thread Sughosh Ganu
On Tue Nov 27, 2018 at 01:08:33PM +0100, Ard Biesheuvel wrote:
> On Tue, 27 Nov 2018 at 11:44, Sughosh Ganu  wrote:
> >
> >
> > Changes since v4:
> > Based on comments from Ard
> >  - Removed now superfluous call to FreePages from MmCommunication.c
> >  - Removed Chipset/AArch64.h header file from ArmMmuStandaloneMmLib.c
> >
> > Changes since v3:
> > Based on review comments from Ard, moved the MMU attribute changing
> > functions for StandaloneMM image into a new library class.
> >
> > Moved the addition of memory space used as a MM_COMMUNICATE buffer to
> > memory type 'EfiGcdMemoryTypeReserved' and removed the call to
> > AllocatgePages.
> >
> > Changes since v2:
> > Based on review comments from Ard, moved the memory attribute updation
> > changes out of DebugPeCoffExtraActionLib into an extra action library
> > added in StandaloneMM package. The patch for setting the memory
> > attributes, now under StandaloneMmPkg directory, will be submitted
> > separately from this series.
> >
> > Changes since v1: Handled review comments from Leif
> >
> >
> > Achin Gupta (4):
> >   ArmPkg: Add PCDs needed for MM communication driver.
> >   ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.
> >   ArmPkg/Include: Add MM interface SVC return codes.
> >   ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.
> >
> > Sughosh Ganu (1):
> >   ArmPkg/Include: Fix the SPM version SVC ID
> >
> 
> Reviewed-by: Ard Biesheuvel 
> 
> Pushed as 13d5d0a56e48..eed947be0b05
> 
> Thanks! I'm very happy we will finally have the pieces in place to
> implement UEFI secure boot on ARM in a sane way.


Thanks a lot for the review and for applying the patches Ard!

-sughosh

> 
> >  ArmPkg/ArmPkg.dec  
> > 
> >  |   4 +
> >  ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf  
> > 
> >  |  56 +++
> >  
> > ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
> >  => ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf |  23 +-
> >  ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h  
> > 
> >  |  28 ++
> >  ArmPkg/Include/IndustryStandard/ArmMmSvc.h 
> > 
> >  |   9 +-
> >  ArmPkg/Include/Library/{ArmMmuLib.h => StandaloneMmMmuLib.h}   
> > 
> >  |  38 +-
> >  ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > 
> >  | 372 
> >  ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c  
> > 
> >  | 184 ++
> >  8 files changed, 669 insertions(+), 45 deletions(-)
> >  create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
> >  copy 
> > ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
> >  => ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf (56%)
> >  create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
> >  copy ArmPkg/Include/Library/{ArmMmuLib.h => StandaloneMmMmuLib.h} (55%)
> >  create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> >  create mode 100644 
> > ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c
> >
> > --
> > 2.7.4
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v5 5/5] ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.

2018-11-27 Thread Sughosh Ganu
From: Achin Gupta 

The Standalone MM environment runs in S-EL0 in AArch64 on ARM Standard
Platforms. Privileged firmware e.g. ARM Trusted Firmware sets up its
architectural context including the initial translation tables for the
S-EL1/EL0 translation regime. The MM environment will still request ARM
TF to change the memory attributes of memory regions during
initialization.

The Standalone MM image is a FV that encapsulates the MM foundation
and drivers. These are PE-COFF images with data and text segments.
To initialise the MM environment, Arm Trusted Firmware has to create
translation tables with sane default attributes for the memory
occupied by the FV. This library sends SVCs to ARM Trusted Firmware
to request memory permissions change for data and text segments.

This patch adds a simple MMU library suitable for execution in S-EL0 and
requesting memory permissions change operations from Arm Trusted Firmware.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/ArmPkg.dec  
 |   1 +
 
ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
 => ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf |  23 +--
 ArmPkg/Include/Library/{ArmMmuLib.h => StandaloneMmMmuLib.h}   
 |  38 
+---
 ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c  
 | 184 

 4 files changed, 202 insertions(+), 44 deletions(-)

diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
index 0db7aa9d301c..d99eb6769ff1 100644
--- a/ArmPkg/ArmPkg.dec
+++ b/ArmPkg/ArmPkg.dec
@@ -42,6 +42,7 @@ [LibraryClasses.common]
   ArmMtlLib|ArmPlatformPkg/Include/Library/ArmMtlLib.h
   ArmSvcLib|Include/Library/ArmSvcLib.h
   OpteeLib|Include/Library/OpteeLib.h
+  StandaloneMmMmuLib|Include/Library/StandaloneMmMmuLib.h
 
 [Guids.common]
   gArmTokenSpaceGuid   = { 0xBB11ECFE, 0x820F, 0x4968, { 0xBB, 0xA6, 0xF7, 
0x6A, 0xFE, 0x30, 0x25, 0x96 } }
diff --git 
a/ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
 b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
similarity index 56%
copy from 
ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
copy to ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
index bd6ac8039844..d589b236033c 100644
--- 
a/ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
+++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
@@ -1,7 +1,6 @@
 #/** @file
-#  Implement ArmGenericTimerCounterLib for Xen using the virtual timer
 #
-#  Copyright (c) 2014 - 2018, Linaro Ltd. All rights reserved.
+#  Copyright (c) 2017 - 2018, 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
@@ -15,19 +14,23 @@
 
 [Defines]
   INF_VERSION= 0x0001001A
-  BASE_NAME  = XenArmGenericTimerVirtCounterLib
-  FILE_GUID  = e3913319-96ac-4ac0-808b-8edb8776a51c
-  MODULE_TYPE= BASE
+  BASE_NAME  = ArmMmuStandaloneMmCoreLib
+  FILE_GUID  = da8f0232-fb14-42f0-922c-63104d2c70bd
+  MODULE_TYPE= MM_CORE_STANDALONE
   VERSION_STRING = 1.0
-  LIBRARY_CLASS  = ArmGenericTimerCounterLib
+  LIBRARY_CLASS  = StandaloneMmMmuLib
+  PI_SPECIFICATION_VERSION   = 0x00010032
 
-[Sources]
-  XenArmGenericTimerVirtCounterLib.c
+[Sources.AARCH64]
+  Aarch64/ArmMmuStandaloneMmLib.c
 
 [Packages]
-  MdePkg/MdePkg.dec
   ArmPkg/ArmPkg.dec
+  MdePkg/MdePkg.dec
 
 [LibraryClasses]
   ArmLib
-  BaseLib
+  CacheMaintenanceLib
+  MemoryAllocationLib
+
+
diff --git a/ArmPkg/Include/Library/ArmMmuLib.h 
b/ArmPkg/Include/Library/StandaloneMmMmuLib.h
similarity index 55%
copy from ArmPkg/Include/Library/ArmMmuLib.h
copy to ArmPkg/Include/Library/StandaloneMmMmuLib.h
index fb7fd006417c..1f7653d00430 100644
--- a/ArmPkg/Include/Library/ArmMmuLib.h
+++ b/ArmPkg/Include/Library/StandaloneMmMmuLib.h
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2015 - 2016, Linaro Ltd. All rights reserved.
+  Copyright (c) 2018, ARM Ltd. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
@@ -12,61 +12,31 @@
 
 **/
 
-#ifndef __ARM_MMU_LIB__
-#define __ARM_MMU_LIB__
-
-#include 
-
-#include 
-
-EFI_STATUS
-EFIAPI
-ArmConfigureMmu (
-  IN  ARM_MEMORY_REGION_DESCRIPTOR  *MemoryTable,
-  OUT VOID  **TranslationTab

[edk2] [PATCH v5 4/5] ArmPkg/Include: Add MM interface SVC return codes.

2018-11-27 Thread Sughosh Ganu
From: Achin Gupta 

This patch adds the Management Mode(MM) - Secure Partition
Manager(SPM) SVC return codes.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/Include/IndustryStandard/ArmMmSvc.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h 
b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
index 81b4654fa5dd..a64b9ec23c4b 100644
--- a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
@@ -40,4 +40,11 @@
 c_perm) & SET_MEM_ATTR_CODE_PERM_MASK) << 
SET_MEM_ATTR_CODE_PERM_SHIFT) | \
 (( (d_perm) & SET_MEM_ATTR_DATA_PERM_MASK) << 
SET_MEM_ATTR_DATA_PERM_SHIFT))
 
+/* MM SVC Return error codes */
+#define ARM_SVC_SPM_RET_SUCCESS   0
+#define ARM_SVC_SPM_RET_NOT_SUPPORTED-1
+#define ARM_SVC_SPM_RET_INVALID_PARAMS   -2
+#define ARM_SVC_SPM_RET_DENIED   -3
+#define ARM_SVC_SPM_RET_NO_MEMORY-5
+
 #endif
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v5 3/5] ArmPkg/Include: Fix the SPM version SVC ID

2018-11-27 Thread Sughosh Ganu
The MM_VERSION SMC call uses SMC32 calling convention. Fix the macro
to reflect the correct value.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/Include/IndustryStandard/ArmMmSvc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h 
b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
index 4c7b6c338627..81b4654fa5dd 100644
--- a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
@@ -20,7 +20,7 @@
  * delegated events and request the Secure partition manager to perform
  * privileged operations on its behalf.
  */
-#define ARM_SVC_ID_SPM_VERSION_AARCH64 0xC460
+#define ARM_SVC_ID_SPM_VERSION_AARCH32 0x8460
 #define ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64   0xC461
 #define ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH64   0xC464
 #define ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64   0xC465
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v5 2/5] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2018-11-27 Thread Sughosh Ganu
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   | 372 

 3 files changed, 456 insertions(+)

diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf 
b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
new file mode 100644
index ..88beafa39c05
--- /dev/null
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
@@ -0,0 +1,56 @@
+#/** @file
+#
+#  DXE MM Communicate driver
+#
+#  Copyright (c) 2016 - 2018, 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.
+#
+#**/
+
+[Defines]
+  INF_VERSION= 0x0001001A
+  BASE_NAME  = ArmMmCommunication
+  FILE_GUID  = 09EE81D3-F15E-43F4-85B4-CB9873DA5D6B
+  MODULE_TYPE= DXE_RUNTIME_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= MmCommunicationInitialize
+
+#
+# The following is for reference only and not required by
+# build tools
+#
+# VALID_ARCHITECTURES= AARCH64
+#
+
+[Sources.AARCH64]
+  MmCommunication.c
+
+[Packages]
+  ArmPkg/ArmPkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  ArmLib
+  ArmSmcLib
+  BaseMemoryLib
+  DebugLib
+  DxeServicesTableLib
+  HobLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gEfiMmCommunicationProtocolGuid  ## PRODUCES
+
+[Pcd.common]
+  gArmTokenSpaceGuid.PcdMmBufferBase
+  gArmTokenSpaceGuid.PcdMmBufferSize
+
+[Depex]
+  gEfiCpuArchProtocolGuid
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h 
b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
new file mode 100644
index ..0bf1c8d4ca0e
--- /dev/null
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
@@ -0,0 +1,28 @@
+/** @file
+
+  Copyright (c) 2016-2018, 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.
+
+**/
+
+#if !defined _MM_COMMUNICATE_H_
+#define _MM_COMMUNICATE_H_
+
+#define MM_MAJOR_VER_MASK0xEFFF
+#define MM_MINOR_VER_MASK0x
+#define MM_MAJOR_VER_SHIFT   16
+
+#define MM_MAJOR_VER(x) (((x) & MM_MAJOR_VER_MASK) >> MM_MAJOR_VER_SHIFT)
+#define MM_MINOR_VER(x) ((x) & MM_MINOR_VER_MASK)
+
+#define MM_CALLER_MAJOR_VER  0x1UL
+#define MM_CALLER_MINOR_VER  0x0
+
+#endif /* _MM_COMMUNICATE_H_ */
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c 
b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
new file mode 100644
index ..feb9fa9f4ead
--- /dev/null
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
@@ -0,0 +1,372 @@
+/** @file
+
+  Copyright (c) 2016-2018, 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 
+
+#include "MmCommunicate.h"
+
+//
+// Address, Length of the pre-allocated buffer for

[edk2] [PATCH v5 1/5] ArmPkg: Add PCDs needed for MM communication driver.

2018-11-27 Thread Sughosh Ganu
From: Achin Gupta 

This patch defines PCDs to describe the base address and size of
communication buffer between normal world (uefi) and standalone MM
environment in the secure world.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/ArmPkg.dec | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
index 84e57a0bf01c..0db7aa9d301c 100644
--- a/ArmPkg/ArmPkg.dec
+++ b/ArmPkg/ArmPkg.dec
@@ -240,6 +240,9 @@ [PcdsFixedAtBuild.common, PcdsDynamic.common, 
PcdsPatchableInModule.common]
   gArmTokenSpaceGuid.PcdSystemMemoryBase|0|UINT64|0x0029
   gArmTokenSpaceGuid.PcdSystemMemorySize|0|UINT64|0x002A
 
+  gArmTokenSpaceGuid.PcdMmBufferBase|0|UINT64|0x0045
+  gArmTokenSpaceGuid.PcdMmBufferSize|0|UINT64|0x0046
+
 [PcdsFixedAtBuild.common, PcdsDynamic.common]
   #
   # ARM Architectural Timer
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v5 0/5] ArmPkg related changes for StandaloneMM package

2018-11-27 Thread Sughosh Ganu


Changes since v4:
Based on comments from Ard
 - Removed now superfluous call to FreePages from MmCommunication.c
 - Removed Chipset/AArch64.h header file from ArmMmuStandaloneMmLib.c

Changes since v3:
Based on review comments from Ard, moved the MMU attribute changing
functions for StandaloneMM image into a new library class.

Moved the addition of memory space used as a MM_COMMUNICATE buffer to
memory type 'EfiGcdMemoryTypeReserved' and removed the call to
AllocatgePages.

Changes since v2:
Based on review comments from Ard, moved the memory attribute updation
changes out of DebugPeCoffExtraActionLib into an extra action library
added in StandaloneMM package. The patch for setting the memory
attributes, now under StandaloneMmPkg directory, will be submitted
separately from this series.

Changes since v1: Handled review comments from Leif


Achin Gupta (4):
  ArmPkg: Add PCDs needed for MM communication driver.
  ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.
  ArmPkg/Include: Add MM interface SVC return codes.
  ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.

Sughosh Ganu (1):
  ArmPkg/Include: Fix the SPM version SVC ID

 ArmPkg/ArmPkg.dec  
 |   4 +
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf  
 |  56 
+++
 
ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
 => ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf |  23 +-
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h  
 |  28 
++
 ArmPkg/Include/IndustryStandard/ArmMmSvc.h 
 |   9 
+-
 ArmPkg/Include/Library/{ArmMmuLib.h => StandaloneMmMmuLib.h}   
 |  38 
+-
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
 | 372 

 ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c  
 | 184 
++
 8 files changed, 669 insertions(+), 45 deletions(-)
 create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
 copy 
ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
 => ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf (56%)
 create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
 copy ArmPkg/Include/Library/{ArmMmuLib.h => StandaloneMmMmuLib.h} (55%)
 create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
 create mode 100644 
ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c

-- 
2.7.4


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v4 5/5] ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.

2018-11-27 Thread Sughosh Ganu
On Tue Nov 27, 2018 at 11:00:51AM +0100, Ard Biesheuvel wrote:
> On Tue, 27 Nov 2018 at 10:58, Sughosh Ganu  wrote:
> >
> > On Tue Nov 27, 2018 at 10:28:50AM +0100, Ard Biesheuvel wrote:
> > > On Tue, 27 Nov 2018 at 09:50, Sughosh Ganu  wrote:
> > > >
> > > > On Tue Nov 27, 2018 at 09:38:24AM +0100, Ard Biesheuvel wrote:
> > > > > On Tue, 27 Nov 2018 at 09:36, Sughosh Ganu  
> > > > > wrote:
> > > > > >
> > > > > > hi Ard,
> > > > > >
> > > > > > On Tue Nov 27, 2018 at 09:14:52AM +0100, Ard Biesheuvel wrote:
> > > > > > > On Tue, 27 Nov 2018 at 07:20, Sughosh Ganu  
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > From: Achin Gupta 
> > > > > > > >
> > > > > > > > The Standalone MM environment runs in S-EL0 in AArch64 on ARM 
> > > > > > > > Standard
> > > > > > > > Platforms. Privileged firmware e.g. ARM Trusted Firmware sets 
> > > > > > > > up its
> > > > > > > > architectural context including the initial translation tables 
> > > > > > > > for the
> > > > > > > > S-EL1/EL0 translation regime. The MM environment will still 
> > > > > > > > request ARM
> > > > > > > > TF to change the memory attributes of memory regions during
> > > > > > > > initialization.
> > > > > > > >
> > > > > > > > The Standalone MM image is a FV that encapsulates the MM 
> > > > > > > > foundation
> > > > > > > > and drivers. These are PE-COFF images with data and text 
> > > > > > > > segments.
> > > > > > > > To initialise the MM environment, Arm Trusted Firmware has to 
> > > > > > > > create
> > > > > > > > translation tables with sane default attributes for the memory
> > > > > > > > occupied by the FV. This library sends SVCs to ARM Trusted 
> > > > > > > > Firmware
> > > > > > > > to request memory permissions change for data and text segments.
> > > > > > > >
> > > > > > > > This patch adds a simple MMU library suitable for execution in 
> > > > > > > > S-EL0 and
> > > > > > > > requesting memory permissions change operations from Arm 
> > > > > > > > Trusted Firmware.
> > > > > > > >
> > > > > > > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > > > > > > Signed-off-by: Sughosh Ganu 
> > > > > > > > ---
> > > > > > > >  ArmPkg/ArmPkg.dec  
> > > > > > > > 
> > > > > > > >  |   1 +
> > > > > > > >  
> > > > > > > > ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
> > > > > > > >  => ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf 
> > > > > > > > |  23 +--
> > > > > > > >  ArmPkg/Include/Library/{ArmMmuLib.h => StandaloneMmMmuLib.h}   
> > > > > > > > 
> > > > > > > >  |  38 +---
> > > > > > > >  
> > > > > > > > ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c
> > > > > > > > 
> > > > > > > >| 185 
> > > > > > > >  4 files changed, 203 insertions(+), 44 deletions(-)
> > > > > >
> > > > > >
> > > > > > 
> > > > > >
> > > > > > > > +#endif /* __STANDALONEMM_MMU_LIB__ */
> > > > > > > > diff --git 
> > > > > > > > a/ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c
> > > > > > > >  
> > > > > > > > b/ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c
> > > > 

Re: [edk2] [PATCH v4 5/5] ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.

2018-11-27 Thread Sughosh Ganu
On Tue Nov 27, 2018 at 10:28:50AM +0100, Ard Biesheuvel wrote:
> On Tue, 27 Nov 2018 at 09:50, Sughosh Ganu  wrote:
> >
> > On Tue Nov 27, 2018 at 09:38:24AM +0100, Ard Biesheuvel wrote:
> > > On Tue, 27 Nov 2018 at 09:36, Sughosh Ganu  wrote:
> > > >
> > > > hi Ard,
> > > >
> > > > On Tue Nov 27, 2018 at 09:14:52AM +0100, Ard Biesheuvel wrote:
> > > > > On Tue, 27 Nov 2018 at 07:20, Sughosh Ganu  
> > > > > wrote:
> > > > > >
> > > > > > From: Achin Gupta 
> > > > > >
> > > > > > The Standalone MM environment runs in S-EL0 in AArch64 on ARM 
> > > > > > Standard
> > > > > > Platforms. Privileged firmware e.g. ARM Trusted Firmware sets up its
> > > > > > architectural context including the initial translation tables for 
> > > > > > the
> > > > > > S-EL1/EL0 translation regime. The MM environment will still request 
> > > > > > ARM
> > > > > > TF to change the memory attributes of memory regions during
> > > > > > initialization.
> > > > > >
> > > > > > The Standalone MM image is a FV that encapsulates the MM foundation
> > > > > > and drivers. These are PE-COFF images with data and text segments.
> > > > > > To initialise the MM environment, Arm Trusted Firmware has to create
> > > > > > translation tables with sane default attributes for the memory
> > > > > > occupied by the FV. This library sends SVCs to ARM Trusted Firmware
> > > > > > to request memory permissions change for data and text segments.
> > > > > >
> > > > > > This patch adds a simple MMU library suitable for execution in 
> > > > > > S-EL0 and
> > > > > > requesting memory permissions change operations from Arm Trusted 
> > > > > > Firmware.
> > > > > >
> > > > > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > > > > Signed-off-by: Sughosh Ganu 
> > > > > > ---
> > > > > >  ArmPkg/ArmPkg.dec  
> > > > > > 
> > > > > >  |   1 +
> > > > > >  
> > > > > > ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
> > > > > >  => ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf |  
> > > > > > 23 +--
> > > > > >  ArmPkg/Include/Library/{ArmMmuLib.h => StandaloneMmMmuLib.h}   
> > > > > > 
> > > > > >  |  38 +---
> > > > > >  ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c  
> > > > > > 
> > > > > >  | 185 
> > > > > >  4 files changed, 203 insertions(+), 44 deletions(-)
> > > >
> > > >
> > > > 
> > > >
> > > > > > +#endif /* __STANDALONEMM_MMU_LIB__ */
> > > > > > diff --git 
> > > > > > a/ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c 
> > > > > > b/ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c
> > > > > > new file mode 100644
> > > > > > index ..d7d87b7d5d69
> > > > > > --- /dev/null
> > > > > > +++ 
> > > > > > b/ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c
> > > > > > @@ -0,0 +1,185 @@
> > > > > > +/** @file
> > > > > > +*  File managing the MMU for ARMv8 architecture in S-EL0
> > > > > > +*
> > > > > > +*  Copyright (c) 2017 - 2018, 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/licen

Re: [edk2] [PATCH v4 5/5] ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.

2018-11-27 Thread Sughosh Ganu
On Tue Nov 27, 2018 at 09:38:24AM +0100, Ard Biesheuvel wrote:
> On Tue, 27 Nov 2018 at 09:36, Sughosh Ganu  wrote:
> >
> > hi Ard,
> >
> > On Tue Nov 27, 2018 at 09:14:52AM +0100, Ard Biesheuvel wrote:
> > > On Tue, 27 Nov 2018 at 07:20, Sughosh Ganu  wrote:
> > > >
> > > > From: Achin Gupta 
> > > >
> > > > The Standalone MM environment runs in S-EL0 in AArch64 on ARM Standard
> > > > Platforms. Privileged firmware e.g. ARM Trusted Firmware sets up its
> > > > architectural context including the initial translation tables for the
> > > > S-EL1/EL0 translation regime. The MM environment will still request ARM
> > > > TF to change the memory attributes of memory regions during
> > > > initialization.
> > > >
> > > > The Standalone MM image is a FV that encapsulates the MM foundation
> > > > and drivers. These are PE-COFF images with data and text segments.
> > > > To initialise the MM environment, Arm Trusted Firmware has to create
> > > > translation tables with sane default attributes for the memory
> > > > occupied by the FV. This library sends SVCs to ARM Trusted Firmware
> > > > to request memory permissions change for data and text segments.
> > > >
> > > > This patch adds a simple MMU library suitable for execution in S-EL0 and
> > > > requesting memory permissions change operations from Arm Trusted 
> > > > Firmware.
> > > >
> > > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > > Signed-off-by: Sughosh Ganu 
> > > > ---
> > > >  ArmPkg/ArmPkg.dec  
> > > > 
> > > >  |   1 +
> > > >  
> > > > ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
> > > >  => ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf |  23 
> > > > +--
> > > >  ArmPkg/Include/Library/{ArmMmuLib.h => StandaloneMmMmuLib.h}   
> > > > 
> > > >  |  38 +---
> > > >  ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c  
> > > > 
> > > >  | 185 
> > > >  4 files changed, 203 insertions(+), 44 deletions(-)
> >
> >
> > 
> >
> > > > +#endif /* __STANDALONEMM_MMU_LIB__ */
> > > > diff --git 
> > > > a/ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c 
> > > > b/ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c
> > > > new file mode 100644
> > > > index ..d7d87b7d5d69
> > > > --- /dev/null
> > > > +++ b/ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c
> > > > @@ -0,0 +1,185 @@
> > > > +/** @file
> > > > +*  File managing the MMU for ARMv8 architecture in S-EL0
> > > > +*
> > > > +*  Copyright (c) 2017 - 2018, 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 
> > >
> > > Why do you need this include? If you can drop it, can you also make
> > > the library generic (i.e., supporting ARM as well as AArch64) ?
> > >
> > > (apologies for not spotting this before)
> >
> > I can remove the header file if it is superfluous. But regarding your
> > comment on making this code generic for Arm as well, i guess we
> > can work on refactoring the code when/if we actually require to
> > support this on Arm. I am not sure if we are going to have a use-case
> > for StandaloneMM on Arm. Currently, we are only supporting it on
> > Aarch64 based platforms. Is that fine. Please let me know. Thanks.
> >
> 
> I'd strongly prefer this code to be generic if you are not using any
> AArch64 specific facilities.
> 
> AFAICT, we'd simply need to move the file out of the AArch64 directory
> and rename [Sources.AARCH64] to [Sources] in the .inf file if the
> header dependency is indeed superfluous.

There are a couple of places where we use something like
ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH64. Apart from this, it is
generic.

-sughosh
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v4 5/5] ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.

2018-11-27 Thread Sughosh Ganu
hi Ard,

On Tue Nov 27, 2018 at 09:14:52AM +0100, Ard Biesheuvel wrote:
> On Tue, 27 Nov 2018 at 07:20, Sughosh Ganu  wrote:
> >
> > From: Achin Gupta 
> >
> > The Standalone MM environment runs in S-EL0 in AArch64 on ARM Standard
> > Platforms. Privileged firmware e.g. ARM Trusted Firmware sets up its
> > architectural context including the initial translation tables for the
> > S-EL1/EL0 translation regime. The MM environment will still request ARM
> > TF to change the memory attributes of memory regions during
> > initialization.
> >
> > The Standalone MM image is a FV that encapsulates the MM foundation
> > and drivers. These are PE-COFF images with data and text segments.
> > To initialise the MM environment, Arm Trusted Firmware has to create
> > translation tables with sane default attributes for the memory
> > occupied by the FV. This library sends SVCs to ARM Trusted Firmware
> > to request memory permissions change for data and text segments.
> >
> > This patch adds a simple MMU library suitable for execution in S-EL0 and
> > requesting memory permissions change operations from Arm Trusted Firmware.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Sughosh Ganu 
> > ---
> >  ArmPkg/ArmPkg.dec  
> > 
> >  |   1 +
> >  
> > ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
> >  => ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf |  23 +--
> >  ArmPkg/Include/Library/{ArmMmuLib.h => StandaloneMmMmuLib.h}   
> > 
> >  |  38 +---
> >  ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c  
> > 
> >  | 185 
> >  4 files changed, 203 insertions(+), 44 deletions(-)




> > +#endif /* __STANDALONEMM_MMU_LIB__ */
> > diff --git 
> > a/ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c 
> > b/ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c
> > new file mode 100644
> > index ..d7d87b7d5d69
> > --- /dev/null
> > +++ b/ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c
> > @@ -0,0 +1,185 @@
> > +/** @file
> > +*  File managing the MMU for ARMv8 architecture in S-EL0
> > +*
> > +*  Copyright (c) 2017 - 2018, 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 
> 
> Why do you need this include? If you can drop it, can you also make
> the library generic (i.e., supporting ARM as well as AArch64) ?
> 
> (apologies for not spotting this before)

I can remove the header file if it is superfluous. But regarding your
comment on making this code generic for Arm as well, i guess we
can work on refactoring the code when/if we actually require to
support this on Arm. I am not sure if we are going to have a use-case
for StandaloneMM on Arm. Currently, we are only supporting it on
Aarch64 based platforms. Is that fine. Please let me know. Thanks.

-sughosh
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v4 2/5] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2018-11-27 Thread Sughosh Ganu
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  ImageHandleThe firmware allocated handle for the EFI image.
> > +  @param  SystemTableA pointer to the EFI System Table.
> > +
> > +  @retval EFI_SUCCESSThe 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 

[edk2] [PATCH v2 2/2] StandaloneMM: Update permissions for Standalone MM drivers memory area

2018-11-26 Thread Sughosh Ganu
The StandaloneMM image executes in S-EL0 on reference Arm platforms
and is deployed by the trusted firmware as BL32 image. Memory for the
Standalone MM drivers is marked as RW+XN initially, allowing the
drivers to be loaded into the memory. Once loaded, the memory
attributes need to be changed to RO+XN for rodata sections and RO+X
for code sections.

Achieve this through the extra action 'UpdatePeCoffPermissions' to
request the privileged firmware in EL3 to update the permissions.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 .../StandaloneMmPeCoffExtraActionLib.inf   |  18 +-
 .../StandaloneMmPeCoffExtraActionLib.c | 222 +
 2 files changed, 233 insertions(+), 7 deletions(-)
 copy ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf => 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
 (72%)
 create mode 100644 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.c

diff --git a/ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf 
b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
similarity index 72%
copy from ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf
copy to 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
index 3be0237a3689..87734f69b75d 100644
--- a/ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf
+++ 
b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
@@ -16,9 +16,9 @@
 #**/
 
 [Defines]
-  INF_VERSION= 0x00010005
-  BASE_NAME  = RvdUnixPeCoffExtraActionLib
-  FILE_GUID  = 5EDEB7E7-EA55-4E92-8216-335AC98A3B11
+  INF_VERSION= 0x0001000A
+  BASE_NAME  = StandaloneMmPeCoffExtraActionLib
+  FILE_GUID  = 8B40543B-9588-48F8-840C-5A60E6DB1B03
   MODULE_TYPE= BASE
   VERSION_STRING = 1.0
   LIBRARY_CLASS  = PeCoffExtraActionLib
@@ -30,12 +30,16 @@ [Defines]
 #
 
 [Sources.common]
-  RvdPeCoffExtraActionLib.c
+  StandaloneMmPeCoffExtraActionLib.c
 
 [Packages]
-  MdePkg/MdePkg.dec
   ArmPkg/ArmPkg.dec
+  MdePkg/MdePkg.dec
+  StandaloneMmPkg/StandaloneMmPkg.dec
+
+[FeaturePcd]
+  gStandaloneMmPkgTokenSpaceGuid.PcdStandaloneMmEnable
 
 [LibraryClasses]
-  DebugLib
-  SemihostLib
+  StandaloneMmMmuLib
+  PcdLib
diff --git 
a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.c
 
b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.c
new file mode 100644
index ..1c9fec201916
--- /dev/null
+++ 
b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.c
@@ -0,0 +1,222 @@
+/**@file
+
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
+Portions copyright (c) 2011 - 2018, ARM Ltd. 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 
+
+typedef RETURN_STATUS (*REGION_PERMISSION_UPDATE_FUNC) (
+  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN  UINT64Length
+  );
+
+STATIC
+RETURN_STATUS
+UpdatePeCoffPermissions (
+  IN  CONST PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,
+  IN  REGION_PERMISSION_UPDATE_FUNC   NoExecUpdater,
+  IN  REGION_PERMISSION_UPDATE_FUNC   ReadOnlyUpdater
+  )
+{
+  RETURN_STATUS Status;
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;
+  EFI_IMAGE_OPTIONAL_HEADER_UNION   HdrData;
+  UINTN Size;
+  UINTN ReadSize;
+  UINT32SectionHeaderOffset;
+  UINTN NumberOfSections;
+  UINTN Index;
+  EFI_IMAGE_SECTION_HEADER  SectionHeader;
+  PE_COFF_LOADER_IMAGE_CONTEXT  TmpContext;
+  EFI_PHYSICAL_ADDRESS  Base;
+
+  //
+  // We need to copy ImageContext since PeCoffLoaderGetImageInfo ()
+  // will mangle the ImageAddress field
+  //
+  CopyMem (&TmpContext, ImageContext, sizeof (TmpContext));
+
+  if (TmpContext.PeCoffHeaderOffset == 0) {
+Status = PeCoffLoaderGetImageInfo (&TmpContext)

[edk2] [PATCH v2 1/2] StandaloneMM: Include the newly added library class for MMU functions

2018-11-26 Thread Sughosh Ganu
The MMU functions needed for StandaloneMM image are now exported
through a separate library class. Make the corresponding change in the
core's entry point inf file so that it references the correct library
class for modifying the MMU attributes.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 .../Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
 
b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
index 66184c4a00f3..3222cd359f3e 100644
--- 
a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
+++ 
b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
@@ -45,7 +45,7 @@ [LibraryClasses]
   DebugLib
 
 [LibraryClasses.AARCH64]
-  ArmMmuLib
+  StandaloneMmMmuLib
   ArmSvcLib
 
 [Guids]
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 0/2] StandaloneMM: Update permissions for Standalone MM drivers memory area

2018-11-26 Thread Sughosh Ganu
Changes since v1:
A new patch has been added to reflect the library class added for
changing the MMU attributes in StandaloneMM image, based on review
comments from Ard Biesheuvel.


These patches needs to be applied on top of the following patch series
 - "ArmPkg related changes for StandaloneMM package".


Sughosh Ganu (2):
  StandaloneMM: Include the newly added library class for MMU functions
  StandaloneMM: Update permissions for Standalone MM drivers memory area

 .../StandaloneMmCoreEntryPoint.inf |   2 +-
 .../StandaloneMmPeCoffExtraActionLib.inf   |  18 +-
 .../StandaloneMmPeCoffExtraActionLib.c | 222 +
 3 files changed, 234 insertions(+), 8 deletions(-)
 copy ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf => 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
 (72%)
 create mode 100644 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.c

-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v4 5/5] ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.

2018-11-26 Thread Sughosh Ganu
From: Achin Gupta 

The Standalone MM environment runs in S-EL0 in AArch64 on ARM Standard
Platforms. Privileged firmware e.g. ARM Trusted Firmware sets up its
architectural context including the initial translation tables for the
S-EL1/EL0 translation regime. The MM environment will still request ARM
TF to change the memory attributes of memory regions during
initialization.

The Standalone MM image is a FV that encapsulates the MM foundation
and drivers. These are PE-COFF images with data and text segments.
To initialise the MM environment, Arm Trusted Firmware has to create
translation tables with sane default attributes for the memory
occupied by the FV. This library sends SVCs to ARM Trusted Firmware
to request memory permissions change for data and text segments.

This patch adds a simple MMU library suitable for execution in S-EL0 and
requesting memory permissions change operations from Arm Trusted Firmware.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/ArmPkg.dec  
 |   1 +
 
ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
 => ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf |  23 +--
 ArmPkg/Include/Library/{ArmMmuLib.h => StandaloneMmMmuLib.h}   
 |  38 
+---
 ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c  
 | 185 

 4 files changed, 203 insertions(+), 44 deletions(-)

diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
index 0db7aa9d301c..d99eb6769ff1 100644
--- a/ArmPkg/ArmPkg.dec
+++ b/ArmPkg/ArmPkg.dec
@@ -42,6 +42,7 @@ [LibraryClasses.common]
   ArmMtlLib|ArmPlatformPkg/Include/Library/ArmMtlLib.h
   ArmSvcLib|Include/Library/ArmSvcLib.h
   OpteeLib|Include/Library/OpteeLib.h
+  StandaloneMmMmuLib|Include/Library/StandaloneMmMmuLib.h
 
 [Guids.common]
   gArmTokenSpaceGuid   = { 0xBB11ECFE, 0x820F, 0x4968, { 0xBB, 0xA6, 0xF7, 
0x6A, 0xFE, 0x30, 0x25, 0x96 } }
diff --git 
a/ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
 b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
similarity index 56%
copy from 
ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
copy to ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
index bd6ac8039844..d589b236033c 100644
--- 
a/ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
+++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
@@ -1,7 +1,6 @@
 #/** @file
-#  Implement ArmGenericTimerCounterLib for Xen using the virtual timer
 #
-#  Copyright (c) 2014 - 2018, Linaro Ltd. All rights reserved.
+#  Copyright (c) 2017 - 2018, 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
@@ -15,19 +14,23 @@
 
 [Defines]
   INF_VERSION= 0x0001001A
-  BASE_NAME  = XenArmGenericTimerVirtCounterLib
-  FILE_GUID  = e3913319-96ac-4ac0-808b-8edb8776a51c
-  MODULE_TYPE= BASE
+  BASE_NAME  = ArmMmuStandaloneMmCoreLib
+  FILE_GUID  = da8f0232-fb14-42f0-922c-63104d2c70bd
+  MODULE_TYPE= MM_CORE_STANDALONE
   VERSION_STRING = 1.0
-  LIBRARY_CLASS  = ArmGenericTimerCounterLib
+  LIBRARY_CLASS  = StandaloneMmMmuLib
+  PI_SPECIFICATION_VERSION   = 0x00010032
 
-[Sources]
-  XenArmGenericTimerVirtCounterLib.c
+[Sources.AARCH64]
+  Aarch64/ArmMmuStandaloneMmLib.c
 
 [Packages]
-  MdePkg/MdePkg.dec
   ArmPkg/ArmPkg.dec
+  MdePkg/MdePkg.dec
 
 [LibraryClasses]
   ArmLib
-  BaseLib
+  CacheMaintenanceLib
+  MemoryAllocationLib
+
+
diff --git a/ArmPkg/Include/Library/ArmMmuLib.h 
b/ArmPkg/Include/Library/StandaloneMmMmuLib.h
similarity index 55%
copy from ArmPkg/Include/Library/ArmMmuLib.h
copy to ArmPkg/Include/Library/StandaloneMmMmuLib.h
index fb7fd006417c..1f7653d00430 100644
--- a/ArmPkg/Include/Library/ArmMmuLib.h
+++ b/ArmPkg/Include/Library/StandaloneMmMmuLib.h
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2015 - 2016, Linaro Ltd. All rights reserved.
+  Copyright (c) 2018, ARM Ltd. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
@@ -12,61 +12,31 @@
 
 **/
 
-#ifndef __ARM_MMU_LIB__
-#define __ARM_MMU_LIB__
-
-#include 
-
-#include 
-
-EFI_STATUS
-EFIAPI
-ArmConfigureMmu (
-  IN  ARM_MEMORY_REGION_DESCRIPTOR  *MemoryTable,
-  OUT VOID  **TranslationTab

[edk2] [PATCH v4 4/5] ArmPkg/Include: Add MM interface SVC return codes.

2018-11-26 Thread Sughosh Ganu
From: Achin Gupta 

This patch adds the Management Mode(MM) - Secure Partition
Manager(SPM) SVC return codes.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/Include/IndustryStandard/ArmMmSvc.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h 
b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
index 81b4654fa5dd..a64b9ec23c4b 100644
--- a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
@@ -40,4 +40,11 @@
 c_perm) & SET_MEM_ATTR_CODE_PERM_MASK) << 
SET_MEM_ATTR_CODE_PERM_SHIFT) | \
 (( (d_perm) & SET_MEM_ATTR_DATA_PERM_MASK) << 
SET_MEM_ATTR_DATA_PERM_SHIFT))
 
+/* MM SVC Return error codes */
+#define ARM_SVC_SPM_RET_SUCCESS   0
+#define ARM_SVC_SPM_RET_NOT_SUPPORTED-1
+#define ARM_SVC_SPM_RET_INVALID_PARAMS   -2
+#define ARM_SVC_SPM_RET_DENIED   -3
+#define ARM_SVC_SPM_RET_NO_MEMORY-5
+
 #endif
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v4 3/5] ArmPkg/Include: Fix the SPM version SVC ID

2018-11-26 Thread Sughosh Ganu
The MM_VERSION SMC call uses SMC32 calling convention. Fix the macro
to reflect the correct value.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/Include/IndustryStandard/ArmMmSvc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h 
b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
index 4c7b6c338627..81b4654fa5dd 100644
--- a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
@@ -20,7 +20,7 @@
  * delegated events and request the Secure partition manager to perform
  * privileged operations on its behalf.
  */
-#define ARM_SVC_ID_SPM_VERSION_AARCH64 0xC460
+#define ARM_SVC_ID_SPM_VERSION_AARCH32 0x8460
 #define ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64   0xC461
 #define ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH64   0xC464
 #define ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64   0xC465
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v4 2/5] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2018-11-26 Thread Sughosh Ganu
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(+)

diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf 
b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
new file mode 100644
index ..88beafa39c05
--- /dev/null
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
@@ -0,0 +1,56 @@
+#/** @file
+#
+#  DXE MM Communicate driver
+#
+#  Copyright (c) 2016 - 2018, 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.
+#
+#**/
+
+[Defines]
+  INF_VERSION= 0x0001001A
+  BASE_NAME  = ArmMmCommunication
+  FILE_GUID  = 09EE81D3-F15E-43F4-85B4-CB9873DA5D6B
+  MODULE_TYPE= DXE_RUNTIME_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= MmCommunicationInitialize
+
+#
+# The following is for reference only and not required by
+# build tools
+#
+# VALID_ARCHITECTURES= AARCH64
+#
+
+[Sources.AARCH64]
+  MmCommunication.c
+
+[Packages]
+  ArmPkg/ArmPkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  ArmLib
+  ArmSmcLib
+  BaseMemoryLib
+  DebugLib
+  DxeServicesTableLib
+  HobLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gEfiMmCommunicationProtocolGuid  ## PRODUCES
+
+[Pcd.common]
+  gArmTokenSpaceGuid.PcdMmBufferBase
+  gArmTokenSpaceGuid.PcdMmBufferSize
+
+[Depex]
+  gEfiCpuArchProtocolGuid
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h 
b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
new file mode 100644
index ..0bf1c8d4ca0e
--- /dev/null
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
@@ -0,0 +1,28 @@
+/** @file
+
+  Copyright (c) 2016-2018, 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.
+
+**/
+
+#if !defined _MM_COMMUNICATE_H_
+#define _MM_COMMUNICATE_H_
+
+#define MM_MAJOR_VER_MASK0xEFFF
+#define MM_MINOR_VER_MASK0x
+#define MM_MAJOR_VER_SHIFT   16
+
+#define MM_MAJOR_VER(x) (((x) & MM_MAJOR_VER_MASK) >> MM_MAJOR_VER_SHIFT)
+#define MM_MINOR_VER(x) ((x) & MM_MINOR_VER_MASK)
+
+#define MM_CALLER_MAJOR_VER  0x1UL
+#define MM_CALLER_MINOR_VER  0x0
+
+#endif /* _MM_COMMUNICATE_H_ */
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c 
b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
new file mode 100644
index ..4e1218671d9a
--- /dev/null
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
@@ -0,0 +1,378 @@
+/** @file
+
+  Copyright (c) 2016-2018, 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 
+
+#include "MmCommunicate.h"
+
+//
+// Address, Length of the pre-allocated buffer for

[edk2] [PATCH v4 1/5] ArmPkg: Add PCDs needed for MM communication driver.

2018-11-26 Thread Sughosh Ganu
From: Achin Gupta 

This patch defines PCDs to describe the base address and size of
communication buffer between normal world (uefi) and standalone MM
environment in the secure world.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/ArmPkg.dec | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
index 84e57a0bf01c..0db7aa9d301c 100644
--- a/ArmPkg/ArmPkg.dec
+++ b/ArmPkg/ArmPkg.dec
@@ -240,6 +240,9 @@ [PcdsFixedAtBuild.common, PcdsDynamic.common, 
PcdsPatchableInModule.common]
   gArmTokenSpaceGuid.PcdSystemMemoryBase|0|UINT64|0x0029
   gArmTokenSpaceGuid.PcdSystemMemorySize|0|UINT64|0x002A
 
+  gArmTokenSpaceGuid.PcdMmBufferBase|0|UINT64|0x0045
+  gArmTokenSpaceGuid.PcdMmBufferSize|0|UINT64|0x0046
+
 [PcdsFixedAtBuild.common, PcdsDynamic.common]
   #
   # ARM Architectural Timer
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v4 0/5] ArmPkg related changes for StandaloneMM package

2018-11-26 Thread Sughosh Ganu


Changes since v3:
Based on review comments from Ard, moved the MMU attribute changing
functions for StandaloneMM image into a new library class.

Moved the addition of memory space used as a MM_COMMUNICATE buffer to
memory type 'EfiGcdMemoryTypeReserved' and removed the call to
AllocatgePages.

Changes since v2:
Based on review comments from Ard, moved the memory attribute updation
changes out of DebugPeCoffExtraActionLib into an extra action library
added in StandaloneMM package. The patch for setting the memory
attributes, now under StandaloneMmPkg directory, will be submitted
separately from this series.

Changes since v1: Handled review comments from Leif

Achin Gupta (4):
  ArmPkg: Add PCDs needed for MM communication driver.
  ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.
  ArmPkg/Include: Add MM interface SVC return codes.
  ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.

Sughosh Ganu (1):
  ArmPkg/Include: Fix the SPM version SVC ID

 ArmPkg/ArmPkg.dec  
 |   4 +
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf  
 |  56 
+++
 
ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
 => ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf |  23 +-
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h  
 |  28 
++
 ArmPkg/Include/IndustryStandard/ArmMmSvc.h 
 |   9 
+-
 ArmPkg/Include/Library/{ArmMmuLib.h => StandaloneMmMmuLib.h}   
 |  38 
+-
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
 | 378 

 ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c  
 | 185 
++
 8 files changed, 676 insertions(+), 45 deletions(-)
 create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
 copy 
ArmVirtPkg/Library/XenArmGenericTimerVirtCounterLib/XenArmGenericTimerVirtCounterLib.inf
 => ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf (56%)
 create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
 copy ArmPkg/Include/Library/{ArmMmuLib.h => StandaloneMmMmuLib.h} (55%)
 create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
 create mode 100644 
ArmPkg/Library/StandaloneMmMmuLib/Aarch64/ArmMmuStandaloneMmLib.c

-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v3 6/6] ArmPkg/ArmMmuLib: Add MMU library inf file suitable for use in S-EL0.

2018-11-24 Thread Sughosh Ganu
hi Ard,

On Fri Nov 23, 2018 at 07:28:19PM +0100, Ard Biesheuvel wrote:
> On Thu, 25 Oct 2018 at 09:33, Sughosh Ganu  wrote:
> >
> > From: Achin Gupta 
> >
> > This patch adds the definitions, sources, packages and library classes
> > needed to compile and link MMU Library suitable for use in S-EL0.
> >
> > Currently, this is used only during the Standalone MM Core
> > initialization and hence defined as MM_CORE_STANDALONE Module.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Sughosh Ganu 
> > ---
> >  ArmPkg/Library/ArmMmuLib/{ArmMmuPeiLib.inf => 
> > ArmMmuStandaloneMmCoreLib.inf} | 23 +---
> 
> The code in the previous patch looks fine, but I'd prefer it if we
> expose this as a separate library class, not ArmMmuLib
> 
> So please just add a new file, say,
> ArmPkg/include/Library/StandaloneMmMmuLib.h, add only the functions
> you need, and add it to the LibraryClasses section of ArmPkg.dec as a
> new library class.
> 
> Then, you can modify the previous patch to include an updated .inf
> that describes it as being an implementation of StandaloneMmMmuLib.
> You can then also drop the unimplemented ArmConfigureMmu etc.

Thanks for reviewing the patches. I will incorporate the review
comments from both the patches, and post a V4 in the coming week.

-sughosh
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v3 0/6] ArmPkg related changes for StandaloneMM package

2018-11-18 Thread Sughosh Ganu
hi Ard,

On Thu Oct 25, 2018 at 01:02:33PM +0530, Sughosh Ganu wrote:
> The following patch series adds support for Management Mode related
> changes for aarch64 based platforms.
> 
> Changes since v2:
> Based on review comments from Ard, moved the memory attribute updation
> changes out of DebugPeCoffExtraActionLib into an extra action library
> added in StandaloneMM package. The patch for setting the memory
> attributes, now under StandaloneMmPkg directory, will be submitted
> separately from this series.

Can you please review the V3 of this series. Based on your review
comments, i have moved the memory attribute updation into an extra
action lib added under StandaloneMmPkg. Can you please check if these
updated patches for ArmPkg[1] and the one under StandaloneMmPkg[2] are
fine.

I had put you and Leif on Cc while sending out the patches, but i
think that the mailserver deleted those, which is why you may have
missed the patches.

-sughosh

[1] - https://lists.01.org/pipermail/edk2-devel/2018-October/031377.html
[2] - https://lists.01.org/pipermail/edk2-devel/2018-October/031384.html

> 
> 
> Achin Gupta (5):
>   ArmPkg: Add PCDs needed for MM communication driver.
>   ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.
>   ArmPkg/Include: Add MM interface SVC return codes.
>   ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.
>   ArmPkg/ArmMmuLib: Add MMU library inf file suitable for use in S-EL0.
> 
> Sughosh Ganu (1):
>   ArmPkg/Include: Fix the SPM version SVC ID
> 
>  ArmPkg/ArmPkg.dec
> |   3 +
>  ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
> |  56 +++
>  ArmPkg/Library/ArmMmuLib/{ArmMmuPeiLib.inf => ArmMmuStandaloneMmCoreLib.inf} 
> |  23 +-
>  ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
> |  28 ++
>  ArmPkg/Include/IndustryStandard/ArmMmSvc.h   
> |   9 +-
>  ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c  
> | 395 
>  ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c 
> | 204 ++
>  7 files changed, 704 insertions(+), 14 deletions(-)
>  create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
>  copy ArmPkg/Library/ArmMmuLib/{ArmMmuPeiLib.inf => 
> ArmMmuStandaloneMmCoreLib.inf} (51%)
>  create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
>  create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
>  create mode 100644 
> ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c
> 
> -- 
> 2.7.4
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel

-- 
-sughosh
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v3 0/6] ArmPkg related changes for StandaloneMM package

2018-11-18 Thread Sughosh Ganu
hi Ard,

On Thu Oct 25, 2018 at 01:02:33PM +0530, Sughosh Ganu wrote:
> The following patch series adds support for Management Mode related
> changes for aarch64 based platforms.
> 
> Changes since v2:
> Based on review comments from Ard, moved the memory attribute updation
> changes out of DebugPeCoffExtraActionLib into an extra action library
> added in StandaloneMM package. The patch for setting the memory
> attributes, now under StandaloneMmPkg directory, will be submitted
> separately from this series.

Can you please review the V3 of this series. Based on your review
comments, i have moved the memory attribute updation into an extra
action lib added under StandaloneMmPkg. Can you please check if these
updated patches for ArmPkg[1] and the one under StandaloneMmPkg[2] are
fine.

I had put you and Leif on Cc while sending out the patches, but i
think that the mailserver deleted those, which is why you may have
missed the patches.

-sughosh

[1] - https://lists.01.org/pipermail/edk2-devel/2018-October/031377.html
[2] - https://lists.01.org/pipermail/edk2-devel/2018-October/031384.html

> 
> 
> Achin Gupta (5):
>   ArmPkg: Add PCDs needed for MM communication driver.
>   ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.
>   ArmPkg/Include: Add MM interface SVC return codes.
>   ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.
>   ArmPkg/ArmMmuLib: Add MMU library inf file suitable for use in S-EL0.
> 
> Sughosh Ganu (1):
>   ArmPkg/Include: Fix the SPM version SVC ID
> 
>  ArmPkg/ArmPkg.dec
> |   3 +
>  ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
> |  56 +++
>  ArmPkg/Library/ArmMmuLib/{ArmMmuPeiLib.inf => ArmMmuStandaloneMmCoreLib.inf} 
> |  23 +-
>  ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
> |  28 ++
>  ArmPkg/Include/IndustryStandard/ArmMmSvc.h   
> |   9 +-
>  ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c  
> | 395 
>  ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c 
> | 204 ++
>  7 files changed, 704 insertions(+), 14 deletions(-)
>  create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
>  copy ArmPkg/Library/ArmMmuLib/{ArmMmuPeiLib.inf => 
> ArmMmuStandaloneMmCoreLib.inf} (51%)
>  create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
>  create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
>  create mode 100644 
> ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c
> 
> -- 
> 2.7.4
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel

-- 
-sughosh
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v1 0/1] StandaloneMM: Update permissions for Standalone MM drivers memory area

2018-10-25 Thread Sughosh Ganu
Patch to update the memory attributes of the region where StandaloneMM
drivers are loaded. Based on the review comments from Ard, this code
has now been moved under StandaloneMmPkg directory.

This patch needs to be applied on top of the following patch series -
"ArmPkg related changes for StandaloneMM package".

Sughosh Ganu (1):
  StandaloneMM: Update permissions for Standalone MM drivers memory area

 ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf => 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
 |  19 +-
 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.c
 | 222 

 2 files changed, 234 insertions(+), 7 deletions(-)
 copy ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf => 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
 (72%)
 create mode 100644 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.c

-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v1 1/1] StandaloneMM: Update permissions for Standalone MM drivers memory area

2018-10-25 Thread Sughosh Ganu
The StandaloneMM image executes in S-EL0 on reference Arm platforms
and is deployed by the trusted firmware as BL32 image. Memory for the
Standalone MM drivers is marked as RW+XN initially, allowing the
drivers to be loaded into the memory. Once loaded, the memory
attributes need to be changed to RO+XN for rodata sections and RO+X
for code sections.

Achieve this through the extra action 'UpdatePeCoffPermissions' to
request the privileged firmware in EL3 to update the permissions.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf => 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
 |  19 +-
 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.c
 | 222 

 2 files changed, 234 insertions(+), 7 deletions(-)

diff --git a/ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf 
b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
similarity index 72%
copy from ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf
copy to 
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
index 3be0237a3689..f9a1afaac0c5 100644
--- a/ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf
+++ 
b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
@@ -16,9 +16,9 @@
 #**/
 
 [Defines]
-  INF_VERSION= 0x00010005
-  BASE_NAME  = RvdUnixPeCoffExtraActionLib
-  FILE_GUID  = 5EDEB7E7-EA55-4E92-8216-335AC98A3B11
+  INF_VERSION= 0x0001000A
+  BASE_NAME  = StandaloneMmPeCoffExtraActionLib
+  FILE_GUID  = 8B40543B-9588-48F8-840C-5A60E6DB1B03
   MODULE_TYPE= BASE
   VERSION_STRING = 1.0
   LIBRARY_CLASS  = PeCoffExtraActionLib
@@ -30,12 +30,17 @@ [Defines]
 #
 
 [Sources.common]
-  RvdPeCoffExtraActionLib.c
+  StandaloneMmPeCoffExtraActionLib.c
 
 [Packages]
-  MdePkg/MdePkg.dec
   ArmPkg/ArmPkg.dec
+  MdePkg/MdePkg.dec
+  StandaloneMmPkg/StandaloneMmPkg.dec
+
+[FeaturePcd]
+  gStandaloneMmPkgTokenSpaceGuid.PcdStandaloneMmEnable
 
 [LibraryClasses]
-  DebugLib
-  SemihostLib
+  ArmMmuLib
+#  DebugLib
+  PcdLib
diff --git 
a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.c
 
b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.c
new file mode 100644
index ..1c9fec201916
--- /dev/null
+++ 
b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.c
@@ -0,0 +1,222 @@
+/**@file
+
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
+Portions copyright (c) 2011 - 2018, ARM Ltd. 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 
+
+typedef RETURN_STATUS (*REGION_PERMISSION_UPDATE_FUNC) (
+  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN  UINT64Length
+  );
+
+STATIC
+RETURN_STATUS
+UpdatePeCoffPermissions (
+  IN  CONST PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,
+  IN  REGION_PERMISSION_UPDATE_FUNC   NoExecUpdater,
+  IN  REGION_PERMISSION_UPDATE_FUNC   ReadOnlyUpdater
+  )
+{
+  RETURN_STATUS Status;
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;
+  EFI_IMAGE_OPTIONAL_HEADER_UNION   HdrData;
+  UINTN Size;
+  UINTN ReadSize;
+  UINT32SectionHeaderOffset;
+  UINTN NumberOfSections;
+  UINTN Index;
+  EFI_IMAGE_SECTION_HEADER  SectionHeader;
+  PE_COFF_LOADER_IMAGE_CONTEXT  TmpContext;
+  EFI_PHYSICAL_ADDRESS  Base;
+
+  //
+  // We need to copy ImageContext since PeCoffLoaderGetImageInfo ()
+  // will mangle the ImageAddress field
+  //
+  CopyMem (&TmpContext, ImageContext, sizeof (TmpContext));
+
+  if (TmpContext.PeCoffHeaderOffset == 0) {
+Status = PeCoffLoaderGetImageInfo (&TmpContext);
+if (RETURN_ERROR (Status)) {
+  DE

[edk2] [PATCH v3 5/6] ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.

2018-10-25 Thread Sughosh Ganu
From: Achin Gupta 

The Standalone MM environment runs in S-EL0 in AArch64 on ARM Standard
Platforms. Privileged firmware e.g. ARM Trusted Firmware sets up its
architectural context including the initial translation tables for the
S-EL1/EL0 translation regime. The MM environment will still request ARM
TF to change the memory attributes of memory regions during
initialization.

The Standalone MM image is a FV that encapsulates the MM foundation
and drivers. These are PE-COFF images with data and text segments.
To initialise the MM environment, Arm Trusted Firmware has to create
translation tables with sane default attributes for the memory
occupied by the FV. This library sends SVCs to ARM Trusted Firmware
to request memory permissions change for data and text segments.

This patch adds a simple MMU library suitable for execution in S-EL0 and
requesting memory permissions change operations from Arm Trusted Firmware.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c | 204 

 1 file changed, 204 insertions(+)

diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c 
b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c
new file mode 100644
index ..ee0a80349051
--- /dev/null
+++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c
@@ -0,0 +1,204 @@
+/** @file
+*  File managing the MMU for ARMv8 architecture in S-EL0
+*
+*  Copyright (c) 2017 - 2018, 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 
+
+EFI_STATUS
+GetMemoryPermissions (
+  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
+  OUT UINT32*MemoryAttributes
+  )
+{
+  ARM_SVC_ARGS  GetMemoryPermissionsSvcArgs = {0};
+
+  GetMemoryPermissionsSvcArgs.Arg0 = ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH64;
+  GetMemoryPermissionsSvcArgs.Arg1 = BaseAddress;
+  GetMemoryPermissionsSvcArgs.Arg2 = 0;
+  GetMemoryPermissionsSvcArgs.Arg3 = 0;
+
+  ArmCallSvc (&GetMemoryPermissionsSvcArgs);
+  if (GetMemoryPermissionsSvcArgs.Arg0 == ARM_SVC_SPM_RET_INVALID_PARAMS) {
+*MemoryAttributes = 0;
+return EFI_INVALID_PARAMETER;
+  }
+
+  *MemoryAttributes = GetMemoryPermissionsSvcArgs.Arg0;
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+RequestMemoryPermissionChange (
+  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN  UINT64Length,
+  IN  UINTN Permissions
+  )
+{
+  EFI_STATUSStatus;
+  ARM_SVC_ARGS  ChangeMemoryPermissionsSvcArgs = {0};
+
+  ChangeMemoryPermissionsSvcArgs.Arg0 = 
ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64;
+  ChangeMemoryPermissionsSvcArgs.Arg1 = BaseAddress;
+  ChangeMemoryPermissionsSvcArgs.Arg2 = EFI_SIZE_TO_PAGES(Length);
+  ChangeMemoryPermissionsSvcArgs.Arg3 = Permissions;
+
+  ArmCallSvc (&ChangeMemoryPermissionsSvcArgs);
+
+  Status = ChangeMemoryPermissionsSvcArgs.Arg0;
+
+  switch (Status) {
+  case ARM_SVC_SPM_RET_SUCCESS:
+Status = EFI_SUCCESS;
+break;
+
+  case ARM_SVC_SPM_RET_NOT_SUPPORTED:
+Status = EFI_UNSUPPORTED;
+break;
+
+  case ARM_SVC_SPM_RET_INVALID_PARAMS:
+Status = EFI_INVALID_PARAMETER;
+break;
+
+  case ARM_SVC_SPM_RET_DENIED:
+Status = EFI_ACCESS_DENIED;
+break;
+
+  case ARM_SVC_SPM_RET_NO_MEMORY:
+Status = EFI_BAD_BUFFER_SIZE;
+break;
+
+  default:
+Status = EFI_ACCESS_DENIED;
+ASSERT (0);
+  }
+
+  return Status;
+}
+
+EFI_STATUS
+ArmSetMemoryRegionNoExec (
+  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN  UINT64Length
+  )
+{
+  EFI_STATUSStatus;
+  UINT32 MemoryAttributes;
+  UINT32 CodePermission;
+
+  Status = GetMemoryPermissions (BaseAddress, &MemoryAttributes);
+  if (Status != EFI_INVALID_PARAMETER) {
+CodePermission = SET_MEM_ATTR_CODE_PERM_XN << SET_MEM_ATTR_CODE_PERM_SHIFT;
+return RequestMemoryPermissionChange (
+ BaseAddress,
+ Length,
+ MemoryAttributes | CodePermission
+ );
+  }
+  return EFI_INVALID_PARAMETER;
+}
+
+EFI_STATUS
+ArmClearMemoryRegionNoExec (
+  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN  UINT64Length
+  )
+{
+  EFI_STATUSStatus;
+  UINT32 MemoryAttributes;
+  UINT32 CodePermission;
+
+  Status = GetMemoryPermissions (BaseAddress, &MemoryAttributes);
+  if (Status != EFI_INVALID_PARAMETER) {
+CodePermission = SET_MEM_ATTR_CODE_PERM_XN << SET

[edk2] [PATCH v3 6/6] ArmPkg/ArmMmuLib: Add MMU library inf file suitable for use in S-EL0.

2018-10-25 Thread Sughosh Ganu
From: Achin Gupta 

This patch adds the definitions, sources, packages and library classes
needed to compile and link MMU Library suitable for use in S-EL0.

Currently, this is used only during the Standalone MM Core
initialization and hence defined as MM_CORE_STANDALONE Module.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/Library/ArmMmuLib/{ArmMmuPeiLib.inf => ArmMmuStandaloneMmCoreLib.inf} | 
23 +---
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf 
b/ArmPkg/Library/ArmMmuLib/ArmMmuStandaloneMmCoreLib.inf
similarity index 51%
copy from ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
copy to ArmPkg/Library/ArmMmuLib/ArmMmuStandaloneMmCoreLib.inf
index ecf13f790734..9f5593d3f6c8 100644
--- a/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
+++ b/ArmPkg/Library/ArmMmuLib/ArmMmuStandaloneMmCoreLib.inf
@@ -1,6 +1,6 @@
 #/** @file
 #
-#  Copyright (c) 2016 Linaro Ltd. All rights reserved.
+#  Copyright (c) 2017 - 2018, 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
@@ -13,22 +13,20 @@
 #**/
 
 [Defines]
-  INF_VERSION= 0x00010005
-  BASE_NAME  = ArmMmuPeiLib
-  FILE_GUID  = b50d8d53-1ad1-44ea-9e69-8c89d4a6d08b
-  MODULE_TYPE= PEIM
+  INF_VERSION= 0x0001001A
+  BASE_NAME  = ArmMmuStandaloneMmCoreLib
+  FILE_GUID  = da8f0232-fb14-42f0-922c-63104d2c70bd
+  MODULE_TYPE= MM_CORE_STANDALONE
   VERSION_STRING = 1.0
-  LIBRARY_CLASS  = ArmMmuLib|PEIM
-  CONSTRUCTOR= ArmMmuPeiLibConstructor
+  LIBRARY_CLASS  = ArmMmuStandaloneMmCoreLib|MM_CORE_STANDALONE
+  PI_SPECIFICATION_VERSION   = 0x00010032
+  CONSTRUCTOR= ArmMmuStandaloneMmCoreLibConstructor
 
 [Sources.AARCH64]
-  AArch64/ArmMmuLibCore.c
-  AArch64/ArmMmuPeiLibConstructor.c
-  AArch64/ArmMmuLibReplaceEntry.S
+  AArch64/ArmMmuStandaloneMmCoreLib.c
 
 [Packages]
   ArmPkg/ArmPkg.dec
-  EmbeddedPkg/EmbeddedPkg.dec
   MdePkg/MdePkg.dec
 
 [LibraryClasses]
@@ -36,5 +34,4 @@ [LibraryClasses]
   CacheMaintenanceLib
   MemoryAllocationLib
 
-[Pcd.AARCH64]
-  gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
+
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v3 2/6] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2018-10-25 Thread Sughosh Ganu
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   | 395 

 3 files changed, 479 insertions(+)

diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf 
b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
new file mode 100644
index ..88beafa39c05
--- /dev/null
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
@@ -0,0 +1,56 @@
+#/** @file
+#
+#  DXE MM Communicate driver
+#
+#  Copyright (c) 2016 - 2018, 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.
+#
+#**/
+
+[Defines]
+  INF_VERSION= 0x0001001A
+  BASE_NAME  = ArmMmCommunication
+  FILE_GUID  = 09EE81D3-F15E-43F4-85B4-CB9873DA5D6B
+  MODULE_TYPE= DXE_RUNTIME_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= MmCommunicationInitialize
+
+#
+# The following is for reference only and not required by
+# build tools
+#
+# VALID_ARCHITECTURES= AARCH64
+#
+
+[Sources.AARCH64]
+  MmCommunication.c
+
+[Packages]
+  ArmPkg/ArmPkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  ArmLib
+  ArmSmcLib
+  BaseMemoryLib
+  DebugLib
+  DxeServicesTableLib
+  HobLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gEfiMmCommunicationProtocolGuid  ## PRODUCES
+
+[Pcd.common]
+  gArmTokenSpaceGuid.PcdMmBufferBase
+  gArmTokenSpaceGuid.PcdMmBufferSize
+
+[Depex]
+  gEfiCpuArchProtocolGuid
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h 
b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
new file mode 100644
index ..0bf1c8d4ca0e
--- /dev/null
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
@@ -0,0 +1,28 @@
+/** @file
+
+  Copyright (c) 2016-2018, 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.
+
+**/
+
+#if !defined _MM_COMMUNICATE_H_
+#define _MM_COMMUNICATE_H_
+
+#define MM_MAJOR_VER_MASK0xEFFF
+#define MM_MINOR_VER_MASK0x
+#define MM_MAJOR_VER_SHIFT   16
+
+#define MM_MAJOR_VER(x) (((x) & MM_MAJOR_VER_MASK) >> MM_MAJOR_VER_SHIFT)
+#define MM_MINOR_VER(x) ((x) & MM_MINOR_VER_MASK)
+
+#define MM_CALLER_MAJOR_VER  0x1UL
+#define MM_CALLER_MINOR_VER  0x0
+
+#endif /* _MM_COMMUNICATE_H_ */
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c 
b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
new file mode 100644
index ..487db00c2a87
--- /dev/null
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
@@ -0,0 +1,395 @@
+/** @file
+
+  Copyright (c) 2016-2018, 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 
+
+#include "MmCommunicate.h"
+
+//
+// Address, Length of the pre-allocated buffer for

[edk2] [PATCH v3 4/6] ArmPkg/Include: Add MM interface SVC return codes.

2018-10-25 Thread Sughosh Ganu
From: Achin Gupta 

This patch adds the Management Mode(MM) - Secure Partition
Manager(SPM) SVC return codes.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/Include/IndustryStandard/ArmMmSvc.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h 
b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
index 81b4654fa5dd..a64b9ec23c4b 100644
--- a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
@@ -40,4 +40,11 @@
 c_perm) & SET_MEM_ATTR_CODE_PERM_MASK) << 
SET_MEM_ATTR_CODE_PERM_SHIFT) | \
 (( (d_perm) & SET_MEM_ATTR_DATA_PERM_MASK) << 
SET_MEM_ATTR_DATA_PERM_SHIFT))
 
+/* MM SVC Return error codes */
+#define ARM_SVC_SPM_RET_SUCCESS   0
+#define ARM_SVC_SPM_RET_NOT_SUPPORTED-1
+#define ARM_SVC_SPM_RET_INVALID_PARAMS   -2
+#define ARM_SVC_SPM_RET_DENIED   -3
+#define ARM_SVC_SPM_RET_NO_MEMORY-5
+
 #endif
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v3 1/6] ArmPkg: Add PCDs needed for MM communication driver.

2018-10-25 Thread Sughosh Ganu
From: Achin Gupta 

This patch defines PCDs to describe the base address and size of
communication buffer between normal world (uefi) and standalone MM
environment in the secure world.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/ArmPkg.dec | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
index 84e57a0bf01c..0db7aa9d301c 100644
--- a/ArmPkg/ArmPkg.dec
+++ b/ArmPkg/ArmPkg.dec
@@ -240,6 +240,9 @@ [PcdsFixedAtBuild.common, PcdsDynamic.common, 
PcdsPatchableInModule.common]
   gArmTokenSpaceGuid.PcdSystemMemoryBase|0|UINT64|0x0029
   gArmTokenSpaceGuid.PcdSystemMemorySize|0|UINT64|0x002A
 
+  gArmTokenSpaceGuid.PcdMmBufferBase|0|UINT64|0x0045
+  gArmTokenSpaceGuid.PcdMmBufferSize|0|UINT64|0x0046
+
 [PcdsFixedAtBuild.common, PcdsDynamic.common]
   #
   # ARM Architectural Timer
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v3 3/6] ArmPkg/Include: Fix the SPM version SVC ID

2018-10-25 Thread Sughosh Ganu
The MM_VERSION SMC call uses SMC32 calling convention. Fix the macro
to reflect the correct value.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/Include/IndustryStandard/ArmMmSvc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h 
b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
index 4c7b6c338627..81b4654fa5dd 100644
--- a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
@@ -20,7 +20,7 @@
  * delegated events and request the Secure partition manager to perform
  * privileged operations on its behalf.
  */
-#define ARM_SVC_ID_SPM_VERSION_AARCH64 0xC460
+#define ARM_SVC_ID_SPM_VERSION_AARCH32 0x8460
 #define ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64   0xC461
 #define ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH64   0xC464
 #define ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64   0xC465
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v3 0/6] ArmPkg related changes for StandaloneMM package

2018-10-25 Thread Sughosh Ganu
The following patch series adds support for Management Mode related
changes for aarch64 based platforms.

Changes since v2:
Based on review comments from Ard, moved the memory attribute updation
changes out of DebugPeCoffExtraActionLib into an extra action library
added in StandaloneMM package. The patch for setting the memory
attributes, now under StandaloneMmPkg directory, will be submitted
separately from this series.


Achin Gupta (5):
  ArmPkg: Add PCDs needed for MM communication driver.
  ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.
  ArmPkg/Include: Add MM interface SVC return codes.
  ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.
  ArmPkg/ArmMmuLib: Add MMU library inf file suitable for use in S-EL0.

Sughosh Ganu (1):
  ArmPkg/Include: Fix the SPM version SVC ID

 ArmPkg/ArmPkg.dec| 
  3 +
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf| 
 56 +++
 ArmPkg/Library/ArmMmuLib/{ArmMmuPeiLib.inf => ArmMmuStandaloneMmCoreLib.inf} | 
 23 +-
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h| 
 28 ++
 ArmPkg/Include/IndustryStandard/ArmMmSvc.h   | 
  9 +-
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c  | 
395 
 ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c | 
204 ++
 7 files changed, 704 insertions(+), 14 deletions(-)
 create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
 copy ArmPkg/Library/ArmMmuLib/{ArmMmuPeiLib.inf => 
ArmMmuStandaloneMmCoreLib.inf} (51%)
 create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
 create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
 create mode 100644 ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c

-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 7/7] ArmPkg: Extra action to update permissions for S-ELO MM Image

2018-08-20 Thread Sughosh Ganu
hi Ard,

On Tue July 23, 2018 at 11:03PM +0530, Supreeth Venkatesh wrote:
> 
> On Sat, 2018-07-21 at 20:06 +0900, Ard Biesheuvel wrote:
> > On 20 July 2018 at 21:38, Sughosh Ganu  wrote:
> > >
> > > From: Achin Gupta 
> > >
> > > The Standalone MM drivers runs in S-EL0 in AArch64 on ARM Standard
> > > Platforms and is deployed during SEC phase. The memory allocated to
> > > the Standalone MM drivers should be marked as RO+X.
> > >
> > > During PE/COFF Image section parsing, this patch implements extra
> > > action "UpdatePeCoffPermissions" to request the privileged firmware
> > > in
> > > EL3 to update the permissions.
> > >
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Sughosh Ganu 
> > Apologies for bringing this up only now, but I don't think I was ever
> > cc'ed on these patches.
> >
> Apologies if you have missed it. But I am pretty sure it was part of
> earlier large patch-set on which you and leif were copied, as it was
> part of ArmPkg.
> >
> > We are relying on a debug hook in the PE/COFF loader to ensure that
> > we
> > don't end up with memory that is both writable and executable in the
> > secure world. Do we really think that is a good idea?
> >
> > (I know this code was derived from a proof of concept that I did
> > years
> > ago, but that was just a PoC)
> I think we need a little bit more details on what is your suggestion?
> 
> A little bit background here: This code runs in S-EL0 and Request gets
> sent to secure world SPM to ensure that the region permissions are
> updated correctly via the "ArmMmuStandaloneMmCoreLib" SVC -
> ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64.
> 
> DebugPeCoffExtraActionLib is just used to extract image region
> information, but the region permission
> update request is sent to secure world for validation.
> 
> With the above explanation, can you provide an insight into what was
> your thinking?
> Do you want us to create a separate library and call it
> as PeCoffExtraActionLib to avoid the "Debug" word though it is a hook
> to PeCoffExtraActionLib in MdePkg or do we want to create this library
> in a separate package (may be in MdePkg?) or something totally
> different.

Supreeth had replied to your comments on the patch. Can you please
check this. If you feel that this needs to be implemented differently,
can you please suggest it to us. Thanks.

-sughosh

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 7/7] ArmPkg: Extra action to update permissions for S-ELO MM Image

2018-07-20 Thread Sughosh Ganu
From: Achin Gupta 

The Standalone MM drivers runs in S-EL0 in AArch64 on ARM Standard
Platforms and is deployed during SEC phase. The memory allocated to
the Standalone MM drivers should be marked as RO+X.

During PE/COFF Image section parsing, this patch implements extra
action "UpdatePeCoffPermissions" to request the privileged firmware in
EL3 to update the permissions.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf |   7 +
 ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c   | 171 
+++-
 2 files changed, 176 insertions(+), 2 deletions(-)

diff --git 
a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf 
b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
index c1f717e5bda1..38bf3993ae99 100644
--- a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
+++ b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
@@ -33,7 +33,14 @@ [Sources.common]
   DebugPeCoffExtraActionLib.c
 
 [Packages]
+  ArmPkg/ArmPkg.dec
   MdePkg/MdePkg.dec
+  StandaloneMmPkg/StandaloneMmPkg.dec
+
+[FeaturePcd]
+  gStandaloneMmPkgTokenSpaceGuid.PcdStandaloneMmEnable
 
 [LibraryClasses]
+  ArmMmuLib
   DebugLib
+  PcdLib
diff --git 
a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c 
b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
index f298e58cdfca..8e621de4a87a 100644
--- a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
+++ b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
@@ -15,14 +15,165 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 **/
 
 #include 
-#include 
 
+#include 
 #include 
-#include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 
+typedef RETURN_STATUS (*REGION_PERMISSION_UPDATE_FUNC) (
+  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN  UINT64Length
+  );
+
+STATIC
+RETURN_STATUS
+UpdatePeCoffPermissions (
+  IN  CONST PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,
+  IN  REGION_PERMISSION_UPDATE_FUNC   NoExecUpdater,
+  IN  REGION_PERMISSION_UPDATE_FUNC   ReadOnlyUpdater
+  )
+{
+  RETURN_STATUS Status;
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;
+  EFI_IMAGE_OPTIONAL_HEADER_UNION   HdrData;
+  UINTN Size;
+  UINTN ReadSize;
+  UINT32SectionHeaderOffset;
+  UINTN NumberOfSections;
+  UINTN Index;
+  EFI_IMAGE_SECTION_HEADER  SectionHeader;
+  PE_COFF_LOADER_IMAGE_CONTEXT  TmpContext;
+  EFI_PHYSICAL_ADDRESS  Base;
+
+  //
+  // We need to copy ImageContext since PeCoffLoaderGetImageInfo ()
+  // will mangle the ImageAddress field
+  //
+  CopyMem (&TmpContext, ImageContext, sizeof (TmpContext));
+
+  if (TmpContext.PeCoffHeaderOffset == 0) {
+Status = PeCoffLoaderGetImageInfo (&TmpContext);
+if (RETURN_ERROR (Status)) {
+  DEBUG ((DEBUG_ERROR,
+"%a: PeCoffLoaderGetImageInfo () failed (Status = %r)\n",
+__FUNCTION__, Status));
+  return Status;
+}
+  }
+
+  if (TmpContext.IsTeImage &&
+  TmpContext.ImageAddress == ImageContext->ImageAddress) {
+DEBUG ((DEBUG_INFO, "%a: ignoring XIP TE image at 0x%lx\n", __FUNCTION__,
+  ImageContext->ImageAddress));
+return RETURN_SUCCESS;
+  }
+
+  if (TmpContext.SectionAlignment < EFI_PAGE_SIZE) {
+//
+// The sections need to be at least 4 KB aligned, since that is the
+// granularity at which we can tighten permissions. So just clear the
+// noexec permissions on the entire region.
+//
+if (!TmpContext.IsTeImage) {
+  DEBUG ((DEBUG_WARN,
+"%a: non-TE Image at 0x%lx has SectionAlignment < 4 KB (%lu)\n",
+__FUNCTION__, ImageContext->ImageAddress, 
TmpContext.SectionAlignment));
+}
+Base = ImageContext->ImageAddress & ~(EFI_PAGE_SIZE - 1);
+Size = ImageContext->ImageAddress - Base + ImageContext->ImageSize;
+return NoExecUpdater (Base, ALIGN_VALUE (Size, EFI_PAGE_SIZE));
+  }
+
+  //
+  // Read the PE/COFF Header. For PE32 (32-bit) this will read in too much
+  // data, but that should not hurt anything. Hdr.Pe32->OptionalHeader.Magic
+  // determines if this is a PE32 or PE32+ image. The magic is in the same
+  // location in both images.
+  //
+  Hdr.Union = &HdrData;
+  Size = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION);
+  ReadSize = Size;
+  Status = TmpContext.ImageRead (TmpContext.Handle,
+ TmpContext.PeCoffHeaderOffset, &Size, Hdr.Pe32);
+  if (RETURN_ERROR (Status) || (Size != ReadSize)) {
+DEBUG ((DEBUG_ERROR,
+  &

[edk2] [PATCH v2 3/7] ArmPkg/Include: Fix the SPM version SVC ID

2018-07-20 Thread Sughosh Ganu
The MM_VERSION SMC call uses SMC32 calling convention. Fix the macro
to reflect the correct value.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/Include/IndustryStandard/ArmMmSvc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h 
b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
index 4c7b6c338627..81b4654fa5dd 100644
--- a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
@@ -20,7 +20,7 @@
  * delegated events and request the Secure partition manager to perform
  * privileged operations on its behalf.
  */
-#define ARM_SVC_ID_SPM_VERSION_AARCH64 0xC460
+#define ARM_SVC_ID_SPM_VERSION_AARCH32 0x8460
 #define ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64   0xC461
 #define ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH64   0xC464
 #define ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64   0xC465
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 4/7] ArmPkg/Include: Add MM interface SVC return codes.

2018-07-20 Thread Sughosh Ganu
From: Achin Gupta 

This patch adds the Management Mode(MM) - Secure Partition
Manager(SPM) SVC return codes.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Supreeth Venkatesh 
---
 ArmPkg/Include/IndustryStandard/ArmMmSvc.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h 
b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
index 81b4654fa5dd..a64b9ec23c4b 100644
--- a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
@@ -40,4 +40,11 @@
 c_perm) & SET_MEM_ATTR_CODE_PERM_MASK) << 
SET_MEM_ATTR_CODE_PERM_SHIFT) | \
 (( (d_perm) & SET_MEM_ATTR_DATA_PERM_MASK) << 
SET_MEM_ATTR_DATA_PERM_SHIFT))
 
+/* MM SVC Return error codes */
+#define ARM_SVC_SPM_RET_SUCCESS   0
+#define ARM_SVC_SPM_RET_NOT_SUPPORTED-1
+#define ARM_SVC_SPM_RET_INVALID_PARAMS   -2
+#define ARM_SVC_SPM_RET_DENIED   -3
+#define ARM_SVC_SPM_RET_NO_MEMORY-5
+
 #endif
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 1/7] ArmPkg: Add PCDs needed for MM communication driver.

2018-07-20 Thread Sughosh Ganu
From: Achin Gupta 

This patch defines PCDs to describe the base address and size of
communication buffer between normal world (uefi) and standalone MM
environment in the secure world.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Supreeth Venkatesh 
---
 ArmPkg/ArmPkg.dec | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
index 3aa229fe2ec9..ce108f2258f4 100644
--- a/ArmPkg/ArmPkg.dec
+++ b/ArmPkg/ArmPkg.dec
@@ -239,6 +239,9 @@ [PcdsFixedAtBuild.common, PcdsDynamic.common, 
PcdsPatchableInModule.common]
   gArmTokenSpaceGuid.PcdSystemMemoryBase|0|UINT64|0x0029
   gArmTokenSpaceGuid.PcdSystemMemorySize|0|UINT64|0x002A
 
+  gArmTokenSpaceGuid.PcdMmBufferBase|0|UINT64|0x0045
+  gArmTokenSpaceGuid.PcdMmBufferSize|0|UINT64|0x0046
+
 [PcdsFixedAtBuild.common, PcdsDynamic.common]
   #
   # ARM Architectural Timer
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 0/7] ArmPkg related changes for StandaloneMM package

2018-07-20 Thread Sughosh Ganu
The following patch series adds support for Management Mode related
changes for aarch64 based platforms.

Changes since v1: Handled review comments from Leif

Achin Gupta (6):
  ArmPkg: Add PCDs needed for MM communication driver.
  ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.
  ArmPkg/Include: Add MM interface SVC return codes.
  ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.
  ArmPkg/ArmMmuLib: Add MMU library inf file suitable for use in S-EL0.
  ArmPkg: Extra action to update permissions for S-ELO MM Image

Sughosh Ganu (1):
  ArmPkg/Include: Fix the SPM version SVC ID

 ArmPkg/ArmPkg.dec  |   3 +
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf  |  56 
+++
 ArmPkg/Library/ArmMmuLib/ArmMmuStandaloneMmCoreLib.inf |  37 ++
 ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf |   7 +
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h  |  28 ++
 ArmPkg/Include/IndustryStandard/ArmMmSvc.h |   9 +-
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c| 395 

 ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c   | 204 
++
 ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c   | 171 
-
 9 files changed, 907 insertions(+), 3 deletions(-)
 create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
 create mode 100644 ArmPkg/Library/ArmMmuLib/ArmMmuStandaloneMmCoreLib.inf
 create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
 create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
 create mode 100644 ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c

-- 
2.7.4
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 5/7] ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.

2018-07-20 Thread Sughosh Ganu
From: Achin Gupta 

The Standalone MM environment runs in S-EL0 in AArch64 on ARM Standard
Platforms. Privileged firmware e.g. ARM Trusted Firmware sets up its
architectural context including the initial translation tables for the
S-EL1/EL0 translation regime. The MM environment will still request ARM
TF to change the memory attributes of memory regions during
initialization.

The Standalone MM image is a FV that encapsulates the MM foundation
and drivers. These are PE-COFF images with data and text segments.
To initialise the MM environment, Arm Trusted Firmware has to create
translation tables with sane default attributes for the memory
occupied by the FV. This library sends SVCs to ARM Trusted Firmware
to request memory permissions change for data and text segments.

This patch adds a simple MMU library suitable for execution in S-EL0 and
requesting memory permissions change operations from Arm Trusted Firmware.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
Signed-off-by: Supreeth Venkatesh 
---
 ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c | 204 

 1 file changed, 204 insertions(+)

diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c 
b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c
new file mode 100644
index ..ee0a80349051
--- /dev/null
+++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c
@@ -0,0 +1,204 @@
+/** @file
+*  File managing the MMU for ARMv8 architecture in S-EL0
+*
+*  Copyright (c) 2017 - 2018, 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 
+
+EFI_STATUS
+GetMemoryPermissions (
+  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
+  OUT UINT32*MemoryAttributes
+  )
+{
+  ARM_SVC_ARGS  GetMemoryPermissionsSvcArgs = {0};
+
+  GetMemoryPermissionsSvcArgs.Arg0 = ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH64;
+  GetMemoryPermissionsSvcArgs.Arg1 = BaseAddress;
+  GetMemoryPermissionsSvcArgs.Arg2 = 0;
+  GetMemoryPermissionsSvcArgs.Arg3 = 0;
+
+  ArmCallSvc (&GetMemoryPermissionsSvcArgs);
+  if (GetMemoryPermissionsSvcArgs.Arg0 == ARM_SVC_SPM_RET_INVALID_PARAMS) {
+*MemoryAttributes = 0;
+return EFI_INVALID_PARAMETER;
+  }
+
+  *MemoryAttributes = GetMemoryPermissionsSvcArgs.Arg0;
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+RequestMemoryPermissionChange (
+  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN  UINT64Length,
+  IN  UINTN Permissions
+  )
+{
+  EFI_STATUSStatus;
+  ARM_SVC_ARGS  ChangeMemoryPermissionsSvcArgs = {0};
+
+  ChangeMemoryPermissionsSvcArgs.Arg0 = 
ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64;
+  ChangeMemoryPermissionsSvcArgs.Arg1 = BaseAddress;
+  ChangeMemoryPermissionsSvcArgs.Arg2 = EFI_SIZE_TO_PAGES(Length);
+  ChangeMemoryPermissionsSvcArgs.Arg3 = Permissions;
+
+  ArmCallSvc (&ChangeMemoryPermissionsSvcArgs);
+
+  Status = ChangeMemoryPermissionsSvcArgs.Arg0;
+
+  switch (Status) {
+  case ARM_SVC_SPM_RET_SUCCESS:
+Status = EFI_SUCCESS;
+break;
+
+  case ARM_SVC_SPM_RET_NOT_SUPPORTED:
+Status = EFI_UNSUPPORTED;
+break;
+
+  case ARM_SVC_SPM_RET_INVALID_PARAMS:
+Status = EFI_INVALID_PARAMETER;
+break;
+
+  case ARM_SVC_SPM_RET_DENIED:
+Status = EFI_ACCESS_DENIED;
+break;
+
+  case ARM_SVC_SPM_RET_NO_MEMORY:
+Status = EFI_BAD_BUFFER_SIZE;
+break;
+
+  default:
+Status = EFI_ACCESS_DENIED;
+ASSERT (0);
+  }
+
+  return Status;
+}
+
+EFI_STATUS
+ArmSetMemoryRegionNoExec (
+  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN  UINT64Length
+  )
+{
+  EFI_STATUSStatus;
+  UINT32 MemoryAttributes;
+  UINT32 CodePermission;
+
+  Status = GetMemoryPermissions (BaseAddress, &MemoryAttributes);
+  if (Status != EFI_INVALID_PARAMETER) {
+CodePermission = SET_MEM_ATTR_CODE_PERM_XN << SET_MEM_ATTR_CODE_PERM_SHIFT;
+return RequestMemoryPermissionChange (
+ BaseAddress,
+ Length,
+ MemoryAttributes | CodePermission
+ );
+  }
+  return EFI_INVALID_PARAMETER;
+}
+
+EFI_STATUS
+ArmClearMemoryRegionNoExec (
+  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN  UINT64Length
+  )
+{
+  EFI_STATUSStatus;
+  UINT32 MemoryAttributes;
+  UINT32 CodePermission;
+
+  Status = GetMemoryPermissions (BaseAddress, &MemoryAttributes);
+  if (Status != EFI_INVALID_PARAMETER) {
+CodePermis

[edk2] [PATCH v2 6/7] ArmPkg/ArmMmuLib: Add MMU library inf file suitable for use in S-EL0.

2018-07-20 Thread Sughosh Ganu
From: Achin Gupta 

This patch adds the definitions, sources, packages and library classes
needed to compile and link MMU Library suitable for use in S-EL0.

Currently, this is used only during the Standalone MM Core
initialization and hence defined as MM_CORE_STANDALONE Module.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Supreeth Venkatesh 
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/Library/ArmMmuLib/ArmMmuStandaloneMmCoreLib.inf | 37 

 1 file changed, 37 insertions(+)

diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuStandaloneMmCoreLib.inf 
b/ArmPkg/Library/ArmMmuLib/ArmMmuStandaloneMmCoreLib.inf
new file mode 100644
index ..9f5593d3f6c8
--- /dev/null
+++ b/ArmPkg/Library/ArmMmuLib/ArmMmuStandaloneMmCoreLib.inf
@@ -0,0 +1,37 @@
+#/** @file
+#
+#  Copyright (c) 2017 - 2018, 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.
+#
+#
+#**/
+
+[Defines]
+  INF_VERSION= 0x0001001A
+  BASE_NAME  = ArmMmuStandaloneMmCoreLib
+  FILE_GUID  = da8f0232-fb14-42f0-922c-63104d2c70bd
+  MODULE_TYPE= MM_CORE_STANDALONE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = ArmMmuStandaloneMmCoreLib|MM_CORE_STANDALONE
+  PI_SPECIFICATION_VERSION   = 0x00010032
+  CONSTRUCTOR= ArmMmuStandaloneMmCoreLibConstructor
+
+[Sources.AARCH64]
+  AArch64/ArmMmuStandaloneMmCoreLib.c
+
+[Packages]
+  ArmPkg/ArmPkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  ArmLib
+  CacheMaintenanceLib
+  MemoryAllocationLib
+
+
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


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

2018-07-20 Thread Sughosh Ganu
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: Supreeth Venkatesh 
Signed-off-by: Sughosh Ganu 
---
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf |  56 +++
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h |  28 ++
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c   | 395 

 3 files changed, 479 insertions(+)

diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf 
b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
new file mode 100644
index ..88beafa39c05
--- /dev/null
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
@@ -0,0 +1,56 @@
+#/** @file
+#
+#  DXE MM Communicate driver
+#
+#  Copyright (c) 2016 - 2018, 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.
+#
+#**/
+
+[Defines]
+  INF_VERSION= 0x0001001A
+  BASE_NAME  = ArmMmCommunication
+  FILE_GUID  = 09EE81D3-F15E-43F4-85B4-CB9873DA5D6B
+  MODULE_TYPE= DXE_RUNTIME_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= MmCommunicationInitialize
+
+#
+# The following is for reference only and not required by
+# build tools
+#
+# VALID_ARCHITECTURES= AARCH64
+#
+
+[Sources.AARCH64]
+  MmCommunication.c
+
+[Packages]
+  ArmPkg/ArmPkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  ArmLib
+  ArmSmcLib
+  BaseMemoryLib
+  DebugLib
+  DxeServicesTableLib
+  HobLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gEfiMmCommunicationProtocolGuid  ## PRODUCES
+
+[Pcd.common]
+  gArmTokenSpaceGuid.PcdMmBufferBase
+  gArmTokenSpaceGuid.PcdMmBufferSize
+
+[Depex]
+  gEfiCpuArchProtocolGuid
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h 
b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
new file mode 100644
index ..a9758914aa0c
--- /dev/null
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
@@ -0,0 +1,28 @@
+/** @file
+
+  Copyright (c) 2016-2018, 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.
+
+**/
+
+#if !defined _MM_COMMUNICATE_H_
+#define _MM_COMMUNICATE_H_
+
+#define MM_MAJOR_VER_MASK0xEFFF
+#define MM_MINOR_VER_MASK0x
+#define MM_MAJOR_VER_SHIFT   16
+
+#define MM_MAJOR_VER(x) (((x) & MM_MAJOR_VER_MASK) >> MM_MAJOR_VER_SHIFT)
+#define MM_MINOR_VER(x) ((x) & MM_MINOR_VER_MASK)
+
+#define MM_CALLER_MAJOR_VER0x1UL
+#define MM_CALLER_MINOR_VER0x0
+
+#endif /* _MM_COMMUNICATE_H_ */
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c 
b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
new file mode 100644
index ..487db00c2a87
--- /dev/null
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
@@ -0,0 +1,395 @@
+/** @file
+
+  Copyright (c) 2016-2018, 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 
+
+#include "MmCommunicate.h"
+
+//
+// Address, Length 

[edk2] [PATCH v2 09/10] StandaloneMmPkg: Add CPU driver suitable for ARM Platforms.

2018-07-13 Thread Sughosh Ganu
From: Supreeth Venkatesh 

This patch adds a simple CPU driver that exports the
EFI_MM_CONFIGURATION_PROTOCOL to allow registration of the Standalone
MM Foundation entry point. It preserves the existing notification
mechanism for the configuration protocol.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
Signed-off-by: Achin Gupta 
Signed-off-by: Supreeth Venkatesh 
---
 .../Drivers/StandaloneMmCpu/AArch64/EventHandle.c  | 220 +++
 .../StandaloneMmCpu/AArch64/StandaloneMmCpu.c  | 232 +
 .../StandaloneMmCpu/AArch64/StandaloneMmCpu.h  |  64 ++
 .../StandaloneMmCpu/AArch64/StandaloneMmCpu.inf|  59 ++
 StandaloneMmPkg/Include/Guid/MpInformation.h   |  41 
 5 files changed, 616 insertions(+)
 create mode 100644 
StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c
 create mode 100644 
StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c
 create mode 100644 
StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h
 create mode 100644 
StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.inf
 create mode 100644 StandaloneMmPkg/Include/Guid/MpInformation.h

diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c 
b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c
new file mode 100644
index ..2814577b3fcc
--- /dev/null
+++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c
@@ -0,0 +1,220 @@
+/** @file
+
+  Copyright (c) 2016 HP Development Company, L.P.
+  Copyright (c) 2016 - 2018, 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  // for EFI_SYSTEM_CONTEXT
+
+#include 
+#include 
+
+#include 
+
+#include "StandaloneMmCpu.h"
+
+EFI_STATUS
+EFIAPI
+MmFoundationEntryRegister (
+  IN CONST EFI_MM_CONFIGURATION_PROTOCOL  *This,
+  IN EFI_MM_ENTRY_POINTMmEntryPoint
+  );
+
+//
+// On ARM platforms every event is expected to have a GUID associated with
+// it. It will be used by the MM Entry point to find the handler for the
+// event. It will either be populated in a EFI_MM_COMMUNICATE_HEADER by the
+// caller of the event (e.g. MM_COMMUNICATE SMC) or by the CPU driver
+// (e.g. during an asynchronous event). In either case, this context is
+// maintained in an array which has an entry for each CPU. The pointer to this
+// array is held in PerCpuGuidedEventContext. Memory is allocated once the
+// number of CPUs in the system are made known through the
+// MP_INFORMATION_HOB_DATA.
+//
+EFI_MM_COMMUNICATE_HEADER **PerCpuGuidedEventContext = NULL;
+
+// Descriptor with whereabouts of memory used for communication with the 
normal world
+EFI_MMRAM_DESCRIPTOR  mNsCommBuffer;
+
+MP_INFORMATION_HOB_DATA *mMpInformationHobData;
+
+EFI_MM_CONFIGURATION_PROTOCOL mMmConfig = {
+  0,
+  MmFoundationEntryRegister
+};
+
+STATIC EFI_MM_ENTRY_POINT mMmEntryPoint = NULL;
+
+EFI_STATUS
+PiMmStandloneArmTfCpuDriverEntry (
+  IN UINTN EventId,
+  IN UINTN CpuNumber,
+  IN UINTN NsCommBufferAddr
+  )
+{
+  EFI_MM_COMMUNICATE_HEADER *GuidedEventContext = NULL;
+  EFI_MM_ENTRY_CONTEXTMmEntryPointContext = {0};
+  EFI_STATUS  Status;
+  UINTN   NsCommBufferSize;
+
+  DEBUG ((DEBUG_INFO, "Received event - 0x%x on cpu %d\n", EventId, 
CpuNumber));
+
+  Status = EFI_SUCCESS;
+  //
+  // ARM TF passes SMC FID of the MM_COMMUNICATE interface as the Event ID upon
+  // receipt of a synchronous MM request. Use the Event ID to distinguish
+  // between synchronous and asynchronous events.
+  //
+  if (ARM_SMC_ID_MM_COMMUNICATE_AARCH64 != EventId) {
+DEBUG ((DEBUG_INFO, "UnRecognized Event - 0x%x\n", EventId));
+return EFI_INVALID_PARAMETER;
+  }
+
+  // Perform parameter validation of NsCommBufferAddr
+  if (NsCommBufferAddr && (NsCommBufferAddr < mNsCommBuffer.PhysicalStart))
+return EFI_ACCESS_DENIED;
+
+  if ((NsCommBufferAddr + sizeof (EFI_MM_COMMUNICATE_HEADER)) >=
+  (mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize))
+return EFI_INVALID_PARAMETER;
+
+  // Find out the size of the buffer passed
+  NsCommBufferSize = ((EFI_MM_COMMUNICATE_HEADER *) 
NsCommBufferAddr)->MessageLength +
+sizeof (EFI_MM_COMMUNICATE_HEADER);
+
+  // perform bounds check.
+  if (NsCommBufferAddr + NsCommBufferSize >=
+  mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize)
+return EFI_ACCESS_DE

[edk2] [PATCH v2 10/10] StandaloneMmPkg: Describe the declaration and definition files.

2018-07-13 Thread Sughosh Ganu
From: Supreeth Venkatesh 

This patch describes the package declarations and definitions
for creating standalone management mode image with
core/foundation and drivers.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Supreeth Venkatesh 
Reviewed-by: Achin Gupta 
Reviewed-by: Jiewen Yao 
Signed-off-by: Sughosh Ganu 
---
 StandaloneMmPkg/StandaloneMmPkg.dec |  47 +
 StandaloneMmPkg/StandaloneMmPkg.dsc | 130 
 2 files changed, 177 insertions(+)
 create mode 100644 StandaloneMmPkg/StandaloneMmPkg.dec
 create mode 100644 StandaloneMmPkg/StandaloneMmPkg.dsc

diff --git a/StandaloneMmPkg/StandaloneMmPkg.dec 
b/StandaloneMmPkg/StandaloneMmPkg.dec
new file mode 100644
index ..34108376233d
--- /dev/null
+++ b/StandaloneMmPkg/StandaloneMmPkg.dec
@@ -0,0 +1,47 @@
+## @file
+# This package is a platform package that provide platform module/library
+# required by Standalone MM platform.
+#
+# Copyright (c) 2016-2018, ARM Ltd. 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.
+#
+#
+
+[Defines]
+  DEC_SPECIFICATION  = 0x0001001A
+  PACKAGE_NAME   = StandaloneMmPkg
+  PACKAGE_GUID   = 2AE82968-7769-4A85-A5BC-A0954CE54A5C
+  PACKAGE_VERSION= 1.0
+
+[Includes]
+  Include
+
+[LibraryClasses]
+
+[Guids]
+  gStandaloneMmPkgTokenSpaceGuid   = { 0x18fe7632, 0xf5c8, 0x4e63, { 
0x8d, 0xe8, 0x17, 0xa5, 0x5c, 0x59, 0x13, 0xbd }}
+  gMpInformationHobGuid= { 0xba33f15d, 0x4000, 0x45c1, { 
0x8e, 0x88, 0xf9, 0x16, 0x92, 0xd4, 0x57, 0xe3 }}
+  gMmFvDispatchGuid= { 0xb65694cc, 0x09e3, 0x4c3b, { 
0xb5, 0xcd, 0x05, 0xf4, 0x4d, 0x3c, 0xdb, 0xff }}
+
+  ## Include/Guid/MmCoreData.h
+  gMmCoreDataHobGuid   = { 0xa160bf99, 0x2aa4, 0x4d7d, { 
0x99, 0x93, 0x89, 0x9c, 0xb1, 0x2d, 0xf3, 0x76 }}
+
+  ## Include/Guid/MmramMemoryReserve.h
+  gEfiMmPeiMmramMemoryReserveGuid  = { 0x0703f912, 0xbf8d, 0x4e2a, { 
0xbe, 0x07, 0xab, 0x27, 0x25, 0x25, 0xc5, 0x92 }}
+
+  gEfiStandaloneMmNonSecureBufferGuid  = { 0xf00497e3, 0xbfa2, 0x41a1, { 
0x9d, 0x29, 0x54, 0xc2, 0xe9, 0x37, 0x21, 0xc5 }}
+  gEfiArmTfCpuDriverEpDescriptorGuid   = { 0x6ecbd5a1, 0xc0f8, 0x4702, { 
0x83, 0x01, 0x4f, 0xc2, 0xc5, 0x47, 0x0a, 0x51 }}
+
+[PcdsFeatureFlag]
+  gStandaloneMmPkgTokenSpaceGuid.PcdStandaloneMmEnable|FALSE|BOOLEAN|0x0001
+
+[Protocols]
+  gEfiMmConfigurationProtocolGuid  = { 0xc109319, 0xc149, 0x450e,  { 
0xa3, 0xe3, 0xb9, 0xba, 0xdd, 0x9d, 0xc3, 0xa4 }}
+
diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc 
b/StandaloneMmPkg/StandaloneMmPkg.dsc
new file mode 100644
index ..c6ddb35b8993
--- /dev/null
+++ b/StandaloneMmPkg/StandaloneMmPkg.dsc
@@ -0,0 +1,130 @@
+## @file
+# Standalone MM Platform.
+#
+# Copyright (c) 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 2018, 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.
+#
+##
+
+
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+
+[Defines]
+  PLATFORM_NAME  = StandaloneMm
+  PLATFORM_GUID  = 9A4BBA60-B4F9-47C7-9258-3BD77CAE9322
+  PLATFORM_VERSION   = 1.0
+  DSC_SPECIFICATION  = 0x00010011
+  OUTPUT_DIRECTORY   = Build/StandaloneMm
+  SUPPORTED_ARCHITECTURES= IA32|X64|AARCH64
+  BUILD_TARGETS  = DEBUG|RELEASE
+  SKUID_IDENTIFIER   = DEFAULT
+
+  # LzmaF86
+  DEFINE COMPRESSION_TOOL_GUID   = D42AE6BD-1352-4bfb-909A-CA72A6EAE889
+
+
+#
+# Library Class section - list of all Library Classes needed by this Platform.
+#
+
+[LibraryClasses]
+  #
+  # Basic
+  #
+  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.in

[edk2] [PATCH v2 08/10] StandaloneMmPkg: Add an AArch64 specific entry point library.

2018-07-13 Thread Sughosh Ganu
From: Supreeth Venkatesh 

The Standalone MM environment runs in S-EL0 in AArch64 on ARM Standard
Platforms and is initialised during the SEC phase. ARM Trusted firmware
in EL3 is responsible for initialising the architectural context for
S-EL0 and loading the Standalone MM image. The memory allocated to this
image is marked as RO+X. Heap memory is marked as RW+XN.

Certain actions have to be completed prior to executing the generic code
in the Standalone MM Core module. These are:

1. Memory permission attributes for each section of the Standalone MM
   Core module need to be changed prior to accessing any RW data.

2. A Hob list has to be created with information that allows the MM
   environment to initialise and dispatch drivers.

Furthermore, this module is responsible for handing over runtime MM
events to the Standalone MM CPU driver and returning control to ARM
Trusted Firmware upon event completion. Hence it needs to know the CPU
driver entry point.

This patch implements an entry point module that ARM Trusted Firmware
jumps to in S-EL0. It then performs the above actions before calling the
Standalone MM Foundation entry point and handling subsequent MM events.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sughosh Ganu 
Signed-off-by: Achin Gupta 
Signed-off-by: Supreeth Venkatesh 
---
 .../Library/AArch64/StandaloneMmCoreEntryPoint.h   | 215 +++
 .../AArch64/CreateHobList.c| 209 ++
 .../AArch64/SetPermissions.c   | 289 +++
 .../AArch64/StandaloneMmCoreEntryPoint.c   | 306 +
 .../StandaloneMmCoreEntryPoint.inf |  55 
 5 files changed, 1074 insertions(+)
 create mode 100644 
StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h
 create mode 100644 
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/CreateHobList.c
 create mode 100644 
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/SetPermissions.c
 create mode 100644 
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c
 create mode 100644 
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf

diff --git 
a/StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h 
b/StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h
new file mode 100644
index ..e4e5875b5d22
--- /dev/null
+++ b/StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h
@@ -0,0 +1,215 @@
+/** @file
+  Entry point to the Standalone MM Foundation when initialized during the SEC
+  phase on ARM platforms
+
+Copyright (c) 2017 - 2018, ARM Ltd. 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 __STANDALONEMMCORE_ENTRY_POINT_H__
+#define __STANDALONEMMCORE_ENTRY_POINT_H__
+
+#include 
+#include 
+
+#define CPU_INFO_FLAG_PRIMARY_CPU  0x0001
+
+typedef struct {
+  UINT8  Type;   /* type of the structure */
+  UINT8  Version;/* version of this structure */
+  UINT16 Size;  /* size of this structure in bytes */
+  UINT32 Attr;  /* attributes: unused bits SBZ */
+} EFI_PARAM_HEADER;
+
+typedef struct {
+  UINT64 Mpidr;
+  UINT32 LinearId;
+  UINT32 Flags;
+} EFI_SECURE_PARTITION_CPU_INFO;
+
+typedef struct {
+  EFI_PARAM_HEADER  Header;
+  UINT64SpMemBase;
+  UINT64SpMemLimit;
+  UINT64SpImageBase;
+  UINT64SpStackBase;
+  UINT64SpHeapBase;
+  UINT64SpNsCommBufBase;
+  UINT64SpSharedBufBase;
+  UINT64SpImageSize;
+  UINT64SpPcpuStackSize;
+  UINT64SpHeapSize;
+  UINT64SpNsCommBufSize;
+  UINT64SpPcpuSharedBufSize;
+  UINT32NumSpMemRegions;
+  UINT32NumCpus;
+  EFI_SECURE_PARTITION_CPU_INFO *CpuInfo;
+} EFI_SECURE_PARTITION_BOOT_INFO;
+
+typedef
+EFI_STATUS
+(*PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT) (
+  IN UINTN EventId,
+  IN UINTN CpuNumber,
+  IN UINTN NsCommBufferAddr
+  );
+
+typedef struct {
+  PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *ArmTfCpuDriverEpPtr;
+} ARM_TF_CPU_DRIVER_EP_DESCRIPTOR;
+
+typedef RETURN_STATUS (*REGION_PERMISSION_UPDATE_FUNC) (
+  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN  UINT64Length
+  );
+
+/**
+  Privileged firmware assigns RO & Executable attributes to all memory occu

[edk2] [PATCH v2 06/10] StandaloneMmPkg: MM driver entry point library.

2018-07-13 Thread Sughosh Ganu
From: Supreeth Venkatesh 

This patch implements module entry point library for Standalone
management mode (MM) Drivers.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Supreeth Venkatesh 
Reviewed-by: Achin Gupta 
Reviewed-by: Jiewen Yao 
Signed-off-by: Sughosh Ganu 
---
 .../Include/Library/StandaloneMmDriverEntryPoint.h | 148 +
 .../StandaloneMmDriverEntryPoint.c |  99 ++
 .../StandaloneMmDriverEntryPoint.inf   |  24 ++--
 3 files changed, 259 insertions(+), 12 deletions(-)
 create mode 100644 
StandaloneMmPkg/Include/Library/StandaloneMmDriverEntryPoint.h
 create mode 100644 
StandaloneMmPkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c
 copy MdePkg/Library/BasePciSegmentInfoLibNull/BasePciSegmentInfoLibNull.inf => 
StandaloneMmPkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
 (53%)

diff --git a/StandaloneMmPkg/Include/Library/StandaloneMmDriverEntryPoint.h 
b/StandaloneMmPkg/Include/Library/StandaloneMmDriverEntryPoint.h
new file mode 100644
index ..4c93c16ef544
--- /dev/null
+++ b/StandaloneMmPkg/Include/Library/StandaloneMmDriverEntryPoint.h
@@ -0,0 +1,148 @@
+/** @file
+  Module entry point library for Standalone MM Drivers.
+
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+Copyright (c) 2016 - 2018, 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 __MODULE_ENTRY_POINT_H__
+#define __MODULE_ENTRY_POINT_H__
+
+///
+///Declare the PI Specification Revision that this driver requires to execute 
correctly.
+///
+extern CONST UINT32   _gMmRevision;
+
+/**
+  The entry point of PE/COFF Image for a Standalone MM Driver.
+
+  This function is the entry point for a Standalone MM Driver.
+  This function must call ProcessLibraryConstructorList() and
+  ProcessModuleEntryPointList().
+  If the return status from ProcessModuleEntryPointList()
+  is an error status, then ProcessLibraryDestructorList() must be called.
+  The return value from ProcessModuleEntryPointList() is returned.
+  If _gDriverUnloadImageCount is greater
+  than zero, then an unload handler must be registered for this image and
+  the unload handler must invoke ProcessModuleUnloadList().
+  If _gUefiDriverRevision is not zero and SystemTable->Hdr.Revision is
+  less than _gUefiDriverRevison, then return EFI_INCOMPATIBLE_VERSION.
+
+  @param  ImageHandle  The image handle of the Standalone MM Driver.
+  @param  SystemTable  A pointer to the EFI System Table.
+
+  @retval  EFI_SUCCESS   The Standalone MM Driver exited normally.
+  @retval  EFI_INCOMPATIBLE_VERSION  _gUefiDriverRevision is greater than
+ SystemTable->Hdr.Revision.
+  @retval  Other Return value from
+ ProcessModuleEntryPointList().
+
+**/
+EFI_STATUS
+EFIAPI
+_ModuleEntryPoint (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE*MmSystemTable
+  );
+
+
+/**
+  Required by the EBC compiler and identical in functionality to 
_ModuleEntryPoint().
+
+  This function is required to call _ModuleEntryPoint() passing in 
ImageHandle, and SystemTable.
+
+  @param  ImageHandle  The image handle of the Standalone MM Driver.
+  @param  SystemTable  A pointer to the EFI System Table.
+
+  @retval  EFI_SUCCESS   The Standalone MM Driver exited normally.
+  @retval  EFI_INCOMPATIBLE_VERSION  _gUefiDriverRevision is greater than
+ SystemTable->Hdr.Revision.
+  @retval  Other Return value from 
ProcessModuleEntryPointList().
+**/
+EFI_STATUS
+EFIAPI
+EfiMain (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE*MmSystemTable
+  );
+
+/**
+  Auto generated function that calls the library constructors for all of the 
module's
+  dependent libraries.
+
+  This function must be called by _ModuleEntryPoint().
+  This function calls the set of library constructors for the set of library 
instances
+  that a module depends on.  This includes library instances that a module 
depends on
+  directly and library instances that a module depends on indirectly through 
other libraries.
+  This function is auto generated by build tools and those build tools are 
responsible
+  for collecting the set of library instances, determine which ones have 
constructors,
+  and calling the library constructors in the proper order based upon each of 
the library
+  instances own dependencie

[edk2] [PATCH v2 04/10] StandaloneMmPkg/MemoryAllocationLib: Add MM memory allocation library.

2018-07-13 Thread Sughosh Ganu
From: Supreeth Venkatesh 

This patch implements management mode memory allocation services.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Supreeth Venkatesh 
Reviewed-by: Achin Gupta 
Reviewed-by: Jiewen Yao 
Signed-off-by: Sughosh Ganu 
---
 StandaloneMmPkg/Include/Guid/MmCoreData.h  | 133 ++
 StandaloneMmPkg/Include/Guid/MmramMemoryReserve.h  |  62 +
 .../StandaloneMmCoreMemoryAllocationLib.c  | 155 -
 .../StandaloneMmCoreMemoryAllocationLib.inf|  49 +++
 .../StandaloneMmCoreMemoryAllocationServices.h |  38 +
 5 files changed, 403 insertions(+), 34 deletions(-)
 create mode 100644 StandaloneMmPkg/Include/Guid/MmCoreData.h
 create mode 100644 StandaloneMmPkg/Include/Guid/MmramMemoryReserve.h
 copy MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c => 
StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.c
 (82%)
 create mode 100644 
StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.inf
 create mode 100644 
StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationServices.h

diff --git a/StandaloneMmPkg/Include/Guid/MmCoreData.h 
b/StandaloneMmPkg/Include/Guid/MmCoreData.h
new file mode 100644
index ..a1168f95f7d5
--- /dev/null
+++ b/StandaloneMmPkg/Include/Guid/MmCoreData.h
@@ -0,0 +1,133 @@
+/** @file
+  MM Core data.
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2018, 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 that 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_CORE_DATA_H__
+#define __MM_CORE_DATA_H__
+
+#define MM_CORE_DATA_HOB_GUID \
+  { 0xa160bf99, 0x2aa4, 0x4d7d, { 0x99, 0x93, 0x89, 0x9c, 0xb1, 0x2d, 0xf3, 
0x76 }}
+
+extern EFI_GUID gMmCoreDataHobGuid;
+
+typedef struct {
+  //
+  // Address pointer to MM_CORE_PRIVATE_DATA
+  //
+  EFI_PHYSICAL_ADDRESS   Address;
+} MM_CORE_DATA_HOB_DATA;
+
+
+///
+/// Define values for the communications buffer used when 
gEfiEventDxeDispatchGuid is
+/// event signaled.  This event is signaled by the DXE Core each time the DXE 
Core
+/// dispatcher has completed its work.  When this event is signaled, the MM 
Core
+/// if notified, so the MM Core can dispatch MM drivers.  If 
COMM_BUFFER_MM_DISPATCH_ERROR
+/// is returned in the communication buffer, then an error occurred 
dispatching MM
+/// Drivers.  If COMM_BUFFER_MM_DISPATCH_SUCCESS is returned, then the MM Core
+/// dispatched all the drivers it could.  If COMM_BUFFER_MM_DISPATCH_RESTART is
+/// returned, then the MM Core just dispatched the MM Driver that registered
+/// the MM Entry Point enabling the use of MM Mode.  In this case, the MM Core
+/// should be notified again to dispatch more MM Drivers using MM Mode.
+///
+#define COMM_BUFFER_MM_DISPATCH_ERROR0x00
+#define COMM_BUFFER_MM_DISPATCH_SUCCESS  0x01
+#define COMM_BUFFER_MM_DISPATCH_RESTART  0x02
+
+///
+/// Signature for the private structure shared between the MM IPL and the MM 
Core
+///
+#define MM_CORE_PRIVATE_DATA_SIGNATURE  SIGNATURE_32 ('m', 'm', 'i', 'c')
+
+///
+/// Private structure that is used to share information between the MM IPL and
+/// the MM Core.  This structure is allocated from memory of type 
EfiRuntimeServicesData.
+/// Since runtime memory types are converted to available memory when a legacy 
boot
+/// is performed, the MM Core must not access any fields of this structure if 
a legacy
+/// boot is performed.  As a result, the MM IPL must create an event 
notification
+/// for the Legacy Boot event and notify the MM Core that a legacy boot is 
being
+/// performed.  The MM Core can then use this information to filter accesses to
+/// thos structure.
+///
+typedef struct {
+  UINT64  Signature;
+
+  ///
+  /// The number of MMRAM ranges passed from the MM IPL to the MM Core.  The MM
+  /// Core uses these ranges of MMRAM to initialize the MM Core memory manager.
+  ///
+  UINT64  MmramRangeCount;
+
+  ///
+  /// A table of MMRAM ranges passed from the MM IPL to the MM Core.  The MM
+  /// Core uses these ranges of MMRAM to initialize the MM Core memory manager.
+  ///
+  EFI_PHYSICAL_ADDRESSMmramRanges;
+
+  ///
+  /// The MM Foundation Entry Point.  The MM Core fills in this field when the
+  /// MM Core is initialized.  The MM IPL is responsbile for registering this 
entry
+  /// point with the MM Configuration Protocol.  The MM Configuration Protocol 
may

[edk2] [PATCH v2 03/10] StandaloneMmPkg/MemLib: Add Standalone MM instance of memory check library.

2018-07-13 Thread Sughosh Ganu
From: Supreeth Venkatesh 

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: Supreeth Venkatesh 
Reviewed-by: Achin Gupta 
Reviewed-by: Jiewen Yao 
Signed-off-by: Sughosh Ganu 
---
 .../Include/Library/StandaloneMmMemLib.h   |  66 ++---
 .../AArch64/StandaloneMmMemLibInternal.c   |  49 
 .../StandaloneMmMemLib/StandaloneMmMemLib.c| 269 +
 .../StandaloneMmMemLib/StandaloneMmMemLib.inf  |  50 
 4 files changed, 402 insertions(+), 32 deletions(-)
 copy MdePkg/Include/Library/SmmMemLib.h => 
StandaloneMmPkg/Include/Library/StandaloneMmMemLib.h (68%)
 create mode 100644 
StandaloneMmPkg/Library/StandaloneMmMemLib/AArch64/StandaloneMmMemLibInternal.c
 create mode 100644 
StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.c
 create mode 100644 
StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf

diff --git a/MdePkg/Include/Library/SmmMemLib.h 
b/StandaloneMmPkg/Include/Library/StandaloneMmMemLib.h
similarity index 68%
copy from MdePkg/Include/Library/SmmMemLib.h
copy to StandaloneMmPkg/Include/Library/StandaloneMmMemLib.h
index e7848b2bce73..8e3f2801aa61 100644
--- a/MdePkg/Include/Library/SmmMemLib.h
+++ b/StandaloneMmPkg/Include/Library/StandaloneMmMemLib.h
@@ -1,11 +1,13 @@
 /** @file
-  Provides services for SMM Memory Operation.
+  Provides services for MM Memory Operation.
 
-  The SMM Mem Library provides function for checking if buffer is outside 
SMRAM and valid.
-  It also provides functions for copy data from SMRAM to non-SMRAM, from 
non-SMRAM to SMRAM,
-  from non-SMRAM to non-SMRAM, or set data in non-SMRAM.
+  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 - 2018, ARM Limited. All rights reserved.
 
-  Copyright (c) 2015 - 2018, Intel Corporation. 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
@@ -16,30 +18,30 @@
 
 **/
 
-#ifndef _SMM_MEM_LIB_H_
-#define _SMM_MEM_LIB_H_
+#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 SMRAM.
+  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 SMRAM.
-  @retval FALSE This buffer is not valid per processor architecture or overlap 
with SMRAM.
+  @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
-SmmIsBufferOutsideSmmValid (
+MmIsBufferOutsideMmValid (
   IN EFI_PHYSICAL_ADDRESS  Buffer,
   IN UINT64Length
   );
 
 /**
-  Copies a source buffer (non-SMRAM) to a destination buffer (SMRAM).
+  Copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).
 
-  This function copies a source buffer (non-SMRAM) to a destination buffer 
(SMRAM).
-  It checks if source buffer is valid per processor architecture and not 
overlap with SMRAM.
+  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.
@@ -48,23 +50,23 @@ SmmIsBufferOutsideSmmValid (
   @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 SMRAM.
+  @retval EFI_SECURITY_VIOLATION The SourceBuffer

[edk2] [PATCH v2 02/10] StandaloneMmPkg/FvLib: Add a common FV Library for management mode.

2018-07-13 Thread Sughosh Ganu
From: Supreeth Venkatesh 

This patch implements a firmware volume library that can be used by the
Standalone management mode core module to parse the firmware volume.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Supreeth Venkatesh 
Reviewed-by: Achin Gupta 
Reviewed-by: Jiewen Yao 
Signed-off-by: Sughosh Ganu 
---
 StandaloneMmPkg/Include/Library/FvLib.h| 109 ++
 StandaloneMmPkg/Library/FvLib/FvLib.c  | 385 +
 .../Library/FvLib/FvLib.inf|  29 +-
 3 files changed, 509 insertions(+), 14 deletions(-)
 create mode 100644 StandaloneMmPkg/Include/Library/FvLib.h
 create mode 100644 StandaloneMmPkg/Library/FvLib/FvLib.c
 copy 
IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSecPlatformLibNull.inf => 
StandaloneMmPkg/Library/FvLib/FvLib.inf (69%)

diff --git a/StandaloneMmPkg/Include/Library/FvLib.h 
b/StandaloneMmPkg/Include/Library/FvLib.h
new file mode 100644
index ..64e65b412d95
--- /dev/null
+++ b/StandaloneMmPkg/Include/Library/FvLib.h
@@ -0,0 +1,109 @@
+/** @file
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2016 - 2018, 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 _FV_LIB_H_
+#define _FV_LIB_H_
+
+#include 
+#include 
+#include 
+
+/**
+  Given the input file pointer, search for the next matching file in the
+  FFS volume as defined by SearchType. The search starts from FileHeader inside
+  the Firmware Volume defined by FwVolHeader.
+
+  @param  SearchType  Filter to find only files of this type.
+  Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
+  @param  FwVolHeader Pointer to the FV header of the volume to search.
+  This parameter must point to a valid FFS volume.
+  @param  FileHeader  Pointer to the current file from which to begin 
searching.
+  This pointer will be updated upon return to reflect the 
file found.
+
+  @retval EFI_NOT_FOUND  No files matching the search criteria were found
+  @retval EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+FfsFindNextFile (
+  IN EFI_FV_FILETYPE SearchType,
+  IN EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader,
+  IN OUT EFI_FFS_FILE_HEADER **FileHeader
+  );
+
+/**
+  Given the input file pointer, search for the next matching section in the
+  FFS volume.
+
+  @param  SearchTypeFilter to find only sections of this type.
+  @param  FfsFileHeader Pointer to the current file to search.
+  @param  SectionHeader Pointer to the Section matching SectionType in 
FfsFileHeader.
+NULL if section not found
+
+  @retval  EFI_NOT_FOUND  No files matching the search criteria were found
+  @retval  EFI_SUCCESS
+**/
+EFI_STATUS
+FfsFindSection (
+  IN EFI_SECTION_TYPE  SectionType,
+  IN EFI_FFS_FILE_HEADER   *FfsFileHeader,
+  IN OUT EFI_COMMON_SECTION_HEADER **SectionHeader
+  );
+
+/**
+  Locates a section within a series of sections
+  with the specified section type.
+
+  @param[in]   SectionsThe sections to search
+  @param[in]   SizeOfSections  Total size of all sections
+  @param[in]   SectionType The section type to locate
+  @param[out]  FoundSectionThe FFS section if found
+
+  @retval EFI_SUCCESS   The file and section was found
+  @retval EFI_NOT_FOUND The file and section was not found
+  @retval EFI_VOLUME_CORRUPTED  The firmware volume was corrupted
+**/
+EFI_STATUS
+EFIAPI
+FindFfsSectionInSections (
+  IN  VOID *Sections,
+  IN  UINTNSizeOfSections,
+  IN  EFI_SECTION_TYPE SectionType,
+  OUT EFI_COMMON_SECTION_HEADER**FoundSection
+  );
+
+/**
+  Given the input file pointer, search for the next matching section in the
+  FFS volume.
+
+  @param  SearchType  Filter to find only sections of this type.
+  @param  FfsFileHeader   Pointer to the current file to search.
+  @param  SectionData Pointer to the Section matching SectionType in 
FfsFileHeader.
+  NULL if section not found
+  @param  SectionDataSize The size of SectionData
+
+  @retval  EFI_NOT_FOUND  No files matching the search criteria were found
+  @retval  EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+FfsFindSectionData (
+  IN EFI_SECTION_TYPE  SectionType,
+  IN EFI_FFS_FILE_HEADER   *FfsFileHeader,
+  OUT VOID **SectionData,
+  OUT UINTN*SectionDataSize
+  );
+
+#endif
diff --git a/StandaloneMmPkg/

[edk2] [PATCH v2 05/10] StandaloneMmPkg/HobLib: Add HOB Library for management mode.

2018-07-13 Thread Sughosh Ganu
From: Supreeth Venkatesh 

The Standalone MM environment is initialized during the SEC phase on ARM
Standard Platforms. The MM Core driver implements an entry point module
which is architecture specific and runs prior to the generic core driver
code. The former creates a Hob list that the latter consumes. This
happens in the same phase.

This patch implements a Hob library that can be used by the entry point
module to produce a Hob list and by the core driver code to consume it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Achin Gupta 
Signed-off-by: Supreeth Venkatesh 
Reviewed-by: Jiewen Yao 
Signed-off-by: Sughosh Ganu 
---
 .../AArch64/StandaloneMmCoreHobLibInternal.c   |  64 +++
 .../StandaloneMmCoreHobLib.c   | 433 +++--
 .../StandaloneMmCoreHobLib.inf |  47 +++
 3 files changed, 330 insertions(+), 214 deletions(-)
 create mode 100644 
StandaloneMmPkg/Library/StandaloneMmCoreHobLib/AArch64/StandaloneMmCoreHobLibInternal.c
 copy MdePkg/Library/DxeCoreHobLib/HobLib.c => 
StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.c (67%)
 create mode 100644 
StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf

diff --git 
a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/AArch64/StandaloneMmCoreHobLibInternal.c
 
b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/AArch64/StandaloneMmCoreHobLibInternal.c
new file mode 100644
index ..90e1cd479cb2
--- /dev/null
+++ 
b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/AArch64/StandaloneMmCoreHobLibInternal.c
@@ -0,0 +1,64 @@
+/** @file
+  HOB Library implementation for Standalone MM Core.
+
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2018, 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 
+
+//
+// Cache copy of HobList pointer.
+//
+extern VOID *gHobList;
+
+EFI_HOB_HANDOFF_INFO_TABLE*
+HobConstructor (
+  IN VOID   *EfiMemoryBegin,
+  IN UINTN  EfiMemoryLength,
+  IN VOID   *EfiFreeMemoryBottom,
+  IN VOID   *EfiFreeMemoryTop
+  )
+{
+  EFI_HOB_HANDOFF_INFO_TABLE  *Hob;
+  EFI_HOB_GENERIC_HEADER  *HobEnd;
+
+  Hob= EfiFreeMemoryBottom;
+  HobEnd = (EFI_HOB_GENERIC_HEADER *)(Hob+1);
+
+  Hob->Header.HobType = EFI_HOB_TYPE_HANDOFF;
+  Hob->Header.HobLength   = sizeof (EFI_HOB_HANDOFF_INFO_TABLE);
+  Hob->Header.Reserved= 0;
+
+  HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
+  HobEnd->HobLength   = sizeof (EFI_HOB_GENERIC_HEADER);
+  HobEnd->Reserved= 0;
+
+  Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
+  Hob->BootMode= BOOT_WITH_FULL_CONFIGURATION;
+
+  Hob->EfiMemoryTop= (UINTN)EfiMemoryBegin + EfiMemoryLength;
+  Hob->EfiMemoryBottom = (UINTN)EfiMemoryBegin;
+  Hob->EfiFreeMemoryTop= (UINTN)EfiFreeMemoryTop;
+  Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)(HobEnd+1);
+  Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
+
+  gHobList = Hob;
+
+  return Hob;
+}
diff --git a/MdePkg/Library/DxeCoreHobLib/HobLib.c 
b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.c
similarity index 67%
copy from MdePkg/Library/DxeCoreHobLib/HobLib.c
copy to StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.c
index 6aac20dd4d8d..e2fcda813d1b 100644
--- a/MdePkg/Library/DxeCoreHobLib/HobLib.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.c
@@ -1,7 +1,9 @@
 /** @file
-  HOB Library implementation for DxeCore driver.
+  HOB Library implementation for Standalone MM Core.
+
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
 
-Copyright (c) 2006 - 2018, Intel Corporation. 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
@@ -12,24 +14,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
 **/
 
-#include 
+#include 
 
 #include 
 #include 
 #include 
-#include 
+
+#include 
+
+//
+// Cache copy of HobList pointer.
+//
+VOID *gHobList = NULL;
 
 /**
   Returns the pointer to the HOB list.
 
   This function returns the pointer to first HOB in the list.
-  For PEI phase, the PEI service GetHobList() can be used to retrieve the 
pointer
-  to the HO

[edk2] [PATCH v2 01/10] StandaloneMmPkg: Delete StandaloneMmPkg file.

2018-07-13 Thread Sughosh Ganu
From: Supreeth Venkatesh 

This patch deletes "StandaloneMmPkg" which was created as a file
intially. This patch enables creation of "StandaloneMmPkg" as a folder.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Supreeth Venkatesh 
Reviewed-by: Achin Gupta 
Reviewed-by: Jiewen Yao 
Signed-off-by: Sughosh Ganu 
---
 StandaloneMmPkg | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 StandaloneMmPkg

diff --git a/StandaloneMmPkg b/StandaloneMmPkg
deleted file mode 100644
index e69de29bb2d1..
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 00/10] Standalone Management Mode Core Interface for AARCH64 Platforms

2018-07-13 Thread Sughosh Ganu
The following patch series adds StandaloneMM core interface for
aarch64 platforms. Following earlier comments from Jeiwen [1], the
patch series has been split into three parts and this series handles
StandaloneMMPkg related changes.

[1] - https://lists.01.org/pipermail/edk2-devel/2018-June/026211.html


Changes since V1:
 - Handle review comments from Achin
 - Coding style fixes

Supreeth Venkatesh (10):
  StandaloneMmPkg: Delete StandaloneMmPkg file.
  StandaloneMmPkg/FvLib: Add a common FV Library for management mode.
  StandaloneMmPkg/MemLib: Add Standalone MM instance of memory check
library.
  StandaloneMmPkg/MemoryAllocationLib: Add MM memory allocation library.
  StandaloneMmPkg/HobLib: Add HOB Library for management mode.
  StandaloneMmPkg: MM driver entry point library.
  StandaloneMmPkg/Core: Implementation of Standalone MM Core Module.
  StandaloneMmPkg: Add an AArch64 specific entry point library.
  StandaloneMmPkg: Add CPU driver suitable for ARM Platforms.
  StandaloneMmPkg: Describe the declaration and definition files.

 StandaloneMmPkg|0
 StandaloneMmPkg/Core/Dependency.c  |  389 +++
 StandaloneMmPkg/Core/Dispatcher.c  | 1071 
 StandaloneMmPkg/Core/FwVol.c   |  104 ++
 StandaloneMmPkg/Core/Handle.c  |  533 ++
 StandaloneMmPkg/Core/InstallConfigurationTable.c   |  178 
 StandaloneMmPkg/Core/Locate.c  |  496 +
 StandaloneMmPkg/Core/Mmi.c |  337 ++
 StandaloneMmPkg/Core/Notify.c  |  203 
 StandaloneMmPkg/Core/Page.c|  384 +++
 StandaloneMmPkg/Core/Pool.c|  293 ++
 StandaloneMmPkg/Core/StandaloneMmCore.c|  712 +
 StandaloneMmPkg/Core/StandaloneMmCore.h|  903 +
 StandaloneMmPkg/Core/StandaloneMmCore.inf  |   80 ++
 StandaloneMmPkg/Core/StandaloneMmCorePrivateData.h |   66 ++
 .../Drivers/StandaloneMmCpu/AArch64/EventHandle.c  |  220 
 .../StandaloneMmCpu/AArch64/StandaloneMmCpu.c  |  232 +
 .../StandaloneMmCpu/AArch64/StandaloneMmCpu.h  |   64 ++
 .../StandaloneMmCpu/AArch64/StandaloneMmCpu.inf|   59 ++
 StandaloneMmPkg/Include/Guid/MmCoreData.h  |  133 +++
 StandaloneMmPkg/Include/Guid/MmFvDispatch.h|   39 +
 StandaloneMmPkg/Include/Guid/MmramMemoryReserve.h  |   62 ++
 StandaloneMmPkg/Include/Guid/MpInformation.h   |   41 +
 .../Library/AArch64/StandaloneMmCoreEntryPoint.h   |  215 
 StandaloneMmPkg/Include/Library/FvLib.h|  109 ++
 .../Include/Library/StandaloneMmCoreEntryPoint.h   |  101 ++
 .../Include/Library/StandaloneMmDriverEntryPoint.h |  148 +++
 .../Include/Library/StandaloneMmMemLib.h   |  140 +++
 StandaloneMmPkg/Include/StandaloneMm.h |   36 +
 StandaloneMmPkg/Library/FvLib/FvLib.c  |  385 +++
 StandaloneMmPkg/Library/FvLib/FvLib.inf|   57 ++
 .../AArch64/CreateHobList.c|  209 
 .../AArch64/SetPermissions.c   |  289 ++
 .../AArch64/StandaloneMmCoreEntryPoint.c   |  306 ++
 .../StandaloneMmCoreEntryPoint.inf |   55 +
 .../AArch64/StandaloneMmCoreHobLibInternal.c   |   64 ++
 .../StandaloneMmCoreHobLib.c   |  608 +++
 .../StandaloneMmCoreHobLib.inf |   47 +
 .../StandaloneMmCoreMemoryAllocationLib.c  |  908 +
 .../StandaloneMmCoreMemoryAllocationLib.inf|   49 +
 .../StandaloneMmCoreMemoryAllocationServices.h |   38 +
 .../StandaloneMmDriverEntryPoint.c |   99 ++
 .../StandaloneMmDriverEntryPoint.inf   |   41 +
 .../AArch64/StandaloneMmMemLibInternal.c   |   49 +
 .../StandaloneMmMemLib/StandaloneMmMemLib.c|  269 +
 .../StandaloneMmMemLib/StandaloneMmMemLib.inf  |   50 +
 StandaloneMmPkg/StandaloneMmPkg.dec|   47 +
 StandaloneMmPkg/StandaloneMmPkg.dsc|  130 +++
 48 files changed, 11048 insertions(+)
 delete mode 100644 StandaloneMmPkg
 create mode 100644 StandaloneMmPkg/Core/Dependency.c
 create mode 100644 StandaloneMmPkg/Core/Dispatcher.c
 create mode 100644 StandaloneMmPkg/Core/FwVol.c
 create mode 100644 StandaloneMmPkg/Core/Handle.c
 create mode 100644 StandaloneMmPkg/Core/InstallConfigurationTable.c
 create mode 100644 StandaloneMmPkg/Core/Locate.c
 create mode 100644 StandaloneMmPkg/Core/Mmi.c
 create mode 100644 StandaloneMmPkg/Core/Notify.c
 create mode 100644 StandaloneMmPkg/Core/Page.c
 create mode 100644 StandaloneMmPkg/Core/Pool.c
 create mode 100644 StandaloneMmPkg/Core/StandaloneMmCore.c
 create mode 100644 StandaloneMmPkg/Core/StandaloneMmCore.h
 create mode 100644 StandaloneMmPkg/Core/StandaloneMmCore.inf
 create mode 100644 StandaloneMmPkg/Co

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

2018-07-09 Thread Sughosh Ganu
hi Leif,

On Tue, Jul 3, 2018 at 7:42 PM, Leif Lindholm  wrote:
> On Tue, Jul 03, 2018 at 03:25:11PM +0530, 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 DEN0060A_ARM_MM_Interface_Specification.pdf
>
> I would prefer the document to be referred to by its official name and
> its document number:
> ARM Management Mode Interface Specification (ARM DEN0060A)
>
>> 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: Achin Gupta 
>> Signed-off-by: Supreeth Venkatesh 
>
> Oh, and only one Signed-off-by per patch please.
> If authorship is to be indicated, ensure that's correct in git before
> calling format-patch.

Supreeth has moved onto some other work, hence I will be working on
the upstreaming of these patches henceforth. Will handle your comments
on all the patches and send an updated version. Regarding the
inclusion of a single Signed-off-By, i have a doubt. Work on these
patches was initially done by Achin, and then Supreeth. I will be
handling your review comments and posting the updated version. You
have posted a comment saying that we can have only a single s-o-b in
any given patch. In such a scenario, how can we attribute the work
done by all the engineers for these patches. Can you please let me
know on this. As per my understanding, other projects do allow
multiple s-o-b's per patch. Thanks.

-sughosh
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v3 00/17] *** Standalone Management Mode Core Interface for AARCH64 Platforms ***

2018-06-06 Thread Sughosh Ganu
On Tue, Jun 5, 2018 at 3:43 AM, Supreeth Venkatesh
 wrote:
> ***
> This patchset v3 contains only the patches that got feedback/comments frome 
> the previous revision v2.
> The patches are
> [PATCH v3 06/17] StandaloneMmPkg: Delete StandaloneMmPkg file.
> [PATCH v3 13/17] StandaloneMmPkg: Add an AArch64 specific entry point library.
> [PATCH v3 17/17] BaseTools/AutoGen: Update header file for MM modules.
>
> Changes Since v2:
> (*) Address feedback provided for the commit "BaseTools/AutoGen: Update 
> header file for MM modules."
> (*) Edit parameters for the StandaloneMmCpu Driver in the commit 
> "StandaloneMmPkg: Add an AArch64 specific entry point library."
>
> Changes Since v1:
> (*) Reorder and Reword commits.
> (*) Reorganize structure of StandaloneMmPkg and rename libraries.
> (*) Address Review Comments from Achin, Jiewen and Daniil.
> ***
> Supreeth Venkatesh (17):
>   ArmPkg: Add PCDs needed for MM communication driver.
>   ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.
>   ArmPkg/Include: Add MM interface SVC return codes.
>   ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.
>   ArmPkg/ArmMmuLib: Add MMU library inf file suitable for use in S-EL0.
>   StandaloneMmPkg: Delete StandaloneMmPkg file.
>   StandaloneMmPkg/FvLib: Add a common FV Library for management mode.
>   StandaloneMmPkg/MemLib: Add Standalone MM instance of memory check
> library.
>   StandaloneMmPkg/MemoryAllocationLib: Add MM memory allocation library.
>   StandaloneMmPkg/HobLib: Add HOB Library for management mode.
>   StandaloneMmPkg: MM driver entry point library.
>   StandaloneMmPkg/Core: Implementation of Standalone MM Core Module.
>   StandaloneMmPkg: Add an AArch64 specific entry point library.
>   StandaloneMmPkg: Add CPU driver suitable for ARM Platforms.
>   StandaloneMmPkg: Describe the declaration and definition files.
>   ArmPkg: Extra action to update permissions for S-ELO MM Image.
>   BaseTools/AutoGen: Update header file for MM modules.

Tested all changes for RAS error injection and error handling on
SGI575 platform.

Tested-by: Sughosh Ganu 

-sughosh
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel