From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <Achin.Gupta@arm.com>
Received-SPF: Pass (sender SPF authorized) identity=mailfrom;
 client-ip=104.47.1.84; helo=eur01-ve1-obe.outbound.protection.outlook.com;
 envelope-from=achin.gupta@arm.com; receiver=edk2-devel@lists.01.org 
Received: from EUR01-VE1-obe.outbound.protection.outlook.com
 (mail-ve1eur01on0084.outbound.protection.outlook.com [104.47.1.84])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits))
 (No client certificate requested)
 by ml01.01.org (Postfix) with ESMTPS id 852DB203B8BED
 for <edk2-devel@lists.01.org>; Mon, 30 Apr 2018 08:49:15 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; 
 s=selector1-arm-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version;
 bh=r8jgw/aR47rPh8X/KpCyCHMbYcU1vYthL3rgaol5V5o=;
 b=F1QKK+maKs2nXiCUX+AJGY2CgYgC3xKewUlISY8ucRg1i3QGjwPBQw5lPspQ6xOzHmI3tZPrqKDCEl2mU8qJajP0jImz7Ueptv3fjZ7i22G0BST9r8cXGkf6iaZBlL7NXWtXtCRKLdc5TOjBz9VwwRpQz1wWN5y66o2TUEp8Dc8=
Authentication-Results: spf=none (sender IP is )
 smtp.mailfrom=Achin.Gupta@arm.com; 
Received: from e104320-lin (217.140.96.140) by
 VI1PR08MB2992.eurprd08.prod.outlook.com (2603:10a6:803:44::22) with Microsoft
 SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.715.20; Mon, 30
 Apr 2018 15:49:11 +0000
Date: Mon, 30 Apr 2018 16:50:39 +0100
From: Achin Gupta <achin.gupta@arm.com>
To: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Cc: edk2-devel@lists.01.org, michael.d.kinney@intel.com,
 liming.gao@intel.com, jiewen.yao@intel.com,
 leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, nd@arm.com
Message-ID: <20180430155038.GW663@e104320-lin>
References: <20180406144223.10931-1-supreeth.venkatesh@arm.com>
 <20180406144223.10931-13-supreeth.venkatesh@arm.com>
MIME-Version: 1.0
In-Reply-To: <20180406144223.10931-13-supreeth.venkatesh@arm.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Originating-IP: [217.140.96.140]
X-ClientProxiedBy: DB6PR01CA0012.eurprd01.prod.exchangelabs.com
 (2603:10a6:6:45::25) To VI1PR08MB2992.eurprd08.prod.outlook.com
 (2603:10a6:803:44::22)
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-HT: Tenant
X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0;
 RULEID:(7020095)(4652020)(48565401081)(5600026)(2017052603328)(7153060)(7193020);
 SRVR:VI1PR08MB2992; 
X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB2992;
 3:G1qIErYhHFQ3Wr+OJ5G5Za1f5C4FA4GhhdYEZ3pp54YUjALmuDFT++ZXt2zOylqzFeYnR8zkWUYWBdHhU4icT5S20iYZTpHs2Hw6WDPkIIGYv366kjbD5sHWjsUU6XrSFBZG3qHwhcQ3dRJ8XVtFy/6qAD8lxtqIS+yEKCFRNKmNIDi/7kPC3oWqL8us7CTaXKyMS4JxqlOJYqoz7QWptER//HSN5DXrYV5C7CW73ttP98hnb4uQK6roErTGbFEY;
 25:hZytoBzHNRdn43DOj08DsoO2ejVzqZQL2oRuJev6oaS82Af+WBapX/E0MyiljmRSj2A9POLY3f/ZGL62FQrgw1Le1Ca34MYfaJfwSzng2Ak08mYpVrOoIr66UFTW7HVm3wW2gWpFqC+EDUsNXWIN65X1ERAURivnDBsHtAn/OCNucv0bhS20HYPqvGvxmn+3xNicPjUqXRwuEvc1+DFVEPf4ti4I8nbmxLUHQAWAE4kKyr5TRHnG6tlrtlbUrBLgrGbsrDJLN/KxBEmpO2KiOKGhWpgYcU6xhRjlIJjKST6UvIBPJrY9kVj6R9X5yl6d42fL/hxMfUop4WF4kjglkg==;
 31:iglaTTX6XZuMipew1MzGtjP3JLM8br0ytYv4kbZ1Cval630GFKkC7I67whJmB4Sb+78AEpi+/aqwM28WqJv9S0ef5gJoidGCbUDWVG9i6MZHyFEOutbPFs5QCfIV80eM9BxkQWvFFUQE3YWWCHrRIygxp2f5DSUl2CSRKx6mRA/ZkKOpx/nB7Cy0uKxteIHGDBvgGthONmIYfd6xZJkPfEbgaq/YP06q9jmaraETjRw=
X-MS-TrafficTypeDiagnostic: VI1PR08MB2992:
NoDisclaimer: True
X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB2992;
 20:ifrmuetbSRtWASM4ND5xYtSPcyYeK77gkipclGxxTtOhrr/UIjQP75KkXuG3xIPwESZThD56YKOPplwcWl8GgEymZFR/juHWlFi5ZApL24qXYSXLWklXs98zBNYbF7DdCs6s8LQtyde2HkGTH7LEmWOWjhXNwpdwBAgqLRe39myYx8JY9oLzORxTEoZVXvG0ME7qAPmbFRWw6QtLnNTX9Hqp/++qQQLgBez1NFpRYdYStDmzzLI3CNu3/uWVR4ne;
 4:KbUyI774LfIxSwAQDVfKciu1LrzlAPuGxDiwps5jajy66rEVZ1fOuBbYkGhcBXvk1ve6k48XNCQq7nCGl/u+FVvlCKNXiMw/u4IFS8YFfxzi6rI7M1q+RMYNAmaDGwO9IkKJmJLkUhaEIqG6fwmgn4MxV4KquYcNZ6odVLz9sBatL28HjW1Dw17qKvTkpHlAaE4vYvxjVoY0+EXq7Jp/b2Av2ANEJQAy8KfvkXCcNm+bNqgloyE4XoqUIwVGETxE3xR9dF5g6mk3mTDz2oze9yT26yb7Xu458bgJWhFCQqsw+u0ccDrbIzulaJPVJThZsz6gRGWtwXD84n5xHiLJrvFI3Mm3rQW1joIQNJx3YrI=
X-Microsoft-Antispam-PRVS: <VI1PR08MB29921124778E146A29B21091FF820@VI1PR08MB2992.eurprd08.prod.outlook.com>
X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(35073007944872);
X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0;
 RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231254)(944501410)(52105095)(6055026)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(6072148)(201708071742011);
 SRVR:VI1PR08MB2992; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB2992; 
X-Forefront-PRVS: 0658BAF71F
X-Forefront-Antispam-Report: SFV:NSPM;
 SFS:(10009020)(6029001)(366004)(396003)(39380400002)(376002)(346002)(39860400002)(199004)(189003)(4326008)(6246003)(6306002)(3846002)(446003)(6116002)(26005)(55016002)(6636002)(50466002)(16799955002)(9686003)(6666003)(23726003)(6496006)(1076002)(486006)(106356001)(44832011)(52116002)(97736004)(53376002)(33656002)(229853002)(5660300001)(72206003)(386003)(47776003)(966005)(33716001)(8936002)(66066001)(8676002)(478600001)(81156014)(58126008)(81166006)(316002)(33896004)(16586007)(6862004)(53946003)(25786009)(956004)(59450400001)(105586002)(305945005)(16526019)(11346002)(15188155005)(7736002)(476003)(53936002)(76176011)(86362001)(2906002)(68736007)(18370500001)(107986001);
 DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB2992; H:e104320-lin; FPR:; SPF:None;
 LANG:en; PTR:InfoNoRecords; A:1; MX:1; 
Received-SPF: None (protection.outlook.com: arm.com does not designate
 permitted sender hosts)
X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR08MB2992;
 23:Wr6XfLykDa+NrM0HQyfrgJ1fbJs7+a9La4hV5lxH+?=
 =?us-ascii?Q?KHH8nB3KnDXOoR7v3b6sKh1ir3zmqUYPqP8dobnwLU+8LKltT/t28uIcI8WB?=
 =?us-ascii?Q?Eh6sougcXeVxNKlK0g+GrLokl7MQZHJuQWJSM9hJTsHKqHDF7mVwnpx0pBif?=
 =?us-ascii?Q?6YdrvatrHe4W1dLiRxUwX6ND1TVTOHHW9JVBl1CGyoaoo5hC15UNLefk1riE?=
 =?us-ascii?Q?YGo/ps74YtT/9D1Ax65VTikyjjtljO14w2RtGStqaEsR5SqbAa0envhPeOwg?=
 =?us-ascii?Q?/7v3rabt5hhKXcxpqCd1TJ80QWu0V1cgJO2enweSA1PxcGSEVDx0bM2XsN8g?=
 =?us-ascii?Q?DoKnECOFB2zWx4amoJ0X3x2zyDIvp5w0CvbJ1M+lcmUixkjUJk2V9cc6THD7?=
 =?us-ascii?Q?d+xgtswBL1AvhmlDSxGSaPOT5xLjsDxVV9a5t/yS1/I5eRbwYvZwVUCKPwCJ?=
 =?us-ascii?Q?nITtSV/ZmlhXBeSRrZ/nHl0MfMh2tuNLm75ewDArzpByjk5LXpGuvfFkb4CP?=
 =?us-ascii?Q?uVLUa0ViT3/VxWF6jQ6caXtQi52l02DVQyU65oKul9An1nZv8phFkVCwokIX?=
 =?us-ascii?Q?DyEogDsB9RWj8S1wWUBJIHlj5ExQDpGoPSperqpPK8MQNuBPWi4Xcra6xOjp?=
 =?us-ascii?Q?LXHBfcKtGhSce9GPjyntOBVlE+hgede9745qLRknPbWhHKon7yip8rnmE/l5?=
 =?us-ascii?Q?ITL/3dvR9ORFnASGYNOZ/T1nTABYo0wQvDStLBUvG4U9/dR/0Uf1ZDTObKBc?=
 =?us-ascii?Q?28SXjYquSMd8nmj5exyIVDndj6YOpUQB1b0pOs0A95UxibPO8DFC+p/EOSjZ?=
 =?us-ascii?Q?1ZrZCbPqHkWxE7Htv+LYeqr5ZMdwHzW/TNjCiXdJEiA0/3p8Fl8s9hy7YCkq?=
 =?us-ascii?Q?Bg5U502CcMFzdMqkrPRvgIGx1/49+ya9QfxxagCVCm6T3gkgfjUAeYO7OuBg?=
 =?us-ascii?Q?SZrcPQLpq/ztBTASXYespPaSnujcjDt7KYs0giA/NmylP0M3E4EYpEzLZ1JW?=
 =?us-ascii?Q?dwUxouG1IN1Mxk+s7+wlRPvKRUI38RygFzg1uaQ/pjIaojTYoeY+zBX1Kn2q?=
 =?us-ascii?Q?dReECXndtkuBzGyfkNMUhVXW2hHzvUTJgP6AseX0IECF8Td16zVz+2eR5fWh?=
 =?us-ascii?Q?ECQcV35GKTkNMrctO2um1qvOxpiwdruyLSTBHc0/h/zeq2mZhpss3WBJK23o?=
 =?us-ascii?Q?0cZ2MwxQF4vNCoob3JZI/cAk8CQi0vV0uuoVxCrR6HdvdXmdrcDev5gOnu97?=
 =?us-ascii?Q?E54fcOHdG8o10c5KOu+cxFOo2oCOT+MAHahXbhXbRstR1fjVXW78UGRq9z+r?=
 =?us-ascii?Q?PIT4I/BcgH47NEjm/wIlJdfC8mimZsXA29qgl4A21iqHWjP5Y8bF2/THbTjJ?=
 =?us-ascii?Q?JsZe/uUJl9OVgnDuBy/I+whrpOCO/zYaJ3UcaYsyoOUtBe9z+Gnezas4Y/nf?=
 =?us-ascii?Q?o/FtKqoxNnki9blCC9Jqg2nRWaRfI8HA1sAMdUkOPdyrEgqlaQuNwvawb2e1?=
 =?us-ascii?Q?nAmLHLJhMqc5EHQ3NEBmwSl88jDtEBAmvY=3D?=
X-Microsoft-Antispam-Message-Info: KlE1yJX826+zP9stfAsmREHgwJw5JtnlJ/TgveedNDqEDddikp2vRDjXbDLPycBgG1zOAGigNfkir7BJ6JZg9Q5QVYajWvDcIEyvm1vystNmm9bXHBR+CXIySTOYcA+cLJHZmSkPUs+5MW41aPhODZxztG+f5RufAEMK5YaJDtTKTq3ONeU1R6H/skW7EkZE
X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB2992;
 6:Gl+mQQYdls03H/qQRVqM+omc+5dr2aZt317af4zsK8ff99IdYAsrOoVesqi5uwvTZl0k/E6pPfn3b6nb+xII31XPTjYYlMntOmhmWnVFHlzLWzI1HyfRp4q+hnVI7mzzqR74FIbUj+q//TOw67C8VTJ/ulCeHqNVXrKoQvD2q0/7AOHtOviprBGCRIlt+GMpEJ6VoKdQI0M6ZJeEU1+ysfAR9mzfwIOAQuJVhECsuYW0Q+dFhPXUskloT/QqWOmnPceoMim65V4+PtEhkqSsqq4pP++4yUDyF7q/6nOs6SINS5G2/Wegkac/rnXcKqLsiu8YXX68GHlYTyb3OFkwkyWv+Y7KN9PWWqJxdRKihgc5HISrhwONLb7YdBBMCU4ZffhtzJXh+yMV40i/rpYZkj7ft18XnknfgD0puJGReUT/VsFBhLHlE7tXtiOtVm1tJh7mq+g0lj+8YWY5rdEn6w==;
 5:U2hxdTCLrwjXMjUJIfD4qfxwZlua04Ji7JqmQe1AlHwhIpDyOO81/JDiAL4LapNA1+jTSYsAm39FHDUGPrAbVugAO4cYVE8DDC6f/ynUUuE/XWGCpQ2FIk5gouLec+GWiBgDUEWRo9pkml9q7sCQCe1dQV1ilJzKwxhfTk8C3tE=;
 24:hF9OgepXrSteg+hkoLjcypSIIg1cAJY5OtJHiK2Rzw7zCrTOwNPfbrjkMWT+wQrWG36OrXg4Mt6zyZg1vNj4BXLfIFlMxT/KMRmTDxJYqyc=
SpamDiagnosticOutput: 1:99
SpamDiagnosticMetadata: NSPM
X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB2992;
 7:5SfFpT9slA+6pZnxNfN7+orEaanR8nntrN20FXc/jk5qMKDmmJOjI/nFXgkOoFPU59JogJQcBAuw04R8DWK3LfsZy5VSsn25xKQrAWkHWABvY2lebGL5cAgJ7LPOYwOHlFX5zGFiIZMR8qRNcg+fuoc9NPhhWtSUti4di288Ejh48eE5Y9xEHGmqXEpao7AVQd/ZxL/gGdayhcq1Hm+vXOwYfx+K9kiwsWbgKJtBRxZSEEEiIoiV1NKbA1LMKJW9
X-MS-Office365-Filtering-Correlation-Id: 56e90edc-ce5f-4021-6337-08d5aeb1eb1a
X-OriginatorOrg: arm.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2018 15:49:11.3206 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: 56e90edc-ce5f-4021-6337-08d5aeb1eb1a
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d
X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB2992
Subject: Re: [PATCH v1 12/18] StandaloneMmPkg/CpuMm: Add CPU driver suitable for ARM Platforms.
X-BeenThere: edk2-devel@lists.01.org
X-Mailman-Version: 2.1.26
Precedence: list
List-Id: EDK II Development  <edk2-devel.lists.01.org>
List-Unsubscribe: <https://lists.01.org/mailman/options/edk2-devel>,
 <mailto:edk2-devel-request@lists.01.org?subject=unsubscribe>
List-Archive: <http://lists.01.org/pipermail/edk2-devel/>
List-Post: <mailto:edk2-devel@lists.01.org>
List-Help: <mailto:edk2-devel-request@lists.01.org?subject=help>
List-Subscribe: <https://lists.01.org/mailman/listinfo/edk2-devel>,
 <mailto:edk2-devel-request@lists.01.org?subject=subscribe>
X-List-Received-Date: Mon, 30 Apr 2018 15:49:16 -0000
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi Supreeth,

Usual comment about copyright years and invalid comments. I also noticed some
TODOs and have provided comments for them. Please see inline

On Fri, Apr 06, 2018 at 03:42:17PM +0100, Supreeth Venkatesh wrote:
> 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: Achin Gupta <achin.gupta@arm.com>
> Signed-off-by: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
> ---
>  StandaloneMmPkg/Drivers/CpuMm/Arm/Entry.S          |  33 +++

This file is not used.

>  StandaloneMmPkg/Drivers/CpuMm/Arm/EventHandle.c    | 231 +++++++++++++++++++++
>  StandaloneMmPkg/Drivers/CpuMm/Arm/Init.c           | 229 ++++++++++++++++++++
>  .../CpuMm/Arm/PiMmStandloneArmTfCpuDriver.h        |  89 ++++++++
>  .../CpuMm/Arm/PiMmStandloneArmTfCpuDriver.inf      |  60 ++++++
>  StandaloneMmPkg/Drivers/CpuMm/Arm/StateSave.c      |  51 +++++
>  StandaloneMmPkg/Include/Guid/MpInformation.h       |  41 ++++
>  7 files changed, 734 insertions(+)
>  create mode 100644 StandaloneMmPkg/Drivers/CpuMm/Arm/Entry.S
>  create mode 100644 StandaloneMmPkg/Drivers/CpuMm/Arm/EventHandle.c
>  create mode 100644 StandaloneMmPkg/Drivers/CpuMm/Arm/Init.c
>  create mode 100644 StandaloneMmPkg/Drivers/CpuMm/Arm/PiMmStandloneArmTfCpuDriver.h
>  create mode 100644 StandaloneMmPkg/Drivers/CpuMm/Arm/PiMmStandloneArmTfCpuDriver.inf
>  create mode 100644 StandaloneMmPkg/Drivers/CpuMm/Arm/StateSave.c
>  create mode 100644 StandaloneMmPkg/Include/Guid/MpInformation.h
> 
> diff --git a/StandaloneMmPkg/Drivers/CpuMm/Arm/Entry.S b/StandaloneMmPkg/Drivers/CpuMm/Arm/Entry.S
> new file mode 100644
> index 0000000000..0b6e1c330d
> --- /dev/null
> +++ b/StandaloneMmPkg/Drivers/CpuMm/Arm/Entry.S
> @@ -0,0 +1,33 @@
> +//
> +//  Copyright (c) 2017, ARM Limited. All rights reserved.
> +//
> +//  This program and the accompanying materials
> +//  are licensed and made available under the terms and conditions of the BSD License
> +//  which accompanies this distribution.  The full text of the license may be found at
> +//  http://opensource.org/licenses/bsd-license.php
> +//
> +//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +//
> +//
> +
> +#include <Base.h>
> +#include <AutoGen.h>
> +#include <IndustryStandard/ArmStdSmc.h>
> +
> +.text
> +.align 3
> +
> +GCC_ASM_IMPORT(PiMmStandloneArmTfCpuDriverEntry)
> +GCC_ASM_EXPORT(_PiMmStandloneArmTfCpuDriverEntry)
> +
> +// Stub entry point to ensure that the stacks are completely unwound before
> +// signalling completion of event handling
> +ASM_PFX(_PiMmStandloneArmTfCpuDriverEntry):
> +  bl    PiMmStandloneArmTfCpuDriverEntry
> +  mov   x1, x0
> +  mov   x0, #(ARM_SMC_ID_MM_EVENT_COMPLETE_AARCH64 & 0xffff)
> +  movk  x0, #((ARM_SMC_ID_MM_EVENT_COMPLETE_AARCH64 >> 16) & 0xffff), lsl #16
> +  svc   #0
> +LoopForever:
> +  b     LoopForever
> diff --git a/StandaloneMmPkg/Drivers/CpuMm/Arm/EventHandle.c b/StandaloneMmPkg/Drivers/CpuMm/Arm/EventHandle.c
> new file mode 100644
> index 0000000000..7b19f53ecb
> --- /dev/null
> +++ b/StandaloneMmPkg/Drivers/CpuMm/Arm/EventHandle.c
> @@ -0,0 +1,231 @@
> +/** @file
> +
> +  Copyright (c) 2016 HP Development Company, L.P.
> +  Copyright (c) 2016 - 2017, ARM Limited. All rights reserved.
> +
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD License
> +  which accompanies this distribution.  The full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include <Base.h>
> +#include <Pi/PiMmCis.h>
> +
> +
> +#include <Library/ArmSvcLib.h>
> +#include <Library/ArmLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/HobLib.h>
> +
> +#include <Protocol/DebugSupport.h> // for EFI_SYSTEM_CONTEXT
> +
> +#include <Guid/ZeroGuid.h>
> +#include <Guid/MmramMemoryReserve.h>
> +
> +#include <IndustryStandard/ArmStdSmc.h>
> +
> +#include "PiMmStandloneArmTfCpuDriver.h"
> +
> +EFI_STATUS
> +EFIAPI
> +MmFoundationEntryRegister(
> +  IN CONST EFI_MM_CONFIGURATION_PROTOCOL  *This,
> +  IN EFI_MM_ENTRY_POINT                    MmEntryPoint
> +  );
> +
> +//
> +// 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;
> +
> +//
> +// When an event is received by the CPU driver, it could correspond to a unique
> +// GUID (e.g. interrupt events) or to multiple GUIDs (e.g. MM_COMMUNICATE
> +// SMC). A table is used by the CPU driver to find the GUID corresponding to the
> +// event id in case there is a 1:1 mapping between the two. If an event id has
> +// multiple GUIDs associated with it then such an entry will not be found in
> +// this table.
> +//
> +// TODO: Currently NULL since there are no asynchronous events
> +static EFI_GUID *EventIdToGuidLookupTable = NULL;

This data structure is not being used at the moment since only MM_COMMUNICATE
SMCs are delegated to the partition. Lets remove it.

> +
> +// 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_CONTEXT        MmEntryPointContext = {0};
> +  EFI_STATUS                  Status;
> +  UINTN                       NsCommBufferSize;
> +
> +  DEBUG ((DEBUG_INFO, "Received event - 0x%x on cpu %d\n", EventId, CpuNumber));
> +
> +  //
> +  // 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) {

Lets change the if condition to return an error status if the EventID is not
ARM_SMC_ID_MM_COMMUNICATE_AARCH64.

> +    // Found a GUID, allocate memory to populate a communication buffer
> +    // with the GUID in it
> +    Status = mMmst->MmAllocatePool(EfiRuntimeServicesData, sizeof(EFI_MM_COMMUNICATE_HEADER), (VOID **) &GuidedEventContext);
> +    if (Status != EFI_SUCCESS) {
> +      DEBUG ((DEBUG_INFO, "Mem alloc failed - 0x%x\n", EventId));
> +      return Status;
> +    }
> +
> +    // Copy the GUID
> +    CopyGuid(&GuidedEventContext->HeaderGuid, &EventIdToGuidLookupTable[EventId]);
> +
> +    // Message Length is 0 'cause of the assumption mentioned above
> +    GuidedEventContext->MessageLength = 0;
> +  } else {
> +    // TODO: Perform parameter validation of NsCommBufferAddr

If this is being done (which is a must) then remove the TODO.

> +
> +    // This event id is the parent of multiple GUIDed handlers. Retrieve
> +    // the specific GUID from the communication buffer passed by the
> +    // caller.

This comment is outdated. It should be removed.

> +
> +    if (NsCommBufferAddr && (NsCommBufferAddr < mNsCommBuffer.PhysicalStart))
> +      return EFI_INVALID_PARAMETER;
> +

This check is not enough before the NsCommBufferAddr is dereferenced in the next
statement. There must be a check to ensure that NsCommBufferAddr points to
enough memory to hold a EFI_MM_COMMUNICATE_HEADER i.e.

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 *)NsCommBufferAddr)->MessageLength) +
> +                        sizeof(((EFI_MM_COMMUNICATE_HEADER *)NsCommBufferAddr)->HeaderGuid);

This check is more complicated that it should be. Can it be changed to:

((EFI_MM_COMMUNICATE_HEADER *) NsCommBufferAddr)->MessageLength + sizeof(EFI_MM_COMMUNICATE_HEADER)

> +
> +    // Alternative approach in case EL3 has preallocated the non-secure
> +    // buffer. MM Foundation is told about the buffer through the Hoblist
> +    // and is responsible for performing the bounds check.

Can this comment be reworded as the "alternative" approach is the only approach
possible at the moment.

> +    if (NsCommBufferAddr + NsCommBufferSize >=
> +      mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize)
> +        return EFI_INVALID_PARAMETER;
> +
> +
> +    // Now that the secure world can see the normal world buffer, allocate
> +    // memory to copy the communication buffer to the secure world.
> +    Status = mMmst->MmAllocatePool(EfiRuntimeServicesData, NsCommBufferSize, (VOID **) &GuidedEventContext);
> +    if (Status != EFI_SUCCESS) {
> +      DEBUG ((DEBUG_INFO, "Mem alloc failed - 0x%x\n", EventId));
> +      // TODO: Unmap secure memory before exiting to the normal world

This TODO is no longer relevant it seems.

> +      return Status;

These return statuses will be returned to the normal world as MM_COMMUNICATE
return codes. AllocatePool returns EFI_OUT_OF_RESOURCES which must be mapped to
a suitable error code as per the MM interface. Ditto for all other status values
that this file returns.
 
> +    }
> +
> +    // X1 contains the VA of the normal world memory accessible from
> +    // S-EL0
> +    CopyMem(GuidedEventContext, (CONST VOID *) NsCommBufferAddr, NsCommBufferSize);
> +  }
> +
> +  // Stash the pointer to the allocated Event Context for this CPU
> +  PerCpuGuidedEventContext[CpuNumber] = GuidedEventContext;
> +
> +  // TODO: Populate entire entry point context with valid information

I don't think we will be able to do this on AArch64. So lets remove this TODO.

> +  MmEntryPointContext.CurrentlyExecutingCpu = CpuNumber;
> +  MmEntryPointContext.NumberOfCpus = mMpInformationHobData->NumberOfProcessors;
> +
> +  // Populate the MM system table with MP and state information
> +  mMmst->CurrentlyExecutingCpu = CpuNumber;
> +  mMmst->NumberOfCpus = mMpInformationHobData->NumberOfProcessors;
> +  mMmst->CpuSaveStateSize = 0;
> +  mMmst->CpuSaveState = NULL;
> +
> +  mMmEntryPoint(&MmEntryPointContext);

It is worth NULL checking mMmEntryPoint!

> +
> +  // Free the memory allocation done earlier and reset the per-cpu context
> +  // TODO: Check for the return status of the FreePool API

Indeed

> +  ASSERT (GuidedEventContext);
> +  CopyMem ((VOID *)NsCommBufferAddr, (CONST VOID *) GuidedEventContext, NsCommBufferSize);
> +  mMmst->MmFreePool((VOID *) GuidedEventContext);

If this fails in the unlikely case them we should just return NO_MEMORY to the
normal world?

cheers,
Achin

> +  PerCpuGuidedEventContext[CpuNumber] = NULL;
> +
> +  return Status;
> +}
> +
> +EFI_STATUS
> +EFIAPI
> +MmFoundationEntryRegister(
> +  IN CONST EFI_MM_CONFIGURATION_PROTOCOL  *This,
> +  IN EFI_MM_ENTRY_POINT                    MmEntryPoint
> +  ) {
> +  // store the entry point in a global
> +  mMmEntryPoint = MmEntryPoint;
> +  return EFI_SUCCESS;
> +}
> +
> +/**
> +  This function is the main entry point for an MM handler dispatch
> +  or communicate-based callback.
> +
> +  @param  DispatchHandle  The unique handle assigned to this handler by MmiHandlerRegister().
> +  @param  Context         Points to an optional handler context which was specified when the handler was registered.
> +  @param  CommBuffer      A pointer to a collection of data in memory that will
> +                          be conveyed from a non-MM environment into an MM environment.
> +  @param  CommBufferSize  The size of the CommBuffer.
> +
> +  @return Status Code
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +PiMmCpuTpFwRootMmiHandler (
> +  IN     EFI_HANDLE               DispatchHandle,
> +  IN     CONST VOID               *Context,        OPTIONAL
> +  IN OUT VOID                     *CommBuffer,     OPTIONAL
> +  IN OUT UINTN                    *CommBufferSize  OPTIONAL
> +  )
> +{
> +  EFI_STATUS Status;
> +  UINTN      CpuNumber;
> +
> +  ASSERT (Context == NULL);
> +  ASSERT (CommBuffer == NULL);
> +  ASSERT (CommBufferSize == NULL);
> +
> +  CpuNumber = mMmst->CurrentlyExecutingCpu;
> +  if (!PerCpuGuidedEventContext[CpuNumber])
> +    return EFI_NOT_FOUND;
> +
> +  DEBUG ((DEBUG_INFO, "CommBuffer - 0x%x, CommBufferSize - 0x%x\n",
> +          PerCpuGuidedEventContext[CpuNumber],
> +          PerCpuGuidedEventContext[CpuNumber]->MessageLength));
> +
> +  Status = mMmst->MmiManage(&PerCpuGuidedEventContext[CpuNumber]->HeaderGuid,
> +                     NULL,
> +                     PerCpuGuidedEventContext[CpuNumber]->Data,
> +                     &PerCpuGuidedEventContext[CpuNumber]->MessageLength);
> +
> +  if (Status != EFI_SUCCESS) {
> +    DEBUG ((DEBUG_WARN, "Unable to manage Guided Event - %d\n", Status));
> +  }
> +
> +  return Status;
> +}
> diff --git a/StandaloneMmPkg/Drivers/CpuMm/Arm/Init.c b/StandaloneMmPkg/Drivers/CpuMm/Arm/Init.c
> new file mode 100644
> index 0000000000..9b48ea15c1
> --- /dev/null
> +++ b/StandaloneMmPkg/Drivers/CpuMm/Arm/Init.c
> @@ -0,0 +1,229 @@
> +/** @file
> +
> +  Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
> +  Copyright (c) 2011, ARM Limited. All rights reserved.

2011?

> +  Copyright (c) 2016 HP Development Company, L.P.
> +  Copyright (c) 2016-2017, ARM Limited. All rights reserved.
> +
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD License
> +  which accompanies this distribution.  The full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include <Base.h>
> +#include <Pi/PiMmCis.h>
> +#include <Library/Arm/StandaloneMmCoreEntryPoint.h>
> +#include <Library/DebugLib.h>
> +#include <Library/ArmSvcLib.h>
> +#include <Library/ArmLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/HobLib.h>
> +
> +#include <Protocol/DebugSupport.h> // for EFI_SYSTEM_CONTEXT
> +
> +#include <Guid/ZeroGuid.h>
> +#include <Guid/MmramMemoryReserve.h>
> +
> +
> +#include "PiMmStandloneArmTfCpuDriver.h"
> +
> +// GUID to identify HOB with whereabouts of communication buffer with Normal
> +// World
> +extern EFI_GUID gEfiStandaloneMmNonSecureBufferGuid;
> +
> +// GUID to identify HOB where the entry point of this CPU driver will be
> +// populated to allow the entry point driver to invoke it upon receipt of an
> +// event
> +extern EFI_GUID gEfiArmTfCpuDriverEpDescriptorGuid;
> +
> +//
> +// Private copy of the MM system table for future use
> +//
> +EFI_MM_SYSTEM_TABLE *mMmst = NULL;
> +
> +//
> +// Globals used to initialize the protocol
> +//
> +static EFI_HANDLE            mMmCpuHandle = NULL;
> +
> +EFI_STATUS
> +GetGuidedHobData (
> +  IN  VOID *HobList,
> +  IN  CONST EFI_GUID *HobGuid,
> +  OUT VOID **HobData)
> +{
> +  EFI_HOB_GUID_TYPE *Hob;
> +
> +  if (!HobList || !HobGuid || !HobData)
> +    return EFI_INVALID_PARAMETER;
> +
> +  Hob = GetNextGuidHob (HobGuid, HobList);
> +  if (!Hob)
> +    return EFI_NOT_FOUND;
> +
> +  *HobData = GET_GUID_HOB_DATA (Hob);
> +  if (!HobData)
> +    return EFI_NOT_FOUND;
> +
> +  return EFI_SUCCESS;
> +}
> +
> +EFI_STATUS
> +PiMmStandloneArmTfCpuDriverInitialize (
> +  IN EFI_HANDLE         ImageHandle,  // not actual imagehandle
> +  IN EFI_MM_SYSTEM_TABLE   *SystemTable  // not actual systemtable
> +  )
> +{
> +  ARM_TF_CPU_DRIVER_EP_DESCRIPTOR *CpuDriverEntryPointDesc;
> +  EFI_CONFIGURATION_TABLE         *ConfigurationTable;
> +  MP_INFORMATION_HOB_DATA         *MpInformationHobData;
> +  EFI_MMRAM_DESCRIPTOR            *NsCommBufMmramRange;
> +  EFI_STATUS                       Status;
> +  EFI_HANDLE                       DispatchHandle;
> +  UINT32                           MpInfoSize;
> +  UINTN                            Index;
> +  UINTN                            ArraySize;
> +  VOID                            *HobStart;
> +
> +  ASSERT (SystemTable != NULL);
> +  mMmst = SystemTable;
> +
> +  // publish the MM config protocol so the MM core can register its entry point
> +  Status = mMmst->MmInstallProtocolInterface (&mMmCpuHandle,
> +                                              &gEfiMmConfigurationProtocolGuid,
> +                                              EFI_NATIVE_INTERFACE,
> +                                              &mMmConfig);
> +  if (EFI_ERROR(Status)) {
> +    return Status;
> +  }
> +
> +  // publish the MM CPU save state protocol
> +  Status = mMmst->MmInstallProtocolInterface (&mMmCpuHandle,
> +    &gEfiMmCpuProtocolGuid, EFI_NATIVE_INTERFACE, &mMmCpuState);
> +  if (EFI_ERROR(Status)) {
> +    return Status;
> +  }

CPU State save access services have not been implemented on AArch64. Lets remove
this protocol.

> +
> +  // register the root MMI handler
> +  Status = mMmst->MmiHandlerRegister (PiMmCpuTpFwRootMmiHandler,
> +                                      NULL,
> +                                      &DispatchHandle);
> +  if (EFI_ERROR(Status)) {
> +    return Status;
> +  }
> +
> +  // Retrieve the Hoblist from the MMST to extract the details of the NS
> +  // communication buffer that has been reserved by S-EL1/EL3
> +  ConfigurationTable = mMmst->MmConfigurationTable;
> +  for (Index = 0; Index < mMmst->NumberOfTableEntries; Index++) {
> +    if (CompareGuid (&gEfiHobListGuid, &(ConfigurationTable[Index].VendorGuid))) {
> +      break;
> +    }
> +  }
> +
> +  // Bail out if the Hoblist could not be found
> +  // TODO: This could also mean that
> +  // the normal world will never interact synchronously with the MM environment

All TODOs must be removed and this one in particular is not relevant now afaics.

> +  if (Index >= mMmst->NumberOfTableEntries) {
> +    DEBUG ((DEBUG_INFO, "Hoblist not found - 0x%x\n", Index));
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +
> +  HobStart = ConfigurationTable[Index].VendorTable;
> +
> +  //
> +  // Locate the HOB with the buffer to populate the entry point of this driver
> +  //
> +  Status = GetGuidedHobData (
> +            HobStart,
> +            &gEfiArmTfCpuDriverEpDescriptorGuid,
> +            (VOID **) &CpuDriverEntryPointDesc);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_INFO, "ArmTfCpuDriverEpDesc HOB data extraction failed - 0x%x\n", Status));
> +    return Status;
> +  }
> +
> +  // Share the entry point of the CPU driver
> +  DEBUG ((DEBUG_INFO, "Sharing Cpu Driver EP *0x%lx = 0x%lx\n",
> +    (UINT64) CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr,
> +    (UINT64) PiMmStandloneArmTfCpuDriverEntry));
> +  *(CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr) = PiMmStandloneArmTfCpuDriverEntry;
> +
> +  // Find the descriptor that contains the whereabouts of the buffer for
> +  // communication with the Normal world.
> +  Status = GetGuidedHobData (
> +            HobStart,
> +            &gEfiStandaloneMmNonSecureBufferGuid,
> +            (VOID **) &NsCommBufMmramRange);
> +  if (EFI_ERROR(Status)) {
> +    DEBUG ((DEBUG_INFO, "NsCommBufMmramRange HOB data extraction failed - 0x%x\n", Status));
> +    return Status;
> +  }
> +
> +  DEBUG ((DEBUG_INFO, "mNsCommBuffer.PhysicalStart - 0x%lx\n", (UINT64) NsCommBufMmramRange->PhysicalStart));
> +  DEBUG ((DEBUG_INFO, "mNsCommBuffer.PhysicalSize - 0x%lx\n", (UINT64) NsCommBufMmramRange->PhysicalSize));
> +
> +  CopyMem (&mNsCommBuffer, NsCommBufMmramRange, sizeof(EFI_MMRAM_DESCRIPTOR));
> +  DEBUG ((DEBUG_INFO, "mNsCommBuffer: 0x%016lx - 0x%lx\n", mNsCommBuffer.CpuStart, mNsCommBuffer.PhysicalSize));
> +
> +  //
> +  // Extract the MP information from the Hoblist
> +  //
> +  Status = GetGuidedHobData (HobStart,
> +                             &gMpInformationHobGuid,
> +                             (VOID **) &MpInformationHobData);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_INFO, "MpInformationHob extraction failed - 0x%x\n", Status));
> +    return Status;
> +  }
> +
> +  //
> +  // Allocate memory for the MP information and copy over the MP information
> +  // passed by Trusted Firmware. Use the number of processors passed in the HOB
> +  // to copy the processor information
> +  //
> +  MpInfoSize = sizeof (MP_INFORMATION_HOB_DATA) +
> +               (sizeof (EFI_PROCESSOR_INFORMATION) *
> +               MpInformationHobData->NumberOfProcessors);
> +  Status = mMmst->MmAllocatePool (EfiRuntimeServicesData,
> +                                  MpInfoSize,
> +                                  (void **) &mMpInformationHobData);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_INFO, "mMpInformationHobData mem alloc failed - 0x%x\n", Status));
> +    return Status;
> +  }
> +
> +  CopyMem (mMpInformationHobData, MpInformationHobData, MpInfoSize);
> +
> +  // Print MP information
> +  DEBUG ((DEBUG_INFO, "mMpInformationHobData: 0x%016lx - 0x%lx\n",
> +          mMpInformationHobData->NumberOfProcessors,
> +          mMpInformationHobData->NumberOfEnabledProcessors));
> +  for (Index = 0; Index < mMpInformationHobData->NumberOfProcessors; Index++) {
> +    DEBUG ((DEBUG_INFO, "mMpInformationHobData[0x%lx]: %d, %d, %d\n",
> +            mMpInformationHobData->ProcessorInfoBuffer[Index].ProcessorId,
> +            mMpInformationHobData->ProcessorInfoBuffer[Index].Location.Package,
> +            mMpInformationHobData->ProcessorInfoBuffer[Index].Location.Core,
> +            mMpInformationHobData->ProcessorInfoBuffer[Index].Location.Thread));
> +  }
> +
> +  //
> +  // Allocate memory for a table to hold pointers to a
> +  // EFI_MM_COMMUNICATE_HEADER for each CPU
> +  //
> +  ArraySize = sizeof (EFI_MM_COMMUNICATE_HEADER *) *
> +              mMpInformationHobData->NumberOfEnabledProcessors;
> +  Status = mMmst->MmAllocatePool (EfiRuntimeServicesData,
> +                                  ArraySize,
> +                                  (VOID **) &PerCpuGuidedEventContext);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_INFO, "PerCpuGuidedEventContext mem alloc failed - 0x%x\n", Status));
> +    return Status;
> +  }
> +  return Status;
> +}
> diff --git a/StandaloneMmPkg/Drivers/CpuMm/Arm/PiMmStandloneArmTfCpuDriver.h b/StandaloneMmPkg/Drivers/CpuMm/Arm/PiMmStandloneArmTfCpuDriver.h
> new file mode 100644
> index 0000000000..17cefd171c
> --- /dev/null
> +++ b/StandaloneMmPkg/Drivers/CpuMm/Arm/PiMmStandloneArmTfCpuDriver.h
> @@ -0,0 +1,89 @@
> +/** @file
> +  Private header with declarations and definitions specific to the MM Standalone
> +  CPU driver
> +
> +  Copyright (c) 2017, ARM Limited. All rights reserved.
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD License
> +  which accompanies this distribution.  The full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef _ARM_TF_CPU_DRIVER_H_
> +#define _ARM_TF_CPU_DRIVER_H_
> +
> +#include <Protocol/MmCommunication.h>
> +#include <Protocol/MmConfiguration.h>
> +#include <Protocol/MmCpu.h>
> +#include <Guid/MpInformation.h>
> +
> +//
> +// Common declarations and definitions
> +//
> +#define EVENT_ID_MM_COMMUNICATE_SMC     0x10

This is not used any longer

> +
> +//
> +// CPU driver initialization specific declarations
> +//
> +extern EFI_MM_SYSTEM_TABLE *mMmst;
> +
> +//
> +// CPU State Save protocol specific declarations
> +//
> +extern EFI_MM_CPU_PROTOCOL mMmCpuState;
> +
> +EFI_STATUS
> +EFIAPI
> +MmReadSaveState (
> +  IN CONST EFI_MM_CPU_PROTOCOL   *This,
> +  IN UINTN                        Width,
> +  IN EFI_MM_SAVE_STATE_REGISTER  Register,
> +  IN UINTN                        CpuIndex,
> +  OUT VOID                        *Buffer
> +  );
> +
> +EFI_STATUS
> +EFIAPI
> +MmWriteSaveState (
> +  IN CONST EFI_MM_CPU_PROTOCOL   *This,
> +  IN UINTN                        Width,
> +  IN EFI_MM_SAVE_STATE_REGISTER  Register,
> +  IN UINTN                        CpuIndex,
> +  IN CONST VOID                   *Buffer
> +  );

This protoocl is not implemented

> +
> +//
> +// MM event handling specific declarations
> +//
> +extern EFI_MM_COMMUNICATE_HEADER    **PerCpuGuidedEventContext;
> +extern EFI_MMRAM_DESCRIPTOR          mNsCommBuffer;
> +extern MP_INFORMATION_HOB_DATA       *mMpInformationHobData;
> +extern EFI_MM_CONFIGURATION_PROTOCOL mMmConfig;
> +
> +EFI_STATUS
> +PiMmStandloneArmTfCpuDriverEntry (
> +  IN UINTN EventId,
> +  IN UINTN CpuNumber,
> +  IN UINTN NsCommBufferAddr
> +  );
> +
> +EFI_STATUS
> +EFIAPI
> +PiMmCpuTpFwRootMmiHandler (
> +  IN     EFI_HANDLE               DispatchHandle,
> +  IN     CONST VOID               *Context,        OPTIONAL
> +  IN OUT VOID                     *CommBuffer,     OPTIONAL
> +  IN OUT UINTN                    *CommBufferSize  OPTIONAL
> +  );
> +
> +EFI_STATUS _PiMmStandloneArmTfCpuDriverEntry (
> +  IN UINTN EventId,
> +  IN UINTN CpuNumber,
> +  IN UINTN NsCommBufferAddr
> +  );
> +
> +#endif
> diff --git a/StandaloneMmPkg/Drivers/CpuMm/Arm/PiMmStandloneArmTfCpuDriver.inf b/StandaloneMmPkg/Drivers/CpuMm/Arm/PiMmStandloneArmTfCpuDriver.inf
> new file mode 100644
> index 0000000000..baf6d957bb
> --- /dev/null
> +++ b/StandaloneMmPkg/Drivers/CpuMm/Arm/PiMmStandloneArmTfCpuDriver.inf
> @@ -0,0 +1,60 @@
> +#/** @file
> +#
> +#  Standalone MM CPU driver for ARM Standard Platforms
> +#
> +#  Copyright (c) 2009, Apple Inc. All rights reserved.<BR>
> +#  Copyright (c) 2016 HP Development Company, L.P.
> +#  Copyright (c) 2017, ARM Limited. All rights reserved.
> +#
> +#  This program and the accompanying materials
> +#  are licensed and made available under the terms and conditions of the BSD License
> +#  which accompanies this distribution.  The full text of the license may be found at
> +#  http://opensource.org/licenses/bsd-license.php
> +#
> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +#**/
> +
> +[Defines]
> +  INF_VERSION                    = 0x0001001A
> +  BASE_NAME                      = PiMmStandloneArmTfCpuDriver
> +  FILE_GUID                      = 58F7A62B-6280-42A7-BC38-10535A64A92C
> +  MODULE_TYPE                    = MM_STANDALONE
> +  VERSION_STRING                 = 1.0
> +  PI_SPECIFICATION_VERSION       = 0x00010032
> +  ENTRY_POINT                    = PiMmStandloneArmTfCpuDriverInitialize
> +
> +[Sources]
> +  Init.c
> +  EventHandle.c
> +  StateSave.c

