Re: [edk2-devel][PATCH 1/2] MdeModulePkg: StackOffset must be aligned to a 16-byte boundary in X64
Hi Marvin, Good day. Thanks for your valuable comments. After checking all of your comments, I decide to drop the patches and close the bugzilla ticket since the changes should be specific to X64 in IntelFspPkg. You still can find my inline comments with [Ted] for your questions. Thanks, Ted -Original Message- From: Marvin Häuser Sent: Tuesday, March 22, 2022 3:46 AM To: devel@edk2.groups.io; Kuo, Ted Cc: Kinney, Michael D ; Bi, Dandan ; Gao, Liming ; De, Debkumar ; Han, Harry ; West, Catharine ; Wang, Jian J Subject: Re: [edk2-devel][PATCH 1/2] MdeModulePkg: StackOffset must be aligned to a 16-byte boundary in X64 Good day, Thanks for the update! On 21.03.22 13:43, Kuo, Ted wrote: > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3865 > For X64, StackOffset must be aligned to a 16-byte boundary as well as > old stack and new stack. Otherwise, it'll get wrong data from Private > pointer after switching from old stack to new stack. > > Cc: Michael D Kinney > Cc: Dandan Bi > Cc: Liming Gao > Cc: Debkumar De > Cc: Harry Han > Cc: Catharine West > Cc: Jian J Wang > Cc: Marvin Häuser > Signed-off-by: Ted Kuo > --- > MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 18 +- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c > b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c > index 3552feda8f..8a2c1ec779 100644 > --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c > +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c > @@ -823,6 +823,19 @@ PeiCheckAndSwitchStack ( > (VOID **)&TemporaryRamSupportPpi > ); > if (!EFI_ERROR (Status)) { > + // > + // For X64, StackOffset must be aligned to a 16-byte boundary. > Otherwise, it'll get wrong data > + // from Private pointer after switching to new stack. > + // > + if ((sizeof (UINTN) == sizeof (UINT64)) && ((StackOffset & 0x0F) == > 8)) { > +if (StackOffsetPositive == TRUE) { > + StackOffset -= 8; > +} else { > + StackOffset += 8; > +} > +Private->StackOffset = StackOffset; > + } > + Hmm, the overall design (not your patch) looks very broken to me. So, if the PPI exists, it's responsible for the migration of the stack, but it is neither passed where to migrate the stack to, nor does it return where it did migrate it to. This means the StackOffset calculated here may be out-of-sync with what actually happens in the PPI, e.g., if the PPI code is changed. There also is no detailed explanation for the memory layout with FSP separate stack vs bootloader shared stack, so I cannot really give detailed comments quickly. *Sigh*. Anyhow, as for the patch, I do not understand a few things: 1) Maybe most important of all, what even is broken? Which address is not 16-Byte-aligned to cause this issue in the first place? [Ted]: CPU will generate exception when running some X64 instructions which need input/output memory address to be 16-Byte-aligned. 2) Why do you align StackOffset? Like yes, if the old top of the stack and the offset to the new top of the stack are both 16-Byte-aligned, then the new top of the stack is 16-Byte-aligned too. However, StackOffset is more of a by-product and TopOfNewStack remains holding the old value. I just don't really understand the idea of this approach. [Ted]: Since new stack must keep the original stack alignment as old stack, it means stack offset must be 16-Byte-aligned too. And the OldStack/NewStack in the fsp patch indicates the *current* old/new stack. The fsp patch just makes left shift 8-byte of whole used stack data when new stack not aligning with old stack. Hence I think no need to update TopOfNewStack. e.g. case1: old stack: 0xfef5e000 new stack: 0x49c8f3b0 stack: 0x9c8f3b0 -> 16-Byte-aligned case2: old stack: 0xfef5e008 new stack: 0x49c8f3b8 stack: 0x9c8f3b0 -> 16-Byte-aligned 3) This only works when StackOffset is guaranteed to be 8-Byte-aligned (is it?). As we are dealing with the *top* of the stack (which should be 4K-aligned even for memory protection!), what would be wrong with just aligning down and up instead? (Same question for the second patch to the FSP code) As my answer in Q2, what we adjust in the fsp patch is the new "current" stack in order to keep the same stack alignment as old stack after switching stack. Top of the new stack remains unchanged. If StackOffset is not adjusted accordingly, bios will get wrong data from Private pointer after switching to new stack. 4) The next patch performs a similar alignment operation (as mentioned before). However, while this patch aligns the *top* of the stack, the FSP patch aligns the *bottom* of the stack. This may or may not be correct based on your premises. Can you maybe document why this is correct, or even better, try to align the top of the stack in FSP as well? (By transitivity, if you align the top corre
[edk2-devel] [PATCH V3 1/1] BaseTools: Add the FeatureFlagExpression usage to the Source Section
From: Yi Li REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3828 FeatureFlagExpression Support in Source section of INF file. The Pcd value in the expression is from INF or DEC. When a FeatureFlagExpression is present,if the expression evaluates to TRUE,then the entry is valid. If the expression evaluates to FALSE, then the EDK II build tools must ignore the entry. This patch is going to add this feature. Change-Id: I5821652330cdba1bfc5544e90f27b32ddf4147fc Cc: Bob Feng Cc: Liming Gao Cc: Heng Luo Signed-off-by: Yi Li --- BaseTools/Source/Python/Common/Expression.py | 2 +- BaseTools/Source/Python/Common/GlobalData.py | 1 + .../Source/Python/Workspace/InfBuildData.py | 52 +-- .../Source/Python/Workspace/MetaFileParser.py | 4 ++ .../Python/Workspace/WorkspaceCommon.py | 5 ++ 5 files changed, 59 insertions(+), 5 deletions(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py index 07ca039a9cf3..31bf0e4b6cf7 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -43,7 +43,7 @@ ERR_IN_OPERAND = 'Macro after IN operator can only be: $(FAMILY), $(ARC __ValidString = re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$') _ReLabel = re.compile('LABEL\((\w+)\)') _ReOffset = re.compile('OFFSET_OF\((\w+)\)') -PcdPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]*$') +PcdPattern = re.compile(r'^[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]*$') ## SplitString # Split string to list according double quote diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/Python/Common/GlobalData.py index 61ab3f7e24cd..197bd8366682 100755 --- a/BaseTools/Source/Python/Common/GlobalData.py +++ b/BaseTools/Source/Python/Common/GlobalData.py @@ -18,6 +18,7 @@ gGlobalDefines = {} gPlatformDefines = {} # PCD name and value pair for fixed at build and feature flag gPlatformPcds = {} +gPlatformFinalPcds = {} # PCDs with type that are not fixed at build and feature flag gPlatformOtherPcds = {} gActivePlatform = None diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py index 45b8ef4716dd..cd23065b0c8e 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -14,6 +14,7 @@ from types import * from .MetaFileParser import * from collections import OrderedDict from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject +from Common.Expression import ValueExpressionEx, PcdPattern ## Get Protocol value from given packages # @@ -528,11 +529,17 @@ class InfBuildData(ModuleBuildClassObject): for Record in RecordList: LineNo = Record[-1] ToolChainFamily = Record[1] -TagName = Record[2] -ToolCode = Record[3] - +# OptionsList := [TagName, ToolCode, FeatureFlag] +OptionsList = ['', '', ''] +TokenList = GetSplitValueList(Record[2], TAB_VALUE_SPLIT) +for Index in range(len(TokenList)): +OptionsList[Index] = TokenList[Index] +if OptionsList[2]: +FeaturePcdExpression = self.CheckFeatureFlagPcd(OptionsList[2]) +if not FeaturePcdExpression: +continue File = PathClass(NormPath(Record[0], Macros), self._ModuleDir, '', - '', False, self._Arch, ToolChainFamily, '', TagName, ToolCode) + '', False, self._Arch, ToolChainFamily, '', OptionsList[0], OptionsList[1]) # check the file validation ErrorCode, ErrorInfo = File.Validate() if ErrorCode != 0: @@ -1046,6 +1053,43 @@ class InfBuildData(ModuleBuildClassObject): if (self.Binaries and not self.Sources) or GlobalData.gIgnoreSource: return True return False +def CheckFeatureFlagPcd(self,Instance): +Pcds = {} +if GlobalData.gPlatformFinalPcds.get(self.Arch): +Pcds = GlobalData.gPlatformFinalPcds[self.Arch].copy() +if PcdPattern.search(Instance): +PcdTuple = tuple(Instance.split('.')[::-1]) +if PcdTuple in self.Pcds: +if not (self.Pcds[PcdTuple].Type == 'FeatureFlag' or self.Pcds[PcdTuple].Type == 'FixedAtBuild') and Instance not in Pcds: +EdkLogger.error('build', FORMAT_INVALID, +"\nit must be defined in a [PcdsFeatureFlag] or [PcdsFixedAtBuild] section of Dsc or Dec file or [FeaturePcd] or [FixedPcd] of Inf file", +File=str(self), ExtraData=Instance) +Pcds[Instance] = self.Pcds[PcdTuple].DefaultValue +if Instance in Pcds: +if Pcds[Instance] == '0': +return False +elif Pcd
[edk2-devel] [PATCH V3 0/1] BaseTools: Add the FeatureFlagExpression usage to the Source Section
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3828 FeatureFlagExpression Support in Source section of INF file. The Pcd value in the expression is from INF or DEC. When a FeatureFlagExpression is present,if the expression evaluates to TRUE,then the entry is valid. If the expression evaluates to FALSE, then the EDK II build tools must ignore the entry. This patch is going to add this feature. Change-Id: I5821652330cdba1bfc5544e90f27b32ddf4147fc Cc: Bob Feng Cc: Liming Gao Cc: Heng Luo Signed-off-by: Yi Li Yi Li (1): BaseTools: Add the FeatureFlagExpression usage to the Source Section BaseTools/Source/Python/Common/Expression.py | 2 +- BaseTools/Source/Python/Common/GlobalData.py | 1 + .../Source/Python/Workspace/InfBuildData.py | 52 +-- .../Source/Python/Workspace/MetaFileParser.py | 4 ++ .../Python/Workspace/WorkspaceCommon.py | 5 ++ 5 files changed, 59 insertions(+), 5 deletions(-) -- 2.33.0.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87819): https://edk2.groups.io/g/devel/message/87819 Mute This Topic: https://groups.io/mt/89947425/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel][PATCH] IntelFsp2Pkg: BaseFspCommonLib Support for X64
Thanks Ted! Reviewed-by: Chasel Chiu > -Original Message- > From: Kuo, Ted > Sent: Monday, March 14, 2022 12:23 PM > To: devel@edk2.groups.io > Cc: Chiu, Chasel ; Desimone, Nathaniel L > ; Zeng, Star ; S, > Ashraf Ali > Subject: [edk2-devel][PATCH] IntelFsp2Pkg: BaseFspCommonLib Support for > X64 > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3867 > Add BaseFspCommonLib Support for X64. > > Cc: Chasel Chiu > Cc: Nate DeSimone > Cc: Star Zeng > Cc: Ashraf Ali S > Signed-off-by: Ted Kuo > --- > IntelFsp2Pkg/FspSecCore/SecFsp.c | 2 +- > IntelFsp2Pkg/FspSecCore/SecFsp.h | 2 +- > IntelFsp2Pkg/Include/FspGlobalData.h | 2 +- > IntelFsp2Pkg/Include/Library/FspCommonLib.h| 6 +- > .../Library/BaseFspCommonLib/FspCommonLib.c| 65 > +- > 5 files changed, 45 insertions(+), 32 deletions(-) > > diff --git a/IntelFsp2Pkg/FspSecCore/SecFsp.c > b/IntelFsp2Pkg/FspSecCore/SecFsp.c > index f79d45900e..68e588dd41 100644 > --- a/IntelFsp2Pkg/FspSecCore/SecFsp.c > +++ b/IntelFsp2Pkg/FspSecCore/SecFsp.c > @@ -217,7 +217,7 @@ FspGlobalDataInit ( > **/ > VOID > FspDataPointerFixUp ( > - IN UINT32 OffsetGap > + IN UINTN OffsetGap >) > { >FSP_GLOBAL_DATA *NewFspData; > diff --git a/IntelFsp2Pkg/FspSecCore/SecFsp.h > b/IntelFsp2Pkg/FspSecCore/SecFsp.h > index aacd32f7f7..7c9be85fe0 100644 > --- a/IntelFsp2Pkg/FspSecCore/SecFsp.h > +++ b/IntelFsp2Pkg/FspSecCore/SecFsp.h > @@ -61,7 +61,7 @@ FspGlobalDataInit ( > **/ > VOID > FspDataPointerFixUp ( > - IN UINT32 OffsetGap > + IN UINTN OffsetGap >); > > /** > diff --git a/IntelFsp2Pkg/Include/FspGlobalData.h > b/IntelFsp2Pkg/Include/FspGlobalData.h > index 71033121c4..2b534075ae 100644 > --- a/IntelFsp2Pkg/Include/FspGlobalData.h > +++ b/IntelFsp2Pkg/Include/FspGlobalData.h > @@ -42,7 +42,7 @@ typedef struct { >UINT32 Signature; >UINT8 Version; >UINT8 Reserved1[3]; > - UINT32 CoreStack; > + UINTN CoreStack; >UINT32 StatusCode; >UINT32 Reserved2[8]; >FSP_PLAT_DATA PlatformData; > diff --git a/IntelFsp2Pkg/Include/Library/FspCommonLib.h > b/IntelFsp2Pkg/Include/Library/FspCommonLib.h > index c70039d9e8..b5e38568e2 100644 > --- a/IntelFsp2Pkg/Include/Library/FspCommonLib.h > +++ b/IntelFsp2Pkg/Include/Library/FspCommonLib.h > @@ -38,7 +38,7 @@ GetFspGlobalDataPointer ( > >@retval ApiParameter FSP API first parameter passed by the bootloader. > **/ > -UINT32 > +UINTN > EFIAPI > GetFspApiParameter ( >VOID > @@ -49,7 +49,7 @@ GetFspApiParameter ( > >@retval ApiParameter FSP API second parameter passed by the > bootloader. > **/ > -UINT32 > +UINTN > EFIAPI > GetFspApiParameter2 ( >VOID > @@ -87,7 +87,7 @@ SetFspApiParameter ( > VOID > EFIAPI > SetFspApiReturnStatus ( > - IN UINT32 ReturnStatus > + IN UINTN ReturnStatus >); > > /** > diff --git a/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c > b/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c > index 8f8453915e..cd10b63c95 100644 > --- a/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c > +++ b/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c > @@ -30,21 +30,34 @@ typedef struct { >UINT16IdtrLimit; >UINT32IdtrBase; >UINT16Reserved; > - UINT32Edi; > - UINT32Esi; > - UINT32Ebp; > - UINT32Esp; > - UINT32Ebx; > - UINT32Edx; > - UINT32Ecx; > - UINT32Eax; > + UINT32Registers[8]; // General Purpose Registers: Edi, Esi, Ebp, Esp, > Ebx, Edx, Ecx and Eax >UINT16Flags[2]; >UINT32FspInfoHeader; >UINT32ApiRet; >UINT32ApiParam[2]; > } CONTEXT_STACK; > > -#define CONTEXT_STACK_OFFSET(x) (UINT32)&((CONTEXT_STACK > *)(UINTN)0)->x > +// > +// API return address +0xB0 > +// pushAPI Parameter2 +0xA8 > +// pushAPI Parameter1 +0xA0 > +// pushFspInfoHeader+0x98 > +// pushfq +0x90 > +// cli > +// PUSHA_64 +0x10 > +// sub rsp, 16 +0x00 > +// sidt[rsp] > +// > +typedef struct { > + UINT64Idtr[2];// IDTR Limit - bit0:bi15, IDTR Base - > bit16:bit79 > + UINT64Registers[16]; // General Purpose Registers: RDI, RSI, RBP, RSP, > RBX, RDX, RCX, RAX, and R15 to R8 > + UINT32Flags[2]; > + UINT64FspInfoHeader; > + UINT64ApiParam[2]; > + UINT64ApiRet; // 64bit stack format is different from the 32bit > one due to x64 calling convention > +} CONTEXT_STACK_64; > + > +#define CONTEXT_STACK_OFFSET(x) (sizeof(UINTN) == sizeof (UINT32) ? > +(UINTN)&((CONTEXT_STACK *)(UINTN)0)->x : > (UINTN)&((CONTEXT_STACK_64 > +*)(UINTN)0)->x) > > #pragma pack() > > @@ -85,7 +98,7 @@ GetFspGlobalDataPointer ( > >@retval ApiParameter FSP API first parameter passed by the bootloader. > **/ > -UINT32 >
Re: [edk2-devel] [PATCH V9 02/47] MdePkg: Update Cpuid.h for Tdx
On Fri, Mar 18, 2022 at 08:45:20AM +0800, Min Xu wrote: > RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 > > Guest software can be designed to run either as a TD, as a legacy virtual > machine, or directly on the CPU, based on enumeration of its run-time > environment. [TDX-Module] Chap 10.2 defines the flow and the new CPUID > leaf 0x21. > > [TDX-Module] Architecture Specification: Intel(R) Trust Domain Extensions > Module, Chap 10.2, 344425-003US, August 2021 > https://www.intel.com/content/dam/develop/external/us/en/documents/ > tdx-module-1.0-public-spec-v0.931.pdf > > Cc: Ray Ni > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Zhiguang Liu > Cc: Brijesh Singh > Cc: Erdem Aktas > Cc: James Bottomley > Cc: Jiewen Yao > Cc: Tom Lendacky > Cc: Gerd Hoffmann > Signed-off-by: Min Xu Acked-by: Gerd Hoffmann -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87822): https://edk2.groups.io/g/devel/message/87822 Mute This Topic: https://groups.io/mt/89858996/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel][PATCH] IntelFsp2Pkg: BaseFspCommonLib Support for X64
Patch pushed: https://github.com/tianocore/edk2/commit/ec0b54849b23efa25caf0055b0eef8bf9b4dec98 Thanks, Chasel > -Original Message- > From: Kuo, Ted > Sent: Monday, March 14, 2022 12:23 PM > To: devel@edk2.groups.io > Cc: Chiu, Chasel ; Desimone, Nathaniel L > ; Zeng, Star ; S, > Ashraf Ali > Subject: [edk2-devel][PATCH] IntelFsp2Pkg: BaseFspCommonLib Support for > X64 > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3867 > Add BaseFspCommonLib Support for X64. > > Cc: Chasel Chiu > Cc: Nate DeSimone > Cc: Star Zeng > Cc: Ashraf Ali S > Signed-off-by: Ted Kuo > --- > IntelFsp2Pkg/FspSecCore/SecFsp.c | 2 +- > IntelFsp2Pkg/FspSecCore/SecFsp.h | 2 +- > IntelFsp2Pkg/Include/FspGlobalData.h | 2 +- > IntelFsp2Pkg/Include/Library/FspCommonLib.h| 6 +- > .../Library/BaseFspCommonLib/FspCommonLib.c| 65 > +- > 5 files changed, 45 insertions(+), 32 deletions(-) > > diff --git a/IntelFsp2Pkg/FspSecCore/SecFsp.c > b/IntelFsp2Pkg/FspSecCore/SecFsp.c > index f79d45900e..68e588dd41 100644 > --- a/IntelFsp2Pkg/FspSecCore/SecFsp.c > +++ b/IntelFsp2Pkg/FspSecCore/SecFsp.c > @@ -217,7 +217,7 @@ FspGlobalDataInit ( > **/ > VOID > FspDataPointerFixUp ( > - IN UINT32 OffsetGap > + IN UINTN OffsetGap >) > { >FSP_GLOBAL_DATA *NewFspData; > diff --git a/IntelFsp2Pkg/FspSecCore/SecFsp.h > b/IntelFsp2Pkg/FspSecCore/SecFsp.h > index aacd32f7f7..7c9be85fe0 100644 > --- a/IntelFsp2Pkg/FspSecCore/SecFsp.h > +++ b/IntelFsp2Pkg/FspSecCore/SecFsp.h > @@ -61,7 +61,7 @@ FspGlobalDataInit ( > **/ > VOID > FspDataPointerFixUp ( > - IN UINT32 OffsetGap > + IN UINTN OffsetGap >); > > /** > diff --git a/IntelFsp2Pkg/Include/FspGlobalData.h > b/IntelFsp2Pkg/Include/FspGlobalData.h > index 71033121c4..2b534075ae 100644 > --- a/IntelFsp2Pkg/Include/FspGlobalData.h > +++ b/IntelFsp2Pkg/Include/FspGlobalData.h > @@ -42,7 +42,7 @@ typedef struct { >UINT32 Signature; >UINT8 Version; >UINT8 Reserved1[3]; > - UINT32 CoreStack; > + UINTN CoreStack; >UINT32 StatusCode; >UINT32 Reserved2[8]; >FSP_PLAT_DATA PlatformData; > diff --git a/IntelFsp2Pkg/Include/Library/FspCommonLib.h > b/IntelFsp2Pkg/Include/Library/FspCommonLib.h > index c70039d9e8..b5e38568e2 100644 > --- a/IntelFsp2Pkg/Include/Library/FspCommonLib.h > +++ b/IntelFsp2Pkg/Include/Library/FspCommonLib.h > @@ -38,7 +38,7 @@ GetFspGlobalDataPointer ( > >@retval ApiParameter FSP API first parameter passed by the bootloader. > **/ > -UINT32 > +UINTN > EFIAPI > GetFspApiParameter ( >VOID > @@ -49,7 +49,7 @@ GetFspApiParameter ( > >@retval ApiParameter FSP API second parameter passed by the > bootloader. > **/ > -UINT32 > +UINTN > EFIAPI > GetFspApiParameter2 ( >VOID > @@ -87,7 +87,7 @@ SetFspApiParameter ( > VOID > EFIAPI > SetFspApiReturnStatus ( > - IN UINT32 ReturnStatus > + IN UINTN ReturnStatus >); > > /** > diff --git a/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c > b/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c > index 8f8453915e..cd10b63c95 100644 > --- a/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c > +++ b/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c > @@ -30,21 +30,34 @@ typedef struct { >UINT16IdtrLimit; >UINT32IdtrBase; >UINT16Reserved; > - UINT32Edi; > - UINT32Esi; > - UINT32Ebp; > - UINT32Esp; > - UINT32Ebx; > - UINT32Edx; > - UINT32Ecx; > - UINT32Eax; > + UINT32Registers[8]; // General Purpose Registers: Edi, Esi, Ebp, Esp, > Ebx, Edx, Ecx and Eax >UINT16Flags[2]; >UINT32FspInfoHeader; >UINT32ApiRet; >UINT32ApiParam[2]; > } CONTEXT_STACK; > > -#define CONTEXT_STACK_OFFSET(x) (UINT32)&((CONTEXT_STACK > *)(UINTN)0)->x > +// > +// API return address +0xB0 > +// pushAPI Parameter2 +0xA8 > +// pushAPI Parameter1 +0xA0 > +// pushFspInfoHeader+0x98 > +// pushfq +0x90 > +// cli > +// PUSHA_64 +0x10 > +// sub rsp, 16 +0x00 > +// sidt[rsp] > +// > +typedef struct { > + UINT64Idtr[2];// IDTR Limit - bit0:bi15, IDTR Base - > bit16:bit79 > + UINT64Registers[16]; // General Purpose Registers: RDI, RSI, RBP, RSP, > RBX, RDX, RCX, RAX, and R15 to R8 > + UINT32Flags[2]; > + UINT64FspInfoHeader; > + UINT64ApiParam[2]; > + UINT64ApiRet; // 64bit stack format is different from the 32bit > one due to x64 calling convention > +} CONTEXT_STACK_64; > + > +#define CONTEXT_STACK_OFFSET(x) (sizeof(UINTN) == sizeof (UINT32) ? > +(UINTN)&((CONTEXT_STACK *)(UINTN)0)->x : > (UINTN)&((CONTEXT_STACK_64 > +*)(UINTN)0)->x) > > #pragma pack() > > @@ -85,7 +98,7 @@ GetFspGlobalDataPointer ( > >@retval ApiPar
Re: [edk2-devel] [PATCH V9 19/47] OvmfPkg/PlatformPei: Move global variables to PlatformInfoHob
On Fri, Mar 18, 2022 at 08:45:37AM +0800, Min Xu wrote: > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 > > The intention of PlatformInitLib is to extract the common function used > in OvmfPkg/PlatformPei. This lib will be used not only in PEI phase but > also in SEC phase. SEC phase cannot use global variables between > different functions. So PlatformInfoHob is created to hold the > informations shared between functions. For example, HostBridgeDevId > corespond to mHostBridgeDevId in PlatformPei. > > In this patch we will first move below global variables to > PlatformInfoHob. > - mBootMode > - mS3Supported > - mPhysMemAddressWidth > - mMaxCpuCount > - mHostBridgeDevId > - mQ35SmramAtDefaultSmbase > - mQemuUc32Base > - mS3AcpiReservedMemorySize > - mS3AcpiReservedMemoryBase > > PlatformInfoHob also holds other information, for example, > PciIoBase / PciIoSize. This is because in SEC phase, PcdSetxxx > doesn't work. So we will restruct the functions which set PCDs > into two, one for PlatformInfoLib, one for PlatformPei. > > So in this patch we first move global variables and PCDs to > PlatformInfoHob. All the changes are in OvmfPkg/PlatformPei. > > Cc: Ard Biesheuvel > Cc: Jordan Justen > Cc: Brijesh Singh > Cc: Erdem Aktas > Cc: James Bottomley > Cc: Jiewen Yao > Cc: Tom Lendacky > Cc: Gerd Hoffmann > Cc: Sebastien Boeuf > Signed-off-by: Min Xu Acked-by: Gerd Hoffmann -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87824): https://edk2.groups.io/g/devel/message/87824 Mute This Topic: https://groups.io/mt/89859026/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH V9 22/47] OvmfPkg/PlatformPei: Refactor AddressWidthInitialization
On Fri, Mar 18, 2022 at 08:45:40AM +0800, Min Xu wrote: > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 > > From this patch we start to restruct the functions which set PCDs into > two, one for PlatformInitLib, one for PlatformPei. > > AddressWidthInitialization is the first one. It is splitted into two: > - PlatformAddressWidthInitialization is for PlatformInitLib > - AddressWidthInitialization is for PlatformPei. It calls >PlatformAddressWidthInitialization then set PCDs. > > Below functions are also refined for PlatformInitLib: > - PlatformScanOrAdd64BitE820Ram > - PlatformGetSystemMemorySizeAbove4gb > - PlatformGetFirstNonAddress > > All the SetPcd codes are removed from above functions. > > Cc: Ard Biesheuvel > Cc: Jordan Justen > Cc: Brijesh Singh > Cc: Erdem Aktas > Cc: James Bottomley > Cc: Jiewen Yao > Cc: Tom Lendacky > Cc: Gerd Hoffmann > Cc: Sebastien Boeuf > Signed-off-by: Min Xu Acked-by: Gerd Hoffmann -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87825): https://edk2.groups.io/g/devel/message/87825 Mute This Topic: https://groups.io/mt/89859031/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH V9 23/47] OvmfPkg/PlatformPei: Refactor MaxCpuCountInitialization
On Fri, Mar 18, 2022 at 08:45:41AM +0800, Min Xu wrote: > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 > > MaxCpuCountInitialization is splitted into two: > - PlatformMaxCpuCountInitialization is for PlatformInitLib > - MaxCpuCountInitialization is for PlatformPei. It calls >PlatformMaxCpuCountInitialization then sets PCDs. > > Cc: Ard Biesheuvel > Cc: Jordan Justen > Cc: Brijesh Singh > Cc: Erdem Aktas > Cc: James Bottomley > Cc: Jiewen Yao > Cc: Tom Lendacky > Cc: Gerd Hoffmann > Cc: Sebastien Boeuf > Signed-off-by: Min Xu Acked-by: Gerd Hoffmann -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87826): https://edk2.groups.io/g/devel/message/87826 Mute This Topic: https://groups.io/mt/89859032/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v1 3/4] OvmfPkg: Revert Uncrustify formatting in VbeShim.h files
On Mon, Mar 21, 2022 at 09:58:13PM -0400, Michael Kubacki wrote: > From: Michael Kubacki > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3875 > > Reverts changes automatically applied by Uncrustify in commit > ac0a286. > > Cc: Ard Biesheuvel > Cc: Jiewen Yao > Cc: Jordan Justen > Cc: Gerd Hoffmann > Cc: Rebecca Cran > Cc: Peter Grehan > Cc: Laszlo Ersek > Signed-off-by: Michael Kubacki Acked-by: Gerd Hoffmann -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87827): https://edk2.groups.io/g/devel/message/87827 Mute This Topic: https://groups.io/mt/89944185/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v1 4/4] OvmfPkg: Do not check VbeShim.h formatting with Uncrustify
On Mon, Mar 21, 2022 at 09:58:14PM -0400, Michael Kubacki wrote: > From: Michael Kubacki > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3875 > > The following files: > OvmfPkg/Bhyve/BhyveRfbDxe/VbeShim.h > OvmfPkg/QemuVideoDxe/VbeShim.h > > Are auto generated by the following generators: > OvmfPkg/Bhyve/BhyveRfbDxe/VbeShim.sh > OvmfPkg/QemuVideoDxe/VbeShim.sh > > Therefore, Uncrustify causes a file update to produce a very large > diff due to formatting changes. > > This change does the following: > 1. Reverts the Uncrustify changes applied to the files in commit > ac0a286f4d74. > 2. Uses a new UncrustifyCheck CI plugin configuration option to > exclude the files from future formatting checks. > > Cc: Ard Biesheuvel > Cc: Jiewen Yao > Cc: Jordan Justen > Cc: Gerd Hoffmann > Cc: Rebecca Cran > Cc: Peter Grehan > Cc: Laszlo Ersek > Signed-off-by: Michael Kubacki Acked-by: Gerd Hoffmann -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87828): https://edk2.groups.io/g/devel/message/87828 Mute This Topic: https://groups.io/mt/89944186/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel][PATCH 1/2] MdeModulePkg: StackOffset must be aligned to a 16-byte boundary in X64
Good day, Thanks for the updates! > On 22. Mar 2022, at 08:23, Kuo, Ted wrote: > > Hi Marvin, > > Good day. Thanks for your valuable comments. After checking all of your > comments, I decide to drop the patches and close the bugzilla ticket since > the changes should be specific to X64 in IntelFspPkg. You still can find my > inline comments with [Ted] for your questions. > > Thanks, > Ted > > -Original Message- > From: Marvin Häuser > Sent: Tuesday, March 22, 2022 3:46 AM > To: devel@edk2.groups.io; Kuo, Ted > Cc: Kinney, Michael D ; Bi, Dandan > ; Gao, Liming ; De, Debkumar > ; Han, Harry ; West, Catharine > ; Wang, Jian J > Subject: Re: [edk2-devel][PATCH 1/2] MdeModulePkg: StackOffset must be > aligned to a 16-byte boundary in X64 > > Good day, > > Thanks for the update! > >> On 21.03.22 13:43, Kuo, Ted wrote: >> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3865 >> For X64, StackOffset must be aligned to a 16-byte boundary as well as >> old stack and new stack. Otherwise, it'll get wrong data from Private >> pointer after switching from old stack to new stack. >> >> Cc: Michael D Kinney >> Cc: Dandan Bi >> Cc: Liming Gao >> Cc: Debkumar De >> Cc: Harry Han >> Cc: Catharine West >> Cc: Jian J Wang >> Cc: Marvin Häuser >> Signed-off-by: Ted Kuo >> --- >> MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 18 +- >> 1 file changed, 17 insertions(+), 1 deletion(-) >> >> diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c >> b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c >> index 3552feda8f..8a2c1ec779 100644 >> --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c >> +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c >> @@ -823,6 +823,19 @@ PeiCheckAndSwitchStack ( >> (VOID **)&TemporaryRamSupportPpi >> ); >> if (!EFI_ERROR (Status)) { >> + // >> + // For X64, StackOffset must be aligned to a 16-byte boundary. >> Otherwise, it'll get wrong data >> + // from Private pointer after switching to new stack. >> + // >> + if ((sizeof (UINTN) == sizeof (UINT64)) && ((StackOffset & 0x0F) == >> 8)) { >> +if (StackOffsetPositive == TRUE) { >> + StackOffset -= 8; >> +} else { >> + StackOffset += 8; >> +} >> +Private->StackOffset = StackOffset; >> + } >> + > > Hmm, the overall design (not your patch) looks very broken to me. So, if the > PPI exists, it's responsible for the migration of the stack, but it is > neither passed where to migrate the stack to, nor does it return where it did > migrate it to. This means the StackOffset calculated here may be out-of-sync > with what actually happens in the PPI, e.g., if the PPI code is changed. > There also is no detailed explanation for the memory layout with FSP separate > stack vs bootloader shared stack, so I cannot really give detailed comments > quickly. *Sigh*. > > Anyhow, as for the patch, I do not understand a few things: > > 1) Maybe most important of all, what even is broken? Which address is not > 16-Byte-aligned to cause this issue in the first place? > [Ted]: CPU will generate exception when running some X64 instructions which > need input/output memory address to be 16-Byte-aligned. Yes, I understood as much. I built a chain of reasoning for alignment in the response for the first revision, because a proper fix needs knowledge of which assumption is wrong in the first place. The question is, which *exact* value in the chain is not 16-Byte aligned, and should it be? Did you ever print all involved values, like PhysicalMemoryBegin (or whatever its name was, sorry, I’m responding from mobile)? > > 2) Why do you align StackOffset? Like yes, if the old top of the stack and > the offset to the new top of the stack are both 16-Byte-aligned, then the new > top of the stack is 16-Byte-aligned too. However, StackOffset is more of a > by-product and TopOfNewStack remains holding the old value. I just don't > really understand the idea of this approach. > [Ted]: Since new stack must keep the original stack alignment as old stack, > it means stack offset must be 16-Byte-aligned too. Yes, I agreed above. But StackOffset is not the definition of where the new stack is located, but only a consequence from it. It is not the primary descriptor is what I’m trying to say. > And the OldStack/NewStack in the fsp patch indicates the *current* old/new > stack. The fsp patch just makes left shift 8-byte of whole used stack data > when new stack not aligning with old stack. Hence I think no need to update > TopOfNewStack. Yes, I understand what is happening, I don’t understand why it is happening. My comment here was separate from the FSP patch and only concerned the code here. If the top of the stack (as described by StackOffset) is aligned from its original value, why can TopOfNewStack remain unchanged, when it all points to the old, unaligned top, where no data sh
[edk2-devel] [PATCH 1/1] CryptoPkg: Add consumed library class by SMM to dsc file
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3881 LibraryClass MmServicesTableLib SynchronizationLib in SmmCryptLib.inf should be listed in CryptoPkg.dsc. Cc: Jiewen Yao Cc: Jian J Wang Cc: Zhihao Li Signed-off-by: yi1 li --- CryptoPkg/CryptoPkg.dsc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc index 0aa72ed87846..e88da4fd7e46 100644 --- a/CryptoPkg/CryptoPkg.dsc +++ b/CryptoPkg/CryptoPkg.dsc @@ -127,6 +127,8 @@ TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf [LibraryClasses.common.DXE_SMM_DRIVER] + MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf + SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf TlsLib|CryptoPkg/Library/TlsLibNull/TlsLibNull.inf -- 2.33.0.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87830): https://edk2.groups.io/g/devel/message/87830 Mute This Topic: https://groups.io/mt/89949443/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v3 1/5] NetworkPkg/HttpDxe: Decofigure Tcp4 before reconfiguring
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2720 Check if the state of the HTTP instance is HTTP_STATE_TCP_CONNECTED, or HTTP_STATE_TCP_CLOSED and de-configure the Tcp4 instance before configuring it again. Signed-off-by: Oliver Steffen --- NetworkPkg/HttpDxe/HttpProto.c | 12 1 file changed, 12 insertions(+) diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c index 9457dd2623d3..cd54c574044b 100644 --- a/NetworkPkg/HttpDxe/HttpProto.c +++ b/NetworkPkg/HttpDxe/HttpProto.c @@ -1086,6 +1086,18 @@ HttpConfigureTcp4 ( Tcp4Option->EnableNagle = TRUE; Tcp4CfgData->ControlOption= Tcp4Option; + if ((HttpInstance->State == HTTP_STATE_TCP_CONNECTED) || + (HttpInstance->State == HTTP_STATE_TCP_CLOSED)) + { +Status = HttpInstance->Tcp4->Configure (HttpInstance->Tcp4, NULL); +if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "HttpConfigureTcp4(NULL) - %r\n", Status)); + return Status; +} + +HttpInstance->State = HTTP_STATE_TCP_UNCONFIGED; + } + Status = HttpInstance->Tcp4->Configure (HttpInstance->Tcp4, Tcp4CfgData); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "HttpConfigureTcp4 - %r\n", Status)); -- 2.35.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87831): https://edk2.groups.io/g/devel/message/87831 Mute This Topic: https://groups.io/mt/89951841/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v3 0/5] Http Fixes (Take Two)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2720 This set of patches fixes booting from HTTP/1.0 servers. It also improves the interaction with HTTP/1.1 servers by recognizing the 'Connection: close' header field, which fixes a problem with servers that close the connection after a 404-error is encountered. It also prevents triggering the TCP issue described in https://bugzilla.tianocore.org/show_bug.cgi?id=3735 when booting from HTTP/1.0 servers. PR: https://github.com/tianocore/edk2/pull/2564 Oliver Steffen (5): NetworkPkg/HttpDxe: Decofigure Tcp4 before reconfiguring NetworkPkg/HttpDxe: Decofigure Tcp6 before reconfiguring NetworkPkg/HttpDxe: Add ConnectionClose flag fo HTTP_PROTOCOL NetworkPkg/HttpDxe: Detect 'Connection: close' header NetworkPkg/HttpDxe: Detect HTTP/1.0 servers NetworkPkg/HttpDxe/HttpProto.h | 2 ++ NetworkPkg/HttpDxe/HttpImpl.c | 25 - NetworkPkg/HttpDxe/HttpProto.c | 24 3 files changed, 50 insertions(+), 1 deletion(-) -- 2.35.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87833): https://edk2.groups.io/g/devel/message/87833 Mute This Topic: https://groups.io/mt/89951844/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v3 2/5] NetworkPkg/HttpDxe: Decofigure Tcp6 before reconfiguring
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2720 Check if the state of the HTTP instance is HTTP_STATE_TCP_CONNECTED, or HTTP_STATE_TCP_CLOSED and de-configure the Tcp6 instance before configuring it again. Signed-off-by: Oliver Steffen --- NetworkPkg/HttpDxe/HttpProto.c | 12 1 file changed, 12 insertions(+) diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c index cd54c574044b..33ae622c3f0b 100644 --- a/NetworkPkg/HttpDxe/HttpProto.c +++ b/NetworkPkg/HttpDxe/HttpProto.c @@ -1168,6 +1168,18 @@ HttpConfigureTcp6 ( Tcp6Option->KeepAliveInterval = HTTP_KEEP_ALIVE_INTERVAL; Tcp6Option->EnableNagle = TRUE; + if ((HttpInstance->State == HTTP_STATE_TCP_CONNECTED) || + (HttpInstance->State == HTTP_STATE_TCP_CLOSED)) + { +Status = HttpInstance->Tcp6->Configure (HttpInstance->Tcp6, NULL); +if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "HttpConfigureTcp6(NULL) - %r\n", Status)); + return Status; +} + +HttpInstance->State = HTTP_STATE_TCP_UNCONFIGED; + } + Status = HttpInstance->Tcp6->Configure (HttpInstance->Tcp6, Tcp6CfgData); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "HttpConfigureTcp6 - %r\n", Status)); -- 2.35.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87832): https://edk2.groups.io/g/devel/message/87832 Mute This Topic: https://groups.io/mt/89951842/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v3 5/5] NetworkPkg/HttpDxe: Detect HTTP/1.0 servers
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2720 Force connection close before the next request if the server identifies as version 1.0. Signed-off-by: Oliver Steffen --- NetworkPkg/HttpDxe/HttpImpl.c | 8 1 file changed, 8 insertions(+) diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index d40d55ac92ad..623e029c606e 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.c +++ b/NetworkPkg/HttpDxe/HttpImpl.c @@ -1105,6 +1105,14 @@ HttpResponseWorker ( HttpInstance->CacheLen = BodyLen; } +// +// Check server's HTTP version. +// +if (AsciiStrnCmp (HttpHeaders, "HTTP/1.0", AsciiStrLen ("HTTP/1.0")) == 0) { + DEBUG ((DEBUG_VERBOSE, "HTTP: Server version is 1.0. Setting Connection close.\n")); + HttpInstance->ConnectionClose = TRUE; +} + // // Search for Status Code. // -- 2.35.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87835): https://edk2.groups.io/g/devel/message/87835 Mute This Topic: https://groups.io/mt/89951849/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v3 4/5] NetworkPkg/HttpDxe: Detect 'Connection: close' header
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2720 Force connection close before the next request if the server sends the 'Connection: close' header. Signed-off-by: Oliver Steffen --- NetworkPkg/HttpDxe/HttpImpl.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index d8b014c94f3a..d40d55ac92ad 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.c +++ b/NetworkPkg/HttpDxe/HttpImpl.c @@ -994,6 +994,7 @@ HttpResponseWorker ( UINTN HdrLen; NET_FRAGMENT Fragment; UINT32TimeoutValue; + UINTN index; if ((Wrap == NULL) || (Wrap->HttpInstance == NULL)) { return EFI_INVALID_PARAMETER; @@ -1200,6 +1201,16 @@ HttpResponseWorker ( FreePool (HttpHeaders); HttpHeaders = NULL; + for (index = 0; index < HttpMsg->HeaderCount; ++index) { +if ((AsciiStriCmp ("Connection", HttpMsg->Headers[index].FieldName) == 0) && +(AsciiStriCmp ("close", HttpMsg->Headers[index].FieldValue) == 0)) +{ + DEBUG ((DEBUG_VERBOSE, "Http: 'Connection: close' header received.\n")); + HttpInstance->ConnectionClose = TRUE; + break; +} + } + // // Init message-body parser by header information. // -- 2.35.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87834): https://edk2.groups.io/g/devel/message/87834 Mute This Topic: https://groups.io/mt/89951848/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v3 3/5] NetworkPkg/HttpDxe: Add ConnectionClose flag fo HTTP_PROTOCOL
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2720 Add ConnectionClose flag to HTTP_PROTOCOL. This boolean is FALSE by default. If set to TRUE, a reconfigure of the Http instance is forced on the next request. The flag is then reset. Signed-off-by: Oliver Steffen --- NetworkPkg/HttpDxe/HttpProto.h | 2 ++ NetworkPkg/HttpDxe/HttpImpl.c | 6 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NetworkPkg/HttpDxe/HttpProto.h b/NetworkPkg/HttpDxe/HttpProto.h index 8ed99c7a02d3..620eb3915843 100644 --- a/NetworkPkg/HttpDxe/HttpProto.h +++ b/NetworkPkg/HttpDxe/HttpProto.h @@ -194,6 +194,8 @@ typedef struct _HTTP_PROTOCOL { EFI_TCP6_IO_TOKEN Tcp6TlsRxToken; EFI_TCP6_RECEIVE_DATA Tcp6TlsRxData; BOOLEAN TlsIsRxDone; + + BOOLEAN ConnectionClose; } HTTP_PROTOCOL; typedef struct { diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index d64cd9e965c0..d8b014c94f3a 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.c +++ b/NetworkPkg/HttpDxe/HttpImpl.c @@ -161,6 +161,7 @@ EfiHttpConfigure ( HttpInstance->HttpVersion= HttpConfigData->HttpVersion; HttpInstance->TimeOutMillisec= HttpConfigData->TimeOutMillisec; HttpInstance->LocalAddressIsIPv6 = HttpConfigData->LocalAddressIsIPv6; +HttpInstance->ConnectionClose= FALSE; if (HttpConfigData->LocalAddressIsIPv6) { CopyMem ( @@ -440,7 +441,8 @@ EfiHttpRequest ( // ReConfigure = FALSE; } else { - if ((HttpInstance->RemotePort == RemotePort) && + if ((HttpInstance->ConnectionClose == FALSE) && + (HttpInstance->RemotePort == RemotePort) && (AsciiStrCmp (HttpInstance->RemoteHost, HostName) == 0) && (!HttpInstance->UseHttps || (HttpInstance->UseHttps && !TlsConfigure && @@ -649,6 +651,8 @@ EfiHttpRequest ( } } + HttpInstance->ConnectionClose = FALSE; + // // Transmit the request message. // -- 2.35.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87836): https://edk2.groups.io/g/devel/message/87836 Mute This Topic: https://groups.io/mt/89951850/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel][PATCH 1/2] MdeModulePkg: StackOffset must be aligned to a 16-byte boundary in X64
Hi Marvin, Please find my inline comments with [Ted2]. Thanks, Ted -Original Message- From: Marvin Häuser Sent: Tuesday, March 22, 2022 5:27 PM To: Kuo, Ted Cc: devel@edk2.groups.io; Kinney, Michael D ; Bi, Dandan ; Gao, Liming ; De, Debkumar ; Han, Harry ; West, Catharine ; Wang, Jian J Subject: Re: [edk2-devel][PATCH 1/2] MdeModulePkg: StackOffset must be aligned to a 16-byte boundary in X64 Good day, Thanks for the updates! > On 22. Mar 2022, at 08:23, Kuo, Ted wrote: > > Hi Marvin, > > Good day. Thanks for your valuable comments. After checking all of your > comments, I decide to drop the patches and close the bugzilla ticket since > the changes should be specific to X64 in IntelFspPkg. You still can find my > inline comments with [Ted] for your questions. > > Thanks, > Ted > > -Original Message- > From: Marvin Häuser > Sent: Tuesday, March 22, 2022 3:46 AM > To: devel@edk2.groups.io; Kuo, Ted > Cc: Kinney, Michael D ; Bi, Dandan > ; Gao, Liming ; De, > Debkumar ; Han, Harry ; > West, Catharine ; Wang, Jian J > > Subject: Re: [edk2-devel][PATCH 1/2] MdeModulePkg: StackOffset must be > aligned to a 16-byte boundary in X64 > > Good day, > > Thanks for the update! > >> On 21.03.22 13:43, Kuo, Ted wrote: >> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3865 >> For X64, StackOffset must be aligned to a 16-byte boundary as well as >> old stack and new stack. Otherwise, it'll get wrong data from Private >> pointer after switching from old stack to new stack. >> >> Cc: Michael D Kinney >> Cc: Dandan Bi >> Cc: Liming Gao >> Cc: Debkumar De >> Cc: Harry Han >> Cc: Catharine West >> Cc: Jian J Wang >> Cc: Marvin Häuser >> Signed-off-by: Ted Kuo >> --- >> MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 18 >> +- >> 1 file changed, 17 insertions(+), 1 deletion(-) >> >> diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c >> b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c >> index 3552feda8f..8a2c1ec779 100644 >> --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c >> +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c >> @@ -823,6 +823,19 @@ PeiCheckAndSwitchStack ( >> (VOID **)&TemporaryRamSupportPpi >> ); >> if (!EFI_ERROR (Status)) { >> + // >> + // For X64, StackOffset must be aligned to a 16-byte boundary. >> Otherwise, it'll get wrong data >> + // from Private pointer after switching to new stack. >> + // >> + if ((sizeof (UINTN) == sizeof (UINT64)) && ((StackOffset & 0x0F) == >> 8)) { >> +if (StackOffsetPositive == TRUE) { >> + StackOffset -= 8; >> +} else { >> + StackOffset += 8; >> +} >> +Private->StackOffset = StackOffset; >> + } >> + > > Hmm, the overall design (not your patch) looks very broken to me. So, if the > PPI exists, it's responsible for the migration of the stack, but it is > neither passed where to migrate the stack to, nor does it return where it did > migrate it to. This means the StackOffset calculated here may be out-of-sync > with what actually happens in the PPI, e.g., if the PPI code is changed. > There also is no detailed explanation for the memory layout with FSP separate > stack vs bootloader shared stack, so I cannot really give detailed comments > quickly. *Sigh*. > > Anyhow, as for the patch, I do not understand a few things: > > 1) Maybe most important of all, what even is broken? Which address is not > 16-Byte-aligned to cause this issue in the first place? > [Ted]: CPU will generate exception when running some X64 instructions which > need input/output memory address to be 16-Byte-aligned. Yes, I understood as much. I built a chain of reasoning for alignment in the response for the first revision, because a proper fix needs knowledge of which assumption is wrong in the first place. The question is, which *exact* value in the chain is not 16-Byte aligned, and should it be? Did you ever print all involved values, like PhysicalMemoryBegin (or whatever its name was, sorry, I’m responding from mobile)? [Ted2]: Yes, I confirmed that no issue with the current design in Dispatcher.c. The unaligned stack offset I observed was caused by the unaligned TopOfOldStack which is produced by sum of SecCoreData->StackBase and SecCoreData->StackSize. In my case, SecCoreData is provided by FspSecCore. Hence we need to ensure SecCoreData->StackBase and SecCoreData->StackSize provided by FspSecCore are 16-byte-aligned instead of making changes in Dispatcher.c in MdeModulePkg. The correct fix should be making the size of CONTEXT_STACK to be 16-byte-aligned for X64 so that FspSecCore can produce 16-byte-aligned stack base and save it in SecCoreData->StackBase. The fix will be included in the patch of enabling FspSecCore support for X64. > > 2) Why do you align StackOffset? Like yes, if the old top of the stack and > the offset to the new top of the stack are both 1
Re: [edk2-devel] [PATCH v1 1/4] .pytool/Plugin/UncrustifyCheck: Update func to return absolute paths
Reviewed-by: Michael D Kinney Mike > -Original Message- > From: devel@edk2.groups.io On Behalf Of Michael Kubacki > Sent: Monday, March 21, 2022 6:58 PM > To: devel@edk2.groups.io > Cc: Kinney, Michael D ; Gao, Liming > ; Sean Brogan > ; Bret Barkelew > Subject: [edk2-devel] [PATCH v1 1/4] .pytool/Plugin/UncrustifyCheck: Update > func to return absolute paths > > From: Michael Kubacki > > Currently, UncrustifyCheck._get_git_ignored_paths() is documented to > return a list of absolute file paths but it currently returns a list > of relative file paths. > > This change updates the function to return a list of absolute file > paths. The result is later compared to the list of absolute file > paths for files to run against Uncrustify. > > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Sean Brogan > Cc: Bret Barkelew > Signed-off-by: Michael Kubacki > --- > .pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py | 6 +- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py > b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py > index 82db7a5a438b..dc133fecc4b2 100644 > --- a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py > +++ b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py > @@ -292,7 +292,11 @@ class UncrustifyCheck(ICiBuildPlugin): > f"An error occurred reading git ignore settings. This will > prevent Uncrustify from running against the expected > set of files.") > > # Note: This will potentially be a large list, but at least sorted > -return outstream_buffer.getvalue().strip().splitlines() > +rel_paths = outstream_buffer.getvalue().strip().splitlines() > +abs_paths = [] > +for path in rel_paths: > +abs_paths.append(os.path.join(self._abs_workspace_path, path)) > +return abs_paths > > def _get_git_submodule_paths(self) -> List[str]: > """ > -- > 2.28.0.windows.1 > > > > -=-=-=-=-=-= > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#87810): https://edk2.groups.io/g/devel/message/87810 > Mute This Topic: https://groups.io/mt/89944182/1643496 > Group Owner: devel+ow...@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [michael.d.kin...@intel.com] > -=-=-=-=-=-= > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87838): https://edk2.groups.io/g/devel/message/87838 Mute This Topic: https://groups.io/mt/89944182/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v1 1/4] .pytool/Plugin/UncrustifyCheck: Update func to return absolute paths
Hi Michael, I meant to ask. Is there a reason you are not normalizing the file paths os.path.normpath() before performing the path comparison? I am concerned that a mix of '/', '\' and '..' in YAML file may not detect what is supposed to be a matching path. Perhaps this is a topic that applies to IgnoreFiles feature for all plugins and can be addressed in a separate patch. Mike > -Original Message- > From: Kinney, Michael D > Sent: Tuesday, March 22, 2022 9:07 AM > To: devel@edk2.groups.io; mikub...@linux.microsoft.com; Kinney, Michael D > > Cc: Gao, Liming ; Sean Brogan > ; Bret Barkelew > Subject: RE: [edk2-devel] [PATCH v1 1/4] .pytool/Plugin/UncrustifyCheck: > Update func to return absolute paths > > Reviewed-by: Michael D Kinney > > Mike > > > -Original Message- > > From: devel@edk2.groups.io On Behalf Of Michael > > Kubacki > > Sent: Monday, March 21, 2022 6:58 PM > > To: devel@edk2.groups.io > > Cc: Kinney, Michael D ; Gao, Liming > > ; Sean Brogan > > ; Bret Barkelew > > Subject: [edk2-devel] [PATCH v1 1/4] .pytool/Plugin/UncrustifyCheck: Update > > func to return absolute paths > > > > From: Michael Kubacki > > > > Currently, UncrustifyCheck._get_git_ignored_paths() is documented to > > return a list of absolute file paths but it currently returns a list > > of relative file paths. > > > > This change updates the function to return a list of absolute file > > paths. The result is later compared to the list of absolute file > > paths for files to run against Uncrustify. > > > > Cc: Michael D Kinney > > Cc: Liming Gao > > Cc: Sean Brogan > > Cc: Bret Barkelew > > Signed-off-by: Michael Kubacki > > --- > > .pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py | 6 +- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py > > b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py > > index 82db7a5a438b..dc133fecc4b2 100644 > > --- a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py > > +++ b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py > > @@ -292,7 +292,11 @@ class UncrustifyCheck(ICiBuildPlugin): > > f"An error occurred reading git ignore settings. This will > > prevent Uncrustify from running against the > expected > > set of files.") > > > > # Note: This will potentially be a large list, but at least sorted > > -return outstream_buffer.getvalue().strip().splitlines() > > +rel_paths = outstream_buffer.getvalue().strip().splitlines() > > +abs_paths = [] > > +for path in rel_paths: > > +abs_paths.append(os.path.join(self._abs_workspace_path, path)) > > +return abs_paths > > > > def _get_git_submodule_paths(self) -> List[str]: > > """ > > -- > > 2.28.0.windows.1 > > > > > > > > -=-=-=-=-=-= > > Groups.io Links: You receive all messages sent to this group. > > View/Reply Online (#87810): https://edk2.groups.io/g/devel/message/87810 > > Mute This Topic: https://groups.io/mt/89944182/1643496 > > Group Owner: devel+ow...@edk2.groups.io > > Unsubscribe: https://edk2.groups.io/g/devel/unsub > > [michael.d.kin...@intel.com] > > -=-=-=-=-=-= > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87839): https://edk2.groups.io/g/devel/message/87839 Mute This Topic: https://groups.io/mt/89944182/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v1 2/4] .pytool/Plugin/UncrustifyCheck: Add ignore file support
Michael, One comment below. Mike > -Original Message- > From: mikub...@linux.microsoft.com > Sent: Monday, March 21, 2022 6:58 PM > To: devel@edk2.groups.io > Cc: Kinney, Michael D ; Gao, Liming > ; Sean Brogan > ; Bret Barkelew > Subject: [PATCH v1 2/4] .pytool/Plugin/UncrustifyCheck: Add ignore file > support > > From: Michael Kubacki > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3880 > > Currently UncrustifyCheck.py provides the following exclusion > options: > > 1. Override the type of files UncrustifyCheck operates against by > default (.c and .h files). Using the "IgnoreStandardPaths" > configuration option. > > 2. By default, UncrustifyCheck skips files in git submodules and > ignored by git (the "SkipGitExclusions" configuration option can > override this behavior). > > The goal of UncrustifyCheck is to provide consistent formatting > across the codebase. In some rare circumstances, maintainers might > need to exclude a specific file (or file pattern) within their > package. For example, a small set of auto-generated files from > another repository. > > This change adds a new configuration option that can be specified > in a package CI YAML file to describe a list of files within the > package that should be ignored by UncrustifyCheck. > > The configuration option is called "IgnoreFiles" and it uses similar > syntax to git ignore to ignore a list of files. > > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Sean Brogan > Cc: Bret Barkelew > Signed-off-by: Michael Kubacki > --- > .pytool/Plugin/UncrustifyCheck/Readme.md | 7 ++ > .pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py | 24 > 2 files changed, 31 insertions(+) > > diff --git a/.pytool/Plugin/UncrustifyCheck/Readme.md > b/.pytool/Plugin/UncrustifyCheck/Readme.md > index 0c46fd241a7a..efe7a573e4fa 100644 > --- a/.pytool/Plugin/UncrustifyCheck/Readme.md > +++ b/.pytool/Plugin/UncrustifyCheck/Readme.md > @@ -41,6 +41,7 @@ The plugin can be configured with a few optional > configuration options. >"AdditionalIncludePaths": [], # Additional paths to check formatting > (wildcards supported). >"AuditOnly": False, # Don't fail the build if there are > errors. Just log them. >"ConfigFilePath": "", # Custom path to an Uncrustify config > file. > + "IgnoreFiles": [],# A list of file patterns to ignore. >"IgnoreStandardPaths": [],# Standard Plugin defined paths that > should be ignored. >"OutputFileDiffs": True, # Output chunks of formatting diffs in > the test case log. > # This can significantly slow down the > plugin on very large packages. > @@ -67,6 +68,12 @@ the test as skipped. This allows visibility into the > failures without breaking t > > When specified in the config file, this is a package relative path to the > Uncrustify configuration file. > > +### `IgnoreFiles` > + > +This option supports .gitignore file and folder matching strings including > wildcards. > + > +The files specified by this configuration option will not be processed by > Uncrustify. > + > ### `IgnoreStandardPaths` > > This plugin by default will check the below standard paths. A package > configuration file can specify any of these paths > diff --git a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py > b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py > index dc133fecc4b2..e8370381032f 100644 > --- a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py > +++ b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py > @@ -13,11 +13,13 @@ import os > import pathlib > import shutil > import timeit > +from collections.abc import Callable > from edk2toolext.environment import version_aggregator > from edk2toolext.environment.plugin_manager import PluginManager > from edk2toolext.environment.plugintypes.ci_build_plugin import > ICiBuildPlugin > from edk2toolext.environment.plugintypes.uefi_helper_plugin import > HelperFunctions > from edk2toolext.environment.var_dict import VarDict > +from edk2toollib.gitignore_parser import parse_gitignore_lines > from edk2toollib.log.junit_report_format import JunitReportTestCase > from edk2toollib.uefi.edk2.path_utilities import Edk2Path > from edk2toollib.utility_functions import RunCmd > @@ -273,6 +275,15 @@ class UncrustifyCheck(ICiBuildPlugin): > f"-c {self._app_config_file} -F {self._app_input_file_path} > --if-changed --suffix > {UncrustifyCheck.FORMATTED_FILE_EXTENSION}", outstream=output) > self._app_output = output.getvalue().strip().splitlines() > > +def _get_files_ignored_in_config(self) -> Callable[[str], bool]: > + > +Returns a function that returns true if a given file string path is > ignored in the plugin configuration file and false > otherwise. > +""" > +ignored_files = [] > +if "IgnoreFiles" in self._package_config: > +ign
Re: [edk2-devel] [PATCH v1 0/4] UncrustifyCheck Ignore Support
Hi Michael, Should this be broken up into 2 series? One for pytool change and one for OvmfPkg? Mike > -Original Message- > From: mikub...@linux.microsoft.com > Sent: Monday, March 21, 2022 6:58 PM > To: devel@edk2.groups.io > Cc: Kinney, Michael D ; Gao, Liming > ; Sean Brogan > ; Bret Barkelew ; Ard > Biesheuvel ; Yao, Jiewen > ; Justen, Jordan L ; Gerd > Hoffmann ; Rebecca Cran > ; Peter Grehan ; Laszlo Ersek > > Subject: [PATCH v1 0/4] UncrustifyCheck Ignore Support > > From: Michael Kubacki > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3880 > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3875 > > This patch series: > 1. Updates ignore handling in UncrustifyCheck including adding > a new CI plugin configuration option to ignore files in a package. > 2. Reverts Uncrustify changes as requested for files in OvmfPkg. > 3. Uses the new ignore file option to ignore the files that had > Uncrustify formatting reverted in OvmfPkg. > > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Sean Brogan > Cc: Bret Barkelew > Cc: Ard Biesheuvel > Cc: Jiewen Yao > Cc: Jordan Justen > Cc: Gerd Hoffmann > Cc: Rebecca Cran > Cc: Peter Grehan > Cc: Laszlo Ersek > Signed-off-by: Michael Kubacki > > Michael Kubacki (4): > .pytool/Plugin/UncrustifyCheck: Update func to return absolute paths > .pytool/Plugin/UncrustifyCheck: Add ignore file support > OvmfPkg: Revert Uncrustify formatting in VbeShim.h files > OvmfPkg: Do not check VbeShim.h formatting with Uncrustify > > .pytool/Plugin/UncrustifyCheck/Readme.md |7 + > .pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py | 30 +- > OvmfPkg/Bhyve/BhyveRfbDxe/VbeShim.h | 1811 ++-- > OvmfPkg/OvmfPkg.ci.yaml |5 + > OvmfPkg/QemuVideoDxe/VbeShim.h| 1389 --- > 5 files changed, 1640 insertions(+), 1602 deletions(-) > > -- > 2.28.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87841): https://edk2.groups.io/g/devel/message/87841 Mute This Topic: https://groups.io/mt/89944179/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v1 00/41] Add PrmPkg
From: Michael Kubacki This patch series adds a new package called PrmPkg. An RFC was sent to the edk2 mailing list on January 28, 2022 detailing the proposal, see https://edk2.groups.io/g/devel/message/86181. Platform Runtime Mechanism (PRM) is a new firmware solution that has been developed in edk2-staging/PlatformRuntimeMechanism. This patch series has been organized to greatly condense the history from the edk2-staging branch but to preserve important decisions and changes in history that help establish context of changes and will serve as valuable references for future development. Interest in PRM has increased across various vendors and we believe it is beneficial to make the source code more widely available for the following reasons: 1. PRM specification adoption 2. Feature completeness 3. Overall validation coverage 4. Interest from the community and future collaboration The technical details of PRM are covered in the PRM Specification in addition to the Readme.md file located in the root of PrmPkg in this patch series. 1. PRM specification adoption Intel and Microsoft have worked together to standardize PRM in the ACPI Specification and the PRM Specification hosted on uefi.org. * ACPI 6.4 Specification: https://uefi.org/node/4149 * PRM Specification: https://uefi.org/sites/default/files/resources/Platform%20Runtime%20Mechanism%20-%20with%20legal%20notice.pdf 2. Feature completeness PrmPkg implements the full firmware functionality described in the PRM Specification and there are no significant changes to functionality planned at this time. Though we are very much interested in evolving PRM based on feedback. 3. Overall validation coverage PrmPkg has been integrated and tested on client and server systems in addition to virtual platforms (OvmfPkg/QEMU). Platform integration is simple and a demonstration of this integration for OvmfPkg is available in the following branch: https://github.com/makubacki/edk2/tree/ovmf_prmpkg_integration The code has been built with: * MSFT VS2015, VS2017, and VS2019 * GCC5 (see https://bugzilla.tianocore.org/show_bug.cgi?id=3802) * iASL compiler (20200528 - https://acpica.org/node/181) The Linux kernel currently includes the following PRM support: * _OSC PRM bit - allows FW to know determine the OS is PRM-capable and can redirect _DSM method from alternate triggers (such as SMI) to PRM. * PRM invocation via _DSM, includes PRM module and handler parsing from ACPI PRMT table, and also the PRM operation region handler for runtime PRM service invocation. * An OS configuration for PRM enabling, PRM support can be disabled during OS image build. Note that upstream Linux does not currently support the following: * Ability for the OS driver to call a PRM handler directly, it has to be via ACPI _DSM. * Run time update PRM module and handler via PE/COFF PRM image. This commit provides additional context of the changes in Linux: https://github.com/torvalds/linux/commit/cefc7ca46235f01d5233e3abd4b79452af01d9e9 Windows 11 (https://www.microsoft.com/software-download/windows11) and Windows Server 2022 (https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk) include the PRM functionality noted above in addition to PRM direct call and PRM runtime updates. PRM has been tested on IA32, X64, and AARCH64 targets. 4. Interest from the community and future collaboration PRM has been presented at several industry conferences: * OSFC 2020 - "PRM: SMM Goes on a Diet" https://cfp.osfc.io/osfc2020/talk/MCJASB/ * OCP Summit 2019 - "Case Study Alternatives for SMM Usage in Intel Platforms" https://www.youtube.com/watch?v=mu3DRLM1dPA In addition, Microsoft plans to publish the Windows PRM driver interface and a WDF sample driver that uses the interface to the Windows Driver Samples GitHub repository (https://github.com/microsoft/Windows-driver-samples). We believe a PrmPkg in edk2 can increase accessibility to PRM and ease collaboration. PrmPkg -- PrmPkg contains the common functionality needed to enable PRM on any system. It does not contain platform-specific code such as PRM modules (and by extension PRM handlers). Other than sample modules, PrmPkg will only contain code needed to provide PRM feature functionality as defined in the PRM Specification. PrmPkg is scoped to continue to only contain platform-agnostic functionality in the future. The proposed maintainers of PrmPkg are: * Michael Kubacki * Nate DeSimone The proposed reviewers of PrmPkg are: * Ankit Sinha Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki Liu (2): PrmPkg: Publish PRM operation region to support PRM ACPI _DSM invocation PrmPkg: Export major/minor version in PRM module PE COFF header Liu Yun Y (1): PrmPkg: Update PRM OpRegion Michael Kubacki (38)
[edk2-devel] [PATCH v1 01/41] PrmPkg: Add package and include headers
From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3812 Adds a new package to maintain Platform Runtime Mechanism (PRM) support. This package is intended to include generic code that provides a common infrastructure to support PRM in firmware and a collection of sample PRM modules that demonstrate how to use the interfaces and other package resources to author a PRM module. The following initial headers are included in this commit: * Prm.h - Includes common content for PRM with no dependencies on other PRM header files. * PrmContextBuffer.h - Includes definitions for PRM context buffers. Context buffers are standardized structures that point to various resources available to a PRM handler during its execution. * PrmDataBuffer.h - Includes definitions for PRM data buffers. Within the context of PRM, these data buffers are composed of a generic header followed by a variable length blob of arbitrary data. * PrmExportDescriptor.h - Includes definitions for creating PRM export descriptors. A PRM export descriptor is a structure referenced in the export table of PRM module that contains PRM-specific metadata about the module. * PrmMmio.h - Includes definitions for describing MMIO ranges uses by PRM modules. * PrmModule.h - Includes definitions commonly used by PRM module authors. This file is provided to serve as a convenient include for PRM module authors. * PrmOsServices.h - Includes content specific to PRM OS services. OS Services will not planned to be present in the final version of PRM. The OS Services have been reduced to a simple debug print function. So this is currently planned to be a temporary file to support debugging during PRM development. Note: Modules built for the UEFI environment can be built by Visual Studio and non-Visual Studio toolchains. However, PRM modules are currently only supported on Visual Studio toolchain due to usage of export tables. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Include/Prm.h | 46 +++ PrmPkg/Include/PrmContextBuffer.h| 131 PrmPkg/Include/PrmDataBuffer.h | 50 PrmPkg/Include/PrmExportDescriptor.h | 87 + PrmPkg/Include/PrmMmio.h | 45 +++ PrmPkg/Include/PrmModule.h | 68 ++ PrmPkg/Include/PrmModuleUpdate.h | 46 +++ PrmPkg/Include/PrmOsServices.h | 45 +++ PrmPkg/PrmPkg.dec| 49 PrmPkg/PrmPkg.uni| 10 ++ 10 files changed, 577 insertions(+) diff --git a/PrmPkg/Include/Prm.h b/PrmPkg/Include/Prm.h new file mode 100644 index ..0e3ccfffa333 --- /dev/null +++ b/PrmPkg/Include/Prm.h @@ -0,0 +1,46 @@ +/** @file + + Common Platform Runtime Mechanism (PRM) definitions. + + Copyright (c) Microsoft Corporation + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef PRM_H_ +#define PRM_H_ + +#include +#include + +#if defined(_MSC_VER) + #define PRM_EXPORT_API __declspec(dllexport) +#else + #define PRM_EXPORT_API +#endif + +#define PRM_HANDLER_NAME_MAXIMUM_LENGTH 128 + +#define PRM_STRING_(x)#x +#define PRM_STRING(x) PRM_STRING_(x) + +/** + A Platform Runtime Mechanism (PRM) handler function. + + @param[in] ParameterBuffer A pointer to a buffer with arbitrary data that is allocated and populated + by the PRM handler caller. + @param[in] ContextBuffer A pointer to a buffer with arbitrary data that is allocated in the firmware + boot environment. + + @retval EFI_STATUS The PRM handler executed successfully. + @retval Others An error occurred in the PRM handler. + +**/ +typedef +EFI_STATUS +(EFIAPI PRM_HANDLER) ( + IN VOID *ParameterBuffer OPTIONAL, + IN PRM_CONTEXT_BUFFER *ContextBuffer OPTIONAL + ); + +#endif diff --git a/PrmPkg/Include/PrmContextBuffer.h b/PrmPkg/Include/PrmContextBuffer.h new file mode 100644 index ..8f8144545e64 --- /dev/null +++ b/PrmPkg/Include/PrmContextBuffer.h @@ -0,0 +1,131 @@ +/** @file + + Definitions for the Platform Runtime Mechanism (PRM) context buffer structures. + + Copyright (c) Microsoft Corporation + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef PRM_CONTEXT_BUFFER_H_ +#define PRM_CONTEXT_BUFFER_H_ + +#include +#include +#include + +#define PRM_CONTEXT_BUFFER_SIGNATURE SIGNATURE_32('P','R','M','C') +#define PRM_CONTEXT_BUFFER_INTERFACE_VERSION 1 + +#pragma pack(push, 1) + +// +// This is the context buffer structure that is passed to a PRM handler. +// +// At OS runtime, the OS wil
[edk2-devel] [PATCH v1 02/41] PrmPkg: Add PrmConfig protocol interface
From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3812 The PRM Configuration protocol is used by PRM module configuration libraries to describe their resources so that a generic PRM Configuration DXE driver can prepare those resources for OS runtime. Therefore, multiple instances are expected in the system per boot with approximately one instance per PRM module. All PRM Configuration Protocol instances must be installed prior to end of DXE. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Include/Protocol/PrmConfig.h | 32 1 file changed, 32 insertions(+) diff --git a/PrmPkg/Include/Protocol/PrmConfig.h b/PrmPkg/Include/Protocol/PrmConfig.h new file mode 100644 index ..d90fe5a0dd73 --- /dev/null +++ b/PrmPkg/Include/Protocol/PrmConfig.h @@ -0,0 +1,32 @@ +/** @file + + PRM Configuration protocol + + PRM Configuration protocol is used by PRM module configuration libraries to + describe their resources so that a generic PRM Configuration DXE driver can prepare those + resources for OS runtime. + + Copyright (c) Microsoft Corporation + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef PRM_CONFIG_H_ +#define PRM_CONFIG_H_ + +#include +#include + +typedef struct _PRM_CONFIG_PROTOCOL PRM_CONFIG_PROTOCOL; + +#define PRM_CONFIG_PROTOCOL_SIGNATURE SIGNATURE_32('P','M','C','P') +#define PRM_CONFIG_PROTOCOL_VERSION 1 + +struct _PRM_CONFIG_PROTOCOL +{ + PRM_MODULE_CONTEXT_BUFFERSModuleContextBuffers; +}; + +extern EFI_GUID gPrmConfigProtocolGuid; + +#endif -- 2.28.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87844): https://edk2.groups.io/g/devel/message/87844 Mute This Topic: https://groups.io/mt/89955949/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v1 03/41] PrmPkg/PrmContextBufferLib: Add initial library instance
From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3812 This library is introduced to add a general abstraction for PRM context buffer management. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Library/DxePrmContextBufferLib/DxePrmContextBufferLib.c | 196 PrmPkg/Include/Library/PrmContextBufferLib.h | 99 ++ PrmPkg/Library/DxePrmContextBufferLib/DxePrmContextBufferLib.inf | 35 3 files changed, 330 insertions(+) diff --git a/PrmPkg/Library/DxePrmContextBufferLib/DxePrmContextBufferLib.c b/PrmPkg/Library/DxePrmContextBufferLib/DxePrmContextBufferLib.c new file mode 100644 index ..1a1a15b5cdbb --- /dev/null +++ b/PrmPkg/Library/DxePrmContextBufferLib/DxePrmContextBufferLib.c @@ -0,0 +1,196 @@ +/** @file + + The PRM Buffer Context library provides a general abstraction for context buffer management. + + Copyright (c) Microsoft Corporation + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +#define _DBGMSGID_"[PRMCONTEXTBUFFERLIB]" + +/** + Finds a PRM context buffer for the given PRM handler GUID. + + Note: PRM_MODULE_CONTEXT_BUFFERS is at the PRM module level while PRM_CONTEXT_BUFFER is at the PRM handler level. + + @param[in] HandlerGuid A pointer to the PRM handler GUID. + @param[in] ModuleContextBuffersA pointer to the PRM context buffers structure for the PRM module. + @param[out] PrmModuleContextBuffer A pointer to a pointer that will be set to the PRM context buffer + if successfully found. + + @retval EFI_SUCCESS The PRM context buffer was found. + @retval EFI_INVALID_PARAMETER A required parameter pointer is NULL. + @retval EFI_NOT_FOUND The context buffer for the given PRM handler GUID could not be found. + +**/ +EFI_STATUS +FindContextBufferInModuleBuffers ( + IN CONST EFI_GUID *HandlerGuid, + IN CONST PRM_MODULE_CONTEXT_BUFFERS*ModuleContextBuffers, + OUT CONST PRM_CONTEXT_BUFFER**ContextBuffer + ) +{ + UINTN Index; + + DEBUG ((DEBUG_INFO, "%a %a - Entry.\n", _DBGMSGID_, __FUNCTION__)); + + if (HandlerGuid == NULL || ModuleContextBuffers == NULL || ContextBuffer == NULL) { +return EFI_INVALID_PARAMETER; + } + + for (Index = 0; Index < ModuleContextBuffers->BufferCount; Index++) { +if (CompareGuid (&ModuleContextBuffers->Buffer[Index].HandlerGuid, HandlerGuid)) { + *ContextBuffer = &ModuleContextBuffers->Buffer[Index]; + return EFI_SUCCESS; +} + } + + return EFI_NOT_FOUND; +} + +/** + Returns a PRM context buffers structure for the given PRM search type. + + This function allows a caller to get the context buffers structure for a PRM module with either the PRM module + GUID or the GUID for a PRM handler in the module. + + Note: PRM_MODULE_CONTEXT_BUFFERS is at the PRM module level while PRM_CONTEXT_BUFFER is at the PRM handler level. + + @param[in] GuidSearchType The type of GUID passed in the Guid argument. + @param[in] GuidA pointer to the GUID of a PRM module or PRM handler. The actual GUID type + will be interpreted based on the value passed in GuidSearchType. + @param[out] PrmModuleContextBuffers A pointer to a pointer that will be set to the PRM context buffers + structure if successfully found. + + @retval EFI_SUCCESS The PRM context buffers structure was found. + @retval EFI_INVALID_PARAMETER A required parameter pointer is NULL. + @retval EFI_NOT_FOUND The context buffers for the given GUID could not be found. + +**/ +EFI_STATUS +GetModuleContextBuffers ( + IN PRM_GUID_SEARCH_TYPEGuidSearchType, + IN CONST EFI_GUID *Guid, + OUT CONST PRM_MODULE_CONTEXT_BUFFERS**PrmModuleContextBuffers + ) +{ + EFI_STATUS Status; + UINTN HandleCount; + UINTN Index; + EFI_HANDLE *HandleBuffer; + PRM_CONFIG_PROTOCOL *PrmConfigProtocol; + CONST PRM_CONTEXT_BUFFER*PrmContextBuffer; + + DEBUG ((DEBUG_INFO, "%a %a - Entry.\n", _DBGMSGID_, __FUNCTION__)); + + if (Guid == NULL || PrmModuleContextBuffers == NULL) { +return EFI_INVALID_PARAMETER; + } + *PrmModuleContextBuffers = NULL; + + Status = gBS->LocateHandleBuffer ( + ByProtocol, + &gPrmConfigProtocolGuid, + NULL, + &HandleCount, + &HandleBuffer +
[edk2-devel] [PATCH v1 04/41] PrmPkg/PrmConfigDxe: Add initial driver
From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3812 This driver serves as a generic PRM configuration driver. Its primary role is to prepare PRM resources published by PRM module configuration libraries for OS runtime. As such, it locates all PRM Configuration Protocol instances and consumes the information to ready those resources. For example, set runtime memory attributes on MMIO ranges and convert physical addresses to virtual addresses in PRM buffers. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/PrmConfigDxe/PrmConfigDxe.c | 559 PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c | 925 PrmPkg/PrmConfigDxe/PrmConfigDxe.inf | 48 + PrmPkg/PrmLoaderDxe/PrmAcpiTable.h | 97 ++ PrmPkg/PrmLoaderDxe/PrmLoader.h | 51 ++ PrmPkg/PrmLoaderDxe/PrmLoaderDxe.inf | 59 ++ 6 files changed, 1739 insertions(+) diff --git a/PrmPkg/PrmConfigDxe/PrmConfigDxe.c b/PrmPkg/PrmConfigDxe/PrmConfigDxe.c new file mode 100644 index ..cb38146bc9e0 --- /dev/null +++ b/PrmPkg/PrmConfigDxe/PrmConfigDxe.c @@ -0,0 +1,559 @@ +/** @file + + This file contains the implementation for a Platform Runtime Mechanism (PRM) configuration driver. + + Copyright (c) Microsoft Corporation + Copyright (c) 2020, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#define _DBGMSGID_"[PRMCONFIG]" + +STATIC UINTN mMaxRuntimeMmioRangeCount; +STATIC UINTN mMaxStaticDataBufferCount; + +STATIC PRM_RUNTIME_MMIO_RANGES **mRuntimeMmioRanges; +STATIC PRM_DATA_BUFFER ***mStaticDataBuffers; + +/** + Converts the runtime memory range physical addresses to virtual addresses. + + @param[in] RuntimeMmioRanges A pointer to a PRM_RUNTIME_MMIO_RANGES buffer. + +**/ +VOID +ConvertRuntimeMemoryRangeAddresses ( + IN PRM_RUNTIME_MMIO_RANGES *RuntimeMmioRanges + ) +{ + UINTN Index; + + if (RuntimeMmioRanges == NULL || RuntimeMmioRanges->Count == 0) { +return; + } + + for (Index = 0; Index < (UINTN) RuntimeMmioRanges->Count; Index++) { +RuntimeMmioRanges->Range[Index].VirtualBaseAddress = RuntimeMmioRanges->Range[Index].PhysicalBaseAddress; +gRT->ConvertPointer (0x0, (VOID **) &(RuntimeMmioRanges->Range[Index].VirtualBaseAddress)); + } +} + +/** + Sets the runtime memory range attributes. + + The EFI_MEMORY_RUNTIME attribute is set for each PRM_RUNTIME_MMIO_RANGE present + in the buffer provided. + + @param[in] RuntimeMmioRanges A pointer to a PRM_RUNTIME_MMIO_RANGES buffer. + +**/ +VOID +SetRuntimeMemoryRangeAttributes ( + IN PRM_RUNTIME_MMIO_RANGES *RuntimeMmioRanges + ) +{ + EFI_STATUSStatus; + EFI_STATUSStatus2; + UINTN Index; + EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor; + + DEBUG ((DEBUG_INFO, "%a %a - Entry.\n", _DBGMSGID_, __FUNCTION__)); + + if (RuntimeMmioRanges == NULL || RuntimeMmioRanges->Count == 0) { +return; + } + + for (Index = 0; Index < (UINTN) RuntimeMmioRanges->Count; Index++) { +DEBUG (( + DEBUG_INFO, " %a %a: Runtime MMIO Range [%d].\n", _DBGMSGID_, __FUNCTION__, Index)); +DEBUG (( + DEBUG_INFO, + " %a %a: Physical address = 0x%016x. Length = 0x%x.\n", + _DBGMSGID_, + __FUNCTION__, + RuntimeMmioRanges->Range[Index].PhysicalBaseAddress, + RuntimeMmioRanges->Range[Index].Length + )); + +// Runtime memory ranges should cover ranges on a page boundary +ASSERT ((RuntimeMmioRanges->Range[Index].PhysicalBaseAddress & EFI_PAGE_MASK) == 0); +ASSERT ((RuntimeMmioRanges->Range[Index].Length & EFI_PAGE_MASK) == 0); + +Status2 = EFI_NOT_FOUND; +Status = gDS->GetMemorySpaceDescriptor (RuntimeMmioRanges->Range[Index].PhysicalBaseAddress, &Descriptor); +if (!EFI_ERROR (Status) && + ( +(Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo && Descriptor.GcdMemoryType != EfiGcdMemoryTypeReserved) || +((Descriptor.Length & EFI_PAGE_MASK) != 0) +) + ) { + Status2 = gDS->RemoveMemorySpace ( +RuntimeMmioRanges->Range[Index].PhysicalBaseAddress, +Descriptor.Length +); +} + +if (Status == EFI_NOT_FOUND || !EFI_ERROR (Status2)) { + Status = gDS->AddMemorySpace ( + EfiGcdMemoryTypeMemoryMappedIo, + RuntimeMmioRanges->Range[Index].PhysicalBaseAddress, + (UINT64) RuntimeMmioRanges->Range[Index].Length, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME +
[edk2-devel] [PATCH v1 05/41] PrmPkg: Add initial PrmSamplePrintModule
From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3812 Adds a simple sample PRM module that demonstrates: 1. How to write a PRM module 2. How to use multiple PRM handlers in a module 3. How to use a basic PRM OS service Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Samples/PrmSamplePrintModule/PrmSamplePrintModule.c | 157 PrmPkg/Samples/PrmSamplePrintModule/PrmSamplePrintModule.inf | 39 + 2 files changed, 196 insertions(+) diff --git a/PrmPkg/Samples/PrmSamplePrintModule/PrmSamplePrintModule.c b/PrmPkg/Samples/PrmSamplePrintModule/PrmSamplePrintModule.c new file mode 100644 index ..85e8eb28a231 --- /dev/null +++ b/PrmPkg/Samples/PrmSamplePrintModule/PrmSamplePrintModule.c @@ -0,0 +1,157 @@ +/** @file + + A sample PRM Module implementation. This PRM Module provides 3 PRM handlers that simply take a DEBUG print + function from the OS and invoke it with a debug message internal the PRM handler. + + Copyright (c) Microsoft Corporation + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include +#include + +// +// PRM Handler GUIDs +// + +// {d5f2ad5f-a347-4d3e-87bc-c2ce63029cc8} +#define PRM_HANDLER_1_GUID {0xd5f2ad5f, 0xa347, 0x4d3e, {0x87, 0xbc, 0xc2, 0xce, 0x63, 0x02, 0x9c, 0xc8}} + +// {a9e7adc3-8cd0-429a-8915-10946ebde318} +#define PRM_HANDLER_2_GUID {0xa9e7adc3, 0x8cd0, 0x429a, {0x89, 0x15, 0x10, 0x94, 0x6e, 0xbd, 0xe3, 0x18}} + +// {b688c214-4081-4eeb-8d26-1eb5a3bcf11a} +#define PRM_HANDLER_N_GUID {0xb688c214, 0x4081, 0x4eeb, {0x8d, 0x26, 0x1e, 0xb5, 0xa3, 0xbc, 0xf1, 0x1a}} + +/** + A sample Platform Runtime Mechanism (PRM) handler. + + This sample handler currently uses the OS_SERVICES to write a debug message + indicating this is PRM handler 1. + + @param[in] ParameterBuffer A pointer to the PRM handler parameter buffer + @param[in] ContextBUffer A pointer to the PRM handler context buffer + + @retval EFI_STATUS The PRM handler executed successfully. + @retval Others An error occurred in the PRM handler. + +**/ +EFI_STATUS +PRM_EXPORT_API +EFIAPI +PrmHandler1 ( + IN VOID *ParameterBuffer, + IN PRM_CONTEXT_BUFFER *ContextBUffer + ) +{ + PRM_OS_SERVICE_DEBUG_PRINT OsServiceDebugPrint; + + if (ParameterBuffer == NULL) { +return EFI_INVALID_PARAMETER; + } + + // In the POC, the OS debug print service is assumed to be at the beginning of ParameterBuffer + OsServiceDebugPrint = *((PRM_OS_SERVICE_DEBUG_PRINT *) ParameterBuffer); + if (OsServiceDebugPrint == NULL) { +return EFI_INVALID_PARAMETER; + } + OsServiceDebugPrint ("PRM1 handler sample message!\n"); + + return EFI_SUCCESS; +} + +/** + A sample Platform Runtime Mechanism (PRM) handler. + + This sample handler currently uses the OS_SERVICES to write a debug message + indicating this is PRM handler 2. + + @param[in] ParameterBufferA pointer to the PRM handler parameter buffer + @param[in] ContextBUffer A pointer to the PRM handler context buffer + + @retval EFI_STATUS The PRM handler executed successfully. + @retval Others An error occurred in the PRM handler. + +**/ +EFI_STATUS +PRM_EXPORT_API +EFIAPI +PrmHandler2 ( + IN VOID *ParameterBuffer, + IN PRM_CONTEXT_BUFFER *ContextBUffer + ) +{ + PRM_OS_SERVICE_DEBUG_PRINT OsServiceDebugPrint; + + if (ParameterBuffer == NULL) { +return EFI_INVALID_PARAMETER; + } + + // In the POC, the OS debug print service is assumed to be at the beginning of ParameterBuffer + OsServiceDebugPrint = *((PRM_OS_SERVICE_DEBUG_PRINT *) ParameterBuffer); + if (OsServiceDebugPrint == NULL) { +return EFI_INVALID_PARAMETER; + } + OsServiceDebugPrint ("PRM2 handler sample message!\n"); + + return EFI_SUCCESS; +} + +/** + A sample Platform Runtime Mechanism (PRM) handler. + + This sample handler currently uses the OS_SERVICES to write a debug message + indicating this is PRM handler N. + + @param[in] ParameterBufferA pointer to the PRM handler parameter buffer + @param[in] ContextBUffer A pointer to the PRM handler context buffer + + @retval EFI_STATUS The PRM handler executed successfully. + @retval Others An error occurred in the PRM handler. + +**/ +EFI_STATUS +PRM_EXPORT_API +EFIAPI +PrmHandlerN ( + IN VOID *ParameterBuffer, + IN PRM_CONTEXT_BUFFER *ContextBUffer + ) +{ + PRM_OS_SERVICE_DEBUG_PRINT OsServiceDebugPrint; + + if (ParameterBuffer == NULL) { +return EFI_INVALID_PARAMETER; + } + + // In the POC, the OS debug print service is assumed to be at the beginning of ParameterBuffer + OsServiceDebugPrint = *((PRM_OS_SERVICE_DEBUG_PRINT *) ParameterBuffer); +
[edk2-devel] [PATCH v1 06/41] PrmPkg: Add initial PrmSampleMemoryAllocationModule
From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3812 DEPRECATED: This module is no longer relevant since OS Services that allow memory allocation have been removed. It is still present in the source tree in the event dynamic memory allocation at OS runtime is needed again. Adds a sample PRM module that demonstrates: 1. How to write a PRM module 2. How to use a basic PRM OS service 3. How to dynamically allocate memory at OS runtime Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Samples/PrmSampleMemoryAllocationModule/PrmSampleMemoryAllocationModule.c | 115 PrmPkg/Samples/PrmSampleMemoryAllocationModule/PrmSampleMemoryAllocationModule.inf | 41 +++ 2 files changed, 156 insertions(+) diff --git a/PrmPkg/Samples/PrmSampleMemoryAllocationModule/PrmSampleMemoryAllocationModule.c b/PrmPkg/Samples/PrmSampleMemoryAllocationModule/PrmSampleMemoryAllocationModule.c new file mode 100644 index ..f1245664ab9c --- /dev/null +++ b/PrmPkg/Samples/PrmSampleMemoryAllocationModule/PrmSampleMemoryAllocationModule.c @@ -0,0 +1,115 @@ +/** @file + + A sample PRM Module implementation. This PRM Module provides 3 PRM handlers that simply take a DEBUG print + function from the OS and invoke it with a debug message internal the PRM handler. + + Copyright (c) Microsoft Corporation + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include +#include +#include +#include + +// +// PRM Handler GUIDs +// + +// {149a5cb3-6a9c-403f-940a-156abf63938a} +#define PRM_HANDLER_1_GUID {0x149a5cb3, 0x6a9c, 0x403f, {0x94, 0x0a, 0x15, 0x6a, 0xbf, 0x63, 0x93, 0x8a}} + +// Note: If the signature size is modified, the PRM Handler test code in this module needs to be updated. +#define MEMORY_ALLOCATION_TEST_DATA_SIGNATURE SIGNATURE_32('T','E','S','T') +#define MEMORY_ALLOCATION_TEST_DATA_SIZE sizeof(UINT32) +#define MEMORY_ALLOCATION_TEST_DATA_BUFFER_SIZE 256 + +/** + A sample Platform Runtime Mechanism (PRM) handler. + + This sample handler currently uses the OS_SERVICES to write a debug message + indicating this is PRM handler 1. + + @param[in] ParameterBufferA pointer to the PRM handler parameter buffer + @param[in] ContextBuffer A pointer to the PRM handler context buffer + + @retval EFI_STATUS The PRM handler executed successfully. + @retval Others An error occurred in the PRM handler. + +**/ +EFI_STATUS +PRM_EXPORT_API +EFIAPI +PrmHandler1 ( + IN VOID *ParameterBuffer, + IN PRM_CONTEXT_BUFFER *ContextBUffer + ) +{ + EFI_STATUS Status; + UINTN Index; + VOID*NonPagedPool; + CHAR8 DebugMessage[256]; + + if (OsServices == NULL || OsServices->DebugPrint == NULL || OsServices->AllocateMemory == NULL) { +return EFI_INVALID_PARAMETER; + } + + OsServices->DebugPrint ("Memory Allocation PrmHandler1 entry.\n"); + OsServices->DebugPrint (" Requesting allocation of a 256 byte non-paged pool...\n"); + + NonPagedPool = NULL; + NonPagedPool = OsServices->AllocateMemory (MEMORY_ALLOCATION_TEST_DATA_BUFFER_SIZE, FALSE); + if (NonPagedPool == NULL) { +OsServices->DebugPrint (" NULL was returned from AllocateMemory()...\n"); +return EFI_OUT_OF_RESOURCES; + } + + AsciiSPrint ( +&DebugMessage[0], +ARRAY_SIZE (DebugMessage), +" Buffer address returned from AllocateMemory() = 0x%016lx.\n", +(UINTN) NonPagedPool +); + OsServices->DebugPrint (&DebugMessage[0]); + + // Write the test data + OsServices->DebugPrint (" Beginning memory buffer write and read back test...\n"); + SetMem32 (NonPagedPool, MEMORY_ALLOCATION_TEST_DATA_BUFFER_SIZE, MEMORY_ALLOCATION_TEST_DATA_SIGNATURE); + + // Read back and verify the test data is valid + for (Index = 0, Status = EFI_SUCCESS; Index < (MEMORY_ALLOCATION_TEST_DATA_BUFFER_SIZE / MEMORY_ALLOCATION_TEST_DATA_SIZE); Index++) { +if (((UINT32 *) NonPagedPool)[Index] != MEMORY_ALLOCATION_TEST_DATA_SIGNATURE) { + Status = EFI_DEVICE_ERROR; + break; +} + } + if (EFI_ERROR (Status)) { +OsServices->DebugPrint ("Memory write & read test failed.\n"); + } else { +OsServices->DebugPrint ("Memory write & read test passed.\n"); + } + + OsServices->DebugPrint ("Memory Allocation PrmHandler1 exit.\n"); + + return EFI_SUCCESS; +} + +// +// Register the PRM export information for this PRM Module +// +PRM_MODULE_EXPORT ( + PRM_HANDLER_EXPORT_ENTRY (PRM_HANDLER_1_GUID, PrmHandler1) + ); + +EFI_STATUS +EFIAPI +PrmSampleMemoryAllocationModuleInit ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE*SystemTable + ) +{ + return EFI_SUCCESS; +} diff --git
[edk2-devel] [PATCH v1 07/41] PrmPkg: Add initial PrmSampleHardwareAccessModule
From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3812 Adds a sample PRM module that demonstrates: 1. How to write a PRM module 2. How to use multiple PRM handlers in a module 3. How to use a basic PRM OS service 4. MSR access at OS runtime Note: This module contains a PRM handler to read from the HPET MMIO range but the memory map changes needed for this to succeed are currently not implemented. These will be implemented in a future change. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.c | 537 PrmPkg/Samples/PrmSampleHardwareAccessModule/Hpet.h | 105 PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.inf | 42 ++ 3 files changed, 684 insertions(+) diff --git a/PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.c b/PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.c new file mode 100644 index ..87fe9cafc912 --- /dev/null +++ b/PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.c @@ -0,0 +1,537 @@ +/** @file + + A sample PRM Module implementation. This PRM Module provides PRM handlers that perform various types + of hardware access. This is simply meant to demonstrate hardware access capabilities from a PRM handler. + + Copyright (c) Microsoft Corporation + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include +#include +#include +#include + +#include +#include + +#include "Hpet.h" + +// +// PRM Handler GUIDs +// + +// {2120cd3c-848b-4d8f-abbb-4b74ce64ac89} +#define MSR_ACCESS_MICROCODE_SIGNATURE_PRM_HANDLER_GUID {0x2120cd3c, 0x848b, 0x4d8f, {0xab, 0xbb, 0x4b, 0x74, 0xce, 0x64, 0xac, 0x89}} + +// {ea0935a7-506b-4159--48deeecb6f58} +#define MSR_ACCESS_MTRR_DUMP_PRM_HANDLER_GUID {0xea0935a7, 0x506b, 0x4159, {0xbb, 0xbb, 0x48, 0xde, 0xee, 0xcb, 0x6f, 0x58}} + +// {1bd1bda9-909a-4614-9699-25ec0c2783f7} +#define MMIO_ACCESS_HPET_PRM_HANDLER_GUID {0x1bd1bda9, 0x909a, 0x4614, {0x96, 0x99, 0x25, 0xec, 0x0c, 0x27, 0x83, 0xf7}} + +#define HPET_BASE_ADDRESS 0xFED0 + +// +// BEGIN: MtrrLib internal library globals and function prototypes here for testing +// +extern CONST CHAR8*mMtrrMemoryCacheTypeShortName[]; + +/** + Initializes the valid bits mask and valid address mask for MTRRs. + + This function initializes the valid bits mask and valid address mask for MTRRs. + + @param[out] MtrrValidBitsMask The mask for the valid bit of the MTRR + @param[out] MtrrValidAddressMask The valid address mask for the MTRR + +**/ +VOID +MtrrLibInitializeMtrrMask ( + OUT UINT64 *MtrrValidBitsMask, + OUT UINT64 *MtrrValidAddressMask + ); + +/** + Convert variable MTRRs to a RAW MTRR_MEMORY_RANGE array. + One MTRR_MEMORY_RANGE element is created for each MTRR setting. + The routine doesn't remove the overlap or combine the near-by region. + + @param[in] VariableSettings The variable MTRR values to shadow + @param[in] VariableMtrrCount The number of variable MTRRs + @param[in] MtrrValidBitsMask The mask for the valid bit of the MTRR + @param[in] MtrrValidAddressMask The valid address mask for MTRR + @param[out] VariableMtrr The array to shadow variable MTRRs content + + @return Number of MTRRs which has been used. + +**/ +UINT32 +MtrrLibGetRawVariableRanges ( + IN MTRR_VARIABLE_SETTINGS *VariableSettings, + IN UINTN VariableMtrrCount, + IN UINT64 MtrrValidBitsMask, + IN UINT64 MtrrValidAddressMask, + OUT MTRR_MEMORY_RANGE *VariableMtrr + ); + +/** + Apply the fixed MTRR settings to memory range array. + + @param Fixed The fixed MTRR settings. + @param RangesReturn the memory range array holding memory type + settings for all memory address. + @param RangeCapacity The capacity of memory range array. + @param RangeCountReturn the count of memory range. + + @retval RETURN_SUCCESS The memory range array is returned successfully. + @retval RETURN_OUT_OF_RESOURCES The count of memory ranges exceeds capacity. +**/ +RETURN_STATUS +MtrrLibApplyFixedMtrrs ( + IN MTRR_FIXED_SETTINGS *Fixed, + IN OUT MTRR_MEMORY_RANGE*Ranges, + IN UINTNRangeCapacity, + IN OUT UINTN*RangeCount + ); + +/** + Apply the variable MTRR settings to memory range array. + + @param VariableMtrr The variable MTRR array. + @param VariableMtrrCount The count of variable MTRRs. + @param RangesReturn the memory range array with new MTRR settings applied. + @param RangeCapacity The capacity of memory ra
[edk2-devel] [PATCH v1 08/41] PrmPkg: Add initial PrmSampleContextBufferModule
From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3812 Adds a sample PRM module that demonstrates: 1. How to write a PRM module 2. How to use a basic PRM OS services 3. How to use a basic PRM module configuration library 4. How to use a context buffer during PRM handler execution Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/DxeContextBufferModuleConfigLib.c | 203 PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleContextBufferModule.c | 182 ++ PrmPkg/Samples/PrmSampleContextBufferModule/Include/StaticData.h | 24 +++ PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/DxeContextBufferModuleConfigLib.inf | 39 PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleContextBufferModule.inf | 42 5 files changed, 490 insertions(+) diff --git a/PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/DxeContextBufferModuleConfigLib.c b/PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/DxeContextBufferModuleConfigLib.c new file mode 100644 index ..3bf5beba7d4a --- /dev/null +++ b/PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/DxeContextBufferModuleConfigLib.c @@ -0,0 +1,203 @@ +/** @file + + The boot services environment configuration library for the Context Buffer Sample PRM module. + + Copyright (c) Microsoft Corporation + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +STATIC EFI_HANDLE mPrmConfigProtocolHandle; + +// {5a6cf42b-8bb4-472c-a233-5c4dc4033dc7} +STATIC CONST EFI_GUID mPrmModuleGuid = {0x5a6cf42b, 0x8bb4, 0x472c, {0xa2, 0x33, 0x5c, 0x4d, 0xc4, 0x03, 0x3d, 0xc7}}; + +// {e1466081-7562-430f-896b-b0e523dc335a} +STATIC CONST EFI_GUID mDumpStaticDataBufferPrmHandlerGuid = {0xe1466081, 0x7562, 0x430f, {0x89, 0x6b, 0xb0, 0xe5, 0x23, 0xdc, 0x33, 0x5a}}; + +/** + Populates the static data buffer for this PRM module. + + @param[out] StaticDataBuffer A pointer to the static data buffer. + + @retval EFI_SUCCESS The static data buffer was populated successfully. + @retval EFI_INVALID_PARAMETER The StaticDataBuffer pointer argument is NULL. + +**/ +EFI_STATUS +PopulateStaticDataBuffer ( + OUT STATIC_DATA_SAMPLE_CONTEXT_BUFFER_MODULE *StaticDataBuffer + ) +{ + if (StaticDataBuffer == NULL) { +return EFI_INVALID_PARAMETER; + } + + // + // Note: In a real-world module these values would likely come from somewhere + // like a Setup menu option, PCD, binary data, runtime device info, etc. Ideally, + // this configuration library would be provided an API to get what it needs (the data) + // and not be concerned with how the data is provided. This makes the PRM module more + // portable across systems. + // + StaticDataBuffer->Policy1Enabled = TRUE; + StaticDataBuffer->Policy2Enabled = FALSE; + SetMem (StaticDataBuffer->SomeValueArray, ARRAY_SIZE (StaticDataBuffer->SomeValueArray), 'D'); + + return EFI_SUCCESS; +} + +/** + Allocates and populates the static data buffer for this PRM module. + + @param[out] StaticDataBuffer A pointer to a pointer to the static data buffer. + + @retval EFI_SUCCESS The static data buffer was allocated and filled successfully. + @retval EFI_INVALID_PARAMETER The StaticDataBuffer pointer argument is NULL. + @retval EFI_OUT_OF_RESOURCES Insufficient memory resources to allocate the static data buffer. + +**/ +EFI_STATUS +GetStaticDataBuffer ( + OUT PRM_DATA_BUFFER **StaticDataBuffer + ) +{ + EFI_STATUS Status; + PRM_DATA_BUFFER *DataBuffer; + UINTN DataBufferLength; + + if (StaticDataBuffer == NULL) { +return EFI_INVALID_PARAMETER; + } + *StaticDataBuffer = NULL; + + // + // Length of the data buffer = Buffer Header Size + Buffer Data Size + // + DataBufferLength = sizeof (PRM_DATA_BUFFER_HEADER) + sizeof (STATIC_DATA_SAMPLE_CONTEXT_BUFFER_MODULE); + + DataBuffer = AllocateRuntimeZeroPool (DataBufferLength); + if (DataBuffer == NULL) { +return EFI_OUT_OF_RESOURCES; + } + + // + // Initialize the data buffer header + // + DataBuffer->Header.Signature = PRM_DATA_BUFFER_HEADER_SIGNATURE; + DataBuffer->Header.Length = (UINT32) DataBufferLength; + + Status = PopulateStaticDataBuffer ((STATIC_DATA_SAMPLE_CONTEXT_BUFFER_MODULE *) &DataBuffer->Data[0]); + ASSERT_EFI_ERROR (Status); + + *StaticDataBuffer = DataBuffer; + return
[edk2-devel] [PATCH v1 09/41] PrmPkg: Add initial package DSC file
From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3812 Adds the PrmPkg DSC file so all of the contents can be built as a stand-alone package. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/PrmPkg.dsc | 107 1 file changed, 107 insertions(+) diff --git a/PrmPkg/PrmPkg.dsc b/PrmPkg/PrmPkg.dsc new file mode 100644 index ..a0237d1fe059 --- /dev/null +++ b/PrmPkg/PrmPkg.dsc @@ -0,0 +1,107 @@ +## @file +# Build description file for PrmPkg +# +# Copyright (C) Microsoft Corporation +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + PLATFORM_NAME = Prm + PLATFORM_GUID = C29BB610-84F9-448D-A7DD-5A04C5A54F52 + PLATFORM_VERSION = 0.1 + DSC_SPECIFICATION = 0x00010005 + OUTPUT_DIRECTORY = Build/$(PLATFORM_NAME) + SUPPORTED_ARCHITECTURES= IA32|X64 + BUILD_TARGETS = DEBUG|RELEASE|NOOPT + SKUID_IDENTIFIER = DEFAULT + + DEFINE PLATFORM_PACKAGE = $(PLATFORM_NAME)Pkg + +[LibraryClasses.common] + # + # EDK II Packages + # + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf + DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf + DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf + MemoryAllocationLib|MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf + MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf + PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf + RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf + RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf + UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf + +[LibraryClasses.common.DXE_DRIVER, LibraryClasses.common.DXE_RUNTIME_DRIVER] + # + # EDK II Packages + # + BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf + DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf + DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf + HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf + MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf + PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf + UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf + UefiLib|MdePkg/Library/UefiLib/UefiLib.inf + UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf + + # + # PRM Package + # + PrmContextBufferLib|$(PLATFORM_PACKAGE)/Library/DxePrmContextBufferLib/DxePrmContextBufferLib.inf + +### +# +# Components Section - List of the modules and components that will be processed by compilation +# tools and the EDK II tools to generate PE32/PE32+/Coff image file. +# +### + +[Components] + # + # PRM Libraries + # + $(PLATFORM_PACKAGE)/Library/DxePrmContextBufferLib/DxePrmContextBufferLib.inf + $(PLATFORM_PACKAGE)/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/DxeContextBufferModuleConfigLib.inf + $(PLATFORM_PACKAGE)/Samples/PrmSampleHardwareAccessModule/Library/DxeHardwareAccessModuleConfigLib/DxeHardwareAccessModuleConfigLib.inf + + # + # PRM Configuration Driver + # + $(PLATFORM_PACKAGE)/PrmConfigDxe/PrmConfigDxe.inf { + + NULL|$(PLATFORM_PACKAGE)/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/DxeContextBufferModuleConfigLib.inf + } + + # + # PRM Module Loader Driver + # + $(PLATFORM_PACKAGE)/PrmLoaderDxe/PrmLoaderDxe.inf + + # + # PRM Sample Modules + # + $(PLATFORM_PACKAGE)/Samples/PrmSamplePrintModule/PrmSamplePrintModule.inf + $(PLATFORM_PACKAGE)/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.inf { + + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf + } + $(PLATFORM_PACKAGE)/Samples/PrmSampleContextBufferModule/PrmSampleContextBufferModule.inf + + # + # The SampleMemoryAllocationModule was used during a time in the POC when the OS + # provided memory allocation services. This module was successful in using those services. + # Since OS services have
[edk2-devel] [PATCH v1 10/41] Readme.md: Add initial content
From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3812 Adds the following content to Readme.md: 1. A basic explanation of how the package is organized and where to find important items. 2. Adds instructions for building PrmPkg with edk2. 3. Adds a "Build Flags" section to the build instructions to explain any build flags that may be passed to influence the build. The final package will not have any build flags. A reasonable number are temporarily used to test different flows until final decisions are made as to which flow to keep. Most notably, only Visual Studio tool chains are currently supported due to the modifications made to support export tables. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Readme.md | 212 1 file changed, 212 insertions(+) diff --git a/PrmPkg/Readme.md b/PrmPkg/Readme.md new file mode 100644 index ..b67b3a391e37 --- /dev/null +++ b/PrmPkg/Readme.md @@ -0,0 +1,212 @@ +# **Platform Runtime Mechanism** + +Platform Runtime Mechanism (PRM) introduces the capability of moving platform-specific code out of SMM and into a +code module that executes within the OS context. Moving this firmware to the OS context provides better transparency +and mitigates the negative system impact currently accompanied with SMM solutions. Futhermore, the PRM code is +packaged into modules with well-defined entry points, each representing a specific PRM functionality. + +The `PrmPkg` maintained in this branch provides a single cohesive set of generic PRM functionality that is intended +to be leveraged by platform firmware with minimal overhead to integrate PRM functionality in the firmware. + +## **IMPORTANT NOTE** +> The code provided in this package and branch are for proof-of-concept purposes only. The code does not represent a +formal design and is not validated at product quality. The development of this feature is shared in the edk2-staging +branch to simplify collaboration by allowing direct code contributions and early feedback throughout its development. + +## How to Build PrmPkg +As noted earlier, resources in `PrmPkg` are intended to be referenced by a platform firmware so it can adopt support +for PRM. In that case, the platform firmware should add the `PrmConfigDxe` and `PrmLoaderDxe` drivers to its DSC and +FDF files so they are built in the platform firmware build and dispatched during its runtime. All that is left is to +add individual PRM modules to the DSC and FDF. These can be built from source or included as binaries into the platform +firmware flash map. + +### PrmPkg Standalone Build +**All changes to `PrmPkg` must not regress the standalone package build**. Any time a change is made to `PrmPkg`, the +package build must be tested. Since this is a forward looking package, to ease potential integration into the edk2 +project in the future, the build is tested against the tip of the master branch in the [edk2](https://github.com/tianocore/edk2) +repository. + +To build `PrmPkg` as a standalone package: +1. If new to EDK II, follow the directions in [Getting Started with EDK II](https://github.com/tianocore/tianocore.github.io/wiki/Getting-Started-with-EDK-II) + +2. Clone the *master* branch on the edk2 repository locally \ + ``git clone https://github.com/tianocore/edk2.git`` + +3. Clone the *PlatformRuntimeMechanism* branch on the edk2-staging repository locally \ + ``git clone -b PlatformRuntimeMechanism --single-branch https://github.com/tianocore/edk2-staging.git`` + > __*Note*__: The *--single-branch* argument is recommended since edk2-staging hosts many branches for completely + unrelated features. If you are just interested in PRM, this will avoid fetching all of the other branches. + +4. Change to the edk2 workspace directory \ + ``cd edk2`` + +5. Run *edksetup* to set local environment variables needed for build + * Windows: + * ``edksetup.bat`` + * Linux: + * If you have not already built BaseTools: + * ``make -C BaseTools`` + * ``. edksetup.sh`` + +6. Set the PACKAGES_PATH environment variable to include the directory path that contains `PrmPkg` + * Windows example: + * ``set PACKAGES_PATH=c:\src\edk2-staging`` + +7. Change to the edk2-staging workspace directory + * Example: ``cd ../edk2-staging`` + +8. Build PrmPkg \ + ``build -p PrmPkg/PrmPkg.dsc -a IA32 -a X64`` + > __*Note*__: Due to the way PRM modules are compiled with exports, **only building on Visual Studio compiler tool + chains is currently supported**. + +### Build Flags +As PRM is a new feature at a proof-of-concept (POC) level of maturity, there's some changes to the normal build +available as build flags. By default, if no flags are specified, the build is done with the currently expected plan of +rec
[edk2-devel] [PATCH v1 12/41] PrmPkg: Enable variable growth for the PRM_MODULE_EXPORT macro
From: Michael Kubacki The PRM_MODULE_EXPORT parameterized macro allows a caller to produce a static PRM module export descriptor structure in the binary by simply passing PRM_HANDLER_EXPORT_ENTRY arguments with each argument representing a PRM handler to be exported by the module. Previously, the PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT used in the PRM_MODULE_EXPORT macro was fixed to a maximum of three handlers. This change removes that restriction and allows the structure to grow based on the number of PRM handlers given to the macro. This means a local type will be customized per PRM module. The reference type PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT keeps a field at the end that allows array access to PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT members. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c | 14 +-- PrmPkg/Include/PrmExportDescriptor.h | 25 +--- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c index 85fffdcbd9f1..5fda4c1b01da 100644 --- a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c +++ b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c @@ -122,7 +122,7 @@ GetPrmModuleExportDescriptorTable ( return EFI_NOT_FOUND; } TempExportDescriptor = (PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT *) ((UINTN) CurrentImageAddress + ExportAddressTable[PrmModuleExportDescriptorOrdinal]); - if (TempExportDescriptor->Signature == PRM_MODULE_EXPORT_DESCRIPTOR_SIGNATURE) { + if (TempExportDescriptor->Header.Signature == PRM_MODULE_EXPORT_DESCRIPTOR_SIGNATURE) { *ExportDescriptor = TempExportDescriptor; DEBUG ((DEBUG_INFO, " %a %a: PRM Module Export Descriptor found at 0x%x.\n", _DBGMSGID_, __FUNCTION__, (UINTN) ExportDescriptor)); } else { @@ -528,7 +528,7 @@ DiscoverPrmModules ( sizeof (*(PrmModuleImageContextListEntry->Context)) ); InsertTailList (&mPrmModuleList, &PrmModuleImageContextListEntry->Link); -mPrmHandlerCount += TempPrmModuleImageContext.ExportDescriptor->NumberPrmHandlers; +mPrmHandlerCount += TempPrmModuleImageContext.ExportDescriptor->Header.NumberPrmHandlers; mPrmModuleCount++; // Todo: Match with global variable refactor change in the future DEBUG ((DEBUG_INFO, "%a %a: New PRM Module inserted into list to be processed.\n", _DBGMSGID_, __FUNCTION__)); } @@ -684,16 +684,16 @@ ProcessPrmModules ( _DBGMSGID_, __FUNCTION__, (CHAR8 *) ((UINTN) CurrentImageAddress + CurrentImageExportDirectory->Name), - CurrentExportDescriptorStruct->NumberPrmHandlers + CurrentExportDescriptorStruct->Header.NumberPrmHandlers )); CurrentModuleInfoStruct->StructureRevision = PRM_MODULE_INFORMATION_STRUCT_REVISION; CurrentModuleInfoStruct->StructureLength = ( OFFSET_OF (PRM_MODULE_INFORMATION_STRUCT, HandlerInfoStructure) + - (CurrentExportDescriptorStruct->NumberPrmHandlers * sizeof (PRM_HANDLER_INFORMATION_STRUCT)) + (CurrentExportDescriptorStruct->Header.NumberPrmHandlers * sizeof (PRM_HANDLER_INFORMATION_STRUCT)) ); -CopyGuid (&CurrentModuleInfoStruct->Identifier, &CurrentExportDescriptorStruct->ModuleGuid); -CurrentModuleInfoStruct->HandlerCount = (UINT32) CurrentExportDescriptorStruct->NumberPrmHandlers; +CopyGuid (&CurrentModuleInfoStruct->Identifier, &CurrentExportDescriptorStruct->Header.ModuleGuid); +CurrentModuleInfoStruct->HandlerCount = (UINT32) CurrentExportDescriptorStruct->Header.NumberPrmHandlers; CurrentModuleInfoStruct->HandlerInfoOffset = OFFSET_OF (PRM_MODULE_INFORMATION_STRUCT, HandlerInfoStructure); CurrentModuleInfoStruct->MajorRevision = 0; @@ -737,7 +737,7 @@ ProcessPrmModules ( // // Iterate across all PRM handlers in the PRM Module // -for (HandlerIndex = 0; HandlerIndex < CurrentExportDescriptorStruct->NumberPrmHandlers; HandlerIndex++) { +for (HandlerIndex = 0; HandlerIndex < CurrentExportDescriptorStruct->Header.NumberPrmHandlers; HandlerIndex++) { CurrentHandlerInfoStruct = &(CurrentModuleInfoStruct->HandlerInfoStructure[HandlerIndex]); CurrentHandlerInfoStruct->StructureRevision = PRM_HANDLER_INFORMATION_STRUCT_REVISION; diff --git a/PrmPkg/Include/PrmExportDescriptor.h b/PrmPkg/Include/PrmExportDescriptor.h index 95198cef659c..fc313fd1acc7 100644 --- a/PrmPkg/Include/PrmExportDescriptor.h +++ b/PrmPkg/Include/PrmExportDescriptor.h @@ -31,11 +31,23 @@ typedef struct { UINT16Revision; UINT16NumberPrmHandlers; GUID
[edk2-devel] [PATCH v1 11/41] PrmPkg: Add ALLOCATE_CONTEXT_BUFFER_IN_FW build option
From: Michael Kubacki There's currently two approaches being considered for how to allocate the context buffer passed to PRM handlers: 1. The context buffer is allocated and populated in firmware. As such, the FW converts all pointers internal to the buffer to virtual memory addresses at the virtual address change event. A single context buffer pointer is given to the OS via the PRM ACPI table and the OS converts this single physical address to a virtual address when it passes the context buffer as a pointer to PRM handlers. 2. The context buffer is allocated and populated in the OS. The OS gets all the information needed to populate the context buffer from other pre-existing resources (mainly physical addresses in the PRM ACPI table). The OS converts all the physical addresses to virtual addresses, allocates the context buffer instances, and fills in the information. The OS passes the context buffer virtual address to PRM handlers. The prior behavior was (1). The current POR behavior has moved to (2). Until (2) is used more widely, it can be kept around with fairly minimal overhead via a build flag in a few places. So the default behavior is now (2) (the expected permanent behavior) with (1) easily enabled by defining "ALLOCATE_CONTEXT_BUFFER_IN_FW" in the compiler defined macros. A DSC define was added in PrmPkg.dsc to set this compiler macro in the package build. At some point in the future, all code (and some peripheral code) surrounded with this build flag can be removed if (2) is fully decided upon. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/PrmConfigDxe/PrmConfigDxe.c | 51 +--- PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c | 6 ++- PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/DxeContextBufferModuleConfigLib.c | 16 ++ PrmPkg/PrmLoaderDxe/PrmAcpiTable.h | 4 ++ PrmPkg/PrmPkg.dsc | 5 ++ PrmPkg/Readme.md | 12 + 6 files changed, 76 insertions(+), 18 deletions(-) diff --git a/PrmPkg/PrmConfigDxe/PrmConfigDxe.c b/PrmPkg/PrmConfigDxe/PrmConfigDxe.c index cb38146bc9e0..7215c2e1dc6f 100644 --- a/PrmPkg/PrmConfigDxe/PrmConfigDxe.c +++ b/PrmPkg/PrmConfigDxe/PrmConfigDxe.c @@ -28,8 +28,8 @@ STATIC UINTN mMaxRuntimeMmioRangeCount; STATIC UINTN mMaxStaticDataBufferCount; -STATIC PRM_RUNTIME_MMIO_RANGES **mRuntimeMmioRanges; -STATIC PRM_DATA_BUFFER ***mStaticDataBuffers; +GLOBAL_REMOVE_IF_UNREFERENCED STATIC PRM_RUNTIME_MMIO_RANGES **mRuntimeMmioRanges; +GLOBAL_REMOVE_IF_UNREFERENCED STATIC PRM_DATA_BUFFER ***mStaticDataBuffers; /** Converts the runtime memory range physical addresses to virtual addresses. @@ -178,32 +178,23 @@ StoreVirtualMemoryAddressChangePointers ( ) { EFI_STATUS Status; - UINTN BufferIndex; UINTN HandleCount; UINTN HandleIndex; UINTN RangeIndex; +#ifdef ALLOCATE_CONTEXT_BUFFER_IN_FW + UINTN BufferIndex; UINTN StaticDataBufferIndex; + PRM_CONTEXT_BUFFER *CurrentContextBuffer; +#endif EFI_HANDLE *HandleBuffer; PRM_CONFIG_PROTOCOL *PrmConfigProtocol; - PRM_CONTEXT_BUFFER *CurrentContextBuffer; DEBUG ((DEBUG_INFO, "%a %a - Entry.\n", _DBGMSGID_, __FUNCTION__)); RangeIndex = 0; +#ifdef ALLOCATE_CONTEXT_BUFFER_IN_FW StaticDataBufferIndex = 0; - mRuntimeMmioRanges = AllocateRuntimeZeroPool (sizeof (*mRuntimeMmioRanges) * mMaxRuntimeMmioRangeCount); - if (mRuntimeMmioRanges == NULL && mMaxRuntimeMmioRangeCount > 0) { -DEBUG (( - DEBUG_ERROR, - " %a %a: Memory allocation for runtime MMIO pointer array failed.\n", - _DBGMSGID_, - __FUNCTION__ - )); -ASSERT (FALSE); -return; - } - mStaticDataBuffers = AllocateRuntimeZeroPool (sizeof (*mStaticDataBuffers) * mMaxStaticDataBufferCount); if (mStaticDataBuffers == NULL && mMaxStaticDataBufferCount > 0) { DEBUG (( @@ -215,6 +206,19 @@ StoreVirtualMemoryAddressChangePointers ( ASSERT (FALSE); return; } +#endif + + mRuntimeMmioRanges = AllocateRuntimeZeroPool (sizeof (*mRuntimeMmioRanges) * mMaxRuntimeMmioRangeCount); + if (mRuntimeMmioRanges == NULL && mMaxRuntimeMmioRangeCoun
[edk2-devel] [PATCH v1 13/41] PrmPkg: Publish PRM operation region to support PRM ACPI _DSM invocation
From: Liu A PRM Handler has a 1-to-1 mapping to the corresponding _DSM method. The UUID of the _DSM Method will be passed by the ASL code to the OpRegionHandler which will look up the PRMT Table to extract the pointer of the corresponding PRM Handler. PRM loader pre-builds an SSDT that includes this PRM operation region. In boot time, the PRM loader will load and publish this SSDT, so that in OS runtime ACPI _DSM can invoke the PRM handler by pass the UUID to PRM operation region. The pre-build SSDT also includes a PRMT device as a Sample ACPI _DSM to invoke PRM handler. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Liu Yun --- PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c | 34 PrmPkg/PrmLoaderDxe/Prm.asl | 87 PrmPkg/PrmLoaderDxe/PrmLoaderDxe.inf | 4 + 3 files changed, 125 insertions(+) diff --git a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c index 5fda4c1b01da..5e14b8e09dd0 100644 --- a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c +++ b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c @@ -3,6 +3,7 @@ This file contains the implementation for a Platform Runtime Mechanism (PRM) loader driver. + Copyright (c) 2020, Intel Corporation. All rights reserved. Copyright (c) Microsoft Corporation SPDX-License-Identifier: BSD-2-Clause-Patent @@ -19,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -809,6 +811,8 @@ PublishPrmAcpiTable ( EFI_STATUS Status; EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol; UINTN TableKey; + EFI_ACPI_DESCRIPTION_HEADER *Ssdt; + UINTN SsdtSize; if (PrmAcpiDescriptionTable == NULL || PrmAcpiDescriptionTable->Header.Signature != PRM_TABLE_SIGNATURE) { return EFI_INVALID_PARAMETER; @@ -832,6 +836,36 @@ PublishPrmAcpiTable ( } ASSERT_EFI_ERROR (Status); + // + // Load SSDT + // + Status = GetSectionFromFv ( + &gEfiCallerIdGuid, + EFI_SECTION_RAW, + 0, + (VOID **) &Ssdt, + &SsdtSize + ); + ASSERT_EFI_ERROR (Status); + DEBUG ((DEBUG_INFO, "%a %a: SSDT loaded ...\n", _DBGMSGID_, __FUNCTION__)); + + // + // Update OEM ID + // + CopyMem (&Ssdt->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (Ssdt->OemId)); + + // + // Publish the SSDT. Table is re-checksumed. + // + TableKey = 0; + Status = AcpiTableProtocol->InstallAcpiTable ( +AcpiTableProtocol, +Ssdt, +SsdtSize, +&TableKey +); + ASSERT_EFI_ERROR (Status); + return Status; } diff --git a/PrmPkg/PrmLoaderDxe/Prm.asl b/PrmPkg/PrmLoaderDxe/Prm.asl new file mode 100644 index ..76b56de732da --- /dev/null +++ b/PrmPkg/PrmLoaderDxe/Prm.asl @@ -0,0 +1,87 @@ +/** @file + The definition block in ACPI table for PRM Operation Region + + Copyright (c) 2020, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +DefinitionBlock ( +"Prm.aml", +"SSDT", +0x01, +"OEMID", +"PRMOPREG", +0x3000 +) +{ +Scope (\_SB) +{ +// +// PRM Bridge Device +// + +Device (PRMB) +{ +Name (_HID, "80860222") +Name (_CID, "80860222") +Name (_DDN, "PRM Bridge Device") +Name (_STA, 0xF) +OperationRegion (OPR1, 0x80, 0, 16) +Field (OPR1, DWordAcc, NoLock, Preserve) //Make it ByteAcc for parameter validation +{ +Var0, 128 +} +Method (SETV, 1, Serialized) +{ +CopyObject (Arg0, \_SB.PRMB.Var0) +} +} + +// +// PRM Test Device +// + +Device (PRMT) +{ +Name (_HID, "80860223") +Name (_CID, "80860223") +Name (_DDN, "PRM Test Device") +Name (_STA, 0xF) +Name (BUF1, Buffer(16) +{ +0x5F, 0xAD, 0xF2, 0xD5, 0x47, 0xA3, 0x3E, 0x4D, //Guid_0 +0x87, 0xBC, 0xC2, 0xCE, 0x63, 0x02, 0x9C, 0xC8, //Guid_1 +}) +Name (BUF2, Buffer(16) +{ +0xC3, 0xAD, 0xE7, 0xA9, 0xD0, 0x8C, 0x9A, 0x42, //Guid_0 +0x89, 0x15, 0x10, 0x94, 0x6E, 0xBD, 0xE3, 0x18, //Guid_1 +}) +Name (BUF3, Buffer(16) +{ +0x14, 0xC2, 0x88, 0xB6, 0x81, 0x40, 0xEB, 0x4E, //Guid_0 +0x8D, 0x26, 0x1E, 0xB5, 0xA3, 0xBC, 0xF1, 0x1A, //Guid_1 +}) +Method (NTST) +{ +\_SB.PRMB.SETV (BUF1) +} +Method (TST1) +
[edk2-devel] [PATCH v1 14/41] PrmPkg: Export major/minor version in PRM module PE COFF header
From: Liu PRMT ACPI defined major version and minor version for each PRM module. PRM module will build its major/minor version in its PE COFF header. In boot time, PRM loader will collect the major/minor version from PE COFF header and fill them into PRMT ACPI table. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Liu Yun --- PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleContextBufferModule.inf | 2 ++ PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.inf | 2 ++ PrmPkg/Samples/PrmSampleMemoryAllocationModule/PrmSampleMemoryAllocationModule.inf | 4 +++- PrmPkg/Samples/PrmSamplePrintModule/PrmSamplePrintModule.inf | 4 +++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleContextBufferModule.inf b/PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleContextBufferModule.inf index 4dd77f526116..b97af923c47a 100644 --- a/PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleContextBufferModule.inf +++ b/PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleContextBufferModule.inf @@ -5,6 +5,7 @@ # that applies the configuration for the PRM context data in the boot environment. A PRM handler # is provided that accesses the context buffer resources and prints their value at OS runtime. # +# Copyright (c) 2020, Intel Corporation. All rights reserved. # Copyright (c) Microsoft Corporation # # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -40,3 +41,4 @@ [Depex] [BuildOptions.common] MSFT:*_*_*_DLINK_FLAGS = /DLL /SUBSYSTEM:CONSOLE /VERSION:1.0 + MSFT:*_*_*_GENFW_FLAGS = --keepoptionalheader diff --git a/PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.inf b/PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.inf index 302183c576f9..369d1eb1e86d 100644 --- a/PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.inf +++ b/PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.inf @@ -4,6 +4,7 @@ # A sample PRM Module implementation. This PRM Module provides PRM handlers that perform various types # of hardware access. This is simply meant to demonstrate hardware access capabilities from a PRM handler. # +# Copyright (c) 2020, Intel Corporation. All rights reserved. # Copyright (c) Microsoft Corporation # # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -40,3 +41,4 @@ [Depex] [BuildOptions.common] MSFT:*_*_*_DLINK_FLAGS = /DLL /SUBSYSTEM:CONSOLE /VERSION:1.0 + MSFT:*_*_*_GENFW_FLAGS = --keepoptionalheader diff --git a/PrmPkg/Samples/PrmSampleMemoryAllocationModule/PrmSampleMemoryAllocationModule.inf b/PrmPkg/Samples/PrmSampleMemoryAllocationModule/PrmSampleMemoryAllocationModule.inf index e6798afe19e8..06be8f40f4ec 100644 --- a/PrmPkg/Samples/PrmSampleMemoryAllocationModule/PrmSampleMemoryAllocationModule.inf +++ b/PrmPkg/Samples/PrmSampleMemoryAllocationModule/PrmSampleMemoryAllocationModule.inf @@ -5,6 +5,7 @@ # a debug message. Three PRM handlers are provided that each print a unique # debug message. # +# Copyright (c) 2020, Intel Corporation. All rights reserved. # Copyright (c) Microsoft Corporation # # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -38,4 +39,5 @@ [Depex] TRUE [BuildOptions.common] - MSFT:*_*_*_DLINK_FLAGS = /DLL /SUBSYSTEM:CONSOLE + MSFT:*_*_*_DLINK_FLAGS = /DLL /SUBSYSTEM:CONSOLE /VERSION:1.0 + MSFT:*_*_*_GENFW_FLAGS = --keepoptionalheader diff --git a/PrmPkg/Samples/PrmSamplePrintModule/PrmSamplePrintModule.inf b/PrmPkg/Samples/PrmSamplePrintModule/PrmSamplePrintModule.inf index d685bf888a1c..7ac291bc6e8a 100644 --- a/PrmPkg/Samples/PrmSamplePrintModule/PrmSamplePrintModule.inf +++ b/PrmPkg/Samples/PrmSamplePrintModule/PrmSamplePrintModule.inf @@ -5,6 +5,7 @@ # a debug message. Three PRM handlers are provided that each print a unique # debug message. # +# Copyright (c) 2020, Intel Corporation. All rights reserved. # Copyright (c) Microsoft Corporation # # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -36,4 +37,5 @@ [Depex] TRUE [BuildOptions.common] - MSFT:*_*_*_DLINK_FLAGS = /DLL /SUBSYSTEM:CONSOLE + MSFT:*_*_*_DLINK_FLAGS = /DLL /SUBSYSTEM:CONSOLE /VERSION:1.0 + MSFT:*_*_*_GENFW_FLAGS = --keepoptionalheader -- 2.28.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87856): https://edk2.groups.io/g/devel/message/87856 Mute This Topic: https://groups.io/mt/89955985/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v1 15/41] PrmPkg: Add initial PrmSsdtInstallDxe module
From: Michael Kubacki Adds a new module that installs a PRM SSDT. Note: A library class would allow a high degree of flexibility for platforms that choose: 1. To not install a PRM SSDT at all (using a NULL library instance) 2. To install a specific PRM SSDT implementation However, it is implemented as a driver since build tools are not linking ACPI tables to drivers from linked library classes. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c | 33 -- PrmPkg/PrmSsdtInstallDxe/PrmSsdtInstallDxe.c | 110 PrmPkg/PrmLoaderDxe/PrmLoaderDxe.inf | 4 +- PrmPkg/PrmPkg.dsc | 5 + PrmPkg/{PrmLoaderDxe => PrmSsdtInstallDxe}/Prm.asl | 18 +--- PrmPkg/PrmSsdtInstallDxe/PrmSsdtInstallDxe.inf | 52 + 6 files changed, 171 insertions(+), 51 deletions(-) diff --git a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c index 5e14b8e09dd0..e45f8685e81f 100644 --- a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c +++ b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -811,8 +810,6 @@ PublishPrmAcpiTable ( EFI_STATUS Status; EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol; UINTN TableKey; - EFI_ACPI_DESCRIPTION_HEADER *Ssdt; - UINTN SsdtSize; if (PrmAcpiDescriptionTable == NULL || PrmAcpiDescriptionTable->Header.Signature != PRM_TABLE_SIGNATURE) { return EFI_INVALID_PARAMETER; @@ -836,36 +833,6 @@ PublishPrmAcpiTable ( } ASSERT_EFI_ERROR (Status); - // - // Load SSDT - // - Status = GetSectionFromFv ( - &gEfiCallerIdGuid, - EFI_SECTION_RAW, - 0, - (VOID **) &Ssdt, - &SsdtSize - ); - ASSERT_EFI_ERROR (Status); - DEBUG ((DEBUG_INFO, "%a %a: SSDT loaded ...\n", _DBGMSGID_, __FUNCTION__)); - - // - // Update OEM ID - // - CopyMem (&Ssdt->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (Ssdt->OemId)); - - // - // Publish the SSDT. Table is re-checksumed. - // - TableKey = 0; - Status = AcpiTableProtocol->InstallAcpiTable ( -AcpiTableProtocol, -Ssdt, -SsdtSize, -&TableKey -); - ASSERT_EFI_ERROR (Status); - return Status; } diff --git a/PrmPkg/PrmSsdtInstallDxe/PrmSsdtInstallDxe.c b/PrmPkg/PrmSsdtInstallDxe/PrmSsdtInstallDxe.c new file mode 100644 index ..bd9ce2c6fa02 --- /dev/null +++ b/PrmPkg/PrmSsdtInstallDxe/PrmSsdtInstallDxe.c @@ -0,0 +1,110 @@ +/** @file + + This file contains a sample implementation of the Platform Runtime Mechanism (PRM) + SSDT Install library. + + Copyright (c) Microsoft Corporation + Copyright (c) 2020, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include + +#define _DBGMSGID_ "[PRMSSDTINSTALL]" + +/** + Installs the PRM SSDT. + + @param[in] OemId OEM ID to be used in the SSDT installation. + + @retval EFI_SUCCESS The PRM SSDT was installed successfully. + @retval EFI_INVALID_PARAMETER The OemId pointer argument is NULL. + @retval EFI_NOT_FOUND An instance of gEfiAcpiTableProtocolGuid was not found installed or + the SSDT (AML RAW section) could not be found in the current FV. + @retval EFI_OUT_OF_RESOURCESInsufficient memory resources to install the PRM SSDT. + +**/ +EFI_STATUS +InstallPrmSsdt ( + IN CONST UINT8 *OemId + ) +{ + EFI_STATUS Status; + UINTN SsdtSize; + UINTN TableKey; + EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol; + EFI_ACPI_DESCRIPTION_HEADER *Ssdt; + + DEBUG ((DEBUG_INFO, "%a %a - Entry.\n", _DBGMSGID_, __FUNCTION__)); + + if (OemId == NULL) { +return EFI_INVALID_PARAMETER; + } + + Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol); + if (!EFI_ERROR (Status)) { +// +// Discover the SSDT +// +Status = GetSectionFromFv ( +&gEfiCallerIdGuid, +EFI_SECTION_RAW, +0, +(VOID **) &Ssdt, +&SsdtSize +); +ASSERT_EFI_ERROR (Status); +DEBUG ((DEBUG_INFO, "%a %a: SSDT loaded...\n", _DBGMSGID_, __FUNCTION__)); + +// +// Update OEM ID in the SSDT +
[edk2-devel] [PATCH v1 16/41] PrmPkg: Remove PRM Module Update Lock
From: Michael Kubacki Per latest design direction, we've abandoned treating the PRM Module Update Lock as an exported object. There was concern sharing the PRM module address space (where the lock structure resided in a data section) with the OS kernel mode driver. The lock will now be entirely maintained in OS context with interaces to control the lock available to ASL (for _DSM invocation) and OS native code (for direct call). Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c | 18 PrmPkg/Include/PrmModule.h | 20 - PrmPkg/Include/PrmModuleUpdate.h | 46 PrmPkg/PrmLoaderDxe/PrmAcpiTable.h | 2 - PrmPkg/Readme.md | 37 5 files changed, 18 insertions(+), 105 deletions(-) diff --git a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c index e45f8685e81f..e2a838ea29bd 100644 --- a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c +++ b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c @@ -26,7 +26,6 @@ #include #include -#include LIST_ENTRY mPrmModuleList; @@ -707,23 +706,6 @@ ProcessPrmModules ( ); ASSERT_EFI_ERROR (Status); -Status = GetExportEntryAddress ( -PRM_STRING (PRM_MODULE_UPDATE_LOCK_DESCRIPTOR_NAME), -CurrentImageAddress, -CurrentImageExportDirectory, -(EFI_PHYSICAL_ADDRESS *) &(CurrentModuleInfoStruct->ModuleUpdateLock) -); -ASSERT_EFI_ERROR (Status); -if (!EFI_ERROR (Status)) { - DEBUG (( -DEBUG_INFO, -"%a %a: Found PRM module update lock physical address at 0x%016x.\n", -_DBGMSGID_, -__FUNCTION__, -CurrentModuleInfoStruct->ModuleUpdateLock -)); -} - // It is currently valid for a PRM module not to use a context buffer Status = GetModuleContextBuffers ( ByModuleGuid, diff --git a/PrmPkg/Include/PrmModule.h b/PrmPkg/Include/PrmModule.h index f40fb42a2b4f..d7047d8eec58 100644 --- a/PrmPkg/Include/PrmModule.h +++ b/PrmPkg/Include/PrmModule.h @@ -15,7 +15,6 @@ #include #include #include -#include #include /** @@ -46,23 +45,4 @@ IN PRM_CONTEXT_BUFFER *ContextBuffer \ ) \ -/** - A macro that declares the PRM Module Update Lock Descriptor for a PRM Module. - - This macro is intended to be used once in a PRM Module so the module update lock descriptor is - exported for the module. - -**/ -#define PRM_MODULE_UPDATE_LOCK_EXPORT \ - PRM_EXPORT_API PRM_MODULE_UPDATE_LOCK_DESCRIPTOR PRM_MODULE_UPDATE_LOCK_DESCRIPTOR_NAME = { \ -PRM_MODULE_UPDATE_LOCK_DESCRIPTOR_SIGNATURE, \ -PRM_MODULE_UPDATE_LOCK_REVISION, \ -{ 0 } \ - } \ - -// -// A PRM module is required to export the PRM Module Update Lock -// -PRM_MODULE_UPDATE_LOCK_EXPORT; - #endif diff --git a/PrmPkg/Include/PrmModuleUpdate.h b/PrmPkg/Include/PrmModuleUpdate.h deleted file mode 100644 index fde97eff0462.. --- a/PrmPkg/Include/PrmModuleUpdate.h +++ /dev/null @@ -1,46 +0,0 @@ -/** @file - - Definition for the Platform Runtime Mechanism (PRM) module update structures. - - Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#ifndef PRM_MODULE_UPDATE_H_ -#define PRM_MODULE_UPDATE_H_ - -#include - -#define PRM_MODULE_UPDATE_LOCK_DESCRIPTOR_NAMEPrmModuleUpdateLock -#define PRM_MODULE_UPDATE_LOCK_DESCRIPTOR_SIGNATURE SIGNATURE_64 ('P', 'R', 'M', '_', 'M', 'U', 'L', '_') -#define PRM_MODULE_UPDATE_LOCK_REVISION 0x0 - -#pragma pack(push, 1) - -/// -/// Maintains the PRM Module Update Lock state -/// -typedef union { - /// - /// Individual bit fields - /// - struct { -UINT8 Acquired : 1; ///< [0] - If 1 lock is acquired. If 0 lock is released. -UINT8 Reserved : 7; ///< [7:1] - Reserved - } Bits; - /// - /// All bit fields as an 8-bit value - /// - UINT8 Uint8; -} PRM_MODULE_UPDATE_LOCK; - -typedef struct { - UINT64Signature; - UINT16Revision; - PRM_MODULE_UPDATE_LOCKLock; -} PRM_MODULE_UPDATE_LOCK_DESCRIPTOR; - -#pragma pack(pop) - -#endif diff --git a/PrmPkg/PrmLoaderDxe/PrmAcpiTable.h b/PrmPkg/PrmLoaderDxe/PrmAcpiTable.h index 8a9c82347d93..ca09be389235 100644 --- a/PrmPkg/PrmLoaderDxe/PrmAcpiTable.h +++ b/PrmPkg/PrmLoaderDxe/PrmAcpiTable.h @@ -5
[edk2-devel] [PATCH v1 17/41] PrmPkg: Remove ALLOCATE_CONTEXT_BUFFER_IN_FW build flag
From: Michael Kubacki The POR is firmly to use an OS allocated context buffer now so the build flag that allows firmware to allocate the context buffer is removed along with supporting code. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/PrmConfigDxe/PrmConfigDxe.c | 72 PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c | 4 -- PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/DxeContextBufferModuleConfigLib.c | 12 +--- PrmPkg/PrmLoaderDxe/PrmAcpiTable.h | 6 -- PrmPkg/PrmPkg.dsc | 5 -- PrmPkg/Readme.md | 12 +--- 6 files changed, 4 insertions(+), 107 deletions(-) diff --git a/PrmPkg/PrmConfigDxe/PrmConfigDxe.c b/PrmPkg/PrmConfigDxe/PrmConfigDxe.c index 7215c2e1dc6f..c547db3eca5e 100644 --- a/PrmPkg/PrmConfigDxe/PrmConfigDxe.c +++ b/PrmPkg/PrmConfigDxe/PrmConfigDxe.c @@ -26,10 +26,8 @@ #define _DBGMSGID_"[PRMCONFIG]" STATIC UINTN mMaxRuntimeMmioRangeCount; -STATIC UINTN mMaxStaticDataBufferCount; GLOBAL_REMOVE_IF_UNREFERENCED STATIC PRM_RUNTIME_MMIO_RANGES **mRuntimeMmioRanges; -GLOBAL_REMOVE_IF_UNREFERENCED STATIC PRM_DATA_BUFFER ***mStaticDataBuffers; /** Converts the runtime memory range physical addresses to virtual addresses. @@ -181,32 +179,12 @@ StoreVirtualMemoryAddressChangePointers ( UINTN HandleCount; UINTN HandleIndex; UINTN RangeIndex; -#ifdef ALLOCATE_CONTEXT_BUFFER_IN_FW - UINTN BufferIndex; - UINTN StaticDataBufferIndex; - PRM_CONTEXT_BUFFER *CurrentContextBuffer; -#endif EFI_HANDLE *HandleBuffer; PRM_CONFIG_PROTOCOL *PrmConfigProtocol; DEBUG ((DEBUG_INFO, "%a %a - Entry.\n", _DBGMSGID_, __FUNCTION__)); RangeIndex = 0; -#ifdef ALLOCATE_CONTEXT_BUFFER_IN_FW - StaticDataBufferIndex = 0; - - mStaticDataBuffers = AllocateRuntimeZeroPool (sizeof (*mStaticDataBuffers) * mMaxStaticDataBufferCount); - if (mStaticDataBuffers == NULL && mMaxStaticDataBufferCount > 0) { -DEBUG (( - DEBUG_ERROR, - " %a %a: Memory allocation for PRM static data buffer pointer array failed.\n", - _DBGMSGID_, - __FUNCTION__ - )); -ASSERT (FALSE); -return; - } -#endif mRuntimeMmioRanges = AllocateRuntimeZeroPool (sizeof (*mRuntimeMmioRanges) * mMaxRuntimeMmioRangeCount); if (mRuntimeMmioRanges == NULL && mMaxRuntimeMmioRangeCount > 0) { @@ -240,28 +218,6 @@ StoreVirtualMemoryAddressChangePointers ( continue; } -#ifdef ALLOCATE_CONTEXT_BUFFER_IN_FW - for (BufferIndex = 0; BufferIndex < PrmConfigProtocol->ModuleContextBuffers.BufferCount; BufferIndex++) { -CurrentContextBuffer = &(PrmConfigProtocol->ModuleContextBuffers.Buffer[BufferIndex]); - -if (CurrentContextBuffer->StaticDataBuffer != NULL) { - if (StaticDataBufferIndex >= mMaxStaticDataBufferCount) { -Status = EFI_BUFFER_TOO_SMALL; -DEBUG (( - DEBUG_ERROR, - " %a %a: Index out of bounds - Actual count (%d) of PRM data buffers exceeds maximum count (%d).\n", - _DBGMSGID_, - __FUNCTION__, - StaticDataBufferIndex + 1, - mMaxStaticDataBufferCount - )); -ASSERT_EFI_ERROR (Status); -return; - } - mStaticDataBuffers[StaticDataBufferIndex++] = &CurrentContextBuffer->StaticDataBuffer; -} - } -#endif if (PrmConfigProtocol->ModuleContextBuffers.RuntimeMmioRanges != NULL) { if (RangeIndex >= mMaxRuntimeMmioRangeCount) { Status = EFI_BUFFER_TOO_SMALL; @@ -286,15 +242,6 @@ StoreVirtualMemoryAddressChangePointers ( __FUNCTION__, RangeIndex )); -#ifdef ALLOCATE_CONTEXT_BUFFER_IN_FW -DEBUG (( - DEBUG_INFO, - " %a %a: %d static buffers saved for future virtual memory conversion.\n", - _DBGMSGID_, - __FUNCTION__, - StaticDataBufferIndex - )); -#endif } } @@ -396,15 +343,6 @@ PrmConfigVirtualAddressChangeEvent ( { UINTN Index; -#ifdef ALLOCATE_CONTEXT_BUFFER_IN_FW - // - // Convert static data buffer pointers - // - for (Index = 0; Index < mMaxStaticDataBufferCount; Index++) { -gRT->ConvertPointer (0x0, (VOID
[edk2-devel] [PATCH v1 18/41] PrmPkg/PrmContextBuffer.h: Add ACPI parameter support structures
From: Michael Kubacki Adds a new type ACPI_PARAMETER_BUFFER_DESCRIPTOR that can be used by PRM module configuration code to associate a PRM handler GUID with an ACPI parameter buffer allocated by the PRM module configuration code. The ACPI parameter buffer descriptors for a given PRM module are tracked in the firmware internal structure PRM_MODULE_CONTEXT_BUFFERS produced by the module configuration code. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Include/PrmContextBuffer.h | 41 1 file changed, 41 insertions(+) diff --git a/PrmPkg/Include/PrmContextBuffer.h b/PrmPkg/Include/PrmContextBuffer.h index 8f8144545e64..869480101773 100644 --- a/PrmPkg/Include/PrmContextBuffer.h +++ b/PrmPkg/Include/PrmContextBuffer.h @@ -19,6 +19,18 @@ #pragma pack(push, 1) +// +// Associates an ACPI parameter buffer with a particular PRM handler in +// a PRM module. +// +// If either the GUID or address are zero then neither value is used to +// copy the ACPI parameter buffer address to the PRMT ACPI table. +// +typedef struct { + EFI_GUID HandlerGuid; + UINT64AcpiParameterBufferAddress; +} ACPI_PARAMETER_BUFFER_DESCRIPTOR; + // // This is the context buffer structure that is passed to a PRM handler. // @@ -124,6 +136,35 @@ typedef struct /// This pointer may be NULL if runtime memory ranges are not needed. /// PRM_RUNTIME_MMIO_RANGES *RuntimeMmioRanges; + + /// + /// The number of ACPI parameter buffer descriptors in the array + /// AcpiParameterBufferDescriptors + /// + UINTN AcpiParameterBufferDescriptorCount; + + /// + /// A pointer to an array of ACPI parameter buffer descriptors. PRM module + /// configuration code uses this structure to associate a specific PRM + /// handler with an ACPI parameter buffer. + /// + /// An ACPI parameter buffer is a parameter buffer allocated by the PRM + /// module configuration code to be used by ACPI as a parameter buffer + /// to the associated PRM handler at OS runtime. + /// + /// This buffer is not required if: + /// 1. A parameter buffer is not used by a PRM handler at all + /// 2. A parameter buffer is used but the PRM handler is never invoked + ///from ACPI (it is directly called by an OS device driver for example) + /// + /// In case #2 above, the direct PRM handler is responsible for allocating + /// a parameter buffer and passing that buffer to the PRM handler. + /// + /// A PRM module only needs to provide an ACPI_PARAMETER_BUFFER_DESCRIPTOR + /// for each PRM handler that actually uses an ACPI parameter buffer. If + /// no handlers use an ACPI parameter buffer this pointer should be NULL. + /// + ACPI_PARAMETER_BUFFER_DESCRIPTOR*AcpiParameterBufferDescriptors; } PRM_MODULE_CONTEXT_BUFFERS; #pragma pack(pop) -- 2.28.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87860): https://edk2.groups.io/g/devel/message/87860 Mute This Topic: https://groups.io/mt/89956000/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v1 19/41] PrmPkg/PrmLoaderDxe: Add ACPI parameter buffer support
From: Michael Kubacki Adds support to PrmLoaderDxe to move the ACPI parameter buffer address for a given PRM handler to the corresponding field in the PRM handler information structure (PRMT ACPI table). Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c | 17 + 1 file changed, 17 insertions(+) diff --git a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c index 433d81cf8009..6416e388a668 100644 --- a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c +++ b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c @@ -621,6 +621,7 @@ ProcessPrmModules ( PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *TempListEntry; CONST CHAR8 *CurrentExportDescriptorHandlerName; + ACPI_PARAMETER_BUFFER_DESCRIPTOR*CurrentModuleAcpiParamDescriptors; PRM_CONTEXT_BUFFER *CurrentContextBuffer; PRM_MODULE_CONTEXT_BUFFERS *CurrentModuleContextBuffers; PRM_MODULE_INFORMATION_STRUCT *CurrentModuleInfoStruct; @@ -628,6 +629,7 @@ ProcessPrmModules ( EFI_STATUS Status; EFI_PHYSICAL_ADDRESSCurrentImageAddress; + UINTN AcpiParamIndex; UINTN HandlerIndex; UINT32 PrmAcpiDescriptionTableBufferSize; @@ -677,6 +679,7 @@ ProcessPrmModules ( CurrentImageAddress = TempListEntry->Context->PeCoffImageContext.ImageAddress; CurrentImageExportDirectory = TempListEntry->Context->ExportDirectory; CurrentExportDescriptorStruct = TempListEntry->Context->ExportDescriptor; +CurrentModuleAcpiParamDescriptors = NULL; DEBUG (( DEBUG_INFO, @@ -715,6 +718,7 @@ ProcessPrmModules ( ASSERT (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND); if (!EFI_ERROR (Status) && CurrentModuleContextBuffers != NULL) { CurrentModuleInfoStruct->RuntimeMmioRanges = (UINT64) (UINTN) CurrentModuleContextBuffers->RuntimeMmioRanges; + CurrentModuleAcpiParamDescriptors = CurrentModuleContextBuffers->AcpiParameterBufferDescriptors; } // @@ -759,6 +763,19 @@ ProcessPrmModules ( CurrentHandlerInfoStruct->PhysicalAddress )); } + + // + // Update the handler ACPI parameter buffer address if applicable + // + if (CurrentModuleAcpiParamDescriptors != NULL) { +for (AcpiParamIndex = 0; AcpiParamIndex < CurrentModuleContextBuffers->AcpiParameterBufferDescriptorCount; AcpiParamIndex++) { + if (CompareGuid (&CurrentModuleAcpiParamDescriptors[AcpiParamIndex].HandlerGuid, &CurrentHandlerInfoStruct->Identifier)) { +CurrentHandlerInfoStruct->AcpiParameterBuffer = (UINT64) (UINTN) ( + CurrentModuleAcpiParamDescriptors[AcpiParamIndex].AcpiParameterBufferAddress + ); + } +} + } } CurrentModuleInfoStruct = (PRM_MODULE_INFORMATION_STRUCT *) ((UINTN) CurrentModuleInfoStruct + CurrentModuleInfoStruct->StructureLength); } -- 2.28.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87861): https://edk2.groups.io/g/devel/message/87861 Mute This Topic: https://groups.io/mt/89956001/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v1 20/41] PrmPkg/PrmSampleContextBufferModule: Remove OS debug print requirement
From: Michael Kubacki Removes the expectation that the parameter buffer contain an OS debug print service at the beginning of the buffer. All supporting code related to printing is also removed. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/DxeContextBufferModuleConfigLib.c | 4 +- PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleContextBufferModule.c | 128 +++- 2 files changed, 17 insertions(+), 115 deletions(-) diff --git a/PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/DxeContextBufferModuleConfigLib.c b/PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/DxeContextBufferModuleConfigLib.c index c222c961f23b..4c0c3348459c 100644 --- a/PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/DxeContextBufferModuleConfigLib.c +++ b/PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/DxeContextBufferModuleConfigLib.c @@ -24,7 +24,7 @@ STATIC EFI_HANDLE mPrmConfigProtocolHandle; STATIC CONST EFI_GUID mPrmModuleGuid = {0x5a6cf42b, 0x8bb4, 0x472c, {0xa2, 0x33, 0x5c, 0x4d, 0xc4, 0x03, 0x3d, 0xc7}}; // {e1466081-7562-430f-896b-b0e523dc335a} -STATIC CONST EFI_GUID mDumpStaticDataBufferPrmHandlerGuid = {0xe1466081, 0x7562, 0x430f, {0x89, 0x6b, 0xb0, 0xe5, 0x23, 0xdc, 0x33, 0x5a}}; +STATIC CONST EFI_GUID mCheckStaticDataBufferPrmHandlerGuid = {0xe1466081, 0x7562, 0x430f, {0x89, 0x6b, 0xb0, 0xe5, 0x23, 0xdc, 0x33, 0x5a}}; /** Populates the static data buffer for this PRM module. @@ -166,7 +166,7 @@ ContextBufferModuleConfigLibConstructor ( Status = EFI_OUT_OF_RESOURCES; goto Done; } - CopyGuid (&PrmContextBuffer->HandlerGuid, &mDumpStaticDataBufferPrmHandlerGuid); + CopyGuid (&PrmContextBuffer->HandlerGuid, &mCheckStaticDataBufferPrmHandlerGuid); PrmContextBuffer->Signature = PRM_CONTEXT_BUFFER_SIGNATURE; PrmContextBuffer->Version = PRM_CONTEXT_BUFFER_INTERFACE_VERSION; PrmContextBuffer->StaticDataBuffer = StaticDataBuffer; diff --git a/PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleContextBufferModule.c b/PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleContextBufferModule.c index 074552d0c07e..5c4e5c7a10eb 100644 --- a/PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleContextBufferModule.c +++ b/PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleContextBufferModule.c @@ -21,146 +21,39 @@ // // {e1466081-7562-430f-896b-b0e523dc335a} -#define DUMP_STATIC_DATA_BUFFER_PRM_HANDLER_GUID {0xe1466081, 0x7562, 0x430f, {0x89, 0x6b, 0xb0, 0xe5, 0x23, 0xdc, 0x33, 0x5a}} - -/** - Dumps the contents of a given buffer. - - @param[in] OsServiceDebugPrint A pointer to the debug print OS service. - @param[in] BufferA pointer to the buffer that should be dumped. - @param[in] BufferSizeThe size of Buffer in bytes. - -**/ -STATIC -VOID -DumpBuffer ( - IN PRM_OS_SERVICE_DEBUG_PRINT OsServiceDebugPrint, - IN CONST VOID *Buffer, - IN UINTN BufferSize - ) -{ - UINTN Count; - CONST UINT8 *Char = Buffer; - CHAR8 DebugMessage[16]; - - if (OsServiceDebugPrint == NULL || Buffer == NULL) { -return; - } - - OsServiceDebugPrint (""); - for (Count = 0; Count < BufferSize; Count++) - { -if (Count && !(Count % 16)) { - OsServiceDebugPrint ("\n"); -} -AsciiSPrint ( - &DebugMessage[0], - ARRAY_SIZE (DebugMessage), - "%02X ", - Char[Count] - ); -OsServiceDebugPrint (&DebugMessage[0]); - } - OsServiceDebugPrint ("\n\n"); -} - -/** - Prints the contents of this PRM module's static data buffer. - - @param[in] OsServiceDebugPrint A pointer to the debug print OS service. - @param[in] StaticDataBuffer A pointer to the static buffer. - -**/ -VOID -EFIAPI -PrintStaticDataBuffer ( - IN PRM_OS_SERVICE_DEBUG_PRINT OsServiceDebugPrint, - IN CONST STATIC_DATA_SAMPLE_CONTEXT_BUFFER_MODULE *StaticDataBuffer - ) -{ - CHAR8 DebugMessage[256]; - - if (OsServiceDebugPrint == NULL || StaticDataBuffer == NULL) { -return; - } - - AsciiSPrint ( -&DebugMessage[0], -ARRAY_SIZE (DebugMessage), -" Policy1Enabled = 0x%x.\n", -StaticDataBuffer->Policy1Enabled -); - OsServiceDebugPrint (&DebugMessage[0]); - - AsciiSPrint ( -&DebugMessage[0], -ARRAY_SIZE (DebugMessage), -" Policy2Enabled = 0x%x.\n", -StaticDataBuffer->Policy2Enabled -); - OsServiceDebugPrint (&DebugMessage[0]); - - OsServiceDebugPrint (" Dumping SomeValueArray:\n"); - DumpBuffer ( -OsServiceDebugPrint, -(CONST VOID *) &StaticDataBuffer->SomeValueArray[0], -ARRAY_SIZE (Stati
[edk2-devel] [PATCH v1 21/41] PrmPkg/PrmSampleHardwareAccessModule: Add non-print PRM handlers
From: Michael Kubacki For each PRM handler that is currently present, a corresponding PRM handler is added that does not print. This allows a caller to execute a sample hardware access PRM handler without requiring that caller to provide a debug print service. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.c | 375 +--- 1 file changed, 243 insertions(+), 132 deletions(-) diff --git a/PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.c b/PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.c index 87fe9cafc912..32e04c5e8592 100644 --- a/PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.c +++ b/PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.c @@ -27,12 +27,21 @@ // {2120cd3c-848b-4d8f-abbb-4b74ce64ac89} #define MSR_ACCESS_MICROCODE_SIGNATURE_PRM_HANDLER_GUID {0x2120cd3c, 0x848b, 0x4d8f, {0xab, 0xbb, 0x4b, 0x74, 0xce, 0x64, 0xac, 0x89}} +// {5d28b4e7-3867-4aee-aa09-51fc282c3b22} +#define MSR_PRINT_MICROCODE_SIGNATURE_PRM_HANDLER_GUID {0x5d28b4e7, 0x3867, 0x4aee, {0xaa, 0x09, 0x51, 0xfc, 0x28, 0x2c, 0x3b, 0x22}} + // {ea0935a7-506b-4159--48deeecb6f58} #define MSR_ACCESS_MTRR_DUMP_PRM_HANDLER_GUID {0xea0935a7, 0x506b, 0x4159, {0xbb, 0xbb, 0x48, 0xde, 0xee, 0xcb, 0x6f, 0x58}} +// {4b64b702-4d2b-4dfe-ac5a-0b4110a2ca47} +#define MSR_PRINT_MTRR_DUMP_PRM_HANDLER_GUID {0x4b64b702, 0x4d2b, 0x4dfe, {0xac, 0x5a, 0x0b, 0x41, 0x10, 0xa2, 0xca, 0x47}} + // {1bd1bda9-909a-4614-9699-25ec0c2783f7} #define MMIO_ACCESS_HPET_PRM_HANDLER_GUID {0x1bd1bda9, 0x909a, 0x4614, {0x96, 0x99, 0x25, 0xec, 0x0c, 0x27, 0x83, 0xf7}} +// {8a0efdde-78d0-45f0-aea0-c28245c7e1db} +#define MMIO_PRINT_HPET_PRM_HANDLER_GUID {0x8a0efdde, 0x78d0, 0x45f0, {0xae, 0xa0, 0xc2, 0x82, 0x45, 0xc7, 0xe1, 0xdb}} + #define HPET_BASE_ADDRESS 0xFED0 // @@ -124,13 +133,18 @@ MtrrLibApplyVariableMtrrs ( // /** - Prints all MTRR values including architectural and variable MTTRs. + Accesses MTRR values including architectural and variable MTRRs. + + If the optional OsServiceDebugPrint function pointer is provided that function is + used to print the MTRR settings. + + @param[in] OsServiceDebugPrint A pointer to an OS-provided debug print function. **/ VOID EFIAPI -PrintAllMtrrs ( - IN PRM_OS_SERVICE_DEBUG_PRINT OsServiceDebugPrint +AccessAllMtrrs ( + IN PRM_OS_SERVICE_DEBUG_PRINT OsServiceDebugPrint OPTIONAL ) { MTRR_SETTINGS LocalMtrrs; @@ -148,7 +162,7 @@ PrintAllMtrrs ( ]; MTRR_MEMORY_RANGE RawVariableRanges[ARRAY_SIZE (Mtrrs->Variables.Mtrr)]; - if (OsServiceDebugPrint == NULL || !IsMtrrSupported ()) { + if (!IsMtrrSupported ()) { return; } @@ -160,56 +174,63 @@ PrintAllMtrrs ( // // Dump RAW MTRR contents // - OsServiceDebugPrint (" MTRR Settings:\n"); - OsServiceDebugPrint (" =\n"); + if (OsServiceDebugPrint != NULL) { +OsServiceDebugPrint (" MTRR Settings:\n"); +OsServiceDebugPrint (" =\n"); - AsciiSPrint ( -&DebugMessage[0], -ARRAY_SIZE (DebugMessage), -" MTRR Default Type: %016lx\n", -Mtrrs->MtrrDefType -); - OsServiceDebugPrint (&DebugMessage[0]); - - for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { AsciiSPrint ( &DebugMessage[0], ARRAY_SIZE (DebugMessage), - " Fixed MTRR[%02d] : %016lx\n", - Index, - Mtrrs->Fixed.Mtrr[Index] + " MTRR Default Type: %016lx\n", + Mtrrs->MtrrDefType ); OsServiceDebugPrint (&DebugMessage[0]); } - ContainVariableMtrr = FALSE; - for (Index = 0; Index < VariableMtrrCount; Index++) { -if ((Mtrrs->Variables.Mtrr[Index].Mask & BIT11) == 0) { - // - // If mask is not valid, then do not display range - // - continue; + + if (OsServiceDebugPrint != NULL) { +for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { +AsciiSPrint ( + &DebugMessage[0], + ARRAY_SIZE (DebugMessage), + " Fixed MTRR[%02d] : %016lx\n", + Index, + Mtrrs->Fixed.Mtrr[Index] + ); +OsServiceDebugPrint (&DebugMessage[0]); + } + +ContainVariableMtrr = FALSE; +for (Index = 0; Index < VariableMtrrCount; Index++) { + if ((Mtrrs->Variables.Mtrr[Index].Mask & BIT11) == 0) { +// +// If mask is not valid, then do not display range +// +continue; + } + ContainVariableMtrr = TRUE; + AsciiSPrint ( +&DebugMessage[0], +ARRAY_SIZE (DebugMessage), +" Variable MTRR[%02d]: Base=%016lx Mask=%016lx\n", +Index, +Mtrrs->Variables.Mtrr[Index].Base, +Mtrrs->Variables.Mtrr[Index].Ma
[edk2-devel] [PATCH v1 22/41] PrmPkg/SampleAcpiParameterBufferModule: Add initial module
From: Michael Kubacki Adds a new PRM module called SampleAcpiParameterBufferModule that demonstrates how a PRM module can use an ACPI parameter buffer with a PRM handler. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Samples/PrmSampleAcpiParameterBufferModule/Library/DxeAcpiParameterBufferModuleConfigLib/DxeAcpiParameterBufferModuleConfigLib.c | 120 PrmPkg/Samples/PrmSampleAcpiParameterBufferModule/PrmSampleAcpiParameterBufferModule.c | 79 + PrmPkg/PrmPkg.dsc | 3 + PrmPkg/Samples/PrmSampleAcpiParameterBufferModule/Library/DxeAcpiParameterBufferModuleConfigLib/DxeAcpiParameterBufferModuleConfigLib.inf | 39 +++ PrmPkg/Samples/PrmSampleAcpiParameterBufferModule/PrmSampleAcpiParameterBufferModule.inf | 41 +++ 5 files changed, 282 insertions(+) diff --git a/PrmPkg/Samples/PrmSampleAcpiParameterBufferModule/Library/DxeAcpiParameterBufferModuleConfigLib/DxeAcpiParameterBufferModuleConfigLib.c b/PrmPkg/Samples/PrmSampleAcpiParameterBufferModule/Library/DxeAcpiParameterBufferModuleConfigLib/DxeAcpiParameterBufferModuleConfigLib.c new file mode 100644 index ..b135517232f7 --- /dev/null +++ b/PrmPkg/Samples/PrmSampleAcpiParameterBufferModule/Library/DxeAcpiParameterBufferModuleConfigLib/DxeAcpiParameterBufferModuleConfigLib.c @@ -0,0 +1,120 @@ +/** @file + + The boot services environment configuration library for the ACPI Parameter Buffer Sample PRM module. + + Copyright (c) Microsoft Corporation + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +STATIC EFI_HANDLE mPrmConfigProtocolHandle; + +// {dc2a58a6-5927-4776-b995-d118a27335a2} +STATIC CONST EFI_GUID mPrmModuleGuid = {0xdc2a58a6, 0x5927, 0x4776, {0xb9, 0x95, 0xd1, 0x18, 0xa2, 0x73, 0x35, 0xa2}}; + +// {2e4f2d13-6240-4ed0-a401-c723fbdc34e8} +STATIC CONST EFI_GUID mCheckParamBufferPrmHandlerGuid = {0x2e4f2d13, 0x6240, 0x4ed0, {0xa4, 0x01, 0xc7, 0x23, 0xfb, 0xdc, 0x34, 0xe8}}; + +/** + Constructor of the PRM configuration library. + + @param[in] ImageHandleThe image handle of the driver. + @param[in] SystemTableThe EFI System Table pointer. + + @retval EFI_SUCCESS The shell command handlers were installed successfully. + @retval EFI_UNSUPPORTED The shell level required was not found. +**/ +EFI_STATUS +EFIAPI +AcpiParameterBufferModuleConfigLibConstructor ( + IN EFI_HANDLEImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUSStatus; + VOID *AcpiParameterBuffer; + ACPI_PARAMETER_BUFFER_DESCRIPTOR *AcpiParamBufferDescriptor; + PRM_CONFIG_PROTOCOL *PrmConfigProtocol; + + AcpiParameterBuffer = NULL; + AcpiParamBufferDescriptor = NULL; + PrmConfigProtocol = NULL; + + /* +In this sample PRM module, the protocol describing this sample module's resources is simply +installed in the constructor. + +However, if some data is not available until later, this constructor could register a callback +on the dependency for the data to be available (e.g. ability to communicate with some device) +and then install the protocol. The requirement is that the protocol is installed before end of DXE. + */ + + // Allocate the ACPI parameter buffer + + // A parameter buffer is arbitrary data that is handler specific. This handler buffer is specified + // to consist of a UINT32 that represents the test data signature ('T', 'E', 'S', 'T'). + AcpiParameterBuffer = AllocateRuntimeZeroPool (sizeof (UINT32)); + ASSERT (AcpiParameterBuffer != NULL); + if (AcpiParameterBuffer == NULL) { +Status = EFI_OUT_OF_RESOURCES; +goto Done; + } + + // Allocate the ACPI Parameter Buffer Descriptor structure for a single PRM handler + AcpiParamBufferDescriptor = AllocateZeroPool (sizeof (*AcpiParamBufferDescriptor)); + ASSERT (AcpiParamBufferDescriptor != NULL); + if (AcpiParamBufferDescriptor == NULL) { +Status = EFI_OUT_OF_RESOURCES; +goto Done; + } + + // Allocate the PRM Configuration protocol structure for this PRM module + PrmConfigProtocol = AllocateZeroPool (sizeof (*PrmConfigProtocol)); + ASSERT (PrmConfigProtocol != NULL); + if (PrmConfigProtocol == NULL) { +Status = EFI_OUT_OF_RESOURCES; +goto Done; + } + CopyGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, &mPrmModuleGuid); + + // Populate the ACPI Parameter Buffer Descriptor structure + CopyGuid (&AcpiParamBufferDescriptor->HandlerGuid, &mCheckParamBufferPrmHandlerGuid); +
[edk2-devel] [PATCH v1 23/41] PrmPkg/HardwareAccessModuleConfigLib: Add initial library
From: Michael Kubacki Adds a PRM module configuration library for PrmSampleHardwareAccessModule that demonstrates marking a runtime MMIO range. In the case of this sample module, the range used is for HPET. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Samples/PrmSampleHardwareAccessModule/Library/DxeHardwareAccessModuleConfigLib/DxeHardwareAccessModuleConfigLib.c | 104 PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.c | 2 - PrmPkg/PrmPkg.dsc | 1 + PrmPkg/Samples/PrmSampleHardwareAccessModule/Hpet.h | 3 + PrmPkg/Samples/PrmSampleHardwareAccessModule/Library/DxeHardwareAccessModuleConfigLib/DxeHardwareAccessModuleConfigLib.inf | 39 5 files changed, 147 insertions(+), 2 deletions(-) diff --git a/PrmPkg/Samples/PrmSampleHardwareAccessModule/Library/DxeHardwareAccessModuleConfigLib/DxeHardwareAccessModuleConfigLib.c b/PrmPkg/Samples/PrmSampleHardwareAccessModule/Library/DxeHardwareAccessModuleConfigLib/DxeHardwareAccessModuleConfigLib.c new file mode 100644 index ..c00ab9ffbbe3 --- /dev/null +++ b/PrmPkg/Samples/PrmSampleHardwareAccessModule/Library/DxeHardwareAccessModuleConfigLib/DxeHardwareAccessModuleConfigLib.c @@ -0,0 +1,104 @@ +/** @file + + The boot services environment configuration library for the Hardware Access Sample PRM module. + + Copyright (c) Microsoft Corporation + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include + +STATIC EFI_HANDLE mPrmConfigProtocolHandle; + +// {0ef93ed7-14ae-425b-928f-b85a6213b57e} +STATIC CONST EFI_GUID mPrmModuleGuid = {0x0ef93ed7, 0x14ae, 0x425b, {0x92, 0x8f, 0xb8, 0x5a, 0x62, 0x13, 0xb5, 0x7e}}; + +/** + Constructor of the PRM configuration library. + + @param[in] ImageHandleThe image handle of the driver. + @param[in] SystemTableThe EFI System Table pointer. + + @retval EFI_SUCCESS The shell command handlers were installed successfully. + @retval EFI_UNSUPPORTED The shell level required was not found. +**/ +EFI_STATUS +EFIAPI +HardwareAccessModuleConfigLibConstructor ( + IN EFI_HANDLEImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUSStatus; + PRM_RUNTIME_MMIO_RANGES *RuntimeMmioRanges; + PRM_CONFIG_PROTOCOL *PrmConfigProtocol; + + RuntimeMmioRanges = NULL; + PrmConfigProtocol = NULL; + + /* +In this sample PRM module, the protocol describing this sample module's resources is simply +installed in the constructor. + +However, if some data is not available until later, this constructor could register a callback +on the dependency for the data to be available (e.g. ability to communicate with some device) +and then install the protocol. The requirement is that the protocol is installed before end of DXE. + */ + + // Runtime MMIO Ranges structure + + // Since this sample module only uses 1 runtime MMIO range, it can use the PRM_RUNTIME_MMIO_RANGES + // type directly without extending the size of the data buffer for additional MMIO ranges. + RuntimeMmioRanges = AllocateRuntimeZeroPool (sizeof (*RuntimeMmioRanges)); + ASSERT (RuntimeMmioRanges != NULL); + if (RuntimeMmioRanges == NULL) { +Status = EFI_OUT_OF_RESOURCES; +goto Done; + } + + // Allocate the PRM Configuration protocol structure for this PRM module + PrmConfigProtocol = AllocateZeroPool (sizeof (*PrmConfigProtocol)); + ASSERT (PrmConfigProtocol != NULL); + if (PrmConfigProtocol == NULL) { +Status = EFI_OUT_OF_RESOURCES; +goto Done; + } + CopyGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, &mPrmModuleGuid); + + // Populate the Runtime MMIO Ranges structure + RuntimeMmioRanges->Count = 1; + RuntimeMmioRanges->Range[0].PhysicalBaseAddress = HPET_BASE_ADDRESS; + RuntimeMmioRanges->Range[0].Length = HPET_RANGE_LENGTH; + + PrmConfigProtocol->ModuleContextBuffers.RuntimeMmioRanges = RuntimeMmioRanges; + + // + // Install the PRM Configuration Protocol for this module. This indicates the configuration + // library has completed resource initialization for the PRM module. + // + Status = gBS->InstallProtocolInterface ( + &mPrmConfigProtocolHandle, + &gPrmConfigProtocolGuid, + EFI_NATIVE_INTERFACE, + (VOID *) PrmConfigProtocol + ); + +Done: + if (EFI_ERROR (Status)) { +if (RuntimeMmioRanges != NULL) { + FreePool (RuntimeMmioRanges); +} +if (P
[edk2-devel] [PATCH v1 24/41] PrmPkg/Samples/Readme.md: Add initial file
From: Michael Kubacki Adds a Readme.md file for the Samples to help a user get started building and using the PRM sample modules. Includes a reference to the Samples/Readme.md file in the top-level file to help make the reader aware the file exists. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Readme.md | 5 +- PrmPkg/Samples/Readme.md | 263 2 files changed, 267 insertions(+), 1 deletion(-) diff --git a/PrmPkg/Readme.md b/PrmPkg/Readme.md index 52b44a95ddbc..b79cb66c4790 100644 --- a/PrmPkg/Readme.md +++ b/PrmPkg/Readme.md @@ -9,7 +9,7 @@ The `PrmPkg` maintained in this branch provides a single cohesive set of generic to be leveraged by platform firmware with minimal overhead to integrate PRM functionality in the firmware. ## **IMPORTANT NOTE** -> The code provided in this package and branch are for proof-of-concept purposes only. The code does not represent a +> The code provided in this package and branch are for proof-of-concept purposes only. The code does not represent a formal design and is not validated at product quality. The development of this feature is shared in the edk2-staging branch to simplify collaboration by allowing direct code contributions and early feedback throughout its development. @@ -120,6 +120,9 @@ prevent the package from being used as-is should be addressed directly in PrmPkg ## PRM Module +> __*Note*__: You can find simple examples of PRM modules in the Samples directory of this package. +> [Samples/Readme.md](PrmPkg/Samples/Readme.md) has more information. + By default, the EDK II implementation of UEFI does not allow images with the subsystem type IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER to be built with exports. diff --git a/PrmPkg/Samples/Readme.md b/PrmPkg/Samples/Readme.md new file mode 100644 index ..4926be243018 --- /dev/null +++ b/PrmPkg/Samples/Readme.md @@ -0,0 +1,263 @@ +# **Platform Runtime Mechanism Sample Modules** + +The PRM module samples provided here serve as focused examples of how to perform various tasks in a PRM module. The +samples can also be used to verify the basic infrastructure needed in your firmware implementation is working as +expected by checking that the sample modules are found properly and the handlers perform their tasks as noted. + +## **IMPORTANT NOTE** +> The sample modules have currently only been tested on the Visual Studio compiler tool chain. Sample module +build may fail on other tool chains. A future work item is to enable broader build support. + +## How to Build PRM Sample Modules +The sample modules are built as part of the normal `PrmPkg` build so you can follow the +[package build instructions](../../Readme.md#how-to-build-prmpkg) and then find the PRM sample binaries in your +workspace build output directory. For example, if your build workspace is called "edk2" and you build +64-bit binaries on the Visual Studio 2017 tool chain, your sample module binaries will be in the following +location: \ +``edk2/Build/Prm/DEBUG_VS2017/X64/PrmPkg/Samples`` + +### Build an Individual PRM Sample Module +Note that the build command does provide the option to build a specific module in a package which can result in +faster build time. If you would like to just build a single PRM module that can be done by specifying the path to +the module INF file with the "-m" argument to `build`. For example, this command builds 32-bit and 64-bit binaries +with Visual Studio 2019: \ +``build -p PrmPkg/PrmPkg.dsc -m PrmPkg/Samples/PrmSamplePrintModule/PrmSamplePrintModule.inf -a IA32 -a X64 -t VS2019`` + +## PRM Sample Module User's Guide + +The following table provides an overview of each sample module provided. By nature, different PRM handlers have +different requirements. The information here is summarized for a user to understand how to use a given sample +PRM handler along with GUID/name information to identify the sample PRM modules and their PRM handlers. + +It is recommended that all PRM authors write a similar set of documentation for their users to better understand +and interact with their PRM modules. + +--- +### Module: PRM Sample Print Module +>* Name: `PrmSamplePrintModule` +>* GUID: `1652b3c2-a7a1-46ac-af93-dd6dee446669` +> * Purpose: +> * Simplest PRM module example +> * Example of a PRM module with multiple PRM handlers + +**Handlers:** + Handler: PRM Handler 1 +* Name: `PrmHandler1` +* GUID: `d5f2ad5f-a347-4d3e-87bc-c2ce63029cc8` +* Actions: + * Use an OS-provided function pointer (pointer at the beginning of the parameter buffer) to write the message +“PRM1 handler sample message!” + +* Parameter Buffer Required: Yes +* Parameter Buffer Contents: + ```c + typedef struct { + +PRM_OS_SERVICE_DEBUG_PRINT * + + } SAMPLE_OSDEBUGPRINT_PARAMETER_BUFFER; + ``` + +* Context Bu
[edk2-devel] [PATCH v1 25/41] PrmPkg: Refactor some PrmLoaderDxe functionality into libraries
From: Michael Kubacki This change breaks out two sets of responsibilities in PrmLoaderDxe into libraries: * PE/COFF functions -> PrmPeCoffLib * PRM module discovery functions -> PrmModuleDiscoveryLib This is core infrastructure code for PRM functionality that needs to be directly reused and tested in other places. At this time, the primary motivating factor is to use this code in two other locations: 1.) Link the functionality into unit testing modules 2.) Link the functionality into a PRM UEFI application Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Library/DxePrmModuleDiscoveryLib/DxePrmModuleDiscoveryLib.c | 382 + PrmPkg/Library/DxePrmPeCoffLib/DxePrmPeCoffLib.c | 411 ++ PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c | 600 +--- PrmPkg/Include/Library/PrmModuleDiscoveryLib.h | 60 ++ PrmPkg/Include/Library/PrmPeCoffLib.h| 111 PrmPkg/Include/PrmModuleImageContext.h | 28 + PrmPkg/Library/DxePrmModuleDiscoveryLib/DxePrmModuleDiscoveryLib.inf | 41 ++ PrmPkg/Library/DxePrmModuleDiscoveryLib/PrmModuleDiscovery.h | 27 + PrmPkg/Library/DxePrmPeCoffLib/DxePrmPeCoffLib.inf | 32 ++ PrmPkg/PrmLoaderDxe/PrmLoader.h | 51 -- PrmPkg/PrmLoaderDxe/PrmLoaderDxe.inf | 5 +- PrmPkg/PrmPkg.dec| 8 + PrmPkg/PrmPkg.dsc| 13 + 13 files changed, 1133 insertions(+), 636 deletions(-) diff --git a/PrmPkg/Library/DxePrmModuleDiscoveryLib/DxePrmModuleDiscoveryLib.c b/PrmPkg/Library/DxePrmModuleDiscoveryLib/DxePrmModuleDiscoveryLib.c new file mode 100644 index ..6977799aa8f3 --- /dev/null +++ b/PrmPkg/Library/DxePrmModuleDiscoveryLib/DxePrmModuleDiscoveryLib.c @@ -0,0 +1,382 @@ +/** @file + + The PRM Module Discovery library provides functionality to discover PRM modules installed by platform firmware. + + Copyright (c) Microsoft Corporation + Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "PrmModuleDiscovery.h" + +#define _DBGMSGID_ "[PRMMODULEDISCOVERYLIB]" + +LIST_ENTRY mPrmModuleList; + +/** + Gets the next PRM module discovered after the given PRM module. + + @param[in,out] ModuleImageContext A pointer to a pointer to a PRM module image context structure. + ModuleImageContext should point to a pointer that points to NULL to + get the first PRM module discovered. + + @retval EFI_SUCCESS The next PRM module was found successfully. + @retval EFI_INVALID_PARAMETER The given ModuleImageContext structure is invalid or the pointer is NULL. + @retval EFI_NOT_FOUND The next PRM module was not found. + +**/ +EFI_STATUS +EFIAPI +GetNextPrmModuleEntry ( + IN OUT PRM_MODULE_IMAGE_CONTEXT**ModuleImageContext + ) +{ + LIST_ENTRY *CurrentLink; + LIST_ENTRY *ForwardLink; + PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *CurrentListEntry; + PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *ForwardListEntry; + + DEBUG ((DEBUG_INFO, "%a %a - Entry.\n", _DBGMSGID_, __FUNCTION__)); + + if (ModuleImageContext == NULL) { +return EFI_INVALID_PARAMETER; + } + + if (*ModuleImageContext == NULL) { +ForwardLink = GetFirstNode (&mPrmModuleList); + } else { +CurrentListEntry = NULL; +CurrentListEntry = CR (*ModuleImageContext, PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY, Context, PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY_SIGNATURE); +if (CurrentListEntry == NULL || CurrentListEntry->Signature != PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY_SIGNATURE) { + return EFI_INVALID_PARAMETER; +} + +CurrentLink = &CurrentListEntry->Link; +ForwardLink = GetNextNode (&mPrmModuleList, CurrentLink); + +if (ForwardLink == &mPrmModuleList) { + return EFI_NOT_FOUND; +} + } + + ForwardListEntry = BASE_CR (ForwardLink, PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY, Link); + if (ForwardListEntry->Signature == PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY_SIGNATURE) { +*ModuleImageContext = &ForwardListEntry->Context; +return EFI_SUCCESS; + } + + return EFI_NOT_FOUND; +} + +/** + Creates a new PRM Module Image Context linked list entry. + + @retval PrmModuleImageContextListEntry If successful, a pointer a PRM Module Image Context linked list entry +
[edk2-devel] [PATCH v1 26/41] PrmPkg/Application/PrmInfo: Add initial application
From: Michael Kubacki Adds a new UEFI application called "PrmInfo" that allows a user to display and test Platform Runtime Mechanism (PRM) modules. Execute the application help command for detailed usage instructions and examples of how to use the application: "PrmInfo -?" This application is intended to be helpful during PRM enabling by allowing the user to: 1. Confirm that their firmware port of the PRM infrastructure implemented in this package is functioning correctly. 2. Quickly get information about what PRM modules and handlers are present on a given system. 3. Quickly test PRM handlers without booting to a fully featured operating system. 4. Develop and exercise PRM handlers prior to the availability of an operating system that is PRM aware. Adds a brief section to Readme.md about the PrmInfo UEFI application with a link to allow the reader to find more information about the application if interested. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Application/PrmInfo/PrmInfo.c | 725 PrmPkg/Application/PrmInfo/PrmInfo.h | 49 ++ PrmPkg/Application/PrmInfo/PrmInfo.inf| 66 ++ PrmPkg/Application/PrmInfo/PrmInfo.uni| 11 + PrmPkg/Application/PrmInfo/PrmInfoExtra.uni | 12 + PrmPkg/Application/PrmInfo/PrmInfoStrings.uni | 132 PrmPkg/PrmPkg.dec | 10 + PrmPkg/PrmPkg.dsc | 28 +- PrmPkg/Readme.md | 19 + 9 files changed, 1050 insertions(+), 2 deletions(-) diff --git a/PrmPkg/Application/PrmInfo/PrmInfo.c b/PrmPkg/Application/PrmInfo/PrmInfo.c new file mode 100644 index ..431a6f206163 --- /dev/null +++ b/PrmPkg/Application/PrmInfo/PrmInfo.c @@ -0,0 +1,725 @@ +/** @file + Prints information about the PRM configuration loaded by the system firmware. + + This application also provides some additional testing features for PRM configuration. For example, + the application can be used to selectively invoke PRM handlers in the UEFI shell environment to + provide a quick testing path of the PRM infrastructure on the firmware and the PRM module implementation. + + This can also be useful to prepare a PRM enabled firmware and PRM modules prior to formal OS support to + test the PRM code. + + Copyright (C) Microsoft Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "PrmInfo.h" + +GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringPrmInfoHelpTokenId = STRING_TOKEN (STR_PRMINFO_HELP); +// +// This is the generated String package data for all .UNI files. +// This data array is ready to be used as input of HiiAddPackages() to +// create a packagelist (which contains Form packages, String packages, etc). +// +extern UINT8PrmInfoStrings[]; + +STATIC UINTNmPrmHandlerCount; +STATIC UINTNmPrmModuleCount; + +STATIC EFI_HII_HANDLE mPrmInfoHiiHandle; +STATIC LIST_ENTRY mPrmHandlerList; + +STATIC CONST SHELL_PARAM_ITEM mParamList[] = { + {L"-l", TypeFlag}, + {L"-t", TypeValue}, + {NULL, TypeMax} + }; + +/** + Frees all of the nodes in a linked list. + + @param[in] ListHead A pointer to the head of the list that should be freed. + + **/ +VOID +EFIAPI +FreeList ( + IN LIST_ENTRY *ListHead + ) +{ + LIST_ENTRY*Link; + LIST_ENTRY*NextLink; + PRM_HANDLER_CONTEXT_LIST_ENTRY*ListEntry; + + if (ListHead == NULL) { +return; + } + + Link = GetFirstNode (&mPrmHandlerList); + while (!IsNull (&mPrmHandlerList, Link)) { +ListEntry = CR (Link, PRM_HANDLER_CONTEXT_LIST_ENTRY, Link, PRM_HANDLER_CONTEXT_LIST_ENTRY_SIGNATURE); +NextLink = GetNextNode (&mPrmHandlerList, Link); + +RemoveEntryList (Link); +FreePool (ListEntry); + +Link = NextLink; + } +} + +/** + Creates a new PRM Module Image Context linked list entry. + + @retvalPrmHandlerContextListEntry If successful, a pointer a PRM Handler Context linked list entry +otherwise, NULL is returned. + +**/ +PRM_HANDLER_CONTEXT_LIST_ENTRY * +CreateNewPrmHandlerListEntry ( + VOID + ) +{ + PRM_HANDLER_CONTEXT_LIST_ENTRY*PrmHandlerContextListEntry; + + PrmHandlerContextListEntry = AllocateZeroPool (sizeof (*PrmHandlerContextListEntry)); + if (PrmHandlerContextListEntry == NULL) { +return NULL; + } + PrmHandlerContextListEntry->Signature = PRM_HANDLER_CONTEXT_LIST_ENTRY_SIGNATURE; + + return PrmHandlerContextListEntry; +} + +/** + Creates a new PRM
[edk2-devel] [PATCH v1 27/41] PrmPkg: Enforce stricter types
From: Michael Kubacki Makes the following changes to enforce stricter types: 1. PrmPkg/PrmConfigDxe The function PrmConfigEndOfDxeNotification () is used as a notify function (of type EFI_EVENT_NOTIFY), however it has a return type of EFI_STATUS whereas the return type should actually be VOID. 2. PrmPkg/PrmLoaderDxe Updates the following types to be more accurate than were allowed in the VS compiler: * 3rd actual argument given to GetModuleContextBuffers () is explicitly marked as CONST PRM_MODULE_CONTEXT_BUFFERS ** * 3rd actual argument given to GetContextBuffer () is explicitly marked as CONST PRM_CONTEXT_BUFFER ** * PrmLoaderEndOfDxeNotification () return type is changed to VOID to align with the EFI_EVENT_NOTIFY type 3. PrmPkg/Application/PrmInfo Updates the following types to be more accurate than were allowed in the VS compiler: * SHELL_STATUS in ParseParameterList () is now EFI_STATUS * 3rd actual argument given to GetModuleContextBuffers () is explicitly marked as CONST PRM_MODULE_CONTEXT_BUFFERS ** * 3rd actual argument given to GetContextBuffer () is explicitly marked as CONST PRM_CONTEXT_BUFFER ** Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Application/PrmInfo/PrmInfo.c | 6 +++--- PrmPkg/PrmConfigDxe/PrmConfigDxe.c | 8 ++-- PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c | 10 +++--- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/PrmPkg/Application/PrmInfo/PrmInfo.c b/PrmPkg/Application/PrmInfo/PrmInfo.c index 431a6f206163..e479667ec7eb 100644 --- a/PrmPkg/Application/PrmInfo/PrmInfo.c +++ b/PrmPkg/Application/PrmInfo/PrmInfo.c @@ -221,7 +221,7 @@ GatherPrmHandlerInfo ( Status = GetModuleContextBuffers ( ByModuleGuid, CurrentModuleGuid, - &CurrentModuleContextBuffers + (CONST PRM_MODULE_CONTEXT_BUFFERS **) &CurrentModuleContextBuffers ); ASSERT (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND); if (!EFI_ERROR (Status) && CurrentModuleContextBuffers != NULL) { @@ -272,7 +272,7 @@ GatherPrmHandlerInfo ( Status = GetContextBuffer ( CurrentHandlerContext.Guid, CurrentModuleContextBuffers, - &CurrentContextBuffer + (CONST PRM_CONTEXT_BUFFER **) &CurrentContextBuffer ); if (!EFI_ERROR (Status)) { CurrentHandlerContext.StaticDataBuffer = CurrentContextBuffer->StaticDataBuffer; @@ -520,7 +520,7 @@ ParseParameterList ( ) { EFI_STATUSStatus; - SHELL_STATUS ReturnStatus; + EFI_STATUSReturnStatus; UINTN ArgumentCount; EFI_GUID HandlerGuid; BOOLEAN PrintHandlerInfo; diff --git a/PrmPkg/PrmConfigDxe/PrmConfigDxe.c b/PrmPkg/PrmConfigDxe/PrmConfigDxe.c index c547db3eca5e..f3223d63de0c 100644 --- a/PrmPkg/PrmConfigDxe/PrmConfigDxe.c +++ b/PrmPkg/PrmConfigDxe/PrmConfigDxe.c @@ -361,10 +361,8 @@ PrmConfigVirtualAddressChangeEvent ( @param[in] Context The pointer to the notification function's context, which is implementation-dependent. - @retval EFI_SUCCESS The function executed successfully - **/ -EFI_STATUS +VOID EFIAPI PrmConfigEndOfDxeNotification ( IN EFI_EVENT Event, @@ -446,8 +444,6 @@ PrmConfigEndOfDxeNotification ( gBS->FreePool (HandleBuffer); } gBS->CloseEvent(Event); - - return EFI_SUCCESS; } /** @@ -476,7 +472,7 @@ PrmConfigEntryPoint ( // Register a notification function to change memory attributes at end of DXE // Event = NULL; - Status = gBS->CreateEventEx( + Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_CALLBACK, PrmConfigEndOfDxeNotification, diff --git a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c index 407c48257432..aa7aab391e8c 100644 --- a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c +++ b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c @@ -151,7 +151,7 @@ ProcessPrmModules ( Status = GetModuleContextBuffers ( ByModuleGuid, &CurrentModuleInfoStruct->Identifier, - &CurrentModuleContextBuffers + (CONST PRM_MODULE_CONTEXT_BUFFERS **) &CurrentModuleContextBuffers ); ASSERT (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND); if (!EFI_ERROR (Status) && CurrentModuleContextBuffers != NULL) { @@ -177,7 +177,7 @@ ProcessPrmModules ( Status = GetContextBuffer ( &CurrentHandlerInfoStruct->Identifier, CurrentModuleContextBuffers, - &CurrentContextBuff
[edk2-devel] [PATCH v1 28/41] PrmPkg/Test/PrmPkgHostTest.dsc: Add initial file
From: Michael Kubacki Adds a new DSC file that will be used to build host-based unit tests in PrmPkg. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Test/PrmPkgHostTest.dsc | 17 + 1 file changed, 17 insertions(+) diff --git a/PrmPkg/Test/PrmPkgHostTest.dsc b/PrmPkg/Test/PrmPkgHostTest.dsc new file mode 100644 index ..41f3c32b8d19 --- /dev/null +++ b/PrmPkg/Test/PrmPkgHostTest.dsc @@ -0,0 +1,17 @@ +## @file +# PrmPkg DSC file used to build host-based unit tests. +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + PLATFORM_NAME = PrmPkgHostTest + PLATFORM_GUID = 5BCCFC54-2162-42FB-ABCA-5B8D0DC4013C + PLATFORM_VERSION= 0.1 + DSC_SPECIFICATION = 0x00010005 + OUTPUT_DIRECTORY= Build/$(PLATFORM_NAME)/HostTest + SUPPORTED_ARCHITECTURES = IA32|X64 + BUILD_TARGETS = NOOPT + SKUID_IDENTIFIER= DEFAULT -- 2.28.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87870): https://edk2.groups.io/g/devel/message/87870 Mute This Topic: https://groups.io/mt/89956025/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v1 29/41] PrmPkg/Test/UnitTest/Library: Add initial UEFI Boot Services test lib
From: Michael Kubacki Adds a host-based specific implementation of UefiBootServicesTableLib. This library implements relatively simple versions of the functionality in the actual boot services implementation and does not depend on dynamic linking to the boot services table. Most unit tests can install the dependencies their code under test depends on prior to invocation and uninstall those dependencies after the test to test code that directly depends on boot services. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibUnitTest.c | 119 ++ PrmPkg/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibUnitTestEventTimer.c | 180 +++ PrmPkg/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibUnitTestImage.c | 163 ++ PrmPkg/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibUnitTestMemory.c | 145 ++ PrmPkg/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibUnitTestMisc.c | 198 +++ PrmPkg/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibUnitTestProtocol.c | 1633 PrmPkg/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibUnitTestTpl.c | 43 + PrmPkg/PrmPkg.dsc |1 + PrmPkg/Test/PrmPkgHostTest.dsc | 11 + PrmPkg/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibTest.uni | 12 + PrmPkg/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibUnitTest.h | 1046 + PrmPkg/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibUnitTest.inf | 46 + PrmPkg/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibUnitTestProtocol.h | 123 ++ 13 files changed, 3720 insertions(+) diff --git a/PrmPkg/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibUnitTest.c b/PrmPkg/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibUnitTest.c new file mode 100644 index ..d41cba3fea0e --- /dev/null +++ b/PrmPkg/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibUnitTest.c @@ -0,0 +1,119 @@ +/** @file + This library supports a Boot Services table library implementation that allows code dependent + upon UefiBootServicesTableLib to operate in an isolated execution environment such as within + the context of a host-based unit test framework. + + The unit test should initialize the Boot Services database with any required elements + (e.g. protocols, events, handles, etc.) prior to the services being invoked by code under test. + + It is strongly recommended to clean any global databases (e.g. protocol, event, handles, etc.) after + every unit test so the tests execute in a predictable manner from a clean state. + + Copyright (c) Microsoft Corporation + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "UefiBootServicesTableLibUnitTest.h" + +EFI_HANDLE gImageHandle = NULL; +EFI_SYSTEM_TABLE *gST = NULL; + +STATIC EFI_BOOT_SERVICES mBootServices = { + { +EFI_BOOT_SERVICES_SIGNATURE, // Signature +EFI_BOOT_SERVICES_REVISION, // Revision +sizeof (EFI_BOOT_SERVICES), // HeaderSize +0, // CRC32 +0 // Reserved + }, + (EFI_RAISE_TPL) UnitTestRaiseTpl, // RaiseTPL + (EFI_RESTORE_TPL) UnitTestRestoreTpl, // RestoreTPL + (EFI_ALLOCATE_PAGES) UnitTestAllocatePages, // AllocatePages + (EFI_FREE_PAGES) UnitTestFreePages, // FreePages + (EFI_GET_MEMORY_MAP) UnitTestGetMemoryMap, // GetMemoryMap + (EFI_ALLOCATE_POOL) UnitTestAllocatePool, // AllocatePool + (EFI_FREE_POOL) UnitTestFreePool, // FreePool + (EFI_CREATE_EVENT)
[edk2-devel] [PATCH v1 30/41] PrmPkg/Library/DxePrmContextBufferLib: Add host-based unit tests
From: Michael Kubacki Adds host-based unit tests for DxePrmContextBufferLib. This tests each function in DxePrmContextBufferLib. Any changes to DxePrmContextBufferLib moving forward must pass the unit tests. The unit tests should be updated as needed if the library API changes. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Library/DxePrmContextBufferLib/UnitTest/DxePrmContextBufferLibUnitTest.c | 649 PrmPkg/Library/DxePrmContextBufferLib/UnitTest/DxePrmContextBufferLibUnitTestHost.inf | 46 ++ PrmPkg/Test/PrmPkgHostTest.dsc | 6 + 3 files changed, 701 insertions(+) diff --git a/PrmPkg/Library/DxePrmContextBufferLib/UnitTest/DxePrmContextBufferLibUnitTest.c b/PrmPkg/Library/DxePrmContextBufferLib/UnitTest/DxePrmContextBufferLibUnitTest.c new file mode 100644 index ..07e247305880 --- /dev/null +++ b/PrmPkg/Library/DxePrmContextBufferLib/UnitTest/DxePrmContextBufferLibUnitTest.c @@ -0,0 +1,649 @@ +/** @file + + Unit tests for the PRM Context Buffer Library. + + Copyright (c) Microsoft Corporation + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define UNIT_TEST_NAME "PRM Context Buffer Library Unit Test" +#define UNIT_TEST_VERSION "0.1" + +///=== TEST DATA == + +EFI_HANDLE mTestProtocolHandle; + +//*--* +//* Context Structures * +//*--* +typedef struct { + PRM_MODULE_CONTEXT_BUFFERS *InstallationStructure; + EFI_HANDLE Handle; + PRM_GUID_SEARCH_TYPEGuidSearchType; + EFI_GUID*Guid; + EFI_GUID*ExpectedModuleGuid; + EFI_STATUS ExpectedStatus; +} PRM_CONTEXT_BUFFERS_TEST_CONTEXT; + +typedef struct { + EFI_GUID*HandlerGuid; + PRM_MODULE_CONTEXT_BUFFERS *ContextBuffers; + PRM_CONTEXT_BUFFER *ExpectedContextBuffer; + EFI_STATUS ExpectedStatus; +} PRM_CONTEXT_BUFFER_TEST_CONTEXT; + +//*--* +//* Test GUIDs * +//*--* + +// {52960b90-2f3a-4917-b91a-ed5f599a8809} +#define HANDLER_TEST_GUID_1 {0x52960b90, 0x2f3a, 0x4917, { 0xb9, 0x1a, 0xed, 0x5f, 0x59, 0x9a, 0x88, 0x09 }} +EFI_GUID mHandlerTestGuid1 = HANDLER_TEST_GUID_1; + +// {9316a80d-06dc-417b-b21d-6b3c2ae4ed6f} +#define HANDLER_TEST_GUID_2 {0x9316a80d, 0x06dc, 0x417b, { 0xb2, 0x1d, 0x6b, 0x3c, 0x2a, 0xe4, 0xed, 0x6f }} +EFI_GUID mHandlerTestGuid2 = HANDLER_TEST_GUID_2; + +// {d32ac8ba-6cc6-456f-9ed9-9233fa310434} +#define HANDLER_TEST_GUID_3 {0xd32ac8ba, 0x6cc6, 0x456f, { 0x9e, 0xd9, 0x92, 0x33, 0xfa, 0x31, 0x04, 0x34 }} +EFI_GUID mHandlerTestGuid3 = HANDLER_TEST_GUID_3; + +// {faadaa95-070b-4a34-a919-18305dc07370} +#define MODULE_TEST_GUID_1 {0xfaadaa95, 0x070b, 0x4a34, { 0xa9, 0x19, 0x18, 0x30, 0x5d, 0xc0, 0x73, 0x70 }} +EFI_GUID mModuleTestGuid1 = MODULE_TEST_GUID_1; + +// {0ea24584-731c-4863-9100-75780af509a7} +#define MODULE_TEST_GUID_2 {0x0ea24584, 0x731c, 0x4863, { 0x91, 0x00, 0x75, 0x78, 0x0a, 0xf5, 0x09, 0xa7 }} +EFI_GUID mModuleTestGuid2 = MODULE_TEST_GUID_2; + +// {f456b7a1-82a6-4427-8486-87e3a602df43} +#define MODULE_TEST_GUID_3 {0xf456b7a1, 0x82a6, 0x4427, { 0x84, 0x86, 0x87, 0xe3, 0xa6, 0x02, 0xdf, 0x43 }} +EFI_GUID mModuleTestGuid3 = MODULE_TEST_GUID_3; + +// {4a941a9c-9dcf-471b-94b5-d9e2d8c64a1b} +#define NEGATIVE_TEST_GUID {0x4a941a9c, 0x9dcf, 0x471b, {0x94, 0xb5, 0xd9, 0xe2, 0xd8, 0xc6, 0x4a, 0x1b }} +EFI_GUID mNegativeTestGuid = NEGATIVE_TEST_GUID; + +//*--* +//* PRM Static Test Structures * +//*--* + +PRM_DATA_BUFFER mTestStaticDataBuffer1 = { + { +PRM_DATA_BUFFER_HEADER_SIGNATURE, +sizeof (PRM_DATA_BUFFER) + } + // No data in the buffer (only a header) +}; + +PRM_CONTEXT_BUFFER mTestPrmContextBuffer1 = { + PRM_CONTEXT_BUFFER_SIGNATURE, // Signature + PRM_CONTEXT_BUFFER_INTERFACE_VERSION, // Version + 0,// Reserved +
[edk2-devel] [PATCH v1 31/41] PrmPkg/DxePrmModuleDiscoveryLib: Add initial host-based unit tests
From: Michael Kubacki Adds host-based unit tests for DxePrmModuleDiscoveryLib. This is an initial set of support, more tests should be added in the future. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Library/DxePrmModuleDiscoveryLib/DxePrmModuleDiscoveryLib.c | 1 - PrmPkg/Library/DxePrmModuleDiscoveryLib/UnitTest/DxePrmModuleDiscoveryLibUnitTest.c | 209 PrmPkg/Library/DxePrmModuleDiscoveryLib/PrmModuleDiscovery.h | 12 ++ PrmPkg/Library/DxePrmModuleDiscoveryLib/UnitTest/DxePrmModuleDiscoveryLibUnitTestHost.inf | 39 PrmPkg/Test/PrmPkgHostTest.dsc | 5 + 5 files changed, 265 insertions(+), 1 deletion(-) diff --git a/PrmPkg/Library/DxePrmModuleDiscoveryLib/DxePrmModuleDiscoveryLib.c b/PrmPkg/Library/DxePrmModuleDiscoveryLib/DxePrmModuleDiscoveryLib.c index 6977799aa8f3..0dd6a76be4d7 100644 --- a/PrmPkg/Library/DxePrmModuleDiscoveryLib/DxePrmModuleDiscoveryLib.c +++ b/PrmPkg/Library/DxePrmModuleDiscoveryLib/DxePrmModuleDiscoveryLib.c @@ -87,7 +87,6 @@ GetNextPrmModuleEntry ( otherwise, NULL is returned. **/ -STATIC PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY * CreateNewPrmModuleImageContextListEntry ( VOID diff --git a/PrmPkg/Library/DxePrmModuleDiscoveryLib/UnitTest/DxePrmModuleDiscoveryLibUnitTest.c b/PrmPkg/Library/DxePrmModuleDiscoveryLib/UnitTest/DxePrmModuleDiscoveryLibUnitTest.c new file mode 100644 index ..ef8abe397cd4 --- /dev/null +++ b/PrmPkg/Library/DxePrmModuleDiscoveryLib/UnitTest/DxePrmModuleDiscoveryLibUnitTest.c @@ -0,0 +1,209 @@ +/** @file + + Unit tests for the PRM Module Discovery Library. + + Copyright (c) Microsoft Corporation + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "../PrmModuleDiscovery.h" + +#define UNIT_TEST_NAME "PRM Module Discovery Library Unit Test" +#define UNIT_TEST_VERSION "0.1" + +///=== TEST CASES = + +///= CREATE NEW PRM MODULE IMAGE CONTEXT LIST ENTRY TESTS SUITE == + +/** + Verifies that the buffer returned can be deallocated. + + @param[in] Context [Optional] An optional context parameter. + Not used in this unit test. + + @retval UNIT_TEST_PASSED Unit test case prerequisites are met. + @retval UNIT_TEST_ERROR_PREREQUISITE_NOT_MET Test case should be skipped.. + +**/ +UNIT_TEST_STATUS +EFIAPI +PrmModuleImageContextListEntryShouldDeallocate ( + IN UNIT_TEST_CONTEXTContext + ) +{ + PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *ListEntry; + + ListEntry = CreateNewPrmModuleImageContextListEntry (); + + UT_ASSERT_NOT_NULL (ListEntry); + if (ListEntry != NULL) { +FreePool (ListEntry); + } + + return UNIT_TEST_PASSED; +} + +/** + Verifies that the list entry signature is set to the appropriate value. + + @param[in] Context [Optional] An optional context parameter. + Not used in this unit test. + + @retval UNIT_TEST_PASSED Unit test case prerequisites are met. + @retval UNIT_TEST_ERROR_PREREQUISITE_NOT_MET Test case should be skipped.. + +**/ +UNIT_TEST_STATUS +EFIAPI +PrmModuleImageContextListEntrySignatureShouldBeValid ( + IN UNIT_TEST_CONTEXTContext + ) +{ + PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *ListEntry; + + ListEntry = CreateNewPrmModuleImageContextListEntry (); + + UT_ASSERT_TRUE (ListEntry->Signature == PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY_SIGNATURE); + + if (ListEntry != NULL) { +FreePool (ListEntry); + } + + return UNIT_TEST_PASSED; +} + +/** + Verifies that the Context buffer in the list entry is initialized to zero. + + @param[in] Context [Optional] An optional context parameter. + Not used in this unit test. + + @retval UNIT_TEST_PASSED Unit test case prerequisites are met. + @retval UNIT_TEST_ERROR_PREREQUISITE_NOT_MET Test case should be skipped.. + +**/ +UNIT_TEST_STATUS +EFIAPI +PrmModuleImageContextListEntryImageContextShouldBeZeroed ( + IN UNIT_TEST_CONTEXTContext + ) +{ + PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *ListEntry; + PRM_MODULE_IMAGE_CONTEXT ImageContext; + + ListEntry = CreateNewPrmModuleImageContextListEntry (); + + ZeroMem (&ImageContext, sizeof (ImageContext)); + UT_ASSERT_MEM_EQUAL (&ListEntry->Context, &ImageContext, sizeof (ImageContext)); + + if (ListEntry
[edk2-devel] [PATCH v1 32/41] PrmPkg: Add PlatformGuid
From: Michael Kubacki Adds a "platform GUID" field to the PRM ACPI table. This field is used by a platform to uniquely identify itself such that it can be targeted by runtime PRM module updates for that platform. Platforms using PRM are currently required to set a unique value for gPrmPkgTokenSpaceGuid.PcdPrmPlatformGuid in their platform DSC. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c | 17 + PrmPkg/PrmLoaderDxe/PrmAcpiTable.h | 3 +++ PrmPkg/PrmLoaderDxe/PrmLoaderDxe.inf | 2 ++ PrmPkg/PrmPkg.dec| 10 ++ PrmPkg/Readme.md | 12 5 files changed, 44 insertions(+) diff --git a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c index aa7aab391e8c..f78c682a654b 100644 --- a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c +++ b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c @@ -11,6 +11,7 @@ #include "PrmAcpiTable.h" +#include #include #include #include @@ -52,6 +53,7 @@ ProcessPrmModules ( OUT PRM_ACPI_DESCRIPTION_TABLE **PrmAcpiDescriptionTable ) { + EFI_GUID*PlatformGuid; EFI_IMAGE_EXPORT_DIRECTORY *CurrentImageExportDirectory; PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT *CurrentExportDescriptorStruct; PRM_ACPI_DESCRIPTION_TABLE *PrmAcpiTable; @@ -79,6 +81,20 @@ ProcessPrmModules ( } *PrmAcpiDescriptionTable = NULL; + PlatformGuid = (EFI_GUID *) PcdGetPtr (PcdPrmPlatformGuid); + // + // The platform should set PcdPrmPlatformGuid to a non-zero value + // + if (CompareGuid (PlatformGuid, &gZeroGuid)) { +DEBUG (( + DEBUG_ERROR, + " %a %a: PcdPrmPlatformGuid must be set to a unique value in the platform DSC file.\n", + _DBGMSGID_, + __FUNCTION__ + )); +ASSERT (!CompareGuid (PlatformGuid, &gZeroGuid)); + } + DEBUG ((DEBUG_INFO, " %a %a: %d total PRM modules to process.\n", _DBGMSGID_, __FUNCTION__, mPrmModuleCount)); DEBUG ((DEBUG_INFO, " %a %a: %d total PRM handlers to process.\n", _DBGMSGID_, __FUNCTION__, mPrmHandlerCount)); @@ -102,6 +118,7 @@ ProcessPrmModules ( PrmAcpiTable->Header.OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision); PrmAcpiTable->Header.CreatorId= PcdGet32 (PcdAcpiDefaultCreatorId); PrmAcpiTable->Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision); + CopyGuid (&PrmAcpiTable->PrmPlatformGuid, PlatformGuid); PrmAcpiTable->PrmModuleInfoOffset = OFFSET_OF (PRM_ACPI_DESCRIPTION_TABLE, PrmModuleInfoStructure); PrmAcpiTable->PrmModuleInfoCount = (UINT32) mPrmModuleCount; diff --git a/PrmPkg/PrmLoaderDxe/PrmAcpiTable.h b/PrmPkg/PrmLoaderDxe/PrmAcpiTable.h index ec3be529d119..6f9ba8f77724 100644 --- a/PrmPkg/PrmLoaderDxe/PrmAcpiTable.h +++ b/PrmPkg/PrmLoaderDxe/PrmAcpiTable.h @@ -56,6 +56,9 @@ typedef struct { typedef struct { EFI_ACPI_DESCRIPTION_HEADER Header; ///< Standard ACPI description header + GUIDPrmPlatformGuid;///< A GUID that uniquely identifies this platform. + ///< Used to check for compatibility in PRM module + ///< runtime updates. UINT32 PrmModuleInfoOffset;///< Offset in bytes from the beginning of this ///< structure to the PRM Module Info array UINT32 PrmModuleInfoCount; ///< Number of entries in the PRM Module Info array diff --git a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.inf b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.inf index 554d49685e2a..7efefdae960f 100644 --- a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.inf +++ b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.inf @@ -31,6 +31,7 @@ [Packages] [Guids] gEfiEndOfDxeEventGroupGuid + gZeroGuid [LibraryClasses] BaseLib @@ -51,6 +52,7 @@ [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision ## CONSUMES + gPrmPkgTokenSpaceGuid.PcdPrmPlatformGuid ## CONSUMES [Protocols] gEfiAcpiTableProtocolGuid diff --git a/PrmPkg/PrmPkg.dec b/PrmPkg/PrmPkg.dec index 94888d1c70a4..6753ac62 100644 --- a/PrmPkg/PrmPkg.dec +++ b/PrmPkg/PrmPkg.dec @@ -65,3 +65,13 @@ [PcdsFixedAtBuild] # report PRM handler execution time in the application. If such a TimerLib # instance is not available, set this PCD to FALSE in the package DSC file. gPrmPkgTokenSpaceGuid.PcdPrmInfoPrintHandlerExecutionTime|TRUE|BOOLEAN|0x0003 + + ## PRM Platform
[edk2-devel] [PATCH v1 33/41] PrmPkg: Update PRM OpRegion
From: Liu Yun Y 1. Enable new PRM OpRegion structure 2. Add PRM Handler Update Lock/Unlock support Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Liu Yun --- PrmPkg/PrmSsdtInstallDxe/Prm.asl | 131 +--- 1 file changed, 88 insertions(+), 43 deletions(-) diff --git a/PrmPkg/PrmSsdtInstallDxe/Prm.asl b/PrmPkg/PrmSsdtInstallDxe/Prm.asl index 0457d09e6954..20a6fef9be7b 100644 --- a/PrmPkg/PrmSsdtInstallDxe/Prm.asl +++ b/PrmPkg/PrmSsdtInstallDxe/Prm.asl @@ -1,7 +1,7 @@ /** @file The definition block in ACPI table for PRM Operation Region - Copyright (c) 2020, Intel Corporation. All rights reserved. + Copyright (c) 2020-2021, Intel Corporation. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -16,60 +16,105 @@ DefinitionBlock ( { Scope (\_SB) { -// -// PRM Bridge Device -// - -Device (PRMB) -{ -Name (_HID, "80860222") -Name (_CID, "80860222") -Name (_DDN, "PRM Bridge Device") -Name (_STA, 0xF) -OperationRegion (OPR1, 0x80, 0, 16) -Field (OPR1, DWordAcc, NoLock, Preserve) //Make it ByteAcc for parameter validation -{ -Var0, 128 -} -Method (SETV, 1, Serialized) -{ -CopyObject (Arg0, \_SB.PRMB.Var0) -} -} - // // PRM Test Device // - Device (PRMT) { Name (_HID, "80860223") Name (_CID, "80860223") Name (_DDN, "PRM Test Device") -Name (_STA, 0xF) -Name (BUF1, Buffer(16) + +// PrmSamplePrintModule handler GUIDs +Name (BUF1, ToUUID("d5f2ad5f-a347-4d3e-87bc-c2ce63029cc8")) +Name (BUF2, ToUUID("a9e7adc3-8cd0-429a-8915-10946ebde318")) +Name (BUFN, ToUUID("b688c214-4081-4eeb-8d26-1eb5a3bcf11a")) + +//PRM operation region format +OperationRegion (PRMR, PlatformRtMechanism, 0, 1) +Field (PRMR, BufferAcc, NoLock, Preserve) //Make it ByteAcc for parameter validation { -0x5F, 0xAD, 0xF2, 0xD5, 0x47, 0xA3, 0x3E, 0x4D, //Guid_0 -0x87, 0xBC, 0xC2, 0xCE, 0x63, 0x02, 0x9C, 0xC8, //Guid_1 -}) -Name (BUF2, Buffer(16) +PRMF, 8 +} + +/* +* Control method to invoke PRM OperationRegion handler +* Arg0 contains a buffer representing a _DSM GUID +*/ +Method (RUNS, 1) { -0xC3, 0xAD, 0xE7, 0xA9, 0xD0, 0x8C, 0x9A, 0x42, //Guid_0 -0x89, 0x15, 0x10, 0x94, 0x6E, 0xBD, 0xE3, 0x18, //Guid_1 -}) -Name (BUF3, Buffer(16) +/* Local0 is the PRM data buffer */ +Local0 = buffer (26){} + +/* Create byte fields over the buffer */ +CreateByteField (Local0, 0x0, PSTA) +CreateQWordField (Local0, 0x1, USTA) +CreateByteField (Local0, 0x9, CMD) +CreateField (Local0, 0x50, 0x80, GUID) + +/* Fill in the command and data fields of the data buffer */ +CMD = 0 // run command +GUID = Arg0 + +/* Invoke PRM OperationRegion Handler and store the result into Local0 */ +Local0 = (PRMF = Local0) + +/* Return status */ +Return (PSTA) +} + +/* +* Control method to lock a PRM transaction +* Arg0 contains a buffer representing a _DSM GUID +*/ +Method (LCKH, 1) { -0x14, 0xC2, 0x88, 0xB6, 0x81, 0x40, 0xEB, 0x4E, //Guid_0 -0x8D, 0x26, 0x1E, 0xB5, 0xA3, 0xBC, 0xF1, 0x1A, //Guid_1 -}) -Method (NTST) +/* Local0 is the PRM data buffer */ +Local0 = buffer (26){} + +/* Create byte fields over the buffer */ +CreateByteField (Local0, 0x0, STAT) +CreateByteField (Local0, 0x9, CMD) +CreateField (Local0, 0x50, 0x80, GUID) +CMD = 1 // Lock command +GUID = Arg0 +Local0 = (PRMF = Local0) + +/* Note STAT contains the return status */ +Return (STAT) +} + +/* +* Control method to unlock a PRM transaction +* Arg0 contains a buffer representing a _DSM GUID +*/ +Method (ULCK, 1) { -\_SB.PRMB.SETV (BUF1) +/* Local0 is the PRM data buffer */ +Local0 = buffer (26){} + +/* Create byte fields over the buffer */ +
[edk2-devel] [PATCH v1 34/41] Readme.md: Add iASL note and QEMU sample link
From: Michael Kubacki Adds a note that the build now depends on an ASL compiler supporting PlatformRtMechanism by default. The minimum iASL version supported is noted in addition to an alternative to remove the code that requires the new OperationRegion. Also, a link is provided to an example of how to integrate the package into a platform using QEMU/OvmfPkg as the sample platform and firmware. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Readme.md | 23 1 file changed, 23 insertions(+) diff --git a/PrmPkg/Readme.md b/PrmPkg/Readme.md index 40df8f00a0c8..f340eeb64258 100644 --- a/PrmPkg/Readme.md +++ b/PrmPkg/Readme.md @@ -13,6 +13,14 @@ to be leveraged by platform firmware with minimal overhead to integrate PRM func formal design and is not validated at product quality. The development of this feature is shared in the edk2-staging branch to simplify collaboration by allowing direct code contributions and early feedback throughout its development. +> By default, the build makes use of a new ACPI OperationRegion type specifically introduced for PRM called +`PlatformRtMechanism`. Support for this OperationRegion is planned for the next release of the ACPI specification. +However, support for `PlatformRtMechanism` is already included in the iASL Compiler/Disassembler for early prototyping +(i.e. this package). If you would like the default build to work and/or to use PRM handlers that are invoked +through ACPI, iASL compiler [20200528](https://acpica.org/node/181) or greater must be used. If you are only +interested in compiling the code and/or using direct call style PRM handlers, you can simply remove +`PrmSsdtInstallDxe` from `PrmPkg.dsc`. + ## How to Build PrmPkg As noted earlier, resources in `PrmPkg` are intended to be referenced by a platform firmware so it can adopt support for PRM. In that case, the platform firmware should add the `PrmConfigDxe` and `PrmLoaderDxe` drivers to its DSC and @@ -60,6 +68,21 @@ To build `PrmPkg` as a standalone package: > __*Note*__: Due to the way PRM modules are compiled with exports, **only building on Visual Studio compiler tool chains is currently supported**. +In the future, each new terminal session can start at step #4. Within a terminal session, start at step #8. + +> __*Note*__: \ +> This package has been used without modification in several environments including client, server, +> and virtual systems. +> +> A functional example of how to integrate this code into a platform is available here: +> https://github.com/makubacki/edk2/tree/sample_ovmfpkg_prmpkg_integration +> +> That build will load the drivers and PRM sample modules provided in this package in the open source emulator +> [QEMU](https://www.qemu.org/) by including it in the [`OvmfPkg`](https://github.com/tianocore/edk2/tree/master/OvmfPkg) build. +> +> You can add your own PRM modules into the build and check them with the `PrmInfo` UEFI application described +> later in this document and dump the PRMT table in the OS to check if your PRM module is represented as expected. + ### Build Flags As PRM is a new feature at a proof-of-concept (POC) level of maturity, there's some changes to the normal build available as build flags. By default, if no flags are specified, the build is done with the currently expected plan of -- 2.28.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87876): https://edk2.groups.io/g/devel/message/87876 Mute This Topic: https://groups.io/mt/89956043/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v1 35/41] PrmPkg: Replace PcdPrmPlatformGuid with EDKII_DSC_PLATFORM_GUID
From: Michael Kubacki Bugzilla request https://bugzilla.tianocore.org/show_bug.cgi?id=2969 was recently completed which causes the PLATFORM_GUID value from the DSC file to be placed into Autogen file .c & .h files. With this change, the PRM Platform GUID can be directly matched to the DSC PLATFORM_GUID value. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c | 12 +- PrmPkg/Include/PrmExportDescriptor.h | 2 ++ PrmPkg/PrmLoaderDxe/PrmLoaderDxe.inf | 1 - PrmPkg/PrmPkg.dec| 10 - PrmPkg/Readme.md | 23 +++- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c index f78c682a654b..e2779f5c1786 100644 --- a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c +++ b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c @@ -53,7 +53,6 @@ ProcessPrmModules ( OUT PRM_ACPI_DESCRIPTION_TABLE **PrmAcpiDescriptionTable ) { - EFI_GUID*PlatformGuid; EFI_IMAGE_EXPORT_DIRECTORY *CurrentImageExportDirectory; PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT *CurrentExportDescriptorStruct; PRM_ACPI_DESCRIPTION_TABLE *PrmAcpiTable; @@ -81,18 +80,17 @@ ProcessPrmModules ( } *PrmAcpiDescriptionTable = NULL; - PlatformGuid = (EFI_GUID *) PcdGetPtr (PcdPrmPlatformGuid); // - // The platform should set PcdPrmPlatformGuid to a non-zero value + // The platform DSC GUID must be set to a non-zero value // - if (CompareGuid (PlatformGuid, &gZeroGuid)) { + if (CompareGuid (&gEdkiiDscPlatformGuid, &gZeroGuid)) { DEBUG (( DEBUG_ERROR, - " %a %a: PcdPrmPlatformGuid must be set to a unique value in the platform DSC file.\n", + " %a %a: The Platform GUID in the DSC file must be set to a unique non-zero value.\n", _DBGMSGID_, __FUNCTION__ )); -ASSERT (!CompareGuid (PlatformGuid, &gZeroGuid)); +ASSERT (!CompareGuid (&gEdkiiDscPlatformGuid, &gZeroGuid)); } DEBUG ((DEBUG_INFO, " %a %a: %d total PRM modules to process.\n", _DBGMSGID_, __FUNCTION__, mPrmModuleCount)); @@ -118,7 +116,7 @@ ProcessPrmModules ( PrmAcpiTable->Header.OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision); PrmAcpiTable->Header.CreatorId= PcdGet32 (PcdAcpiDefaultCreatorId); PrmAcpiTable->Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision); - CopyGuid (&PrmAcpiTable->PrmPlatformGuid, PlatformGuid); + CopyGuid (&PrmAcpiTable->PrmPlatformGuid, &gEdkiiDscPlatformGuid); PrmAcpiTable->PrmModuleInfoOffset = OFFSET_OF (PRM_ACPI_DESCRIPTION_TABLE, PrmModuleInfoStructure); PrmAcpiTable->PrmModuleInfoCount = (UINT32) mPrmModuleCount; diff --git a/PrmPkg/Include/PrmExportDescriptor.h b/PrmPkg/Include/PrmExportDescriptor.h index fc313fd1acc7..76b67a05458a 100644 --- a/PrmPkg/Include/PrmExportDescriptor.h +++ b/PrmPkg/Include/PrmExportDescriptor.h @@ -30,6 +30,7 @@ typedef struct { UINT64Signature; UINT16Revision; UINT16NumberPrmHandlers; + GUID PlatformGuid; GUID ModuleGuid; } PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER; @@ -98,6 +99,7 @@ typedef struct { PRM_MODULE_EXPORT_DESCRIPTOR_SIGNATURE, \ PRM_MODULE_EXPORT_REVISION, \ VA_ARG_COUNT(__VA_ARGS__), \ + EDKII_DSC_PLATFORM_GUID, \ EFI_CALLER_ID_GUID \ }, \ { __VA_ARGS__ } \ diff --git a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.inf b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.inf index 7efefdae960f..26e7cc169897 100644 --- a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.inf +++ b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.inf @@ -52,7 +52,6 @@ [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision ## CONSUMES - gPrmPkgTokenSpaceGuid.PcdPrmPlatformGuid ## CONSUMES [Protocols] gEfiAcpiTableProtocolGuid diff --git a/PrmPkg/PrmPkg.dec b/PrmPkg/PrmPkg.dec index 6753ac62..94888d1c70a4 100644 --- a/PrmPkg/PrmPk
[edk2-devel] [PATCH v1 36/41] PrmPkg/Samples: Remove PrmSampleMemoryAllocationModule
From: Michael Kubacki Removes PrmSampleMemoryAllocationModule since the module depends upon the deprecated concept of OS services. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Samples/PrmSampleMemoryAllocationModule/PrmSampleMemoryAllocationModule.c | 115 PrmPkg/PrmPkg.dsc | 8 -- PrmPkg/Samples/PrmSampleMemoryAllocationModule/PrmSampleMemoryAllocationModule.inf | 43 3 files changed, 166 deletions(-) diff --git a/PrmPkg/Samples/PrmSampleMemoryAllocationModule/PrmSampleMemoryAllocationModule.c b/PrmPkg/Samples/PrmSampleMemoryAllocationModule/PrmSampleMemoryAllocationModule.c deleted file mode 100644 index f1245664ab9c.. --- a/PrmPkg/Samples/PrmSampleMemoryAllocationModule/PrmSampleMemoryAllocationModule.c +++ /dev/null @@ -1,115 +0,0 @@ -/** @file - - A sample PRM Module implementation. This PRM Module provides 3 PRM handlers that simply take a DEBUG print - function from the OS and invoke it with a debug message internal the PRM handler. - - Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include - -#include -#include -#include -#include - -// -// PRM Handler GUIDs -// - -// {149a5cb3-6a9c-403f-940a-156abf63938a} -#define PRM_HANDLER_1_GUID {0x149a5cb3, 0x6a9c, 0x403f, {0x94, 0x0a, 0x15, 0x6a, 0xbf, 0x63, 0x93, 0x8a}} - -// Note: If the signature size is modified, the PRM Handler test code in this module needs to be updated. -#define MEMORY_ALLOCATION_TEST_DATA_SIGNATURE SIGNATURE_32('T','E','S','T') -#define MEMORY_ALLOCATION_TEST_DATA_SIZE sizeof(UINT32) -#define MEMORY_ALLOCATION_TEST_DATA_BUFFER_SIZE 256 - -/** - A sample Platform Runtime Mechanism (PRM) handler. - - This sample handler currently uses the OS_SERVICES to write a debug message - indicating this is PRM handler 1. - - @param[in] ParameterBufferA pointer to the PRM handler parameter buffer - @param[in] ContextBuffer A pointer to the PRM handler context buffer - - @retval EFI_STATUS The PRM handler executed successfully. - @retval Others An error occurred in the PRM handler. - -**/ -EFI_STATUS -PRM_EXPORT_API -EFIAPI -PrmHandler1 ( - IN VOID *ParameterBuffer, - IN PRM_CONTEXT_BUFFER *ContextBUffer - ) -{ - EFI_STATUS Status; - UINTN Index; - VOID*NonPagedPool; - CHAR8 DebugMessage[256]; - - if (OsServices == NULL || OsServices->DebugPrint == NULL || OsServices->AllocateMemory == NULL) { -return EFI_INVALID_PARAMETER; - } - - OsServices->DebugPrint ("Memory Allocation PrmHandler1 entry.\n"); - OsServices->DebugPrint (" Requesting allocation of a 256 byte non-paged pool...\n"); - - NonPagedPool = NULL; - NonPagedPool = OsServices->AllocateMemory (MEMORY_ALLOCATION_TEST_DATA_BUFFER_SIZE, FALSE); - if (NonPagedPool == NULL) { -OsServices->DebugPrint (" NULL was returned from AllocateMemory()...\n"); -return EFI_OUT_OF_RESOURCES; - } - - AsciiSPrint ( -&DebugMessage[0], -ARRAY_SIZE (DebugMessage), -" Buffer address returned from AllocateMemory() = 0x%016lx.\n", -(UINTN) NonPagedPool -); - OsServices->DebugPrint (&DebugMessage[0]); - - // Write the test data - OsServices->DebugPrint (" Beginning memory buffer write and read back test...\n"); - SetMem32 (NonPagedPool, MEMORY_ALLOCATION_TEST_DATA_BUFFER_SIZE, MEMORY_ALLOCATION_TEST_DATA_SIGNATURE); - - // Read back and verify the test data is valid - for (Index = 0, Status = EFI_SUCCESS; Index < (MEMORY_ALLOCATION_TEST_DATA_BUFFER_SIZE / MEMORY_ALLOCATION_TEST_DATA_SIZE); Index++) { -if (((UINT32 *) NonPagedPool)[Index] != MEMORY_ALLOCATION_TEST_DATA_SIGNATURE) { - Status = EFI_DEVICE_ERROR; - break; -} - } - if (EFI_ERROR (Status)) { -OsServices->DebugPrint ("Memory write & read test failed.\n"); - } else { -OsServices->DebugPrint ("Memory write & read test passed.\n"); - } - - OsServices->DebugPrint ("Memory Allocation PrmHandler1 exit.\n"); - - return EFI_SUCCESS; -} - -// -// Register the PRM export information for this PRM Module -// -PRM_MODULE_EXPORT ( - PRM_HANDLER_EXPORT_ENTRY (PRM_HANDLER_1_GUID, PrmHandler1) - ); - -EFI_STATUS -EFIAPI -PrmSampleMemoryAllocationModuleInit ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE*SystemTable - ) -{ - return EFI_SUCCESS; -} diff --git a/PrmPkg/PrmPkg.dsc b/PrmPkg/PrmPkg.dsc index 911158302404..c6e5a151eeca 100644 --- a/PrmPkg/PrmPkg.dsc +++ b/PrmPkg/PrmPkg.dsc @@ -141,14 +141,6 @@ [Components] # $(PLATFORM_PACKAGE)/Application/PrmInfo/PrmInfo.inf - # - # The Sampl
[edk2-devel] [PATCH v1 37/41] PrmPkg/Samples: Remove PrmSamplePrintModule
From: Michael Kubacki This sample module is removed since it directly depends on OS services which are no longer supported as of the current PRM design. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Samples/PrmSamplePrintModule/PrmSamplePrintModule.c | 157 PrmPkg/PrmPkg.dsc| 1 - PrmPkg/PrmSsdtInstallDxe/Prm.asl | 5 - PrmPkg/Samples/PrmSamplePrintModule/PrmSamplePrintModule.inf | 41 - PrmPkg/Samples/Readme.md | 73 + 5 files changed, 1 insertion(+), 276 deletions(-) diff --git a/PrmPkg/Samples/PrmSamplePrintModule/PrmSamplePrintModule.c b/PrmPkg/Samples/PrmSamplePrintModule/PrmSamplePrintModule.c deleted file mode 100644 index 85e8eb28a231.. --- a/PrmPkg/Samples/PrmSamplePrintModule/PrmSamplePrintModule.c +++ /dev/null @@ -1,157 +0,0 @@ -/** @file - - A sample PRM Module implementation. This PRM Module provides 3 PRM handlers that simply take a DEBUG print - function from the OS and invoke it with a debug message internal the PRM handler. - - Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include - -#include -#include - -// -// PRM Handler GUIDs -// - -// {d5f2ad5f-a347-4d3e-87bc-c2ce63029cc8} -#define PRM_HANDLER_1_GUID {0xd5f2ad5f, 0xa347, 0x4d3e, {0x87, 0xbc, 0xc2, 0xce, 0x63, 0x02, 0x9c, 0xc8}} - -// {a9e7adc3-8cd0-429a-8915-10946ebde318} -#define PRM_HANDLER_2_GUID {0xa9e7adc3, 0x8cd0, 0x429a, {0x89, 0x15, 0x10, 0x94, 0x6e, 0xbd, 0xe3, 0x18}} - -// {b688c214-4081-4eeb-8d26-1eb5a3bcf11a} -#define PRM_HANDLER_N_GUID {0xb688c214, 0x4081, 0x4eeb, {0x8d, 0x26, 0x1e, 0xb5, 0xa3, 0xbc, 0xf1, 0x1a}} - -/** - A sample Platform Runtime Mechanism (PRM) handler. - - This sample handler currently uses the OS_SERVICES to write a debug message - indicating this is PRM handler 1. - - @param[in] ParameterBuffer A pointer to the PRM handler parameter buffer - @param[in] ContextBUffer A pointer to the PRM handler context buffer - - @retval EFI_STATUS The PRM handler executed successfully. - @retval Others An error occurred in the PRM handler. - -**/ -EFI_STATUS -PRM_EXPORT_API -EFIAPI -PrmHandler1 ( - IN VOID *ParameterBuffer, - IN PRM_CONTEXT_BUFFER *ContextBUffer - ) -{ - PRM_OS_SERVICE_DEBUG_PRINT OsServiceDebugPrint; - - if (ParameterBuffer == NULL) { -return EFI_INVALID_PARAMETER; - } - - // In the POC, the OS debug print service is assumed to be at the beginning of ParameterBuffer - OsServiceDebugPrint = *((PRM_OS_SERVICE_DEBUG_PRINT *) ParameterBuffer); - if (OsServiceDebugPrint == NULL) { -return EFI_INVALID_PARAMETER; - } - OsServiceDebugPrint ("PRM1 handler sample message!\n"); - - return EFI_SUCCESS; -} - -/** - A sample Platform Runtime Mechanism (PRM) handler. - - This sample handler currently uses the OS_SERVICES to write a debug message - indicating this is PRM handler 2. - - @param[in] ParameterBufferA pointer to the PRM handler parameter buffer - @param[in] ContextBUffer A pointer to the PRM handler context buffer - - @retval EFI_STATUS The PRM handler executed successfully. - @retval Others An error occurred in the PRM handler. - -**/ -EFI_STATUS -PRM_EXPORT_API -EFIAPI -PrmHandler2 ( - IN VOID *ParameterBuffer, - IN PRM_CONTEXT_BUFFER *ContextBUffer - ) -{ - PRM_OS_SERVICE_DEBUG_PRINT OsServiceDebugPrint; - - if (ParameterBuffer == NULL) { -return EFI_INVALID_PARAMETER; - } - - // In the POC, the OS debug print service is assumed to be at the beginning of ParameterBuffer - OsServiceDebugPrint = *((PRM_OS_SERVICE_DEBUG_PRINT *) ParameterBuffer); - if (OsServiceDebugPrint == NULL) { -return EFI_INVALID_PARAMETER; - } - OsServiceDebugPrint ("PRM2 handler sample message!\n"); - - return EFI_SUCCESS; -} - -/** - A sample Platform Runtime Mechanism (PRM) handler. - - This sample handler currently uses the OS_SERVICES to write a debug message - indicating this is PRM handler N. - - @param[in] ParameterBufferA pointer to the PRM handler parameter buffer - @param[in] ContextBUffer A pointer to the PRM handler context buffer - - @retval EFI_STATUS The PRM handler executed successfully. - @retval Others An error occurred in the PRM handler. - -**/ -EFI_STATUS -PRM_EXPORT_API -EFIAPI -PrmHandlerN ( - IN VOID *ParameterBuffer, - IN PRM_CONTEXT_BUFFER *ContextBUffer - ) -{ - PRM_OS_SERVICE_DEBUG_PRINT OsServiceDebugPrint; - - if (ParameterBuffer == NULL) { -return EFI_INVALID_PARAMETER; - } - - // In the POC, the OS debug print s
[edk2-devel] [PATCH v1 38/41] PrmPkg: Remove the concept of OS services
From: Michael Kubacki OS services are no longer supported as of the current PRM design. 1. Removes OS services from PrmSampleHardwareAccessModule 2. Removes the PrmOsServices.h file Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.c | 328 +--- PrmPkg/Include/PrmModule.h | 1 - PrmPkg/Include/PrmOsServices.h | 45 --- PrmPkg/PrmPkg.dsc | 5 +- PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.inf | 1 - PrmPkg/Samples/Readme.md | 62 6 files changed, 8 insertions(+), 434 deletions(-) diff --git a/PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.c b/PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.c index 35da1fcf5f17..14d1e56ab88a 100644 --- a/PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.c +++ b/PrmPkg/Samples/PrmSampleHardwareAccessModule/PrmSampleHardwareAccessModule.c @@ -12,7 +12,6 @@ #include #include -#include #include #include @@ -27,21 +26,12 @@ // {2120cd3c-848b-4d8f-abbb-4b74ce64ac89} #define MSR_ACCESS_MICROCODE_SIGNATURE_PRM_HANDLER_GUID {0x2120cd3c, 0x848b, 0x4d8f, {0xab, 0xbb, 0x4b, 0x74, 0xce, 0x64, 0xac, 0x89}} -// {5d28b4e7-3867-4aee-aa09-51fc282c3b22} -#define MSR_PRINT_MICROCODE_SIGNATURE_PRM_HANDLER_GUID {0x5d28b4e7, 0x3867, 0x4aee, {0xaa, 0x09, 0x51, 0xfc, 0x28, 0x2c, 0x3b, 0x22}} - // {ea0935a7-506b-4159--48deeecb6f58} #define MSR_ACCESS_MTRR_DUMP_PRM_HANDLER_GUID {0xea0935a7, 0x506b, 0x4159, {0xbb, 0xbb, 0x48, 0xde, 0xee, 0xcb, 0x6f, 0x58}} -// {4b64b702-4d2b-4dfe-ac5a-0b4110a2ca47} -#define MSR_PRINT_MTRR_DUMP_PRM_HANDLER_GUID {0x4b64b702, 0x4d2b, 0x4dfe, {0xac, 0x5a, 0x0b, 0x41, 0x10, 0xa2, 0xca, 0x47}} - // {1bd1bda9-909a-4614-9699-25ec0c2783f7} #define MMIO_ACCESS_HPET_PRM_HANDLER_GUID {0x1bd1bda9, 0x909a, 0x4614, {0x96, 0x99, 0x25, 0xec, 0x0c, 0x27, 0x83, 0xf7}} -// {8a0efdde-78d0-45f0-aea0-c28245c7e1db} -#define MMIO_PRINT_HPET_PRM_HANDLER_GUID {0x8a0efdde, 0x78d0, 0x45f0, {0xae, 0xa0, 0xc2, 0x82, 0x45, 0xc7, 0xe1, 0xdb}} - // // BEGIN: MtrrLib internal library globals and function prototypes here for testing // @@ -133,27 +123,19 @@ MtrrLibApplyVariableMtrrs ( /** Accesses MTRR values including architectural and variable MTRRs. - If the optional OsServiceDebugPrint function pointer is provided that function is - used to print the MTRR settings. - - @param[in] OsServiceDebugPrint A pointer to an OS-provided debug print function. - **/ VOID EFIAPI AccessAllMtrrs ( - IN PRM_OS_SERVICE_DEBUG_PRINT OsServiceDebugPrint OPTIONAL + VOID ) { MTRR_SETTINGS LocalMtrrs; MTRR_SETTINGS *Mtrrs; - UINTN Index; UINTN RangeCount; UINT64 MtrrValidBitsMask; UINT64 MtrrValidAddressMask; UINT32 VariableMtrrCount; - BOOLEAN ContainVariableMtrr; - CHAR8 DebugMessage[256]; MTRR_MEMORY_RANGE Ranges[ MTRR_NUMBER_OF_FIXED_MTRR * sizeof (UINT64) + 2 * ARRAY_SIZE (Mtrrs->Variables.Mtrr) + 1 @@ -169,66 +151,6 @@ AccessAllMtrrs ( MtrrGetAllMtrrs (&LocalMtrrs); Mtrrs = &LocalMtrrs; - // - // Dump RAW MTRR contents - // - if (OsServiceDebugPrint != NULL) { -OsServiceDebugPrint (" MTRR Settings:\n"); -OsServiceDebugPrint (" =\n"); - -AsciiSPrint ( - &DebugMessage[0], - ARRAY_SIZE (DebugMessage), - " MTRR Default Type: %016lx\n", - Mtrrs->MtrrDefType - ); -OsServiceDebugPrint (&DebugMessage[0]); - } - - if (OsServiceDebugPrint != NULL) { -for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { -AsciiSPrint ( - &DebugMessage[0], - ARRAY_SIZE (DebugMessage), - " Fixed MTRR[%02d] : %016lx\n", - Index, - Mtrrs->Fixed.Mtrr[Index] - ); -OsServiceDebugPrint (&DebugMessage[0]); - } - -ContainVariableMtrr = FALSE; -for (Index = 0; Index < VariableMtrrCount; Index++) { - if ((Mtrrs->Variables.Mtrr[Index].Mask & BIT11) == 0) { -// -// If mask is not valid, then do not display range -// -continue; - } - ContainVariableMtrr = TRUE; - AsciiSPrint ( -&DebugMessage[0], -ARRAY_SIZE (DebugMessage), -" Variable MTRR[%02d]: Base=%016lx Mask=%016lx\n", -Index, -Mtrrs->Variables.Mtrr[Index].Bas
[edk2-devel] [PATCH v1 39/41] Readme.md: Add a link to PRM Specification
From: Michael Kubacki Adds a link to the PRM Specification now that it is available on uefi.org. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PrmPkg/Readme.md b/PrmPkg/Readme.md index 4aec5982af54..848f898ab6d3 100644 --- a/PrmPkg/Readme.md +++ b/PrmPkg/Readme.md @@ -5,6 +5,8 @@ code module that executes within the OS context. Moving this firmware to the OS and mitigates the negative system impact currently accompanied with SMM solutions. Futhermore, the PRM code is packaged into modules with well-defined entry points, each representing a specific PRM functionality. +For more details on PRM, refer to the [Platform Runtime Mechanism Specification on uefi.org](https://uefi.org/sites/default/files/resources/Platform%20Runtime%20Mechanism%20-%20with%20legal%20notice.pdf). + The `PrmPkg` maintained in this branch provides a single cohesive set of generic PRM functionality that is intended to be leveraged by platform firmware with minimal overhead to integrate PRM functionality in the firmware. -- 2.28.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87881): https://edk2.groups.io/g/devel/message/87881 Mute This Topic: https://groups.io/mt/89956066/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v1 40/41] PrmPkg: Changes for edk2 repo transition
From: Michael Kubacki Updates the Readme.md files to remove information that was specific to the package in edk2-staging and adds key definitions being added for PRM support in the ACPI Specification. Adds PrmPkg/PrmPkg.ci.yaml to support CI. Adds PrmPkg to .pytool/CISettings.py. Adds PrmPkg maintainers to Maintainers.txt. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- .azurepipelines/templates/pr-gate-build-job.yml | 2 +- .pytool/CISettings.py | 1 + Maintainers.txt | 8 ++ PrmPkg/PrmPkg.ci.yaml | 110 + PrmPkg/Readme.md| 129 PrmPkg/Samples/Readme.md| 16 +++ 6 files changed, 189 insertions(+), 77 deletions(-) diff --git a/.azurepipelines/templates/pr-gate-build-job.yml b/.azurepipelines/templates/pr-gate-build-job.yml index 244cffdbfaba..69e4c50afdbb 100644 --- a/.azurepipelines/templates/pr-gate-build-job.yml +++ b/.azurepipelines/templates/pr-gate-build-job.yml @@ -37,7 +37,7 @@ jobs: Build.Pkgs: 'NetworkPkg,RedfishPkg' Build.Targets: 'DEBUG,RELEASE,NO-TARGET' TARGET_OTHER: -Build.Pkgs: 'PcAtChipsetPkg,ShellPkg,StandaloneMmPkg' +Build.Pkgs: 'PcAtChipsetPkg,PrmPkg,ShellPkg,StandaloneMmPkg' Build.Targets: 'DEBUG,RELEASE,NO-TARGET' TARGET_FMP_FAT_TEST: Build.Pkgs: 'FmpDevicePkg,FatPkg,UnitTestFrameworkPkg,DynamicTablesPkg' diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py index ce330e2c73a3..cf9e0d77b19b 100644 --- a/.pytool/CISettings.py +++ b/.pytool/CISettings.py @@ -65,6 +65,7 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag "StandaloneMmPkg", "FatPkg", "CryptoPkg", +"PrmPkg", "UnitTestFrameworkPkg", "OvmfPkg", "RedfishPkg", diff --git a/Maintainers.txt b/Maintainers.txt index e32507dd6eb7..26662c9221ee 100644 --- a/Maintainers.txt +++ b/Maintainers.txt @@ -540,6 +540,14 @@ F: PcAtChipsetPkg/ W: https://github.com/tianocore/tianocore.github.io/wiki/PcAtChipsetPkg M: Ray Ni [niruiyu] +PrmPkg +F: PrmPkg/ +M: Michael Kubacki [makubacki] +M: Nate DeSimone [nate-desimone] + +PrmPkg: ACPI related modules +R: Ankit Sinha [ankit13s] + RedfishPkg: Redfish related modules F: RedfishPkg/ M: Abner Chang [changab] diff --git a/PrmPkg/PrmPkg.ci.yaml b/PrmPkg/PrmPkg.ci.yaml new file mode 100644 index ..babaf2214ec8 --- /dev/null +++ b/PrmPkg/PrmPkg.ci.yaml @@ -0,0 +1,110 @@ +## @file +# CI configuration for PrmPkg +# +# Copyright (c) Microsoft Corporation +# SPDX-License-Identifier: BSD-2-Clause-Patent +## +{ +## options defined .pytool/Plugin/LicenseCheck +"LicenseCheck": { +"IgnoreFiles": [] +}, + +"EccCheck": { +## Exception sample looks like below: +## "ExceptionList": [ +## "", "" +## ] +"ExceptionList": [ + "5001", "PRM_HANDLER_EXPORT", + "8006", "PRM_HANDLER_EXPORT" +], +## Both file path and directory path are accepted. +"IgnoreFiles": [ + "Library/DxePrmContextBufferLib/UnitTest", + "Library/DxePrmModuleDiscoveryLib/UnitTest", + "Samples", + "Test" +] +}, + +## options defined .pytool/Plugin/CompilerPlugin +"CompilerPlugin": { +"DscPath": "PrmPkg.dsc" +}, + +## options defined .pytool/Plugin/HostUnitTestCompilerPlugin +"HostUnitTestCompilerPlugin": { +"DscPath": "Test/PrmPkgHostTest.dsc" +}, + +## options defined .pytool/Plugin/CharEncodingCheck +"CharEncodingCheck": { +"IgnoreFiles": [] +}, + +## options defined .pytool/Plugin/DependencyCheck +"DependencyCheck": { +"AcceptableDependencies": [ +"MdeModulePkg/MdeModulePkg.dec", +"MdePkg/MdePkg.dec", +"PrmPkg/PrmPkg.dec", +"ShellPkg/ShellPkg.dec", +"UefiCpuPkg/UefiCpuPkg.dec" +], +# For host based unit tests +"AcceptableDependencies-HOST_APPLICATION":[ +"UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec" +], +# For UEFI shell based apps +"AcceptableDependencies-UEFI_APPLICATION":[], +"IgnoreInf": [] +}, + +## options defined .pytool/Plugin/DscCompleteCheck +"DscCompleteCheck": { +"IgnoreInf": [], +"DscPath": "PrmPkg.dsc" +}, + +## options defined .pytool/Plugin/HostUnitTestDscCompleteCheck +"HostUnitTestDscCompleteCheck": { +"IgnoreInf": [""], +"DscPath": "Test/PrmPkgHostTest.dsc" +}, + +## options defined .pytool/Plugin/GuidCheck +"GuidCheck": { +
Re: [edk2-devel] [PATCH V2 2/3] MdePkg/Base.h: Introduce various alignment-related macros
Considering all my branches are badly broken because of the Uncrustify changes, there have been many changes to the existing PE/COFF libraries in the mean time (and more external dependencies incoming with PMR), and even this non-invasive patch has been mostly ignored (thanks for the review, Ray!), can I now safely assume there is no (and frankly never was) any actual interest in the reworked PE/COFF library? Things are at a point where I cannot update all my changes to latest master on my own, and if nobody provides any active support, you may best mark all related BZs as WONTFIX to reflect the roadmap. Best regards, Marvin On 23.11.21 11:12, Marvin Häuser wrote: Ping? :) On 16.08.21 15:10, Marvin Häuser wrote: Hey Ray, On 16/08/2021 11:42, Ni, Ray wrote: Marvin, So lucky to have you in the edk2 project looking into these fundamentals! Thank you. :) + #define ALIGNOF(TYPE) OFFSET_OF (struct { CHAR8 C; TYPE A; }, A) 1. Does struct{} inside a macro conform to C standard? How is the compatibility with different compilers? This should work, yes. The C standard defines offsetof as such: "The macros are [...] offsetof(type, member-designator) which expands to an integer constant expression that has type size_t, the value of which is the offset in bytes, to the structure member (designated by member-designator), from the beginning of its structure (designated by type). The type and member designator shall be such that given static type t; then the expression &(t.member-designator) evaluates to an address constant. [...]" [1] If we plug in t: static struct { CHAR8 C; TYPE A; } t; we get a valid static storage duration variable declaration that satisfies the the last condition because: "An address constant is [...], a pointer to an lvalue designating an object of static storage duration, or [...]" [2] It worked with all compilers I tinkered with at https://godbolt.org/ I sadly do not have access to any of the compilers where this may be used effectively (RVCT, EBC). +#define IS_POW2(Value) ((Value) != 0U && ((Value) & ((Value) - 1U)) == +0U) 2. Good to me. I learned this trick when implementing the MtrrLib. +#define ALIGN_VALUE_ADDEND(Value, Alignment) (((Alignment) - (Value)) +& ((Alignment) - 1U)) 3. Is any other open source project using the same macro for the addend? This is actually a general question to all new macros. I would like the macros look familiar to developers from other open source projects. Good question, I never really saw it. I only came up with it because for the new PE loader, we may align the PE memory within an underaligned buffer, and for that we need the addend. I initially used to align up and then subtract, but I saw this could be simplified with ALIGN_VALUE_ADDEND, which was used in ALIGN_VALUE anyway. If you have a better name, I'll change it. Best regards, Marvin [1] ISO/IEC 9899:2011, 7.19, 3. [2] ISO/IEC 9899:2011, 6.6, 9. -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87884): https://edk2.groups.io/g/devel/message/87884 Mute This Topic: https://groups.io/mt/84909448/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] GSoC 2022: Add S3 resume support to MinPlatform
Hi all, I'm Benjamin Doron. Last year, I worked on a board port to MinPlatform. This year, I hope to pick up where I left off and help improve MinPlatform by adding support for S3 resume (time permitting and if my skills are sufficient, etc). Previously, I worked a little on coreboot (mainly a board port), and a fork with some improvements for UefiPayloadPkg. I'm a little apprehensive reading the task proposal, but I really don't think that I would have to design the S3 architecture; the easiest part is adding the module stack. It's some of the deviations from the regular boot-flow in related areas like memory and CPU init (complicated by preparing the data structures and the adjacent FSP) that I have to worry about, as I understand (which I began looking at last year and discussed with Nate and Michael). Before, code analysis gave me some hints and I found issues to address, but I want to consider actual possibilities for debugging. I've looked at the S3 boot-flow and from early PEI to the S3Resume2 PPI, the boot script and SMM, there are a lot of things to verify. Analysing code at each step to resolve issues might take a while. Some ideas I had: - Realistically, the SPI flash console or an accessible serial port. - Simics, or other simulator/emulator: Would be helpful, if the architecture of SimicsOpenBoardPkg weren't so different from MinPlatform. - System debug with DCI: Would be great, but my laptop has disconnected CPU<->PCH JTAG pins. Fixing this would presumably be very risky. (I now also have a Tigerlake system, where DCI might work, but I haven't tried and I don't have a port yet.) I should mention that I'll almost certainly be taking at least one course, but no more than two. Looking forward to working with you all! Best regards, Benjamin -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87885): https://edk2.groups.io/g/devel/message/87885 Mute This Topic: https://groups.io/mt/89962508/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [edk2-platforms][PATCH v1 1/1] MinPlatformPkg/TestPointCheckLib: Fix mis-parsed HSTI structures
From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3612 Printing corruption can occur if the DumpHsti helper function encounters a structure from the IHV (i.e. one that contains the 'Required' field). Co-authored-by: Bret Barkelew Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Cc: Eric Dong Signed-off-by: Michael Kubacki --- Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckHsti.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckHsti.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckHsti.c index 7756369ae17b..f2f3fa83a57c 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckHsti.c +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckHsti.c @@ -40,6 +40,16 @@ DumpHsti ( DEBUG ((DEBUG_INFO, " SecurityFeaturesSize- 0x%08x\n", Hsti->SecurityFeaturesSize)); SecurityFeatures = (UINT8 *) (Hsti + 1); + + if (Hsti->Role == PLATFORM_SECURITY_ROLE_PLATFORM_REFERENCE) { +DEBUG ((DEBUG_INFO, " SecurityFeaturesRequired- ")); +for (Index = 0; Index < Hsti->SecurityFeaturesSize; Index++) { + DEBUG ((DEBUG_INFO, "%02x ", SecurityFeatures[Index])); +} +DEBUG ((DEBUG_INFO, "\n")); +SecurityFeatures = (UINT8 *) (SecurityFeatures + Hsti->SecurityFeaturesSize); + } + DEBUG ((DEBUG_INFO, " SecurityFeaturesImplemented - ")); for (Index = 0; Index < Hsti->SecurityFeaturesSize; Index++) { DEBUG ((DEBUG_INFO, "%02x ", SecurityFeatures[Index])); @@ -81,7 +91,7 @@ TestPointCheckHsti ( EFI_STATUS Status; UINTN Index; BOOLEAN Result; - + Result = TRUE; DEBUG ((DEBUG_INFO, " TestPointCheckHsti - Enter\n")); for (Index = 0; Index < sizeof(mRole)/sizeof(mRole[0]); Index++) { -- 2.28.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87886): https://edk2.groups.io/g/devel/message/87886 Mute This Topic: https://groups.io/mt/89966782/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] Event: TianoCore Bug Triage - APAC / NAMO - 03/22/2022 #cal-reminder
BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Groups.io Inc//Groups.io Calendar//EN METHOD:PUBLISH REFRESH-INTERVAL;VALUE=DURATION:PT1H X-PUBLISHED-TTL:PT1H CALSCALE:GREGORIAN BEGIN:VTIMEZONE TZID:America/Los_Angeles LAST-MODIFIED:20220317T223602Z TZURL:http://tzurl.org/zoneinfo-outlook/America/Los_Angeles X-LIC-LOCATION:America/Los_Angeles BEGIN:DAYLIGHT TZNAME:PDT TZOFFSETFROM:-0800 TZOFFSETTO:-0700 DTSTART:19700308T02 RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU END:DAYLIGHT BEGIN:STANDARD TZNAME:PST TZOFFSETFROM:-0700 TZOFFSETTO:-0800 DTSTART:19701101T02 RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU END:STANDARD END:VTIMEZONE BEGIN:VEVENT X-GIOIDS:Event:1238717 UID:mlda.1580078539586725120.r...@groups.io DTSTAMP:20220323T011501Z ORGANIZER;CN=Liming Gao:mailto:gaolim...@byosoft.com.cn DTSTART:20220323T013000Z DTEND:20220323T023000Z SUMMARY:TianoCore Bug Triage - APAC / NAMO DESCRIPTION:TianoCore Bug Triage - APAC / NAMO\n\nHosted by Liming Gao\n\ n \n\nMicrosoft Teams meeting\n\n*Join on your computer or mobile a pp*\n\nClick here to join the meeting ( https://teams.microsoft.com/l/mee tup-join/19%3ameeting_OTUyZTg2NjgtNDhlNS00ODVlLTllYTUtYzg1OTNjNjdiZjFh%40 thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255 d%22%2c%22Oid%22%3a%22b286b53a-1218-4db3-bfc9-3d4c5aa7669e%22%7d )\n\n*Jo in with a video conferencing device*\n\nte...@conf.intel.com\n\nVideo Con ference ID: 116 062 094 0\n\nAlternate VTC dialing instructions ( https:/ /conf.intel.com/teams/?conf=1160620940&ivr=teams&d=conf.intel.com&test=te st_call )\n\n*Or call in (audio only)*\n\n+1 916-245-6934\,\,77463821# ( tel:+19162456934\,\,77463821# ) United States\, Sacramento\n\nPhone Confe rence ID: 774 638 21#\n\nFind a local number ( https://dialin.teams.micro soft.com/d195d438-2daa-420e-b9ea-da26f9d1d6d5?id=77463821 ) | Reset PIN ( https://mysettings.lync.com/pstnconferencing )\n\nLearn More ( https://a ka.ms/JoinTeamsMeeting ) | Meeting options ( https://teams.microsoft.com/ meetingOptions/?organizerId=b286b53a-1218-4db3-bfc9-3d4c5aa7669e&tenantId =46c98d88-e344-4ed4-8496-4ed7712e255d&threadId=19_meeting_OTUyZTg2NjgtNDh lNS00ODVlLTllYTUtYzg1OTNjNjdiZjFh@thread.v2&messageId=0&language=en-US ) LOCATION:https://teams.microsoft.com/l/meetup-join/19%3ameeting_OTk1YzJhN 2UtOGQwNi00NjY4LWEwMTktY2JiODRlYTY1NmY0%40thread.v2/0?context=%7b%22Tid%2 2%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%226e4ce4c4- 1242-431b-9a51-92cd01a5df3c%22%7d SEQUENCE:2 END:VEVENT END:VCALENDAR invite.ics Description: application/ics
[edk2-devel] 回复: [PATCH V9 02/47] MdePkg: Update Cpuid.h for Tdx
Min: I have no comments on this patch. Reviewed-by: Liming Gao Ray: Have you any comments on this patch? Thanks Liming > -邮件原件- > 发件人: Xu, Min M > 发送时间: 2022年3月22日 11:02 > 收件人: devel@edk2.groups.io; Gao, Liming > 抄送: Ni, Ray ; Kinney, Michael D > ; Liu, Zhiguang ; > Brijesh Singh ; Aktas, Erdem > ; James Bottomley ; Yao, > Jiewen ; Tom Lendacky > ; Gerd Hoffmann > 主题: RE: [PATCH V9 02/47] MdePkg: Update Cpuid.h for Tdx > > Hi, Liming > Can you help to review this patch? > https://edk2.groups.io/g/devel/message/87678 > > Thanks > Min -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87888): https://edk2.groups.io/g/devel/message/87888 Mute This Topic: https://groups.io/mt/89966887/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
回复: [edk2-devel] [PATCH v3 0/5] Http Fixes (Take Two)
Maciej, Jiaxin and Siyuan: Can you help review this fix? Thanks Liming > -邮件原件- > 发件人: devel@edk2.groups.io 代表 Oliver Steffen > 发送时间: 2022年3月22日 21:30 > 收件人: devel@edk2.groups.io > 抄送: maciej.rab...@linux.intel.com; jiaxin...@intel.com; > siyuan...@intel.com; kra...@redhat.com; Oliver Steffen > > 主题: [edk2-devel] [PATCH v3 0/5] Http Fixes (Take Two) > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2720 > > This set of patches fixes booting from HTTP/1.0 servers. > It also improves the interaction with HTTP/1.1 servers by recognizing > the 'Connection: close' header field, which fixes a problem with > servers that close the connection after a 404-error is encountered. > > It also prevents triggering the TCP issue described in > https://bugzilla.tianocore.org/show_bug.cgi?id=3735 > when booting from HTTP/1.0 servers. > > PR: https://github.com/tianocore/edk2/pull/2564 > > Oliver Steffen (5): > NetworkPkg/HttpDxe: Decofigure Tcp4 before reconfiguring > NetworkPkg/HttpDxe: Decofigure Tcp6 before reconfiguring > NetworkPkg/HttpDxe: Add ConnectionClose flag fo HTTP_PROTOCOL > NetworkPkg/HttpDxe: Detect 'Connection: close' header > NetworkPkg/HttpDxe: Detect HTTP/1.0 servers > > NetworkPkg/HttpDxe/HttpProto.h | 2 ++ > NetworkPkg/HttpDxe/HttpImpl.c | 25 - > NetworkPkg/HttpDxe/HttpProto.c | 24 > 3 files changed, 50 insertions(+), 1 deletion(-) > > -- > 2.35.1 > > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87889): https://edk2.groups.io/g/devel/message/87889 Mute This Topic: https://groups.io/mt/89966934/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [edk2-platforms][PATCH v1 1/1] MinPlatformPkg: Add missing libraries to [Components] in DSC
From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3619 Adds libraries implemented in MinPlatformPkg to the [Components] section in MinPlatformPkg.dsc so they are included in the package build. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Cc: Eric Dong Signed-off-by: Michael Kubacki --- Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc | 7 +++ 1 file changed, 7 insertions(+) diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc index 0f47182c2647..a8373a4ecb37 100644 --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc @@ -211,6 +211,13 @@ [Components] MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.inf MinPlatformPkg/Library/SmmVariableReadLib/StandaloneMmVariableReadLib.inf MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMmVariableWriteLib.inf + MinPlatformPkg/Library/PeiVariableReadLib/PeiVariableReadLib.inf + MinPlatformPkg/Library/DxeRuntimeVariableReadLib/DxeRuntimeVariableReadLib.inf + MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeRuntimeVariableWriteLib.inf + MinPlatformPkg/Library/SmmVariableReadLib/TraditionalMmVariableReadLib.inf + MinPlatformPkg/Library/SmmVariableWriteLib/TraditionalMmVariableWriteLib.inf + MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableReadLib.inf + MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableWriteLib.inf [BuildOptions] *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES -- 2.28.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87890): https://edk2.groups.io/g/devel/message/87890 Mute This Topic: https://groups.io/mt/89967094/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [edk2-platforms][PATCH v1 1/1] MinPlatformPkg/TestPointCheckLib: Fix mis-parsed HSTI structures
Reviewed-by: Chasel Chiu > -Original Message- > From: mikub...@linux.microsoft.com > Sent: Wednesday, March 23, 2022 9:11 AM > To: devel@edk2.groups.io > Cc: Bret Barkelew ; Chiu, Chasel > ; Desimone, Nathaniel L > ; Gao, Liming > ; Dong, Eric > Subject: [edk2-platforms][PATCH v1 1/1] > MinPlatformPkg/TestPointCheckLib: Fix mis-parsed HSTI structures > > From: Michael Kubacki > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3612 > > Printing corruption can occur if the DumpHsti helper function encounters a > structure from the IHV (i.e. one that contains the 'Required' field). > > Co-authored-by: Bret Barkelew > Cc: Chasel Chiu > Cc: Nate DeSimone > Cc: Liming Gao > Cc: Eric Dong > Signed-off-by: Michael Kubacki > --- > > Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckH > sti.c | 12 +++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git > a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeChec > kHsti.c > b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeChec > kHsti.c > index 7756369ae17b..f2f3fa83a57c 100644 > --- > a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeChec > kHsti.c > +++ > b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCh > +++ eckHsti.c > @@ -40,6 +40,16 @@ DumpHsti ( >DEBUG ((DEBUG_INFO, " SecurityFeaturesSize- 0x%08x\n", Hsti- > >SecurityFeaturesSize)); > >SecurityFeatures = (UINT8 *) (Hsti + 1); > + > + if (Hsti->Role == PLATFORM_SECURITY_ROLE_PLATFORM_REFERENCE) { > +DEBUG ((DEBUG_INFO, " SecurityFeaturesRequired- ")); > +for (Index = 0; Index < Hsti->SecurityFeaturesSize; Index++) { > + DEBUG ((DEBUG_INFO, "%02x ", SecurityFeatures[Index])); > +} > +DEBUG ((DEBUG_INFO, "\n")); > +SecurityFeatures = (UINT8 *) (SecurityFeatures + > + Hsti->SecurityFeaturesSize); } > + >DEBUG ((DEBUG_INFO, " SecurityFeaturesImplemented - ")); >for (Index = 0; Index < Hsti->SecurityFeaturesSize; Index++) { > DEBUG ((DEBUG_INFO, "%02x ", SecurityFeatures[Index])); @@ -81,7 > +91,7 @@ TestPointCheckHsti ( >EFI_STATUS Status; >UINTN Index; >BOOLEAN Result; > - > + >Result = TRUE; >DEBUG ((DEBUG_INFO, " TestPointCheckHsti - Enter\n")); >for (Index = 0; Index < sizeof(mRole)/sizeof(mRole[0]); Index++) { > -- > 2.28.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87891): https://edk2.groups.io/g/devel/message/87891 Mute This Topic: https://groups.io/mt/89966782/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [edk2-platforms][PATCH v1 1/1] MinPlatformPkg: Add missing libraries to [Components] in DSC
Reviewed-by: Chasel Chiu > -Original Message- > From: mikub...@linux.microsoft.com > Sent: Wednesday, March 23, 2022 9:28 AM > To: devel@edk2.groups.io > Cc: Chiu, Chasel ; Desimone, Nathaniel L > ; Gao, Liming > ; Dong, Eric > Subject: [edk2-platforms][PATCH v1 1/1] MinPlatformPkg: Add missing > libraries to [Components] in DSC > > From: Michael Kubacki > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3619 > > Adds libraries implemented in MinPlatformPkg to the [Components] > section in MinPlatformPkg.dsc so they are included in the package build. > > Cc: Chasel Chiu > Cc: Nate DeSimone > Cc: Liming Gao > Cc: Eric Dong > Signed-off-by: Michael Kubacki > --- > Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc | 7 +++ > 1 file changed, 7 insertions(+) > > diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc > b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc > index 0f47182c2647..a8373a4ecb37 100644 > --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc > +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc > @@ -211,6 +211,13 @@ [Components] > > MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull. > inf > > MinPlatformPkg/Library/SmmVariableReadLib/StandaloneMmVariableRead > Lib.inf > > MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMmVariableWri > teLib.inf > + MinPlatformPkg/Library/PeiVariableReadLib/PeiVariableReadLib.inf > + > + > MinPlatformPkg/Library/DxeRuntimeVariableReadLib/DxeRuntimeVariableR > ea > + dLib.inf > + > MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeRuntimeVariable > Wr > + iteLib.inf > + > MinPlatformPkg/Library/SmmVariableReadLib/TraditionalMmVariableRead > Lib > + .inf > + > MinPlatformPkg/Library/SmmVariableWriteLib/TraditionalMmVariableWrit > eL > + ib.inf > + > MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableReadLib.i > + nf > + MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableWriteLib. > + inf > > [BuildOptions] >*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES > -- > 2.28.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87892): https://edk2.groups.io/g/devel/message/87892 Mute This Topic: https://groups.io/mt/89967094/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-