From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.107.3.52; helo=eur03-am5-obe.outbound.protection.outlook.com; envelope-from=achin.gupta@arm.com; receiver=edk2-devel@lists.01.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30052.outbound.protection.outlook.com [40.107.3.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 03DDB211D56BC for ; Wed, 6 Mar 2019 08:58:47 -0800 (PST) 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:X-MS-Exchange-SenderADCheck; bh=eRt9yGb2VUVJhrKIP2OjQPLD5yY+EyhIHuthkqn4AOI=; b=k7yPCBQxd15c6qE750UeU5B6guSvkKnPwkmpS+vgCQgRetMv2v0stE4OrZLKs8b4DDOOUucRWWXxCi/bxuISFzcb9ydJ868377rJoc/aPV50Qylcc0+LsBiDQnNxCU5bxmas/UDSFePUbTeda8Dh1ey6bx6zjeYbFc62W9jfIzM= Received: from AM0PR08MB2980.eurprd08.prod.outlook.com (52.134.92.153) by AM0PR08MB4481.eurprd08.prod.outlook.com (20.179.36.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.17; Wed, 6 Mar 2019 16:58:45 +0000 Received: from AM0PR08MB2980.eurprd08.prod.outlook.com ([fe80::a133:50fa:bbbe:81a6]) by AM0PR08MB2980.eurprd08.prod.outlook.com ([fe80::a133:50fa:bbbe:81a6%5]) with mapi id 15.20.1665.020; Wed, 6 Mar 2019 16:58:45 +0000 From: Achin Gupta To: Ard Biesheuvel CC: "edk2-devel@lists.01.org" , Supreeth Venkatesh , Jiewen Yao , Leif Lindholm , Jagadeesh Ujja , nd Thread-Topic: [PATCH 10/10] ArmPkg/MmCommunicationDxe: signal architected PI events into MM context Thread-Index: AQHU01f5SIrfF7+4WUiqIts3FFy1GaX+1P8A Date: Wed, 6 Mar 2019 16:58:45 +0000 Message-ID: <20190306165838.GV21602@mac-ubuntu-vm> References: <20190305133248.4828-1-ard.biesheuvel@linaro.org> <20190305133248.4828-11-ard.biesheuvel@linaro.org> In-Reply-To: <20190305133248.4828-11-ard.biesheuvel@linaro.org> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Mutt/1.9.4 (2018-02-28) x-originating-ip: [95.146.138.15] x-clientproxiedby: LNXP265CA0014.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::26) To AM0PR08MB2980.eurprd08.prod.outlook.com (2603:10a6:208:5b::25) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Achin.Gupta@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d565e223-a30c-460c-82fc-08d6a254fe9d x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB4481; x-ms-traffictypediagnostic: AM0PR08MB4481: nodisclaimer: True x-microsoft-exchange-diagnostics: 1; AM0PR08MB4481; 20:tv2L/XPg9arcPbQBWHTr1t25LT+YYqiKnbfLIClD/9LvyhiTydWoGjSoZTBOe176xlICrgG8nJl9b03UT3Tmna76fovZ2g2W7eu/l1XRlB+495pOBwuL+ReZx6r+4Bl6xmxE5HwSIFGXNnrkPe99J1ziK99dmWhpspFQ3DEtIQ0= x-microsoft-antispam-prvs: x-forefront-prvs: 0968D37274 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6029001)(7916004)(366004)(39860400002)(396003)(346002)(136003)(376002)(199004)(189003)(14444005)(256004)(478600001)(9686003)(486006)(2906002)(44832011)(53936002)(6512007)(476003)(11346002)(6916009)(81166006)(6506007)(72206003)(8936002)(7736002)(8676002)(81156014)(229853002)(52116002)(3846002)(6246003)(6116002)(102836004)(33656002)(25786009)(386003)(99286004)(4326008)(76176011)(66066001)(446003)(5660300002)(105586002)(58126008)(54906003)(316002)(68736007)(106356001)(1076003)(86362001)(14454004)(33716001)(305945005)(6436002)(71190400001)(71200400001)(186003)(97736004)(26005)(6486002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB4481; H:AM0PR08MB2980.eurprd08.prod.outlook.com; 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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: fNBBejMBGDGEbmuBlDSOM+veksHvmUfZcsTxgcWAdYCHF/8tvLbkhNzNgOlKzNm8ucKbbsPGcs2mB12AijHpBRXdE0eC2jDh5DnygG0QewKsjTUkSq2f3PU+qz6b9jTGbEtRs/LNIauUommDMT2YLiDRHIPjw8ospm8VwQVuIKFilGCwva+yLoSias1KgD/UCuXhAe7Ys8AWswp8a6onO0cBAJ3Vr8kvlNtRgDjedBFzLmbXPohYuaaN/XDh7wy1pl9toBLcA8c1CzmP7zDIdZFObVm42IkwRo32njiVbA1A853LZ0s6a9g81jQN3zTumU2cYjjUz1FDib3jvOFTGQuwanT/eZMd3tDw165k1+Pwuq+1upTi/xF6xUpadEdsbuAnuIb+mvbVnN4QgvSPkKzXgL1kyCHNvrY3TEz1DSM= MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: d565e223-a30c-460c-82fc-08d6a254fe9d X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Mar 2019 16:58:45.4713 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4481 Subject: Re: [PATCH 10/10] ArmPkg/MmCommunicationDxe: signal architected PI events into MM context X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Mar 2019 16:58:48 -0000 X-List-Received-Date: Wed, 06 Mar 2019 16:58:48 -0000 X-List-Received-Date: Wed, 06 Mar 2019 16:58:48 -0000 X-List-Received-Date: Wed, 06 Mar 2019 16:58:48 -0000 X-List-Received-Date: Wed, 06 Mar 2019 16:58:48 -0000 X-List-Received-Date: Wed, 06 Mar 2019 16:58:48 -0000 X-List-Received-Date: Wed, 06 Mar 2019 16:58:48 -0000 X-List-Received-Date: Wed, 06 Mar 2019 16:58:48 -0000 X-List-Received-Date: Wed, 06 Mar 2019 16:58:48 -0000 X-List-Received-Date: Wed, 06 Mar 2019 16:58:48 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-ID: <5A9D17AC571F1847894F2CEB381DD336@eurprd08.prod.outlook.com> Content-Transfer-Encoding: quoted-printable Reviewed-by: achin.gupta@arm.com On Tue, Mar 05, 2019 at 02:32:48PM +0100, Ard Biesheuvel wrote: > PI defines a few architected events that have significance in the MM > context as well as in the non-secure DXE context. So register notify > handlers for these events, and relay them into the standalone MM world. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf | 5 +++ > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 47 +++++++++++++= ++++++- > 2 files changed, 50 insertions(+), 2 deletions(-) > > diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf b/ArmP= kg/Drivers/MmCommunicationDxe/MmCommunication.inf > index 88beafa39c05..8bf269270f9d 100644 > --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf > +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf > @@ -48,6 +48,11 @@ [LibraryClasses] > [Protocols] > gEfiMmCommunicationProtocolGuid ## PRODUCES > > +[Guids] > + gEfiEndOfDxeEventGroupGuid > + gEfiEventExitBootServicesGuid > + gEfiEventReadyToBootGuid > + > [Pcd.common] > gArmTokenSpaceGuid.PcdMmBufferBase > gArmTokenSpaceGuid.PcdMmBufferSize > diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg= /Drivers/MmCommunicationDxe/MmCommunication.c > index feb9fa9f4ead..3203cf801a19 100644 > --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c > +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c > @@ -265,6 +265,43 @@ GetMmCompatibility () > return Status; > } > > +STATIC EFI_GUID* CONST mGuidedEventGuid[] =3D { > + &gEfiEndOfDxeEventGroupGuid, > + &gEfiEventExitBootServicesGuid, > + &gEfiEventReadyToBootGuid, > +}; > + > +STATIC EFI_EVENT mGuidedEvent[ARRAY_SIZE (mGuidedEventGuid)]; > + > +/** > + Event notification that is fired when GUIDed Event Group is signaled. > + > + @param Event The Event that is being processed, not u= sed. > + @param Context Event Context, not used. > + > +**/ > +STATIC > +VOID > +EFIAPI > +MmGuidedEventNotify ( > + IN EFI_EVENT Event, > + IN VOID *Context > + ) > +{ > + EFI_MM_COMMUNICATE_HEADER Header; > + UINTN Size; > + > + // > + // Use Guid to initialize EFI_SMM_COMMUNICATE_HEADER structure > + // > + CopyGuid (&Header.HeaderGuid, Context); > + Header.MessageLength =3D 1; > + Header.Data[0] =3D 0; > + > + Size =3D sizeof (Header); > + MmCommunicationCommunicate (&mMmCommunication, &Header, &Size); > +} > + > /** > The Entry Point for MM Communication > > @@ -287,6 +324,7 @@ MmCommunicationInitialize ( > ) > { > EFI_STATUS Status; > + UINTN Index; > > // Check if we can make the MM call > Status =3D GetMmCompatibility (); > @@ -351,8 +389,13 @@ MmCommunicationInitialize ( > NULL, > &mSetVirtualAddressMapEvent > ); > - if (Status =3D=3D EFI_SUCCESS) { > - return Status; > + ASSERT_EFI_ERROR (Status); > + > + for (Index =3D 0; Index < ARRAY_SIZE (mGuidedEventGuid); Index++) { > + Status =3D gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, > + MmGuidedEventNotify, mGuidedEventGuid[Index], > + mGuidedEventGuid[Index], &mGuidedEvent[Index]); > + ASSERT_EFI_ERROR (Status); > } > > gBS->UninstallProtocolInterface ( > -- > 2.20.1 >