Not needed.

> +
> +[Packages]
> +  ArmPkg/ArmPkg.dec
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  StandaloneMmPkg/StandaloneMmPkg.dec
> +
> +[LibraryClasses]
> +  ArmLib
> +  ArmSvcLib
> +  BaseMemoryLib
> +  DebugLib
> +  HobLib
> +  StandaloneMmDriverEntryPoint
> +
> +[Protocols]
> +  gEfiMmConfigurationProtocolGuid                        # PROTOCOL ALWAYS_PRODUCED
> +  gEfiMmCpuProtocolGuid                                  # PROTOCOL ALWAYS_PRODUCED
> +
> +[Guids]
> +  gEfiHobListGuid
> +  gEfiMmPeiMmramMemoryReserveGuid
> +  gZeroGuid
> +  gMpInformationHobGuid
> +  gEfiStandaloneMmNonSecureBufferGuid
> +  gEfiArmTfCpuDriverEpDescriptorGuid
> +
> +[Depex]
> +  TRUE
> diff --git a/StandaloneMmPkg/Drivers/CpuMm/Arm/StateSave.c b/StandaloneMmPkg/Drivers/CpuMm/Arm/StateSave.c
> new file mode 100644
> index 0000000000..c5155e1b31
> --- /dev/null
> +++ b/StandaloneMmPkg/Drivers/CpuMm/Arm/StateSave.c
> @@ -0,0 +1,51 @@
> +/** @file
> +
> +  Copyright (c) 2016 HP Development Company, L.P.
> +  Copyright (c) 2016-2017, ARM Limited. All rights reserved.
> +
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD License
> +  which accompanies this distribution.  The full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include <Base.h>
> +#include <Pi/PiSmmCis.h>
> +#include <Library/DebugLib.h>
> +
> +#include "PiMmStandloneArmTfCpuDriver.h"
> +
> +EFI_MM_CPU_PROTOCOL mMmCpuState = {
> +  MmReadSaveState,
> +  MmWriteSaveState
> +};
> +
> +EFI_STATUS
> +EFIAPI
> +MmReadSaveState(
> +  IN CONST EFI_MM_CPU_PROTOCOL   *This,
> +  IN UINTN                        Width,
> +  IN EFI_MM_SAVE_STATE_REGISTER  Register,
> +  IN UINTN                        CpuIndex,
> +  OUT VOID                        *Buffer
> +  ) {
> +  // todo: implement
> +  return EFI_UNSUPPORTED;
> +}
> +
> +EFI_STATUS
> +EFIAPI
> +MmWriteSaveState(
> +  IN CONST EFI_MM_CPU_PROTOCOL   *This,
> +  IN UINTN                        Width,
> +  IN EFI_MM_SAVE_STATE_REGISTER  Register,
> +  IN UINTN                        CpuIndex,
> +  IN CONST VOID                   *Buffer
> +  ) {
> +  // todo: implement
> +  return EFI_UNSUPPORTED;
> +}

This file must be removed as described earlier.

> diff --git a/StandaloneMmPkg/Include/Guid/MpInformation.h b/StandaloneMmPkg/Include/Guid/MpInformation.h
> new file mode 100644
> index 0000000000..4e9a3c04ec
> --- /dev/null
> +++ b/StandaloneMmPkg/Include/Guid/MpInformation.h
> @@ -0,0 +1,41 @@
> +/** @file
> +  EFI MP information protocol provides a lightweight MP_SERVICES_PROTOCOL.
> +
> +  MP information protocol only provides static information of MP processor.
> +
> +  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2016 - 2017, ARM Limited. All rights reserved.<BR>
> +
> +  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 _MP_INFORMATION_H_
> +#define _MP_INFORMATION_H_
> +
> +#include <Protocol/MpService.h>
> +#include <PiPei.h>
> +#include <Ppi/SecPlatformInformation.h>
> +
> +#define MP_INFORMATION_GUID \
> +  { \
> +    0xba33f15d, 0x4000, 0x45c1, {0x8e, 0x88, 0xf9, 0x16, 0x92, 0xd4, 0x57, 0xe3}  \
> +  }
> +
> +#pragma pack(1)
> +typedef struct {
> +  UINT64                     NumberOfProcessors;
> +  UINT64                     NumberOfEnabledProcessors;
> +  EFI_PROCESSOR_INFORMATION  ProcessorInfoBuffer[];
> +} MP_INFORMATION_HOB_DATA;
> +#pragma pack()
> +
> +extern EFI_GUID gMpInformationHobGuid;
> +
> +#endif
> -- 
> 2.16.2
>