From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4411021A0483A for ; Wed, 12 Apr 2017 12:39:31 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Apr 2017 12:39:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,191,1488873600"; d="scan'208";a="88358017" Received: from orsmsx106.amr.corp.intel.com ([10.22.225.133]) by fmsmga006.fm.intel.com with ESMTP; 12 Apr 2017 12:39:30 -0700 Received: from orsmsx156.amr.corp.intel.com (10.22.240.22) by ORSMSX106.amr.corp.intel.com (10.22.225.133) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 12 Apr 2017 12:39:30 -0700 Received: from orsmsx113.amr.corp.intel.com ([169.254.9.59]) by ORSMSX156.amr.corp.intel.com ([169.254.8.229]) with mapi id 14.03.0319.002; Wed, 12 Apr 2017 12:39:29 -0700 From: "Kinney, Michael D" To: Leo Duran , "edk2-devel@ml01.01.org" , "Kinney, Michael D" CC: Laszlo Ersek , "Tian, Feng" , Brijesh Singh , "Zeng, Star" Thread-Topic: [edk2] [PATCH] MdeModulePkg: Add EFI_GCD_MEMORY_SPACE_NOTIFY_PROTOCOL Thread-Index: AQHSs76QLLN8w8aIl0q3JQpKnVQPVqHCiuUA//+P2vA= Date: Wed, 12 Apr 2017 19:39:29 +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: <1492023400-16132-2-git-send-email-leo.duran@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMGFlM2YyZTUtMGYxZi00ZWE4LTllMWEtN2UwOTY2ZDc2Y2VjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6ImNnUU82Q3RvWWJlbFY0RWpFMFJHaXJUXC9JdXRRQVpncXY3b2xtcnozRlo0PSJ9 dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.22.254.138] MIME-Version: 1.0 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 19:39:31 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Leo, DXE Main is supposed to use Arch Protocols for platform specific behavior. In this case, can the CPU Arch Protocol SetMemoryAttributes() function be used to customize behavior? 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 from GCD also call gDS-> SetMemorySpaceAttributes() so a CPU specific module can perform extra actions? Thanks, Mike > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Le= o Duran > Sent: Wednesday, April 12, 2017 11:57 AM > To: edk2-devel@ml01.01.org > Cc: Laszlo Ersek ; Tian, Feng ; L= eo Duran > ; Brijesh Singh ; Zeng, Star > > Subject: [edk2] [PATCH] MdeModulePkg: Add EFI_GCD_MEMORY_SPACE_NOTIFY_PRO= TOCOL >=20 > GCD consumes the protocol to issue a Notify() on Add/Remove operations. >=20 > The intended use-case is to allow OvmfPkg take actions on behalf of an > SEV-enabled guest. >=20 > The new protocol is simply added to the list of optional protocols handle= d > by DxeMain, and as such leverages the existing DxeProtocolNotify framewor= k. >=20 > 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 >=20 > diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeM= ain.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. >=20 > 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 BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > @@ -17,7 +19,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER > EXPRESS OR IMPLIED. > #define _DXE_MAIN_H_ >=20 >=20 > - > #include >=20 > #include > @@ -53,6 +54,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER > EXPRESS OR IMPLIED. > #include > #include > #include > +#include > + > #include > #include > #include > @@ -296,12 +299,13 @@ extern EFI_RUNTIME_ARCH_PROTOCOL > gRuntimeTemplate; >=20 > extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE > gLoadModuleAtFixAddressConfigurationTable; > extern BOOLEAN > gLoadFixedAddressCodeMemoryReady; > + > +extern EFI_GCD_MEMORY_SPACE_NOTIFY_PROTOCOL *gGcdMemorySpaceNotify; > + > // > // Service Initialization Functions > // >=20 > - > - > /** > Called to initialize the pool. >=20 > 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 DXE = 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 ma= y be > found at > @@ -162,6 +164,8 @@ > gEfiSmmBase2ProtocolGuid ## SOMETIMES_CONSUMES > gEfiBlockIoProtocolGuid ## SOMETIMES_CONSUMES >=20 > + 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 >=20 > 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 BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > @@ -42,6 +44,11 @@ EFI_GUID *gDxeCoreFileName; > EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage; >=20 > // > +// 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. >=20 > 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 BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > @@ -45,9 +47,10 @@ EFI_CORE_PROTOCOL_NOTIFY_ENTRY mArchProtocols[] =3D { > // Optional protocols that the DXE Core will use if they are present > // > EFI_CORE_PROTOCOL_NOTIFY_ENTRY mOptionalProtocols[] =3D { > - { &gEfiSecurity2ArchProtocolGuid, (VOID **)&gSecurity2, NUL= L, NULL, > FALSE }, > - { &gEfiSmmBase2ProtocolGuid, (VOID **)&gSmmBase2, NUL= L, NULL, > FALSE }, > - { NULL, (VOID **)NULL, NUL= L, NULL, > FALSE } > + { &gEfiSecurity2ArchProtocolGuid, (VOID **)&gSecurity2, > NULL, NULL, FALSE }, > + { &gEfiSmmBase2ProtocolGuid, (VOID **)&gSmmBase2, > NULL, NULL, FALSE }, > + { &gEfiGcdMemorySpaceNotifyProtocolGuid, (VOID **)&gGcdMemorySpaceNoti= fy, > NULL, NULL, FALSE }, > + { NULL, (VOID **)NULL, > NULL, NULL, FALSE } > }; >=20 > // > 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. >=20 > 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 BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > @@ -896,6 +898,9 @@ CoreConvertSpace ( > } else { > Entry->Capabilities =3D Capabilities | EFI_MEMORY_RUNTIME; > } > + if (gGcdMemorySpaceNotify) { > + gGcdMemorySpaceNotify->MemorySpaceAddNotify (GcdMemoryType, Base= Address, > 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, Len= gth); > + } > 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/REMOV= E > 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 I= MPLIED. > + > +**/ > + > +#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, 0x5= 3, 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.de= c > index ca09cbc..95f9311 100644 > --- a/MdeModulePkg/MdeModulePkg.dec > +++ b/MdeModulePkg/MdeModulePkg.dec > @@ -546,6 +546,9 @@ > ## Include/Protocol/NonDiscoverableDevice.h > gEdkiiNonDiscoverableDeviceProtocolGuid =3D { 0x0d51905b, 0xb77e, 0x45= 2a, {0xa2, > 0xc0, 0xec, 0xa0, 0xcc, 0x8d, 0x51, 0x4a } } >=20 > + ## 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 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel