From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on060f.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe44::60f]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DB62021A0483A for ; Wed, 12 Apr 2017 13:34:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=NEQ/UEA1pc6VUhp+D1kyh0vq6uvIv1KRJVbb/ceen3w=; b=gGzkNh3RrZji+VohVw3t+bq0FNB3wl5T3rg1FNnT2sZZba8bsVabPDXFoQeGLb0OCSau1srvDtiLa69zFCp1tJtBrBYuZhr+dzxD8yEwiVNVL+UVZao1ZspL4yaOm3HldH8eQEwXMqpUdbnx7VkWArYcnrqNXcEhFBxv9pqpq20= Received: from DM5PR12MB1243.namprd12.prod.outlook.com (10.168.237.22) by CY4PR1201MB0133.namprd12.prod.outlook.com (10.172.78.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.17; Wed, 12 Apr 2017 20:34:20 +0000 Received: from DM5PR12MB1243.namprd12.prod.outlook.com ([10.168.237.22]) by DM5PR12MB1243.namprd12.prod.outlook.com ([10.168.237.22]) with mapi id 15.01.1019.025; Wed, 12 Apr 2017 20:34:19 +0000 From: "Duran, Leo" To: "Kinney, Michael D" , "edk2-devel@ml01.01.org" CC: Laszlo Ersek , "Tian, Feng" , "Singh, Brijesh" , "Zeng, Star" Thread-Topic: [edk2] [PATCH] MdeModulePkg: Add EFI_GCD_MEMORY_SPACE_NOTIFY_PROTOCOL Thread-Index: AQHSs76MLkQIdnpq4U2h4aFYdb9TEqHCFYwAgAAL9oCAAA0bwA== Date: Wed, 12 Apr 2017 20:34:19 +0000 Message-ID: References: <1492023400-16132-1-git-send-email-leo.duran@amd.com> <1492023400-16132-2-git-send-email-leo.duran@amd.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=amd.com; x-originating-ip: [165.204.53.123] x-microsoft-exchange-diagnostics: 1; CY4PR1201MB0133; 7:6opc/Y40P0TBwDELvOdyHpdpOAU/sd43O3V7W0ipR11jg6jqu5IdcXPL05CFdXp/+QpTynkTVTIZcPHQuG06RwJlBOP+6Hu9uDOpsC0pNWsSuRCHWyEtoUu9YM+eDqN91gIILW7a+wfkENWp3O/fd+I+dbCSfH/Q8nWcVyXEwnNfwVnY7E6di/zHdxuYxfrIWpGloPYCFY0tJupr0WFOoUaD1YhHoZm4L3CKccZXLCEpdTq7COs5ZxwCP7LXAMKcSfrAuI7l4lDtANheBhJUv6LpsodAQmdbjRWS3FFFJxIoTsz5uuWqWhplKOir0mxImdd3ZNUlIMfzJKS+ZYyntw==; 20:SAJQ28/W4ew8H/KA+H8UoeCdLKbQYu/2AEghvPH7xXh7x2/AbZYMKMEOAcxc/2oXGlQTMUve0g67kAHBXbwy4QzbwV1HUnhgjJVWcy4uvtlQEGQPspY/23M4fzla9PkTaDEBzYFPQr8NpdYLrCjBhN0pWdcBbk10pYuD6VOgZ0YYG6xhU/6ZZeUp/tJjxmMX/39WHG5LtOtGhj3xBfAaiURA5Z+NqcUX3zHJIond/+5P9XCOaW1MR4cKklEMHqgm x-forefront-antispam-report: SFV:SKI; SCL:-1SFV:NSPM; SFS:(10009020)(6009001)(39850400002)(39400400002)(39860400002)(39410400002)(39450400003)(39840400002)(377454003)(13464003)(53936002)(6246003)(966004)(33656002)(6306002)(74316002)(54075001)(5660300001)(81166006)(8676002)(8936002)(2950100002)(76176999)(3846002)(7696004)(102836003)(50986999)(575784001)(38730400002)(54356999)(189998001)(6116002)(53376002)(4326008)(305945005)(9686003)(66066001)(53546009)(3280700002)(2906002)(77096006)(3660700001)(2501003)(122556002)(25786009)(2900100001)(6436002)(6506006)(55016002)(16799955002)(99286003)(54906002)(86362001)(15188155005)(229853002)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR1201MB0133; H:DM5PR12MB1243.namprd12.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; x-ms-office365-filtering-correlation-id: 0b7b899a-4645-4c32-76c6-08d481e34ba3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081); SRVR:CY4PR1201MB0133; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(767451399110)(162533806227266)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123555025)(20161123562025)(6072148); SRVR:CY4PR1201MB0133; BCL:0; PCL:0; RULEID:; SRVR:CY4PR1201MB0133; x-forefront-prvs: 027578BB13 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Apr 2017 20:34:19.1244 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB0133 Subject: Re: [PATCH] MdeModulePkg: Add EFI_GCD_MEMORY_SPACE_NOTIFY_PROTOCOL X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Apr 2017 20:34:22 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Mike, Please see my replies below. Leo. > -----Original Message----- > From: Kinney, Michael D [mailto:michael.d.kinney@intel.com] > Sent: Wednesday, April 12, 2017 2:39 PM > To: Duran, Leo ; edk2-devel@ml01.01.org; Kinney, > Michael D > Cc: Laszlo Ersek ; Tian, Feng ; > Singh, Brijesh ; Zeng, Star > Subject: RE: [edk2] [PATCH] MdeModulePkg: Add > EFI_GCD_MEMORY_SPACE_NOTIFY_PROTOCOL >=20 > Hi Leo, >=20 > DXE Main is supposed to use Arch Protocols for platform specific behavior= . >=20 > In this case, can the CPU Arch Protocol SetMemoryAttributes() function be > used to customize behavior? [Duran, Leo] DxeMain supports a list of Arch protocols and also a list of = optional protocols. SetMemoryAttributes() is a service provided by GCD, via CoreConvertSpace(),= just as Add/RemoveMemorySpace(). The behavior we need is a notification into OvmfPkg as GCD gets called to A= dd/RemoveMemorySpace(), not just if/when GCD gets called to SetMemoryAttrib= utes(). BTW, SetMemoryAttributes() may get called on any range, without specifying = type (whereas we're interested in MMIO ranges, which are specified in ADD o= perations) >=20 > In other modules that add/remove/modify MMIO, gDS- > >SetMemorySpaceAttributes() Is called to set memory space attributed such > as cachability. Can the module that is adding/removing memory regions fr= om > GCD also call > gDS-> SetMemorySpaceAttributes() so a CPU specific module can perform > extra actions? >=20 > Thanks, >=20 > Mike >=20 >=20 >=20 > > -----Original Message----- > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > > Leo Duran > > Sent: Wednesday, April 12, 2017 11:57 AM > > To: edk2-devel@ml01.01.org > > Cc: Laszlo Ersek ; Tian, Feng > > ; Leo Duran ; Brijesh Singh > > ; Zeng, Star > > Subject: [edk2] [PATCH] MdeModulePkg: Add > > EFI_GCD_MEMORY_SPACE_NOTIFY_PROTOCOL > > > > GCD consumes the protocol to issue a Notify() on Add/Remove operations. > > > > The intended use-case is to allow OvmfPkg take actions on behalf of an > > SEV-enabled guest. > > > > The new protocol is simply added to the list of optional protocols > > handled by DxeMain, and as such leverages the existing DxeProtocolNotif= y > framework. > > > > Cc: Feng Tian > > Cc: Star Zeng > > Cc: Laszlo Ersek > > Cc: Brijesh Singh > > Contributed-under: TianoCore Contribution Agreement 1.0 > > Signed-off-by: Leo Duran > > --- > > MdeModulePkg/Core/Dxe/DxeMain.h | 10 +++- > > MdeModulePkg/Core/Dxe/DxeMain.inf | 4 ++ > > MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 7 +++ > > MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c | 9 ++- > > MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 8 +++ > > .../Include/Protocol/GcdMemorySpaceNotify.h | 65 > ++++++++++++++++++++++ > > MdeModulePkg/MdeModulePkg.dec | 3 + > > 7 files changed, 100 insertions(+), 6 deletions(-) create mode > > 100644 MdeModulePkg/Include/Protocol/GcdMemorySpaceNotify.h > > > > diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h > > b/MdeModulePkg/Core/Dxe/DxeMain.h index 1a0babb..8a037ff 100644 > > --- a/MdeModulePkg/Core/Dxe/DxeMain.h > > +++ b/MdeModulePkg/Core/Dxe/DxeMain.h > > @@ -3,6 +3,8 @@ > > internal structure and functions used by DxeCore module. > > > > Copyright (c) 2006 - 2017, Intel Corporation. All rights > > reserved.
> > +Copyright (c) 2017, AMD Incorporated. 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 @@ -17,7 +19,6 @@ WITHOUT WARRANTIES OR > REPRESENTATIONS OF > > ANY KIND, EITHER EXPRESS OR IMPLIED. > > #define _DXE_MAIN_H_ > > > > > > - > > #include > > > > #include > > @@ -53,6 +54,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF > ANY KIND, > > EITHER EXPRESS OR IMPLIED. > > #include > > #include > > #include > > +#include > > + > > #include #include > > #include > @@ > > -296,12 +299,13 @@ extern EFI_RUNTIME_ARCH_PROTOCOL > gRuntimeTemplate; > > > > extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE > > gLoadModuleAtFixAddressConfigurationTable; > > extern BOOLEAN > > gLoadFixedAddressCodeMemoryReady; > > + > > +extern EFI_GCD_MEMORY_SPACE_NOTIFY_PROTOCOL > *gGcdMemorySpaceNotify; > > + > > // > > // Service Initialization Functions > > // > > > > - > > - > > /** > > Called to initialize the pool. > > > > diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf > > b/MdeModulePkg/Core/Dxe/DxeMain.inf > > index 30d5984..888a16f 100644 > > --- a/MdeModulePkg/Core/Dxe/DxeMain.inf > > +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf > > @@ -4,6 +4,8 @@ > > # It provides an implementation of DXE Core that is compliant with DX= E > CIS. > > # > > # Copyright (c) 2006 - 2017, Intel Corporation. All rights > > reserved.
> > +# Copyright (c) 2017, AMD Incorporated. 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 @@ -162,6 +164,8 @@ > > gEfiSmmBase2ProtocolGuid ## SOMETIMES_CONSUMES > > gEfiBlockIoProtocolGuid ## SOMETIMES_CONSUMES > > > > + gEfiGcdMemorySpaceNotifyProtocolGuid ## CONSUMES > > + > > # Arch Protocols > > gEfiBdsArchProtocolGuid ## CONSUMES > > gEfiCpuArchProtocolGuid ## CONSUMES > > diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c > > b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c > > index 91e94a7..46b68da 100644 > > --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c > > +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c > > @@ -2,6 +2,8 @@ > > DXE Core Main Entry Point > > > > Copyright (c) 2006 - 2017, Intel Corporation. All rights > > reserved.
> > +Copyright (c) 2017, AMD Incorporated. 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 > > @@ -42,6 +44,11 @@ EFI_GUID *gDxeCoreFileName= ; > > EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage; > > > > // > > +// DXE Core global for GCD notification protocol // > > +EFI_GCD_MEMORY_SPACE_NOTIFY_PROTOCOL > *gGcdMemorySpaceNotify =3D NULL; > > + > > +// > > // DXE Core Module Variables > > // > > EFI_BOOT_SERVICES mBootServices =3D { > > diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c > > b/MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c > > index ea7c610..2314e34 100644 > > --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c > > +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c > > @@ -4,6 +4,8 @@ > > events that represent the Architectural Protocols. > > > > Copyright (c) 2006 - 2014, Intel Corporation. All rights > > reserved.
> > +Copyright (c) 2017, AMD Incorporated. 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 @@ -45,9 +47,10 @@ EFI_CORE_PROTOCOL_NOTIFY_ENTRY > > mArchProtocols[] =3D { // Optional protocols that the DXE Core will us= e > > if they are present // EFI_CORE_PROTOCOL_NOTIFY_ENTRY > > mOptionalProtocols[] =3D { > > - { &gEfiSecurity2ArchProtocolGuid, (VOID **)&gSecurity2, N= ULL, > NULL, > > FALSE }, > > - { &gEfiSmmBase2ProtocolGuid, (VOID **)&gSmmBase2, N= ULL, > NULL, > > FALSE }, > > - { NULL, (VOID **)NULL, N= ULL, NULL, > > FALSE } > > + { &gEfiSecurity2ArchProtocolGuid, (VOID **)&gSecurity2, > > NULL, NULL, FALSE }, > > + { &gEfiSmmBase2ProtocolGuid, (VOID **)&gSmmBase2, > > NULL, NULL, FALSE }, > > + { &gEfiGcdMemorySpaceNotifyProtocolGuid, (VOID > > + **)&gGcdMemorySpaceNotify, > > NULL, NULL, FALSE }, > > + { NULL, (VOID **)NULL, > > NULL, NULL, FALSE } > > }; > > > > // > > diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > > b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c index a06f8bb..223fcd8 100644 > > --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > > +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > > @@ -4,6 +4,8 @@ > > are accessible to the CPU that is executing the DXE core. > > > > Copyright (c) 2006 - 2017, Intel Corporation. All rights > > reserved.
> > +Copyright (c) 2017, AMD Incorporated. 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 @@ -896,6 +898,9 @@ CoreConvertSpace ( > > } else { > > Entry->Capabilities =3D Capabilities | EFI_MEMORY_RUNTIME; > > } > > + if (gGcdMemorySpaceNotify) { > > + gGcdMemorySpaceNotify->MemorySpaceAddNotify > (GcdMemoryType, > > + BaseAddress, > > Length, Entry->Capabilities); > > + } > > break; > > case GCD_ADD_IO_OPERATION: > > Entry->GcdIoType =3D GcdIoType; > > @@ -914,6 +919,9 @@ CoreConvertSpace ( > > case GCD_REMOVE_MEMORY_OPERATION: > > Entry->GcdMemoryType =3D EfiGcdMemoryTypeNonExistent; > > Entry->Capabilities =3D 0; > > + if (gGcdMemorySpaceNotify) { > > + gGcdMemorySpaceNotify->MemorySpaceRemoveNotify > (BaseAddress, Length); > > + } > > break; > > case GCD_REMOVE_IO_OPERATION: > > Entry->GcdIoType =3D EfiGcdIoTypeNonExistent; diff --git > > a/MdeModulePkg/Include/Protocol/GcdMemorySpaceNotify.h > > b/MdeModulePkg/Include/Protocol/GcdMemorySpaceNotify.h > > new file mode 100644 > > index 0000000..9174957 > > --- /dev/null > > +++ b/MdeModulePkg/Include/Protocol/GcdMemorySpaceNotify.h > > @@ -0,0 +1,65 @@ > > +/** @file > > + This file declares the GcdMemorySpaceNotify Protocol. > > + > > + This Protocol is consumed by GCD to issue notications during > > + ADD/REMOVE > > operations. > > + > > + Copyright (c) 2017, AMD Inc. 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 __EFI_GCD_MEMORY_SPACE_NOTIFY_H__ #define > > +__EFI_GCD_MEMORY_SPACE_NOTIFY_H__ > > + > > +#define EFI_GCD_MEMORY_SPACE_NOTIFY_GUID \ > > + { \ > > + 0xc842db69, 0x610e, 0x401a, {0x90, 0xd0, 0x88, 0x41, 0xf1, 0xdc, > > +0x53, 0x79 > > } \ > > + } > > + > > +/** > > + Notify on: Add a segment of memory to GCD map. > > + > > + @param GcdMemoryType Memory type of the segment. > > + @param BaseAddress Base address of the segment. > > + @param Length Length of the segment. > > + @param Capabilities Alterable attributes of the segment. > > + > > +**/ > > +typedef > > +VOID > > +(EFIAPI *GCD_ADD_MEMORY_NOTIFY) ( > > + IN EFI_GCD_MEMORY_TYPE GcdMemoryType, > > + IN EFI_PHYSICAL_ADDRESS BaseAddress, > > + IN UINT64 Length, > > + IN UINT64 Capabilities > > +); > > + > > +/** > > + Notify on: Remove a segment of memory to GCD map. > > + > > + @param BaseAddress Base address of the segment. > > + @param Length Length of the segment. > > + > > +**/ > > +typedef > > +VOID > > +(EFIAPI *GCD_REMOVE_MEMORY_NOTIFY) ( > > + IN EFI_PHYSICAL_ADDRESS BaseAddress, > > + IN UINT64 Length > > +); > > + > > +typedef struct { > > + GCD_ADD_MEMORY_NOTIFY MemorySpaceAddNotify; > > + GCD_REMOVE_MEMORY_NOTIFY MemorySpaceRemoveNotify; } > > +EFI_GCD_MEMORY_SPACE_NOTIFY_PROTOCOL; > > + > > +extern EFI_GUID gEfiGcdMemorySpaceNotifyProtocolGuid; > > + > > +#endif > > diff --git a/MdeModulePkg/MdeModulePkg.dec > > b/MdeModulePkg/MdeModulePkg.dec index ca09cbc..95f9311 100644 > > --- a/MdeModulePkg/MdeModulePkg.dec > > +++ b/MdeModulePkg/MdeModulePkg.dec > > @@ -546,6 +546,9 @@ > > ## Include/Protocol/NonDiscoverableDevice.h > > gEdkiiNonDiscoverableDeviceProtocolGuid =3D { 0x0d51905b, 0xb77e, > > 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc, 0x8d, 0x51, 0x4a } } > > > > + ## Include/Protocol/GcdMemorySpaceNotify.h > > + gEfiGcdMemorySpaceNotifyProtocolGuid =3D { 0xc842db69, 0x610e, > > + 0x401a, {0x90, > > 0xd0, 0x88, 0x41, 0xf1, 0xdc, 0x53, 0x79 } } > > + > > # > > # [Error.gEfiMdeModulePkgTokenSpaceGuid] > > # 0x80000001 | Invalid value provided. > > -- > > 2.7.4 > > > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel