Re: [edk2] [PATCH 06/10] OvmfPkg/Sec: Disable optimizations for TemporaryRamMigration
On Mon, 18 Feb 2019 at 05:12, Jordan Justen wrote: > This needs an explanation why optimization needs to be disabled. > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jordan Justen > Cc: Laszlo Ersek > Cc: Ard Biesheuvel > Cc: Anthony Perard > Cc: Julien Grall > --- > OvmfPkg/Sec/SecMain.c | 12 > 1 file changed, 12 insertions(+) > > diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c > index 46ac739862..86c22a2ac9 100644 > --- a/OvmfPkg/Sec/SecMain.c > +++ b/OvmfPkg/Sec/SecMain.c > @@ -873,6 +873,13 @@ SecStartupPhase2( >CpuDeadLoop (); > } > > +#ifdef __GNUC__ > +#pragma GCC push_options > +#pragma GCC optimize ("O0") > +#else > +#pragma optimize ("", off) > +#endif > + > EFI_STATUS > EFIAPI > TemporaryRamMigration ( > @@ -946,3 +953,8 @@ TemporaryRamMigration ( >return EFI_SUCCESS; > } > > +#ifdef __GNUC__ > +#pragma GCC pop_options > +#else > +#pragma optimize ("", on) > +#endif I can't tell from the context if this is the end of the file, but if it is not, aren't you turning on optimization here for non-GCC even if it was not enabled on the command line to begin with? ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch edk2-wiki] Update ECC wiki page
Update ECC wiki page to record how to solve the problem “ModuleNotFoundError: No module named 'antlr4'” when run ECC tool with python3.x. Cc: Liming Gao Cc: Bob Feng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- ECC-tool.md | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ECC-tool.md b/ECC-tool.md index eaf4137..03dbb30 100644 --- a/ECC-tool.md +++ b/ECC-tool.md @@ -12,18 +12,27 @@ Steps to run ECC tool: **1). Enter edk2 directory, run: **edksetup.bat (**on Windows**) **Enter edk2 directory, run: **source edksetup.sh (**on Linux**) **2). Then in edk2 directory, you can type "Ecc" to run ECC tool directly**. -**3). If you meet following error:** +**3). If you meet following errors:** +**Error 1:** **import antlr3** **ImportError: No module named antlr3** -Since ECC depends on antlr V3.0.1, you can download it from http://www.antlr3.org/download/Python/ +This error may be met when you run ECC tool with python 2.x, then ECC depends on antlr V3.0.1, you can download it from http://www.antlr3.org/download/Python/ After download and extract it, you can enter the antlr tool directory and run: **C:\Python27\python.exe setup.py install** to install it.(**on Windows**) -**python setup.py install**" to install it, root access may be required.(**on Linux**) +**python setup.py install** to install it, root access may be required.(**on Linux**) + +**Error 2:** +**import antlr4 as antlr** +**ModuleNotFoundError: No module named 'antlr4'** + +This error may be met when you run ECC tool with python 3.x, then ECC depends on antlr4, you can install it through following command. +**py -3 -m pip install antlr4-python3-runtime** to install it.(**on Windows**) +**sudo python3 -m pip install antlr4-python3-runtime** to install it. (**on Linux**) **4). You can type "Ecc -h/Ecc --help" to get the help info of ECC tool**. **5). Common usage model:** **Ecc -c config file -e exception file -t the target directory which need to be scanned by ECC -r the ECC scan result csv file** -- 2.18.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH 1/2] MdeModulePkg: Add a new API ResetSystem
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1460 Add a new API ResetSystem: VOID EFIAPI ResetSystem ( IN EFI_RESET_TYPE ResetType, IN EFI_STATUS ResetStatus, IN UINTNDataSize, IN VOID *ResetData OPTIONAL ) The Consumer of ResetSystemLib can use this new API to reset system with additional reset data.Because ResetSystemRuntimeDxe has a same function name with it, change the function name from ResetSystem to EfiRuntimeResetSystem(both ResetSystem and EfiResetSystem are used in ResetSystemLiband RuntimeLib, and the driver consumes these two library) in driver ResetSystemRuntimeDxe. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhichao Gao Cc: Ray Ni Cc: Liming Gao --- MdeModulePkg/Include/Library/ResetSystemLib.h | 25 ++- .../Library/DxeResetSystemLib/DxeResetSystemLib.c | 28 +- .../Library/PeiResetSystemLib/PeiResetSystemLib.c | 28 +- .../Universal/ResetSystemRuntimeDxe/ResetSystem.c | 8 +++ .../Universal/ResetSystemRuntimeDxe/ResetSystem.h | 4 ++-- 5 files changed, 84 insertions(+), 9 deletions(-) diff --git a/MdeModulePkg/Include/Library/ResetSystemLib.h b/MdeModulePkg/Include/Library/ResetSystemLib.h index 55d1923ae1..2f5d15ade8 100644 --- a/MdeModulePkg/Include/Library/ResetSystemLib.h +++ b/MdeModulePkg/Include/Library/ResetSystemLib.h @@ -2,7 +2,7 @@ System reset Library Services. This library class defines a set of methods that reset the whole system. -Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. +Copyright (c) 2005 - 2019, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at @@ -83,4 +83,27 @@ ResetPlatformSpecific ( IN VOID*ResetData ); +/** + The ResetSystem function resets the entire platform. + + @param[in] ResetType The type of reset to perform. + @param[in] ResetStatusThe status code for the reset. + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown +the data buffer starts with a Null-terminated string, optionally +followed by additional binary data. The string is a description +that the caller may use to further indicate the reason for the +system reset. ResetData is only valid if ResetStatus is something +other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific +where a minimum amount of ResetData is always required. +**/ +VOID +EFIAPI +ResetSystem ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTNDataSize, + IN VOID *ResetData OPTIONAL + ); + #endif diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c index ea4878cab1..f5c7386c9a 100644 --- a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c +++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c @@ -1,7 +1,7 @@ /** @file DXE Reset System Library instance that calls gRT->ResetSystem(). - Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved. + Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -96,3 +96,29 @@ ResetPlatformSpecific ( { gRT->ResetSystem (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, ResetData); } + +/** + The ResetSystem function resets the entire platform. + + @param[in] ResetType The type of reset to perform. + @param[in] ResetStatusThe status code for the reset. + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown +the data buffer starts with a Null-terminated string, optionally +followed by additional binary data. The string is a description +that the caller may use to further indicate the reason for the +system reset. ResetData is only valid if ResetStatus is something +other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific +where a minimum amount of ResetData is always required. +**/ +VOID +EFIAPI
[edk2] [PATCH 2/2] MdeModulePkg: Add a runtime library instance of ResetSystemLib
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1461 For now there is no ResetSystemLib instance that can be linked against Runtime driver. And it's improper to extend the existing DxeResetSystemLib to support Runtime driver because no one converts gRT when entering RT phase. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhichao Gao Cc: Ray Ni Cc: Liming Gao --- .../RuntimeResetSystemLib/RuntimeResetSystemLib.c | 216 + .../RuntimeResetSystemLib.inf | 50 + .../RuntimeResetSystemLib.uni | 21 ++ 3 files changed, 287 insertions(+) create mode 100644 MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.c create mode 100644 MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.inf create mode 100644 MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.uni diff --git a/MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.c b/MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.c new file mode 100644 index 00..17826cd6a9 --- /dev/null +++ b/MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.c @@ -0,0 +1,216 @@ +/** @file + DXE Reset System Library instance that calls gRT->ResetSystem(). + + Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved. + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include +#include + +EFI_EVENT mRuntimeResetSystemLibVirtualAddressChangeEvent; +EFI_RUNTIME_SERVICES *mInternalRT; + +/** + This function causes a system-wide reset (cold reset), in which + all circuitry within the system returns to its initial state. This type of reset + is asynchronous to system operation and operates without regard to + cycle boundaries. + + If this function returns, it means that the system does not support cold reset. +**/ +VOID +EFIAPI +ResetCold ( + VOID + ) +{ + mInternalRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); +} + +/** + This function causes a system-wide initialization (warm reset), in which all processors + are set to their initial state. Pending cycles are not corrupted. + + If this function returns, it means that the system does not support warm reset. +**/ +VOID +EFIAPI +ResetWarm ( + VOID + ) +{ + mInternalRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL); +} + +/** + This function causes the system to enter a power state equivalent + to the ACPI G2/S5 or G3 states. + + If this function returns, it means that the system does not support shut down reset. +**/ +VOID +EFIAPI +ResetShutdown ( + VOID + ) +{ + mInternalRT->ResetSystem (EfiResetShutdown, EFI_SUCCESS, 0, NULL); +} + +/** + This function causes the system to enter S3 and then wake up immediately. + + If this function returns, it means that the system does not support S3 feature. +**/ +VOID +EFIAPI +EnterS3WithImmediateWake ( + VOID + ) +{ +} + +/** + This function causes a systemwide reset. The exact type of the reset is + defined by the EFI_GUID that follows the Null-terminated Unicode string passed + into ResetData. If the platform does not recognize the EFI_GUID in ResetData + the platform must pick a supported reset type to perform.The platform may + optionally log the parameters from any non-normal reset that occurs. + + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData The data buffer starts with a Null-terminated string, + followed by the EFI_GUID. +**/ +VOID +EFIAPI +ResetPlatformSpecific ( + IN UINTN DataSize, + IN VOID*ResetData + ) +{ + mInternalRT->ResetSystem (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, ResetData); +} + +/** + The ResetSystem function resets the entire platform. + + @param[in] ResetType The type of reset to perform. + @param[in] ResetStatusThe status code for the reset. + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown +the data buffer starts with a Null-terminated string, optionally +followed by additional binary data. The string is a description +that the caller may use to further indicate the reason for the +system reset. ResetData is only valid if ResetStatus is something +other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific +
[edk2] [PATCH 0/2] ResetSystemLib changings
Add a new API ResetSystem in ResetSystemLib. Implement a runtime library instance of ResetSystemLib. The runtime library instance is base on the new API implementation. Cc: Liming Gao Cc: Ray Ni Zhichao Gao (2): MdeModulePkg: Add a new API ResetSystem MdeModulePkg: Add a runtime library instance of ResetSystemLib MdeModulePkg/Include/Library/ResetSystemLib.h | 25 ++- .../Library/DxeResetSystemLib/DxeResetSystemLib.c | 28 ++- .../Library/PeiResetSystemLib/PeiResetSystemLib.c | 28 ++- .../RuntimeResetSystemLib/RuntimeResetSystemLib.c | 216 + .../RuntimeResetSystemLib.inf | 50 + .../RuntimeResetSystemLib.uni | 21 ++ .../Universal/ResetSystemRuntimeDxe/ResetSystem.c | 8 +- .../Universal/ResetSystemRuntimeDxe/ResetSystem.h | 4 +- 8 files changed, 371 insertions(+), 9 deletions(-) create mode 100644 MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.c create mode 100644 MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.inf create mode 100644 MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.uni -- 2.16.2.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] IntelSiliconPkg/MicrocodeUpdateDxe: Error message enhancement
The error message of ExtendedTableCount is not clear. Add the count number into the debug message. https://bugzilla.tianocore.org/show_bug.cgi?id=1500 Cc: Ray Ni Cc: Rangasai V Chaganty Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Shenglei Zhang --- .../Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c| 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c b/IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c index 9098712c2f..9b5757da71 100644 --- a/IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c +++ b/IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c @@ -518,7 +518,7 @@ VerifyMicrocode ( // ExtendedTableCount = ExtendedTableHeader->ExtendedSignatureCount; if (ExtendedTableCount > (ExtendedTableLength - sizeof(CPU_MICROCODE_EXTENDED_TABLE_HEADER)) / sizeof(CPU_MICROCODE_EXTENDED_TABLE)) { -DEBUG((DEBUG_ERROR, "VerifyMicrocode - ExtendedTableCount too big\n")); +DEBUG((DEBUG_ERROR, "VerifyMicrocode - ExtendedTableCount %d is too big\n", ExtendedTableCount)); } else { ExtendedTable = (CPU_MICROCODE_EXTENDED_TABLE *)(ExtendedTableHeader + 1); for (Index = 0; Index < ExtendedTableCount; Index++) { -- 2.18.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH v5 06/13] MdeModulePkg/NvmExpressPei: Add logic to produce SSC PPI
Hi Hao, Got it. In this case, Reviewed-by: Eric Dongfor 6,7,8 patches. Thanks, Eric > -Original Message- > From: Wu, Hao A > Sent: Monday, February 18, 2019 2:07 PM > To: Dong, Eric ; edk2-devel@lists.01.org > Cc: Wang, Jian J ; Ni, Ray > Subject: RE: [PATCH v5 06/13] MdeModulePkg/NvmExpressPei: Add logic to > produce SSC PPI > > > -Original Message- > > From: Dong, Eric > > Sent: Monday, February 18, 2019 10:59 AM > > To: Wu, Hao A; edk2-devel@lists.01.org > > Cc: Wang, Jian J; Ni, Ray > > Subject: RE: [PATCH v5 06/13] MdeModulePkg/NvmExpressPei: Add logic > to > > produce SSC PPI > > > > Hi Hao, > > > > > -Original Message- > > > From: Wu, Hao A > > > Sent: Friday, February 15, 2019 2:24 PM > > > To: edk2-devel@lists.01.org > > > Cc: Wu, Hao A ; Wang, Jian J > > ; > > > Ni, Ray ; Dong, Eric > > > Subject: [PATCH v5 06/13] MdeModulePkg/NvmExpressPei: Add logic to > > > produce SSC PPI > > > > > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409 > > > > > > For the NvmExpressPei driver, this commit will add codes to produce the > > > Storage Security Command PPI if the underlying NVM Express controller > > > supports the Security Send and Security Receive commands. > > > > > > Cc: Jian J Wang > > > Cc: Ray Ni > > > Cc: Eric Dong > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > > Signed-off-by: Hao Wu > > > --- > > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf | 10 > > +- > > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h| 58 > > ++- > > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.h | > 20 > > +- > > > > > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiStorageSecurity.h > > > | 247 > > > MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c | 231 > > > +++ > > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c| 143 > > > +-- > > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.c | > 32 > > +- > > > > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiStorageSecurity.c > > > | 423 > > > 8 files changed, 1075 insertions(+), 89 deletions(-) > > > > > > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > > > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > > > index 9591572fec..0666e5892b 100644 > > > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > > > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > > > @@ -2,7 +2,7 @@ > > > # The NvmExpressPei driver is used to manage non-volatile memory > > > subsystem > > > # which follows NVM Express specification at PEI phase. > > > # > > > -# Copyright (c) 2018, Intel Corporation. All rights reserved. > > > +# Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved. > > > # > > > # This program and the accompanying materials > > > # are licensed and made available under the terms and conditions of the > > > BSD License > > > @@ -30,6 +30,7 @@ > > > # > > > > > > [Sources] > > > + DevicePath.c > > >DmaMem.c > > >NvmExpressPei.c > > >NvmExpressPei.h > > > @@ -39,6 +40,8 @@ > > >NvmExpressPeiHci.h > > >NvmExpressPeiPassThru.c > > >NvmExpressPeiPassThru.h > > > + NvmExpressPeiStorageSecurity.c > > > + NvmExpressPeiStorageSecurity.h > > > > > > [Packages] > > >MdePkg/MdePkg.dec > > > @@ -54,11 +57,12 @@ > > >PeimEntryPoint > > > > > > [Ppis] > > > - gEfiPeiVirtualBlockIoPpiGuid ## PRODUCES > > > - gEfiPeiVirtualBlockIo2PpiGuid ## PRODUCES > > >gEdkiiPeiNvmExpressHostControllerPpiGuid ## CONSUMES > > >gEdkiiIoMmuPpiGuid ## CONSUMES > > >gEfiEndOfPeiSignalPpiGuid ## CONSUMES > > > + gEfiPeiVirtualBlockIoPpiGuid ## SOMETIMES_PRODUCES > > > + gEfiPeiVirtualBlockIo2PpiGuid ## SOMETIMES_PRODUCES > > > + gEdkiiPeiStorageSecurityCommandPpiGuid ## > > > SOMETIMES_PRODUCES > > > > > > [Depex] > > >gEfiPeiMemoryDiscoveredPpiGuid AND > > > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > > > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > > > index 0135eca6f0..92c3854c6e 100644 > > > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > > > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > > > @@ -25,6 +25,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > > > > @@ -44,6 +45,7 @@ typedef struct > > > _PEI_NVME_CONTROLLER_PRIVATE_DATA > > > PEI_NVME_CONTROLLER_PRIVATE_DA > > > #include "NvmExpressPeiHci.h" > > > #include "NvmExpressPeiPassThru.h" > > > #include "NvmExpressPeiBlockIo.h" > > > +#include "NvmExpressPeiStorageSecurity.h" > > > > > > // > > > // NVME PEI driver implementation related definitions > > > @@ -90,10 +92,15 @@ struct _PEI_NVME_NAMESPACE_INFO { > > > struct
[edk2] [PATCH] BaseTools:Fix a ECC issue
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1522 A property error occurred because the property of the function was not defined. a property is now redefined. Cc: Bob Feng Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan --- BaseTools/Source/Python/Ecc/CodeFragmentCollector.py | 2 +- BaseTools/Source/Python/Ecc/Configuration.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py index 21fed59cad..f844b4a0b3 100644 --- a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py +++ b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py @@ -27,7 +27,7 @@ if sys.version_info.major == 3: from Ecc.CParser4.CParser import CParser else: import antlr3 as antlr -antlr.InputString = antlr.StringStream +antlr.InputStream = antlr.StringStream from Ecc.CParser3.CLexer import CLexer from Ecc.CParser3.CParser import CParser diff --git a/BaseTools/Source/Python/Ecc/Configuration.py b/BaseTools/Source/Python/Ecc/Configuration.py index c19a3990c7..f2b2b86487 100644 --- a/BaseTools/Source/Python/Ecc/Configuration.py +++ b/BaseTools/Source/Python/Ecc/Configuration.py @@ -192,6 +192,8 @@ class Configuration(object): self.GeneralCheckLineEnding = 1 # Check if there is no trailing white space in one line. self.GeneralCheckTrailingWhiteSpaceLine = 1 + +self.CFunctionLayoutCheckNoDeprecated = 1 ## Space Checking self.SpaceCheckAll = 1 -- 2.14.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH V2] BaseTools:BaseTools supports to the driver combination.
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1520 To save the image size without the compression, more than one drivers can be combined into single one. When more than one drivers are combined, their depex will be AND together. Below is the example to combine BootManagerPolicyDxe into DriverHealthManagerDxe. Besides this patch, BaseTools also needs to check the module type and make sure all module type are same. Otherwise, BaseTools will report the error. DRIVER INF has the parameter ENTRY_POINT LIBRARY INF has the parameter LIBRARY_CLASS Cc: Bob Feng Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan --- BaseTools/Source/Python/AutoGen/GenC.py | 32 +++- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index 9700bf8527..e6fc5cda3c 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -1455,10 +1455,25 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH): def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH): if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_SEC]: return +ModuleEntryPointList = [] +for Lib in Info.DependentLibraryList: +if len(Lib.ModuleEntryPointList) > 0: +if Lib.ModuleType == Info.ModuleType: +ModuleEntryPointList = ModuleEntryPointList + Lib.ModuleEntryPointList +else: +EdkLogger.error( +"build", +PREBUILD_ERROR, +"Driver's ModuleType must be consistent [%s]"%(str(Lib)), +File=str(Info.PlatformInfo), +ExtraData="consumed by [%s]" % str(Info.MetaFile) +) +ModuleEntryPointList = ModuleEntryPointList + Info.Module.ModuleEntryPointList + # # Module Entry Points # -NumEntryPoints = len(Info.Module.ModuleEntryPointList) +NumEntryPoints = len(ModuleEntryPointList) if 'PI_SPECIFICATION_VERSION' in Info.Module.Specification: PiSpecVersion = Info.Module.Specification['PI_SPECIFICATION_VERSION'] else: @@ -1468,7 +1483,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH): else: UefiSpecVersion = '0x' Dict = { -'Function' : Info.Module.ModuleEntryPointList, +'Function' : ModuleEntryPointList, 'PiSpecVersion' : PiSpecVersion + 'U', 'UefiSpecVersion': UefiSpecVersion + 'U' } @@ -1481,7 +1496,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH): AUTOGEN_ERROR, '%s must have exactly one entry point' % Info.ModuleType, File=str(Info), - ExtraData= ", ".join(Info.Module.ModuleEntryPointList) + ExtraData= ", ".join(ModuleEntryPointList) ) if Info.ModuleType == SUP_MODULE_PEI_CORE: AutoGenC.Append(gPeiCoreEntryPointString.Replace(Dict)) @@ -1535,11 +1550,18 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH): def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH): if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_SEC]: return + +ModuleUnloadImageList = [] +for Lib in Info.DependentLibraryList: +if len(Lib.ModuleUnloadImageList) > 0: +ModuleUnloadImageList = ModuleUnloadImageList + Lib.ModuleUnloadImageList +ModuleUnloadImageList = ModuleUnloadImageList + Info.Module.ModuleUnloadImageList + # # Unload Image Handlers # -NumUnloadImage = len(Info.Module.ModuleUnloadImageList) -Dict = {'Count':str(NumUnloadImage) + 'U', 'Function':Info.Module.ModuleUnloadImageList} +NumUnloadImage = len(ModuleUnloadImageList) +Dict = {'Count':str(NumUnloadImage) + 'U', 'Function':ModuleUnloadImageList} if NumUnloadImage < 2: AutoGenC.Append(gUefiUnloadImageString[NumUnloadImage].Replace(Dict)) else: -- 2.14.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH v5 06/13] MdeModulePkg/NvmExpressPei: Add logic to produce SSC PPI
> -Original Message- > From: Dong, Eric > Sent: Monday, February 18, 2019 10:59 AM > To: Wu, Hao A; edk2-devel@lists.01.org > Cc: Wang, Jian J; Ni, Ray > Subject: RE: [PATCH v5 06/13] MdeModulePkg/NvmExpressPei: Add logic to > produce SSC PPI > > Hi Hao, > > > -Original Message- > > From: Wu, Hao A > > Sent: Friday, February 15, 2019 2:24 PM > > To: edk2-devel@lists.01.org > > Cc: Wu, Hao A ; Wang, Jian J > ; > > Ni, Ray ; Dong, Eric > > Subject: [PATCH v5 06/13] MdeModulePkg/NvmExpressPei: Add logic to > > produce SSC PPI > > > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409 > > > > For the NvmExpressPei driver, this commit will add codes to produce the > > Storage Security Command PPI if the underlying NVM Express controller > > supports the Security Send and Security Receive commands. > > > > Cc: Jian J Wang > > Cc: Ray Ni > > Cc: Eric Dong > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Hao Wu > > --- > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf | 10 > +- > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h| 58 > ++- > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.h | 20 > +- > > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiStorageSecurity.h > > | 247 > > MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c | 231 > > +++ > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c| 143 > > +-- > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.c | 32 > +- > > > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiStorageSecurity.c > > | 423 > > 8 files changed, 1075 insertions(+), 89 deletions(-) > > > > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > > index 9591572fec..0666e5892b 100644 > > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > > @@ -2,7 +2,7 @@ > > # The NvmExpressPei driver is used to manage non-volatile memory > > subsystem > > # which follows NVM Express specification at PEI phase. > > # > > -# Copyright (c) 2018, Intel Corporation. All rights reserved. > > +# Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved. > > # > > # This program and the accompanying materials > > # are licensed and made available under the terms and conditions of the > > BSD License > > @@ -30,6 +30,7 @@ > > # > > > > [Sources] > > + DevicePath.c > >DmaMem.c > >NvmExpressPei.c > >NvmExpressPei.h > > @@ -39,6 +40,8 @@ > >NvmExpressPeiHci.h > >NvmExpressPeiPassThru.c > >NvmExpressPeiPassThru.h > > + NvmExpressPeiStorageSecurity.c > > + NvmExpressPeiStorageSecurity.h > > > > [Packages] > >MdePkg/MdePkg.dec > > @@ -54,11 +57,12 @@ > >PeimEntryPoint > > > > [Ppis] > > - gEfiPeiVirtualBlockIoPpiGuid ## PRODUCES > > - gEfiPeiVirtualBlockIo2PpiGuid ## PRODUCES > >gEdkiiPeiNvmExpressHostControllerPpiGuid ## CONSUMES > >gEdkiiIoMmuPpiGuid ## CONSUMES > >gEfiEndOfPeiSignalPpiGuid ## CONSUMES > > + gEfiPeiVirtualBlockIoPpiGuid ## SOMETIMES_PRODUCES > > + gEfiPeiVirtualBlockIo2PpiGuid ## SOMETIMES_PRODUCES > > + gEdkiiPeiStorageSecurityCommandPpiGuid ## > > SOMETIMES_PRODUCES > > > > [Depex] > >gEfiPeiMemoryDiscoveredPpiGuid AND > > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > > index 0135eca6f0..92c3854c6e 100644 > > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > > @@ -25,6 +25,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > > > @@ -44,6 +45,7 @@ typedef struct > > _PEI_NVME_CONTROLLER_PRIVATE_DATA > > PEI_NVME_CONTROLLER_PRIVATE_DA > > #include "NvmExpressPeiHci.h" > > #include "NvmExpressPeiPassThru.h" > > #include "NvmExpressPeiBlockIo.h" > > +#include "NvmExpressPeiStorageSecurity.h" > > > > // > > // NVME PEI driver implementation related definitions > > @@ -90,10 +92,15 @@ struct _PEI_NVME_NAMESPACE_INFO { > > struct _PEI_NVME_CONTROLLER_PRIVATE_DATA { > >UINT32Signature; > >UINTN MmioBase; > > + UINTN DevicePathLength; > > + EFI_DEVICE_PATH_PROTOCOL *DevicePath; > > + > >EFI_PEI_RECOVERY_BLOCK_IO_PPI BlkIoPpi; > >EFI_PEI_RECOVERY_BLOCK_IO2_PPIBlkIo2Ppi; > > + EDKII_PEI_STORAGE_SECURITY_CMD_PPIStorageSecurityPpi; > >EFI_PEI_PPI_DESCRIPTORBlkIoPpiList; > >EFI_PEI_PPI_DESCRIPTORBlkIo2PpiList; > > +
Re: [edk2] [PATCH 1/1] MdeModulePkg/SdMmcPciHcDxe Fix eMMC HS400 switch sequence
Hi Mateusz, I found that the patch proposed is actually handling one of the issues reported in the below BZ tracker: https://bugzilla.tianocore.org/show_bug.cgi?id=1140 According to the discussion within the tracker, there are 2 fixes needed for the SdMmcPciHcDxe: 1. Move the clock supply before doing send status 2. More robust handle to the send status CRC error on the switch to HS200 I think the proposed patch is handling the 1st issue listed above. So could you help to add the below line: REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1140 at the beginning of your commit log message? Also, please see the below inline comments below: > -Original Message- > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of > Albecki, Mateusz > Sent: Friday, February 15, 2019 10:45 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A > Subject: [edk2] [PATCH 1/1] MdeModulePkg/SdMmcPciHcDxe Fix eMMC > HS400 switch sequence > > In eMMC HS400 switch sequence flow eMMC driver attampted 'attampted' -> 'attempted' > to execute SEND_STATUS just after switching bus timing to high > speed and before downgrading clock frequency to 52MHz. Since link > was at that time in incorrect state SEND_STATUS was failing which > made driver think switch to HS400 failed. > This change makes driver always change clock frequency after > switching bus timing and before executing SEND_STATUS. > > Change-Id: Ib1f2c78a8693c2a4ef6e1f1b5da2f4133f6210d2 Please help to remove the above 'Change-Id' information. > Cc: Hao Wu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Albecki Mateusz > --- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c | 37 > + > 1 file changed, 19 insertions(+), 18 deletions(-) > > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c > index 4ef849fd0962..22200f806f26 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c > @@ -642,7 +642,7 @@ EmmcSwitchBusWidth ( > } > > /** > - Switch the clock frequency to the specified value. > + Switch the bus timing and clock frequency. > >Refer to EMMC Electrical Standard Spec 5.1 Section 6.6 and SD Host > Controller >Simplified Spec 3.0 Figure 3-3 for details. > @@ -660,7 +660,7 @@ EmmcSwitchBusWidth ( > > **/ > EFI_STATUS > -EmmcSwitchClockFreq ( > +EmmcSwitchBusTiming ( Could you help to update the debug messages that include keyword 'EmmcSwitchClockFreq' to 'EmmcSwitchBusTiming' to align with the function name change? Best Regards, Hao Wu >IN EFI_PCI_IO_PROTOCOL*PciIo, >IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, >IN UINT8 Slot, > @@ -693,18 +693,6 @@ EmmcSwitchClockFreq ( > return Status; >} > > - Status = EmmcSendStatus (PassThru, Slot, Rca, ); > - if (EFI_ERROR (Status)) { > -DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: Send status fails > with %r\n", Status)); > -return Status; > - } > - // > - // Check the switch operation is really successful or not. > - // > - if ((DevStatus & BIT7) != 0) { > -DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: The switch operation > fails as DevStatus is 0x%08x\n", DevStatus)); > -return EFI_DEVICE_ERROR; > - } >// >// Convert the clock freq unit from MHz to KHz. >// > @@ -713,6 +701,19 @@ EmmcSwitchClockFreq ( > return Status; >} > > + Status = EmmcSendStatus (PassThru, Slot, Rca, ); > + if (EFI_ERROR (Status)) { > +DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: Send status fails > with %r\n", Status)); > +return Status; > + } > + // > + // Check the switch operation is really successful or not. > + // > + if ((DevStatus & BIT7) != 0) { > +DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: The switch operation > fails as DevStatus is 0x%08x\n", DevStatus)); > +return EFI_DEVICE_ERROR; > + } > + >if (mOverride != NULL && mOverride->NotifyPhase != NULL) { > Status = mOverride->NotifyPhase ( >Private->ControllerHandle, > @@ -799,7 +800,7 @@ EmmcSwitchToHighSpeed ( >} > >HsTiming = 1; > - Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, Timing, > ClockFreq); > + Status = EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, HsTiming, > Timing, ClockFreq); > >return Status; > } > @@ -887,7 +888,7 @@ EmmcSwitchToHS200 ( >Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_CLOCK_CTRL, sizeof > (ClockCtrl), ); > >HsTiming = 2; > - Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, Timing, > ClockFreq); > + Status = EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, HsTiming, > Timing, ClockFreq); >if (EFI_ERROR (Status)) { > return Status; >} > @@ -937,7 +938,7 @@ EmmcSwitchToHS400 ( >// Set to Hight Speed timing and set the clock frequency to a value less > than > 52MHz. >// >HsTiming
Re: [edk2] [PATCH] UefiCpuPkg/Microcode: Fix incorrect checksum issue for extended table
Hi ChenChen Thanks! Do you think we also need fix IntelSiliconPkg\Feature\Capsule\MicrocodeUpdateDxe? Thank you Yao Jiewen > -Original Message- > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of > Chen A Chen > Sent: Monday, February 18, 2019 1:54 PM > To: edk2-devel@lists.01.org > Cc: Dong, Eric > Subject: [edk2] [PATCH] UefiCpuPkg/Microcode: Fix incorrect checksum > issue for extended table > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1020 > > The following Microcode payload format is define in SDM spec. > Payload: > |MicrocodeHeader|MicrocodeBinary|ExtendedHeader|ExtendedTable|. > When we verify the CheckSum32 with ExtendedTable, we should use the > fields > of ExtendedTable to replace corresponding fields in MicrocodeHeader, > and then calculate the CheckSum32 with > MicrocodeHeader+MicrocodeBinary. > This patch already verified on ICL platform. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Chen A Chen > Cc: Ray Ni > Cc: Eric Dong > --- > UefiCpuPkg/Library/MpInitLib/Microcode.c | 38 > > 1 file changed, 29 insertions(+), 9 deletions(-) > > diff --git a/UefiCpuPkg/Library/MpInitLib/Microcode.c > b/UefiCpuPkg/Library/MpInitLib/Microcode.c > index d84344c6f5..38880cdbec 100644 > --- a/UefiCpuPkg/Library/MpInitLib/Microcode.c > +++ b/UefiCpuPkg/Library/MpInitLib/Microcode.c > @@ -57,6 +57,7 @@ MicrocodeDetect ( >UINT32 LatestRevision; >UINTN TotalSize; >UINT32 CheckSum32; > + UINT32 > InCompleteCheckSum32; >BOOLEAN CorrectMicrocode; >VOID*MicrocodeData; >MSR_IA32_PLATFORM_ID_REGISTER PlatformIdMsr; > @@ -121,6 +122,26 @@ MicrocodeDetect ( >MicrocodeData = NULL; >MicrocodeEnd = (UINTN) (CpuMpData->MicrocodePatchAddress + > CpuMpData->MicrocodePatchRegionSize); >MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (UINTN) > CpuMpData->MicrocodePatchAddress; > + > + // > + // To avoid double calculate checksum32 value. > + // Save the CheckSum32 of the common parts in advance. > + // > + if (MicrocodeEntryPoint->DataSize == 0) { > +InCompleteCheckSum32 = CalculateSum32 ( > + (UINT32 *) MicrocodeEntryPoint, > + sizeof (CPU_MICROCODE_HEADER) + > 2000 > + ); > + } else { > +InCompleteCheckSum32 = CalculateSum32 ( > + (UINT32 *) MicrocodeEntryPoint, > + sizeof (CPU_MICROCODE_HEADER) + > MicrocodeEntryPoint->DataSize > + ); > + } > + InCompleteCheckSum32 -= > MicrocodeEntryPoint->ProcessorSignature.Uint32; > + InCompleteCheckSum32 -= MicrocodeEntryPoint->ProcessorFlags; > + InCompleteCheckSum32 -= MicrocodeEntryPoint->Checksum; > + >do { > // > // Check if the microcode is for the Cpu and the version is newer > @@ -137,14 +158,10 @@ MicrocodeDetect ( >MicrocodeEntryPoint->UpdateRevision > LatestRevision && >(MicrocodeEntryPoint->ProcessorFlags & (1 << PlatformId)) >) { > -if (MicrocodeEntryPoint->DataSize == 0) { > - CheckSum32 = CalculateSum32 ((UINT32 *) > MicrocodeEntryPoint, 2048); > -} else { > - CheckSum32 = CalculateSum32 ( > - (UINT32 *) MicrocodeEntryPoint, > - MicrocodeEntryPoint->DataSize + sizeof > (CPU_MICROCODE_HEADER) > - ); > -} > +CheckSum32 = InCompleteCheckSum32; > +CheckSum32 += > MicrocodeEntryPoint->ProcessorSignature.Uint32; > +CheckSum32 += MicrocodeEntryPoint->ProcessorFlags; > +CheckSum32 += MicrocodeEntryPoint->Checksum; > if (CheckSum32 == 0) { >CorrectMicrocode = TRUE; >ProcessorFlags = MicrocodeEntryPoint->ProcessorFlags; > @@ -171,7 +188,10 @@ MicrocodeDetect ( >ExtendedTableCount = > ExtendedTableHeader->ExtendedSignatureCount; >ExtendedTable = > (CPU_MICROCODE_EXTENDED_TABLE *) (ExtendedTableHeader + 1); >for (Index = 0; Index < ExtendedTableCount; Index ++) { > -CheckSum32 = CalculateSum32 ((UINT32 *) > ExtendedTable, sizeof(CPU_MICROCODE_EXTENDED_TABLE)); > +CheckSum32 = InCompleteCheckSum32; > +CheckSum32 += > ExtendedTable->ProcessorSignature.Uint32; > +CheckSum32 += ExtendedTable->ProcessorFlag; > +CheckSum32 += ExtendedTable->Checksum; > if (CheckSum32 == 0) { >// >// Verify Header > -- > 2.16.2.windows.1 > > ___ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] UefiCpuPkg/Microcode: Fix incorrect checksum issue for extended table
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1020 The following Microcode payload format is define in SDM spec. Payload: |MicrocodeHeader|MicrocodeBinary|ExtendedHeader|ExtendedTable|. When we verify the CheckSum32 with ExtendedTable, we should use the fields of ExtendedTable to replace corresponding fields in MicrocodeHeader, and then calculate the CheckSum32 with MicrocodeHeader+MicrocodeBinary. This patch already verified on ICL platform. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Chen A Chen Cc: Ray Ni Cc: Eric Dong --- UefiCpuPkg/Library/MpInitLib/Microcode.c | 38 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/Microcode.c b/UefiCpuPkg/Library/MpInitLib/Microcode.c index d84344c6f5..38880cdbec 100644 --- a/UefiCpuPkg/Library/MpInitLib/Microcode.c +++ b/UefiCpuPkg/Library/MpInitLib/Microcode.c @@ -57,6 +57,7 @@ MicrocodeDetect ( UINT32 LatestRevision; UINTN TotalSize; UINT32 CheckSum32; + UINT32 InCompleteCheckSum32; BOOLEAN CorrectMicrocode; VOID*MicrocodeData; MSR_IA32_PLATFORM_ID_REGISTER PlatformIdMsr; @@ -121,6 +122,26 @@ MicrocodeDetect ( MicrocodeData = NULL; MicrocodeEnd = (UINTN) (CpuMpData->MicrocodePatchAddress + CpuMpData->MicrocodePatchRegionSize); MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (UINTN) CpuMpData->MicrocodePatchAddress; + + // + // To avoid double calculate checksum32 value. + // Save the CheckSum32 of the common parts in advance. + // + if (MicrocodeEntryPoint->DataSize == 0) { +InCompleteCheckSum32 = CalculateSum32 ( + (UINT32 *) MicrocodeEntryPoint, + sizeof (CPU_MICROCODE_HEADER) + 2000 + ); + } else { +InCompleteCheckSum32 = CalculateSum32 ( + (UINT32 *) MicrocodeEntryPoint, + sizeof (CPU_MICROCODE_HEADER) + MicrocodeEntryPoint->DataSize + ); + } + InCompleteCheckSum32 -= MicrocodeEntryPoint->ProcessorSignature.Uint32; + InCompleteCheckSum32 -= MicrocodeEntryPoint->ProcessorFlags; + InCompleteCheckSum32 -= MicrocodeEntryPoint->Checksum; + do { // // Check if the microcode is for the Cpu and the version is newer @@ -137,14 +158,10 @@ MicrocodeDetect ( MicrocodeEntryPoint->UpdateRevision > LatestRevision && (MicrocodeEntryPoint->ProcessorFlags & (1 << PlatformId)) ) { -if (MicrocodeEntryPoint->DataSize == 0) { - CheckSum32 = CalculateSum32 ((UINT32 *) MicrocodeEntryPoint, 2048); -} else { - CheckSum32 = CalculateSum32 ( - (UINT32 *) MicrocodeEntryPoint, - MicrocodeEntryPoint->DataSize + sizeof (CPU_MICROCODE_HEADER) - ); -} +CheckSum32 = InCompleteCheckSum32; +CheckSum32 += MicrocodeEntryPoint->ProcessorSignature.Uint32; +CheckSum32 += MicrocodeEntryPoint->ProcessorFlags; +CheckSum32 += MicrocodeEntryPoint->Checksum; if (CheckSum32 == 0) { CorrectMicrocode = TRUE; ProcessorFlags = MicrocodeEntryPoint->ProcessorFlags; @@ -171,7 +188,10 @@ MicrocodeDetect ( ExtendedTableCount = ExtendedTableHeader->ExtendedSignatureCount; ExtendedTable = (CPU_MICROCODE_EXTENDED_TABLE *) (ExtendedTableHeader + 1); for (Index = 0; Index < ExtendedTableCount; Index ++) { -CheckSum32 = CalculateSum32 ((UINT32 *) ExtendedTable, sizeof(CPU_MICROCODE_EXTENDED_TABLE)); +CheckSum32 = InCompleteCheckSum32; +CheckSum32 += ExtendedTable->ProcessorSignature.Uint32; +CheckSum32 += ExtendedTable->ProcessorFlag; +CheckSum32 += ExtendedTable->Checksum; if (CheckSum32 == 0) { // // Verify Header -- 2.16.2.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] MdeModulePkg[MdePkg]: Add a new API EfiResetSystem()
Zhichao: Based on BZ description, new API should be ResetSystem(). Please clarify it with BZ submitter. Thanks Liming >-Original Message- >From: Gao, Zhichao >Sent: Monday, February 18, 2019 11:17 AM >To: edk2-devel@lists.01.org >Cc: Ni, Ray ; Gao, Liming >Subject: [PATCH] MdeModulePkg[MdePkg]: Add a new API EfiResetSystem() > >BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1460 >Add a new API EfiReesetSystem(): >VOID >EFIAPI >EfiResetSystem ( > IN EFI_RESET_TYPE ResetType, > IN EFI_STATUS ResetStatus, > IN UINTNDataSize, > IN VOID *ResetData OPTIONAL > ) >The Consumer of ResetSystemLib can use this new API to reset >system with additional reset data. >Because RuntimeLib has the same API name, change RuntimeLib >API's name from EfiResetSystem to EfiRuntimeResetSystem. And >change the related callings such as CapsuleRuntimeDxe. > >Contributed-under: TianoCore Contribution Agreement 1.1 >Signed-off-by: Zhichao Gao >Cc: Ray Ni >Cc: Liming Gao >--- > MdeModulePkg/Include/Library/ResetSystemLib.h | 25 >++- > .../Library/DxeResetSystemLib/DxeResetSystemLib.c | 28 >+- > .../Library/PeiResetSystemLib/PeiResetSystemLib.c | 28 >+- > .../Universal/CapsuleRuntimeDxe/CapsuleService.c | 4 ++-- > MdePkg/Include/Library/UefiRuntimeLib.h| 6 ++--- > MdePkg/Library/UefiRuntimeLib/RuntimeLib.c | 6 ++--- > 6 files changed, 86 insertions(+), 11 deletions(-) > >diff --git a/MdeModulePkg/Include/Library/ResetSystemLib.h >b/MdeModulePkg/Include/Library/ResetSystemLib.h >index 55d1923ae1..c2aebd1c3a 100644 >--- a/MdeModulePkg/Include/Library/ResetSystemLib.h >+++ b/MdeModulePkg/Include/Library/ResetSystemLib.h >@@ -2,7 +2,7 @@ > System reset Library Services. This library class defines a set of > methods that reset the whole system. > >-Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. >+Copyright (c) 2005 - 2019, Intel Corporation. All rights reserved. > This program and the accompanying materials are licensed and made >available under > the terms and conditions of the BSD License that accompanies this >distribution. > The full text of the license may be found at >@@ -83,4 +83,27 @@ ResetPlatformSpecific ( > IN VOID*ResetData > ); > >+/** >+ The EfiResetSystem function resets the entire platform. >+ >+ @param[in] ResetType The type of reset to perform. >+ @param[in] ResetStatusThe status code for the reset. >+ @param[in] DataSize The size, in bytes, of ResetData. >+ @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, >or EfiResetShutdown >+the data buffer starts with a Null-terminated >string, optionally >+followed by additional binary data. The string is >a description >+that the caller may use to further indicate the >reason for the >+system reset. ResetData is only valid if >ResetStatus is >something >+other than EFI_SUCCESS unless the ResetType is >EfiResetPlatformSpecific >+where a minimum amount of ResetData is always >required. >+**/ >+VOID >+EFIAPI >+EfiResetSystem ( >+ IN EFI_RESET_TYPE ResetType, >+ IN EFI_STATUS ResetStatus, >+ IN UINTNDataSize, >+ IN VOID *ResetData OPTIONAL >+ ); >+ > #endif >diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c >b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c >index ea4878cab1..71c05e47dc 100644 >--- a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c >+++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c >@@ -1,7 +1,7 @@ > /** @file > DXE Reset System Library instance that calls gRT->ResetSystem(). > >- Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved. >+ Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved. > This program and the accompanying materials > are licensed and made available under the terms and conditions of the BSD >License > which accompanies this distribution. The full text of the license may be >found at >@@ -96,3 +96,29 @@ ResetPlatformSpecific ( > { > gRT->ResetSystem (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, >ResetData); > } >+ >+/** >+ The EfiResetSystem function resets the entire platform. >+ >+ @param[in] ResetType The type of reset to perform. >+ @param[in] ResetStatusThe status code for the reset. >+ @param[in] DataSize The size, in bytes, of ResetData. >+ @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, >or EfiResetShutdown >+the data buffer starts with a Null-terminated >string, optionally >+followed by additional binary data. The string is >a
[edk2] [PATCH 00/10] Fix PEI Core issue during TemporaryRamMigration
https://github.com/jljusten/edk2.git temp-ram-support This series fixes an issue that, while rare, is possible based on the way the TemporaryRamSupport PPI is defined along with how it is used by the PEI Core. Liu Yu reported a boot issue with EmulatorPkg, which I believe was caused by this issue. The details of the issue are described in the commit message of the "MdeModePkg/Core/Pei: Add code path to allow assembly temp-ram migration" patch. Along with this, I added a few Temporary RAM patches for EmulatorPkg and OvmfPkg. Cc: Liu Yu Cc: Andrew Fish Cc: Anthony Perard Cc: Ard Biesheuvel Cc: Hao Wu Cc: Jian J Wang Cc: Julien Grall Cc: Laszlo Ersek Cc: Ray Ni Cc: Star Zeng Jordan Justen (10): EmulatorPkg/build.sh: Fix missing usage of -b BUILDTARGET parameter EmulatorPkg/Unix/Host: Use PcdInitValueInTempStack to init temp-ram EmulatorPkg/Sec: Replace assembly temp-ram support with C code EmulatorPkg/Sec: Disable optimizations for TemporaryRamMigration function OvmfPkg/Sec: Swap TemporaryRam Stack and Heap locations OvmfPkg/Sec: Disable optimizations for TemporaryRamMigration MdeModePkg/Core/Pei: Add code path to allow assembly temp-ram migration MdeModulePkg/Core/Pei: Use assembly for X64 TemporaryRamMigration MdeModulePkg/Core/Pei: Use assembly for IA32 TemporaryRamMigration OvmfPkg/Sec: Fill Temp Ram after TemporaryRamMigration EmulatorPkg/Sec/Ia32/SwitchRam.S | 95 --- EmulatorPkg/Sec/Ia32/SwitchRam.asm| 94 -- EmulatorPkg/Sec/Ia32/TempRam.c| 65 - EmulatorPkg/Sec/Sec.c | 76 ++- EmulatorPkg/Sec/Sec.inf | 13 +-- EmulatorPkg/Sec/X64/SwitchRam.S | 72 -- EmulatorPkg/Sec/X64/SwitchRam.asm | 76 --- EmulatorPkg/Unix/Host/Host.c | 2 +- EmulatorPkg/Unix/Host/Host.inf| 1 + EmulatorPkg/build.sh | 10 +- MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 59 .../Dispatcher/Ia32/TemporaryRamMigration.S | 72 ++ .../Ia32/TemporaryRamMigration.nasm | 78 +++ .../Pei/Dispatcher/TemporaryRamMigration.c| 52 ++ .../Dispatcher/X64/TemporaryRamMigration.S| 69 ++ .../Dispatcher/X64/TemporaryRamMigration.nasm | 75 +++ MdeModulePkg/Core/Pei/PeiMain.h | 52 ++ MdeModulePkg/Core/Pei/PeiMain.inf | 14 +++ OvmfPkg/Sec/Ia32/SecEntry.nasm| 2 +- OvmfPkg/Sec/SecMain.c | 59 OvmfPkg/Sec/X64/SecEntry.nasm | 2 +- 21 files changed, 577 insertions(+), 461 deletions(-) delete mode 100644 EmulatorPkg/Sec/Ia32/SwitchRam.S delete mode 100644 EmulatorPkg/Sec/Ia32/SwitchRam.asm delete mode 100644 EmulatorPkg/Sec/Ia32/TempRam.c delete mode 100644 EmulatorPkg/Sec/X64/SwitchRam.S delete mode 100644 EmulatorPkg/Sec/X64/SwitchRam.asm create mode 100644 MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.S create mode 100644 MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.nasm create mode 100644 MdeModulePkg/Core/Pei/Dispatcher/TemporaryRamMigration.c create mode 100644 MdeModulePkg/Core/Pei/Dispatcher/X64/TemporaryRamMigration.S create mode 100644 MdeModulePkg/Core/Pei/Dispatcher/X64/TemporaryRamMigration.nasm -- 2.20.0.rc1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH 05/10] OvmfPkg/Sec: Swap TemporaryRam Stack and Heap locations
Apparently something depends on the heap being above the stack after TemporaryRamMigration. This is the opposite order that OVMF has always used for TempRam before migration to permanent ram. In 42a83e80f37c (svn r10770), Mike changed OVMF's TemporaryRamMigration to swap the locations of heap and stack during the migration. Rather than doing the swap during TemporaryRamMigration, this change causes OVMF to boot with TemporaryRam setup with heap being above the stack. Then, during TemporaryRamMigration, we can directly copy all of TemporaryRam. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Anthony Perard Cc: Julien Grall --- OvmfPkg/Sec/Ia32/SecEntry.nasm | 2 +- OvmfPkg/Sec/SecMain.c | 39 +- OvmfPkg/Sec/X64/SecEntry.nasm | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/OvmfPkg/Sec/Ia32/SecEntry.nasm b/OvmfPkg/Sec/Ia32/SecEntry.nasm index 03501969eb..61917b9eef 100644 --- a/OvmfPkg/Sec/Ia32/SecEntry.nasm +++ b/OvmfPkg/Sec/Ia32/SecEntry.nasm @@ -57,7 +57,7 @@ ASM_PFX(_ModuleEntryPoint): ; Load temporary RAM stack based on PCDs ; %define SEC_TOP_OF_STACK (FixedPcdGet32 (PcdOvmfSecPeiTempRamBase) + \ - FixedPcdGet32 (PcdOvmfSecPeiTempRamSize)) + (FixedPcdGet32 (PcdOvmfSecPeiTempRamSize) / 2)) mov eax, SEC_TOP_OF_STACK mov esp, eax nop diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c index f7fec3d8c0..46ac739862 100644 --- a/OvmfPkg/Sec/SecMain.c +++ b/OvmfPkg/Sec/SecMain.c @@ -1,7 +1,7 @@ /** @file Main SEC phase code. Transitions to PEI. - Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved. + Copyright (c) 2008 - 2019, Intel Corporation. All rights reserved. (C) Copyright 2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials @@ -779,15 +779,15 @@ SecCoreStartupWithStack ( #endif // - // |-| <-- TopOfCurrentStack - // | Stack | 32k // |-| // |Heap | 32k + // |-| <-- TopOfCurrentStack + // | Stack | 32k // |-| <-- SecCoreData.TemporaryRamBase // ASSERT ((UINTN) (PcdGet32 (PcdOvmfSecPeiTempRamBase) + - PcdGet32 (PcdOvmfSecPeiTempRamSize)) == + (PcdGet32 (PcdOvmfSecPeiTempRamSize) / 2)) == (UINTN) TopOfCurrentStack); // @@ -795,14 +795,17 @@ SecCoreStartupWithStack ( // SecCoreData.DataSize = sizeof(EFI_SEC_PEI_HAND_OFF); - SecCoreData.TemporaryRamSize = (UINTN) PcdGet32 (PcdOvmfSecPeiTempRamSize); - SecCoreData.TemporaryRamBase = (VOID*)((UINT8 *)TopOfCurrentStack - SecCoreData.TemporaryRamSize); + SecCoreData.TemporaryRamBase = +(VOID*)(UINTN) PcdGet32 (PcdOvmfSecPeiTempRamBase); + SecCoreData.TemporaryRamSize = (UINTN) PcdGet32 (PcdOvmfSecPeiTempRamSize); - SecCoreData.PeiTemporaryRamBase= SecCoreData.TemporaryRamBase; - SecCoreData.PeiTemporaryRamSize= SecCoreData.TemporaryRamSize >> 1; + SecCoreData.PeiTemporaryRamBase = +(UINT8*)(VOID*)(UINTN) PcdGet32 (PcdOvmfSecPeiTempRamBase) + +((UINTN) PcdGet32 (PcdOvmfSecPeiTempRamSize) / 2); + SecCoreData.PeiTemporaryRamSize = PcdGet32 (PcdOvmfSecPeiTempRamSize) / 2; - SecCoreData.StackBase = (UINT8 *)SecCoreData.TemporaryRamBase + SecCoreData.PeiTemporaryRamSize; - SecCoreData.StackSize = SecCoreData.TemporaryRamSize >> 1; + SecCoreData.StackBase = (VOID*)(UINTN) PcdGet32 (PcdOvmfSecPeiTempRamBase); + SecCoreData.StackSize = PcdGet32 (PcdOvmfSecPeiTempRamSize) / 2; SecCoreData.BootFirmwareVolumeBase = BootFv; SecCoreData.BootFirmwareVolumeSize = (UINTN) BootFv->FvLength; @@ -895,10 +898,10 @@ TemporaryRamMigration ( (UINT64)CopySize )); - OldHeap = (VOID*)(UINTN)TemporaryMemoryBase; + OldHeap = (VOID*)((UINTN)TemporaryMemoryBase + (CopySize >> 1)); NewHeap = (VOID*)((UINTN)PermanentMemoryBase + (CopySize >> 1)); - OldStack = (VOID*)((UINTN)TemporaryMemoryBase + (CopySize >> 1)); + OldStack = (VOID*)(UINTN)TemporaryMemoryBase; NewStack = (VOID*)(UINTN)PermanentMemoryBase; DebugAgentContext.HeapMigrateOffset = (UINTN)NewHeap - (UINTN)OldHeap; @@ -908,15 +911,13 @@ TemporaryRamMigration ( InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, (VOID *) , NULL); // - // Migrate Heap + // Migrate the whole temporary memory to permenent memory. // - CopyMem (NewHeap, OldHeap, CopySize >> 1); + CopyMem( +(VOID*)(UINTN)PermanentMemoryBase, +(VOID*)(UINTN)TemporaryMemoryBase, +CopySize); - // - // Migrate Stack - // - CopyMem (NewStack, OldStack, CopySize >> 1); - // // Rebase IDT table in permanent memory // diff --git a/OvmfPkg/Sec/X64/SecEntry.nasm b/OvmfPkg/Sec/X64/SecEntry.nasm index d76adcffd8..dd603d6eb0 100644 ---
[edk2] [PATCH 04/10] EmulatorPkg/Sec: Disable optimizations for TemporaryRamMigration function
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jordan Justen Cc: Andrew Fish Cc: Ray Ni --- EmulatorPkg/Sec/Sec.c | 12 1 file changed, 12 insertions(+) diff --git a/EmulatorPkg/Sec/Sec.c b/EmulatorPkg/Sec/Sec.c index bd61e5ac4a..7d5534cb67 100644 --- a/EmulatorPkg/Sec/Sec.c +++ b/EmulatorPkg/Sec/Sec.c @@ -41,6 +41,13 @@ EFI_PEI_PPI_DESCRIPTOR gPrivateDispatchTable[] = { } }; +#ifdef __GNUC__ +#pragma GCC push_options +#pragma GCC optimize ("O0") +#else +#pragma optimize ("", off) +#endif + EFI_STATUS EFIAPI TemporaryRamMigration ( @@ -94,6 +101,11 @@ TemporaryRamMigration ( return EFI_SUCCESS; } +#ifdef __GNUC__ +#pragma GCC pop_options +#else +#pragma optimize ("", on) +#endif /** The entry point of PE/COFF Image for the PEI Core, that has been hijacked by this -- 2.20.0.rc1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH 03/10] EmulatorPkg/Sec: Replace assembly temp-ram support with C code
OvmfPkg uses similar code based on SetJump/LongJump. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jordan Justen Cc: Andrew Fish Cc: Ray Ni --- EmulatorPkg/Sec/Ia32/SwitchRam.S | 95 -- EmulatorPkg/Sec/Ia32/SwitchRam.asm | 94 - EmulatorPkg/Sec/Ia32/TempRam.c | 65 EmulatorPkg/Sec/Sec.c | 64 +++- EmulatorPkg/Sec/Sec.inf| 13 +--- EmulatorPkg/Sec/X64/SwitchRam.S| 72 -- EmulatorPkg/Sec/X64/SwitchRam.asm | 76 7 files changed, 66 insertions(+), 413 deletions(-) delete mode 100644 EmulatorPkg/Sec/Ia32/SwitchRam.S delete mode 100644 EmulatorPkg/Sec/Ia32/SwitchRam.asm delete mode 100644 EmulatorPkg/Sec/Ia32/TempRam.c delete mode 100644 EmulatorPkg/Sec/X64/SwitchRam.S delete mode 100644 EmulatorPkg/Sec/X64/SwitchRam.asm diff --git a/EmulatorPkg/Sec/Ia32/SwitchRam.S b/EmulatorPkg/Sec/Ia32/SwitchRam.S deleted file mode 100644 index 39304daef1..00 --- a/EmulatorPkg/Sec/Ia32/SwitchRam.S +++ /dev/null @@ -1,95 +0,0 @@ -#-- -# -# Copyright (c) 2007, Intel Corporation. All rights reserved. -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http:#opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# Module Name: -# -# Stack.asm -# -# Abstract: -# -# Switch the stack from temporary memory to permenent memory. -# -#-- - - .text - - -//-- -// VOID -// EFIAPI -// SecSwitchStack ( -// UINT32 TemporaryMemoryBase, -// UINT32 PermenentMemoryBase -// )// -//-- -ASM_GLOBAL ASM_PFX(SecSwitchStack) -ASM_PFX(SecSwitchStack): -# -# Save three register: eax, ebx, ecx -# -push %eax -push %ebx -push %ecx -push %edx - -# -# !!CAUTION!! this function address's is pushed into stack after -# migration of whole temporary memory, so need save it to permenent -# memory at first! -# - -movl 20(%esp), %ebx# Save the first parameter -movl 24(%esp), %ecx# Save the second parameter - -# -# Save this function's return address into permenent memory at first. -# Then, Fixup the esp point to permenent memory -# - -movl %esp, %eax -subl %ebx, %eax -addl %ecx, %eax -movl (%esp), %edx # copy pushed register's value to permenent memory -movl %edx, (%eax) -movl 4(%esp), %edx -movl %edx, 4(%eax) -movl 8(%esp), %edx -movl %edx, 8(%eax) -movl 12(%esp), %edx -movl %edx, 12(%eax) -movl 16(%esp), %edx -movl %edx, 16(%eax) -movl %eax, %esp # From now, esp is pointed to permenent memory - -# -# Fixup the ebp point to permenent memory -# -#ifndef __APPLE__ -movl %ebp, %eax -subl %ebx, %eax -addl %ecx, %eax -movl %eax, %ebp # From now, ebp is pointed to permenent memory - -# -# Fixup callee's ebp point for PeiDispatch -# -movl (%ebp), %eax -subl %ebx, %eax -addl %ecx, %eax -movl %eax, (%ebp)# From now, Temporary's PPI caller's stack is in permenent memory -#endif - -pop %edx -pop %ecx -pop %ebx -pop %eax -ret - diff --git a/EmulatorPkg/Sec/Ia32/SwitchRam.asm b/EmulatorPkg/Sec/Ia32/SwitchRam.asm deleted file mode 100644 index 731ee0ffdb..00 --- a/EmulatorPkg/Sec/Ia32/SwitchRam.asm +++ /dev/null @@ -1,94 +0,0 @@ -;-- -; -; Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved. -; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; Stack.asm -; -; Abstract: -; -; Switch the stack from temporary memory to permenent memory. -; -;-- - -.586p -.model flat,C -.code - -;-- -; VOID -; EFIAPI -; SecSwitchStack ( -;
[edk2] [PATCH 02/10] EmulatorPkg/Unix/Host: Use PcdInitValueInTempStack to init temp-ram
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jordan Justen Cc: Andrew Fish Cc: Ray Ni --- EmulatorPkg/Unix/Host/Host.c | 2 +- EmulatorPkg/Unix/Host/Host.inf | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/EmulatorPkg/Unix/Host/Host.c b/EmulatorPkg/Unix/Host/Host.c index 9aba7c854d..2537b0427b 100644 --- a/EmulatorPkg/Unix/Host/Host.c +++ b/EmulatorPkg/Unix/Host/Host.c @@ -216,7 +216,7 @@ main ( for (StackPointer = (UINTN*) (UINTN) InitialStackMemory; StackPointer < (UINTN*)(UINTN)((UINTN) InitialStackMemory + (UINT64) InitialStackMemorySize); StackPointer ++) { -*StackPointer = 0x5AA55AA5; +*StackPointer = PcdGet32 (PcdInitValueInTempStack); } // diff --git a/EmulatorPkg/Unix/Host/Host.inf b/EmulatorPkg/Unix/Host/Host.inf index 6db269842e..9cafa7b771 100644 --- a/EmulatorPkg/Unix/Host/Host.inf +++ b/EmulatorPkg/Unix/Host/Host.inf @@ -109,6 +109,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwSpareBase gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize + gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage [FeaturePcd] -- 2.20.0.rc1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH 08/10] MdeModulePkg/Core/Pei: Use assembly for X64 TemporaryRamMigration
Some compilers may optimize register usage in ways that are incompatible with the TemporaryRamSupport PPI. Using assembly code to call the TemporaryRamMigration function prevents this issue. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jordan Justen Cc: Jian J Wang Cc: Hao Wu Cc: Ray Ni Cc: Star Zeng --- .../Dispatcher/X64/TemporaryRamMigration.S| 69 + .../Dispatcher/X64/TemporaryRamMigration.nasm | 75 +++ MdeModulePkg/Core/Pei/PeiMain.inf | 14 +++- 3 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 MdeModulePkg/Core/Pei/Dispatcher/X64/TemporaryRamMigration.S create mode 100644 MdeModulePkg/Core/Pei/Dispatcher/X64/TemporaryRamMigration.nasm diff --git a/MdeModulePkg/Core/Pei/Dispatcher/X64/TemporaryRamMigration.S b/MdeModulePkg/Core/Pei/Dispatcher/X64/TemporaryRamMigration.S new file mode 100644 index 00..cd9d902224 --- /dev/null +++ b/MdeModulePkg/Core/Pei/Dispatcher/X64/TemporaryRamMigration.S @@ -0,0 +1,69 @@ +#-- +# +# Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved. +# +# This program and the accompanying materials are licensed and made +# available under the terms and conditions of the BSD License which +# accompanies this distribution. The full text of the license may be +# found at http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" +# BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER +# EXPRESS OR IMPLIED. +# +#-- + +#-- +# VOID +# EFIAPI +# PeiTemporaryRamMigration ( +# IN PEI_CORE_TEMPORARY_RAM_TRANSITION *TempRamTransitionData +# ); +# +# @param[in] RCX Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION +# +# @return None This routine does not return +#-- +ASM_GLOBAL ASM_PFX(PeiTemporaryRamMigration) +ASM_PFX(PeiTemporaryRamMigration): + +# +# We never return from this call +# +add $8, %rsp + +# +# (rax) Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION +# +mov %rcx, %rax + +# +# We'll store the new location of TempRamTransitionData after +# migration in rbx. By the X64 calling convention we should +# normally save rbx, but we won't be returning to the caller, so +# we don't need to save it. By the same rule, the +# TemporaryRamMigration PPI call should preserve rbx for us. +# +mov %rcx, %rbx +add 0x18(%rax), %rbx +sub 0x10(%rax), %rbx + +# +# Setup parameters and call TemporaryRamSupport->TemporaryRamMigration +# (rcx) PeiServices +# (rdx) TemporaryMemoryBase +# (r8) PermanentMemoryBase +# (r9) CopySize +# +mov 0x08(%rax), %rcx +mov 0x10(%rax), %rdx +mov 0x18(%rax), %r8 +mov 0x20(%rax), %r9 +callq *(%rax) + +# +# Setup parameters and call PeiTemporaryRamMigrated +# (rcx) Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION +# +mov %rbx, %rcx +callASM_PFX(PeiTemporaryRamMigrated) diff --git a/MdeModulePkg/Core/Pei/Dispatcher/X64/TemporaryRamMigration.nasm b/MdeModulePkg/Core/Pei/Dispatcher/X64/TemporaryRamMigration.nasm new file mode 100644 index 00..2783b0f403 --- /dev/null +++ b/MdeModulePkg/Core/Pei/Dispatcher/X64/TemporaryRamMigration.nasm @@ -0,0 +1,75 @@ +;-- +; +; Copyright (c) 2018, Intel Corporation. All rights reserved. +; +; This program and the accompanying materials are licensed and made +; available under the terms and conditions of the BSD License which +; accompanies this distribution. The full text of the license may be +; found at http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" +; BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER +; EXPRESS OR IMPLIED. +; +;-- + +#include + +SECTION .text + +extern ASM_PFX(PeiTemporaryRamMigrated) + +;-- +; VOID +; EFIAPI +; PeiTemporaryRamMigration ( +; IN PEI_CORE_TEMPORARY_RAM_TRANSITION *TempRamTransitionData +; ); +; +; @param[in] RCX Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION +; +; @return None This routine does not return +;-- +global ASM_PFX(PeiTemporaryRamMigration) +ASM_PFX(PeiTemporaryRamMigration): + +; +; We never return from this call +; +add rsp, 8 + +; +; (rax) Pointer to
[edk2] [PATCH 09/10] MdeModulePkg/Core/Pei: Use assembly for IA32 TemporaryRamMigration
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jordan Justen Cc: Jian J Wang Cc: Hao Wu Cc: Ray Ni Cc: Star Zeng --- .../Dispatcher/Ia32/TemporaryRamMigration.S | 72 + .../Ia32/TemporaryRamMigration.nasm | 78 +++ MdeModulePkg/Core/Pei/PeiMain.inf | 3 +- 3 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.S create mode 100644 MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.nasm diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.S b/MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.S new file mode 100644 index 00..363cadca2a --- /dev/null +++ b/MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.S @@ -0,0 +1,72 @@ +#-- +# +# Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved. +# +# This program and the accompanying materials are licensed and made +# available under the terms and conditions of the BSD License which +# accompanies this distribution. The full text of the license may be +# found at http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" +# BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER +# EXPRESS OR IMPLIED. +# +#-- + +#-- +# VOID +# EFIAPI +# PeiTemporaryRamMigration ( +# IN PEI_CORE_TEMPORARY_RAM_TRANSITION *TempRamTransitionData +# ); +# +# @param[in] Stack Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION +# +# @return None This routine does not return +#-- +ASM_GLOBAL ASM_PFX(PeiTemporaryRamMigration) +ASM_PFX(PeiTemporaryRamMigration): + +# +# We never return from this call +# +add $4, %esp + +# +# (eax) Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION +# +mov (%esp), %eax + +# +# We'll store the new location of TempRamTransitionData after +# migration in ebx. By the IA32 calling convention we should +# normally save ebx, but we won't be returning to the caller, so +# we don't need to save it. By the same rule, the +# TemporaryRamMigration PPI call should preserve ebx for us. +# +mov (%esp), %ebx +add 0x10(%eax), %ebx +sub 0x08(%eax), %ebx + +# +# Setup parameters and call TemporaryRamSupport->TemporaryRamMigration +# 32-bit PeiServices +# 64-bit TemporaryMemoryBase +# 64-bit PermanentMemoryBase +# 32-bit CopySize +# +pushl 0x18(%eax) # CopySize +pushl 0x14(%eax) # PermanentMemoryBase Upper 32-bit +pushl 0x10(%eax) # PermanentMemoryBase Lower 32-bit +pushl 0x0c(%eax) # TemporaryMemoryBase Upper 32-bit +pushl 0x08(%eax) # TemporaryMemoryBase Lower 32-bit +pushl 0x04(%eax) # PeiServices +calll *(%eax) +sub 0x18, %esp + +# +# Setup parameters and call PeiTemporaryRamMigrated +# 32-bit Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION +# +push%ebx +callASM_PFX(PeiTemporaryRamMigrated) diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.nasm b/MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.nasm new file mode 100644 index 00..e200a3631f --- /dev/null +++ b/MdeModulePkg/Core/Pei/Dispatcher/Ia32/TemporaryRamMigration.nasm @@ -0,0 +1,78 @@ +;-- +; +; Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved. +; +; This program and the accompanying materials are licensed and made +; available under the terms and conditions of the BSD License which +; accompanies this distribution. The full text of the license may be +; found at http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" +; BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER +; EXPRESS OR IMPLIED. +; +;-- + +#include + +SECTION .text + +extern ASM_PFX(PeiTemporaryRamMigrated) + +;-- +; VOID +; EFIAPI +; PeiTemporaryRamMigration ( +; IN PEI_CORE_TEMPORARY_RAM_TRANSITION *TempRamTransitionData +; ); +; +; @param[in] Stack Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION +; +; @return None This routine does not return +;-- +global ASM_PFX(PeiTemporaryRamMigration) +ASM_PFX(PeiTemporaryRamMigration): + +; +; We never return from this call +; +add
[edk2] [PATCH 07/10] MdeModePkg/Core/Pei: Add code path to allow assembly temp-ram migration
There is potential problem with PEI Core's usage of the TemporaryRamMigration PPI. When the TemporaryRamMigration function is called, it returns to C based code after changing the stack to the new permanent memory copy of the stack. But, the C compiler may have stored pointers to addresses on the old temporary RAM stack. Even though the stack is copied to a new permanent memory location, it is not possible to adjust all pointers that the C compiler may have added within the stack data. For this reason, it is only safe to return to assembly code after calling TemporaryRamMigration. The assembly code can make sure the old temporary RAM stack is not used before calling a new C function. When the new function is called, it will use the new permanent memory stack, so it is safe to use C code again. This code adds new function named PeiTemporaryRamMigration which can be implemented in assembly code as described above. PeiTemporaryRamMigration must call the TemporaryRamMigration function, and then calls a new C PeiTemporaryRamMigrated function. This guanantees PeiTemporaryRamMigrated will only use the permanent memory stack. For now, this patch should have no effect, since it still uses C to implement PeiTemporaryRamMigration. But, PeiTemporaryRamMigration can then be changed into an assembly code function to fix the issue described above. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jordan Justen Cc: Jian J Wang Cc: Hao Wu Cc: Ray Ni Cc: Star Zeng --- MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 59 --- .../Pei/Dispatcher/TemporaryRamMigration.c| 52 MdeModulePkg/Core/Pei/PeiMain.h | 52 MdeModulePkg/Core/Pei/PeiMain.inf | 1 + 4 files changed, 143 insertions(+), 21 deletions(-) create mode 100644 MdeModulePkg/Core/Pei/Dispatcher/TemporaryRamMigration.c diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c index 68670f43e0..8e3fa161dd 100644 --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c @@ -688,6 +688,7 @@ PeiCheckAndSwitchStack ( EFI_PHYSICAL_ADDRESS TempBase2; UINTN TempSize2; UINTN Index; + PEI_CORE_TEMPORARY_RAM_TRANSITION TempRamTransitionData; PeiServices = (CONST EFI_PEI_SERVICES **) >Ps; @@ -822,30 +823,20 @@ PeiCheckAndSwitchStack ( Private = (PEI_CORE_INSTANCE *)((UINTN)(VOID *)Private - StackOffset); } - // - // Temporary Ram Support PPI is provided by platform, it will copy - // temporary memory to permanent memory and do stack switching. - // After invoking Temporary Ram Support PPI, the following code's - // stack is in permanent memory. - // - TemporaryRamSupportPpi->TemporaryRamMigration ( -PeiServices, -TemporaryRamBase, -(EFI_PHYSICAL_ADDRESS)(UINTN)(TopOfNewStack - TemporaryStackSize), -TemporaryRamSize -); - - // - // Migrate memory pages allocated in pre-memory phase. - // It could not be called before calling TemporaryRamSupportPpi->TemporaryRamMigration() - // as the migrated memory pages may be overridden by TemporaryRamSupportPpi->TemporaryRamMigration(). - // - MigrateMemoryPages (Private, TRUE); + TempRamTransitionData.TemporaryRamMigration = +TemporaryRamSupportPpi->TemporaryRamMigration; + TempRamTransitionData.PeiServices = PeiServices; + TempRamTransitionData.TemporaryMemoryBase = TemporaryRamBase; + TempRamTransitionData.PermanentMemoryBase = +(EFI_PHYSICAL_ADDRESS)(UINTN)(TopOfNewStack - TemporaryStackSize); + TempRamTransitionData.CopySize = TemporaryRamSize; + TempRamTransitionData.Private = Private; + TempRamTransitionData.SecCoreData = SecCoreData; // - // Entry PEI Phase 2 + // Migrate Temporary RAM and enter PEI Phase 2 // - PeiCore (SecCoreData, NULL, Private); + PeiTemporaryRamMigration(); } else { // // Migrate memory pages allocated in pre-memory phase. @@ -958,6 +949,32 @@ PeiCheckAndSwitchStack ( } } +VOID +EFIAPI +PeiTemporaryRamMigrated ( + IN VOID *CallbackContext + ) +{ + PEI_CORE_TEMPORARY_RAM_TRANSITION *TempRamTransitionData = +(PEI_CORE_TEMPORARY_RAM_TRANSITION*)CallbackContext; + + // + // Migrate memory pages allocated in pre-memory phase. + // It could not be called before calling TemporaryRamSupportPpi->TemporaryRamMigration() + // as the migrated memory pages may be overridden by TemporaryRamSupportPpi->TemporaryRamMigration(). + // + MigrateMemoryPages (TempRamTransitionData->Private, TRUE); + + // + // Entry PEI Phase 2 + // + PeiCore ( +
[edk2] [PATCH 06/10] OvmfPkg/Sec: Disable optimizations for TemporaryRamMigration
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Anthony Perard Cc: Julien Grall --- OvmfPkg/Sec/SecMain.c | 12 1 file changed, 12 insertions(+) diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c index 46ac739862..86c22a2ac9 100644 --- a/OvmfPkg/Sec/SecMain.c +++ b/OvmfPkg/Sec/SecMain.c @@ -873,6 +873,13 @@ SecStartupPhase2( CpuDeadLoop (); } +#ifdef __GNUC__ +#pragma GCC push_options +#pragma GCC optimize ("O0") +#else +#pragma optimize ("", off) +#endif + EFI_STATUS EFIAPI TemporaryRamMigration ( @@ -946,3 +953,8 @@ TemporaryRamMigration ( return EFI_SUCCESS; } +#ifdef __GNUC__ +#pragma GCC pop_options +#else +#pragma optimize ("", on) +#endif -- 2.20.0.rc1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH 10/10] OvmfPkg/Sec: Fill Temp Ram after TemporaryRamMigration
On some platforms, the TemporaryRamMigration PPI may cause Temporary RAM to become inaccessible after the RAM is migrated. To emulate this in OVMF, we should initialize memory to a bad state to make sure it isn't accidentally being used after TemporaryRamMigration is called. I tested IA32 booting to shell and X64 booting to OS with this change. With X64 I also tested S3 suspend/resume. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Anthony Perard Cc: Julien Grall --- OvmfPkg/Sec/SecMain.c | 8 1 file changed, 8 insertions(+) diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c index 86c22a2ac9..72946e0eab 100644 --- a/OvmfPkg/Sec/SecMain.c +++ b/OvmfPkg/Sec/SecMain.c @@ -948,6 +948,14 @@ TemporaryRamMigration ( LongJump (, (UINTN)-1); } + // + // Initialize Temporary RAM to a bad value to make sure it will not + // be used after migration. + // + SetMem32 ( +(VOID*)(UINTN)TemporaryMemoryBase, CopySize, +PcdGet32 (PcdInitValueInTempStack)); + SaveAndSetDebugTimerInterrupt (OldStatus); return EFI_SUCCESS; -- 2.20.0.rc1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH 01/10] EmulatorPkg/build.sh: Fix missing usage of -b BUILDTARGET parameter
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jordan Justen Cc: Andrew Fish Cc: Ray Ni --- EmulatorPkg/build.sh | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/EmulatorPkg/build.sh b/EmulatorPkg/build.sh index 2ddcd4..2af6b5f998 100755 --- a/EmulatorPkg/build.sh +++ b/EmulatorPkg/build.sh @@ -1,7 +1,7 @@ #!/bin/bash # # Copyright (c) 2008 - 2011, Apple Inc. All rights reserved. -# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved. +# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. # # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -194,7 +194,7 @@ do done PLATFORMFILE=$WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -BUILD_DIR=$BUILD_OUTPUT_DIR/DEBUG_"$TARGET_TOOLS" +BUILD_DIR=$BUILD_OUTPUT_DIR/"$BUILDTARGET"_"$TARGET_TOOLS" BUILD_ROOT_ARCH=$BUILD_DIR/$PROCESSOR if [[ ! -f `which build` || ! -f `which GenFv` ]]; @@ -224,11 +224,11 @@ if [[ "$RUN_EMULATOR" == "yes" ]]; then then # only older versions of Xcode support -ccc-host-tripe, for newer versions # it is -target -cp $WORKSPACE/EmulatorPkg/Unix/lldbefi.py $BUILD_OUTPUT_DIR/DEBUG_"$TARGET_TOOLS"/$PROCESSOR +cp $WORKSPACE/EmulatorPkg/Unix/lldbefi.py $BUILD_OUTPUT_DIR/"$BUILDTARGET"_"$TARGET_TOOLS"/$PROCESSOR cd $BUILD_ROOT_ARCH; /usr/bin/lldb --source $WORKSPACE/EmulatorPkg/Unix/lldbinit Host exit $? else -cp $WORKSPACE/EmulatorPkg/Unix/.gdbinit $BUILD_OUTPUT_DIR/DEBUG_"$TARGET_TOOLS"/$PROCESSOR +cp $WORKSPACE/EmulatorPkg/Unix/.gdbinit $BUILD_OUTPUT_DIR/"$BUILDTARGET"_"$TARGET_TOOLS"/$PROCESSOR fi ;; esac @@ -261,7 +261,7 @@ if [[ $HOST_TOOLS == $TARGET_TOOLS ]]; then else build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc $BUILD_OPTIONS -a $PROCESSOR -b $BUILDTARGET -t $HOST_TOOLS -D BUILD_$ARCH_SIZE -D UNIX_SEC_BUILD -D SKIP_MAIN_BUILD -n 3 modules build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc $BUILD_OPTIONS -a $PROCESSOR -b $BUILDTARGET -t $TARGET_TOOLS -D BUILD_$ARCH_SIZE $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3 - cp $BUILD_OUTPUT_DIR/DEBUG_"$HOST_TOOLS"/$PROCESSOR/Host $BUILD_ROOT_ARCH + cp $BUILD_OUTPUT_DIR/"$BUILDTARGET"_"$HOST_TOOLS"/$PROCESSOR/Host $BUILD_ROOT_ARCH fi exit $? -- 2.20.0.rc1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] MdeModulePkg[MdePkg]: Add a new API EfiResetSystem()
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1460 Add a new API EfiReesetSystem(): VOID EFIAPI EfiResetSystem ( IN EFI_RESET_TYPE ResetType, IN EFI_STATUS ResetStatus, IN UINTNDataSize, IN VOID *ResetData OPTIONAL ) The Consumer of ResetSystemLib can use this new API to reset system with additional reset data. Because RuntimeLib has the same API name, change RuntimeLib API's name from EfiResetSystem to EfiRuntimeResetSystem. And change the related callings such as CapsuleRuntimeDxe. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhichao Gao Cc: Ray Ni Cc: Liming Gao --- MdeModulePkg/Include/Library/ResetSystemLib.h | 25 ++- .../Library/DxeResetSystemLib/DxeResetSystemLib.c | 28 +- .../Library/PeiResetSystemLib/PeiResetSystemLib.c | 28 +- .../Universal/CapsuleRuntimeDxe/CapsuleService.c | 4 ++-- MdePkg/Include/Library/UefiRuntimeLib.h| 6 ++--- MdePkg/Library/UefiRuntimeLib/RuntimeLib.c | 6 ++--- 6 files changed, 86 insertions(+), 11 deletions(-) diff --git a/MdeModulePkg/Include/Library/ResetSystemLib.h b/MdeModulePkg/Include/Library/ResetSystemLib.h index 55d1923ae1..c2aebd1c3a 100644 --- a/MdeModulePkg/Include/Library/ResetSystemLib.h +++ b/MdeModulePkg/Include/Library/ResetSystemLib.h @@ -2,7 +2,7 @@ System reset Library Services. This library class defines a set of methods that reset the whole system. -Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. +Copyright (c) 2005 - 2019, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at @@ -83,4 +83,27 @@ ResetPlatformSpecific ( IN VOID*ResetData ); +/** + The EfiResetSystem function resets the entire platform. + + @param[in] ResetType The type of reset to perform. + @param[in] ResetStatusThe status code for the reset. + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown +the data buffer starts with a Null-terminated string, optionally +followed by additional binary data. The string is a description +that the caller may use to further indicate the reason for the +system reset. ResetData is only valid if ResetStatus is something +other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific +where a minimum amount of ResetData is always required. +**/ +VOID +EFIAPI +EfiResetSystem ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTNDataSize, + IN VOID *ResetData OPTIONAL + ); + #endif diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c index ea4878cab1..71c05e47dc 100644 --- a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c +++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c @@ -1,7 +1,7 @@ /** @file DXE Reset System Library instance that calls gRT->ResetSystem(). - Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved. + Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -96,3 +96,29 @@ ResetPlatformSpecific ( { gRT->ResetSystem (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, ResetData); } + +/** + The EfiResetSystem function resets the entire platform. + + @param[in] ResetType The type of reset to perform. + @param[in] ResetStatusThe status code for the reset. + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown +the data buffer starts with a Null-terminated string, optionally +followed by additional binary data. The string is a description +that the caller may use to further indicate the reason for the +system reset. ResetData is only valid if ResetStatus is something +other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific +where a minimum amount of ResetData is always required. +**/ +VOID +EFIAPI +EfiResetSystem ( + IN EFI_RESET_TYPE
Re: [edk2] [PATCH v5 07/13] MdeModulePkg/NvmExpressPei: Consume S3StorageDeviceInitList LockBox
Hi Hao, > -Original Message- > From: Wu, Hao A > Sent: Friday, February 15, 2019 2:24 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Wang, Jian J ; > Ni, Ray ; Dong, Eric > Subject: [PATCH v5 07/13] MdeModulePkg/NvmExpressPei: Consume > S3StorageDeviceInitList LockBox > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409 > > For the NvmExpressPei driver, this commit will update the driver to consume > the S3StorageDeviceInitList LockBox in S3 phase. The purpose is to perform > an on-demand (partial) NVM Express device enumeration/initialization to > benefit the S3 resume performance. > > Cc: Jian J Wang > Cc: Ray Ni > Cc: Eric Dong > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Hao Wu > --- > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf | 8 +- > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h | 36 +++ > MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c | 53 + > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c | 20 > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c | 114 > > 5 files changed, 230 insertions(+), 1 deletion(-) > > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > index 0666e5892b..22b703e971 100644 > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > @@ -40,6 +40,7 @@ >NvmExpressPeiHci.h >NvmExpressPeiPassThru.c >NvmExpressPeiPassThru.h > + NvmExpressPeiS3.c >NvmExpressPeiStorageSecurity.c >NvmExpressPeiStorageSecurity.h > > @@ -54,6 +55,7 @@ >BaseMemoryLib >IoLib >TimerLib > + LockBoxLib >PeimEntryPoint > > [Ppis] > @@ -64,9 +66,13 @@ >gEfiPeiVirtualBlockIo2PpiGuid ## SOMETIMES_PRODUCES >gEdkiiPeiStorageSecurityCommandPpiGuid ## SOMETIMES_PRODUCES > > +[Guids] > + gS3StorageDeviceInitListGuid ## SOMETIMES_CONSUMES ## > UNDEFINED > + > [Depex] >gEfiPeiMemoryDiscoveredPpiGuid AND > - gEdkiiPeiNvmExpressHostControllerPpiGuid > + gEdkiiPeiNvmExpressHostControllerPpiGuid AND > + gEfiPeiMasterBootModePpiGuid > > [UserExtensions.TianoCore."ExtraFiles"] >NvmExpressPeiExtra.uni > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > index 92c3854c6e..e2a693abe8 100644 > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > @@ -267,6 +267,26 @@ NvmePeimEndOfPei ( >); > > /** > + Get the size of the current device path instance. > + > + @param[in] DevicePath A pointer to the > EFI_DEVICE_PATH_PROTOCOL > + structure. > + @param[out] InstanceSize The size of the current device path > instance. > + @param[out] EntireDevicePathEndIndicate whether the instance is the > last > + one in the device path strucure. > + > + @retval EFI_SUCCESSThe size of the current device path instance is > fetched. > + @retval Others Fails to get the size of the current device path > instance. > + > +**/ > +EFI_STATUS > +GetDevicePathInstanceSize ( > + IN EFI_DEVICE_PATH_PROTOCOL*DevicePath, > + OUT UINTN *InstanceSize, > + OUT BOOLEAN *EntireDevicePathEnd > + ); > + > +/** >Check the validity of the device path of a NVM Express host controller. > >@param[in] DevicePath A pointer to the EFI_DEVICE_PATH_PROTOCOL > @@ -309,4 +329,20 @@ NvmeBuildDevicePath ( >OUT EFI_DEVICE_PATH_PROTOCOL**DevicePath >); > > +/** > + Determine if a specific NVM Express controller can be skipped for S3 phase. > + > + @param[in] HcDevicePath Device path of the controller. > + @param[in] HcDevicePathLengthLength of the device path specified by > +HcDevicePath. > + > + @retvalThe number of ports that need to be enumerated. > + > +**/ > +BOOLEAN > +NvmeS3SkipThisController ( > + IN EFI_DEVICE_PATH_PROTOCOL*HcDevicePath, > + IN UINTN HcDevicePathLength > + ); > + > #endif > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c > b/MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c > index 5dab447f09..ed05d7a2be 100644 > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c > @@ -89,6 +89,59 @@ NextDevicePathNode ( > } > > /** > + Get the size of the current device path instance. > + > + @param[in] DevicePath A pointer to the > EFI_DEVICE_PATH_PROTOCOL > + structure. > + @param[out] InstanceSize The size of the current device path > instance. > + @param[out] EntireDevicePathEndIndicate whether the instance is the > last > +
Re: [edk2] [PATCH v5 06/13] MdeModulePkg/NvmExpressPei: Add logic to produce SSC PPI
Hi Hao, > -Original Message- > From: Wu, Hao A > Sent: Friday, February 15, 2019 2:24 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Wang, Jian J ; > Ni, Ray ; Dong, Eric > Subject: [PATCH v5 06/13] MdeModulePkg/NvmExpressPei: Add logic to > produce SSC PPI > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409 > > For the NvmExpressPei driver, this commit will add codes to produce the > Storage Security Command PPI if the underlying NVM Express controller > supports the Security Send and Security Receive commands. > > Cc: Jian J Wang > Cc: Ray Ni > Cc: Eric Dong > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Hao Wu > --- > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf | 10 +- > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h| 58 ++- > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.h | 20 +- > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiStorageSecurity.h > | 247 > MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c | 231 > +++ > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c| 143 > +-- > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.c | 32 +- > MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiStorageSecurity.c > | 423 > 8 files changed, 1075 insertions(+), 89 deletions(-) > > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > index 9591572fec..0666e5892b 100644 > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf > @@ -2,7 +2,7 @@ > # The NvmExpressPei driver is used to manage non-volatile memory > subsystem > # which follows NVM Express specification at PEI phase. > # > -# Copyright (c) 2018, Intel Corporation. All rights reserved. > +# Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved. > # > # This program and the accompanying materials > # are licensed and made available under the terms and conditions of the > BSD License > @@ -30,6 +30,7 @@ > # > > [Sources] > + DevicePath.c >DmaMem.c >NvmExpressPei.c >NvmExpressPei.h > @@ -39,6 +40,8 @@ >NvmExpressPeiHci.h >NvmExpressPeiPassThru.c >NvmExpressPeiPassThru.h > + NvmExpressPeiStorageSecurity.c > + NvmExpressPeiStorageSecurity.h > > [Packages] >MdePkg/MdePkg.dec > @@ -54,11 +57,12 @@ >PeimEntryPoint > > [Ppis] > - gEfiPeiVirtualBlockIoPpiGuid ## PRODUCES > - gEfiPeiVirtualBlockIo2PpiGuid ## PRODUCES >gEdkiiPeiNvmExpressHostControllerPpiGuid ## CONSUMES >gEdkiiIoMmuPpiGuid ## CONSUMES >gEfiEndOfPeiSignalPpiGuid ## CONSUMES > + gEfiPeiVirtualBlockIoPpiGuid ## SOMETIMES_PRODUCES > + gEfiPeiVirtualBlockIo2PpiGuid ## SOMETIMES_PRODUCES > + gEdkiiPeiStorageSecurityCommandPpiGuid ## > SOMETIMES_PRODUCES > > [Depex] >gEfiPeiMemoryDiscoveredPpiGuid AND > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > index 0135eca6f0..92c3854c6e 100644 > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h > @@ -25,6 +25,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -44,6 +45,7 @@ typedef struct > _PEI_NVME_CONTROLLER_PRIVATE_DATA > PEI_NVME_CONTROLLER_PRIVATE_DA > #include "NvmExpressPeiHci.h" > #include "NvmExpressPeiPassThru.h" > #include "NvmExpressPeiBlockIo.h" > +#include "NvmExpressPeiStorageSecurity.h" > > // > // NVME PEI driver implementation related definitions > @@ -90,10 +92,15 @@ struct _PEI_NVME_NAMESPACE_INFO { > struct _PEI_NVME_CONTROLLER_PRIVATE_DATA { >UINT32Signature; >UINTN MmioBase; > + UINTN DevicePathLength; > + EFI_DEVICE_PATH_PROTOCOL *DevicePath; > + >EFI_PEI_RECOVERY_BLOCK_IO_PPI BlkIoPpi; >EFI_PEI_RECOVERY_BLOCK_IO2_PPIBlkIo2Ppi; > + EDKII_PEI_STORAGE_SECURITY_CMD_PPIStorageSecurityPpi; >EFI_PEI_PPI_DESCRIPTORBlkIoPpiList; >EFI_PEI_PPI_DESCRIPTORBlkIo2PpiList; > + EFI_PEI_PPI_DESCRIPTORStorageSecurityPpiList; >EFI_PEI_NOTIFY_DESCRIPTOR EndOfPeiNotifyList; > >// > @@ -139,11 +146,13 @@ struct _PEI_NVME_CONTROLLER_PRIVATE_DATA { >PEI_NVME_NAMESPACE_INFO *NamespaceInfo; > }; > > -#define GET_NVME_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO(a) \ > +#define GET_NVME_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO(a) > \ >CR (a, PEI_NVME_CONTROLLER_PRIVATE_DATA, BlkIoPpi, >
Re: [edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Use 16/32-bit IO widths
Hello Jeff, Sorry for the delayed response. I have verified your patch with the board on my side and it is working fine. And I saw around 3~4 milliseconds performance boost. So I think the patch will bring performance benefit to the driver. Some minor inline comments below: From: Jeff Brasen [mailto:jbra...@nvidia.com] Sent: Saturday, February 02, 2019 1:53 AM To: Wu, Hao A; edk2-devel@lists.01.org Cc: Edgar Handal Subject: Re: [edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Use 16/32-bit IO widths From: Wu, Hao A Sent: Friday, February 1, 2019 12:54 AM To: Jeff Brasen; edk2-devel@lists.01.org Cc: Edgar Handal Subject: RE: [edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Use 16/32-bit IO widths > -Original Message- > From: Jeff Brasen [mailto:jbra...@nvidia.com] > Sent: Friday, February 01, 2019 3:12 PM > To: Wu, Hao A; edk2-devel@lists.01.org > Cc: Edgar Handal > Subject: RE: [edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Use 16/32-bit IO > widths > > > > -Original Message- > From: Wu, Hao A > Sent: Thursday, January 31, 2019 10:56 PM > To: Jeff Brasen ; edk2-devel@lists.01.org > Cc: Edgar Handal > Subject: RE: [edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Use 16/32-bit IO > widths > > > -Original Message- > > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of > > Jeff Brasen > > Sent: Thursday, January 31, 2019 7:59 AM > > To: edk2-devel@lists.01.org > > Cc: Edgar Handal; Jeff Brasen > > Subject: [edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Use 16/32-bit IO > > widths > > Could you help to file a Bugzilla tracker to state the purpose of this patch and make a reference in the commit log message here? Thanks. > > From: Edgar Handal > > > > Use 16-bit and 32-bit IO widths for SDMMC MMIO to prevent all register > > accesses from being split up into 8-bit accesses. > > > > The SDHCI specification states that the registers shall be accessable > > in byte, word, and double word accesses. 'accessable' -> 'accessible'. Also, could you help to quote the detailed context from the SD HCI spec for the above statement? Lastly, could you help to add your performance evaluation data in the commit log message as well? With the above 3 minor comments handled: Reviewed-by: Hao Wu Best Regards, Hao Wu > > Hi, > > Thanks for the contribution. The change seems good to me. > > Just curious, if the accesses are always slit into byte(8-bit), is there any > issue or > performance impact is encountered during your usage? > > It will be helpful to get more information on the purpose of the patch. > Thanks. > > Best Regards, > Hao Wu > > [JMB] We were working with a simulation module that has some issues when > accessing 16 or 32 bit registers by byte (This should be supported per the > SDHCI > specification.), and this patch resolves this while we work on getting the > model > fixed. This should also optimize performance as there will less read/write > instructions (My guess is this is a marginal improvement as most of the SD > access time would be DMA operations.) Thanks Jeff, Got it. May I know is it possible for you to collect some performance data for the change? [JMB] Sure, did a several boots on silicon platform and see an average boot time improvement of 15ms. With a range of 10-20ms and never saw the performance get worse. Meanwhile, I will test this patch with the boards I own and try to collect some data. Please grant me some time for this. Since the current implementation does not violate the spec, let us evaluate whether better performance will be brought. Best Regards, Hao Wu > > Thanks, > Jeff > > > > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Jeff Brasen > > --- > > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 25 > > > > 1 file changed, 21 insertions(+), 4 deletions(-) > > > > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c > > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c > > index 5aec8c6..82f4493 100644 > > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c > > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c > > @@ -152,19 +152,36 @@ SdMmcHcRwMmio ( > >) > > { > >EFI_STATUS Status; > > + EFI_PCI_IO_PROTOCOL_WIDTHWidth; > > > >if ((PciIo == NULL) || (Data == NULL)) { > > return EFI_INVALID_PARAMETER; > >} > > > > - if ((Count != 1) && (Count != 2) && (Count != 4) && (Count != 8)) { > > -return EFI_INVALID_PARAMETER; > > + switch (Count) { > > +case 1: > > + Width = EfiPciIoWidthUint8; > > + break; > > +case 2: > > + Width = EfiPciIoWidthUint16; > > + Count = 1; > > + break; > > +case 4: > > + Width = EfiPciIoWidthUint32; > > + Count = 1; > > + break; > > +case 8: > > + Width = EfiPciIoWidthUint32; > > + Count = 2; > > + break; > > +default: > > + return EFI_INVALID_PARAMETER; > >} > > > >
Re: [edk2] [patch V2] MdeModulePkg/ReportStatusCodeLib: Avoid using AllocatePool if possible
> -Original Message- > From: Zeng, Star > Sent: Friday, February 15, 2019 5:25 PM > To: Bi, Dandan ; edk2-devel@lists.01.org > Cc: Wu, Hao A ; Michael Turner > ; Max Knutsen > ; Gao, Liming ; Zeng, > Star > Subject: RE: [edk2] [patch V2] MdeModulePkg/ReportStatusCodeLib: Avoid > using AllocatePool if possible > > After applying the patch, the author is Max and the Signed-off-by is Dandan, > is it expected? > > And the code below is better to be into the else condition (stack buffer is > not > enough), right? Thanks for the comments. Yes, I agree. V3 patch has been sent for review. Thanks, Dandan > > if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) { > return EFI_UNSUPPORTED; > } > > // > // Retrieve the current TPL > // > Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); > gBS->RestoreTPL (Tpl); > > > Thanks, > Star > -Original Message- > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of > Dandan Bi > Sent: Thursday, February 14, 2019 10:39 AM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Michael Turner > ; Max Knutsen > ; Gao, Liming > Subject: [edk2] [patch V2] MdeModulePkg/ReportStatusCodeLib: Avoid > using AllocatePool if possible > > From: Max Knutsen > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1114 > > V2: simplify the code logic. > update > if (!mHaveExitedBootServices && > (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer)) { > gBS->FreePool (StatusCodeData); > } > to > if (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer) { > gBS->FreePool (StatusCodeData); > } > > When report status code with ExtendedData data, and the extended data > can fit in the local static buffer, there is no need to use AllocatePool to > hold > the ExtendedData data. > > This patch is just to do the enhancement to avoid using AllocatePool. > > Cc: Jian J Wang > Cc: Hao Wu > Cc: Michael Turner > Cc: Liming Gao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Dandan Bi > --- > .../Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c | 9 +++-- > .../RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c | 9 +++-- > 2 files changed, 14 insertions(+), 4 deletions(-) > > diff --git > a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c > b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c > index b28dc5c3bb..c88be5a1a3 100644 > --- > a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c > +++ > b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c > @@ -505,13 +505,18 @@ ReportStatusCodeEx ( >// >Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); >gBS->RestoreTPL (Tpl); > >StatusCodeData = NULL; > - if (Tpl <= TPL_NOTIFY) { > + if (ExtendedDataSize <= (MAX_EXTENDED_DATA_SIZE - sizeof > + (EFI_STATUS_CODE_DATA))) { > // > -// Allocate space for the Status Code Header and its buffer > +// Use Buffer instead of allocating if possible. > +// > +StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer; } else if (Tpl <= > + TPL_NOTIFY){ > +// > +// If Buffer is not big enough, allocate space for the Status Code > + Header and its buffer > // > gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) > + ExtendedDataSize, (VOID **)); >} > >if (StatusCodeData == NULL) { > diff --git > a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusC > odeLib.c > b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusC > odeLib.c > index b73103517a..75e2f88ad2 100644 > --- > a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusC > odeLib.c > +++ > b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusC > od > +++ eLib.c > @@ -635,11 +635,14 @@ ReportStatusCodeEx ( >if (mHaveExitedBootServices) { > if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > > MAX_EXTENDED_DATA_SIZE) { >return EFI_OUT_OF_RESOURCES; > } > StatusCodeData = (EFI_STATUS_CODE_DATA *) StatusCodeBuffer; > - } else { > + } else if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > > MAX_EXTENDED_DATA_SIZE) { > +// > +// Only use AllocatePool for larger ExtendedData. > +// > if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) { >return EFI_UNSUPPORTED; > } > > // > @@ -648,10 +651,12 @@ ReportStatusCodeEx ( > StatusCodeData = NULL; > gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) > + ExtendedDataSize, (VOID **)); > if (StatusCodeData == NULL) { >return EFI_OUT_OF_RESOURCES; > } > + } else { > +StatusCodeData = (EFI_STATUS_CODE_DATA *) StatusCodeBuffer; >} > >// >// Fill in the extended data header >// > @@ -678,11 +683,11 @@ ReportStatusCodeEx ( >Status = InternalReportStatusCode (Type, Value, Instance, CallerId, > StatusCodeData); > >// >// Free the allocated buffer >//
Re: [edk2] EmulatorPkg Unix Host Segmentation fault.
On 2019-02-17 18:25:01, Ni, Ray wrote: > Jordan, > > Study the PeiCore migration logic a bit more, I found since PeiCore > > knows the exact size of new stack in permanent memory, it migrates > > old stack to the top of new stack. > > But the migration logic in above C code (since it doesn't know the > > size of new stack, CopySize is the size of temporary memory) may copy > > the old stack to the middle in new stack. > > Maybe your new RamMigration2 PPI needs to carry both the old and new > stack/heap location and size. > It helps: > 1. migrate the old stack to top of new stack (instead of middle of new > stack). > 2. potentially reduce the size of memory that needs to be copied. > > TemporaryRamMigration ( >IN CONST EFI_PEI_SERVICES **PeiServices, >IN EFI_PHYSICAL_ADDRESS TemporaryStackBase, >IN EFI_PHYSICAL_ADDRESS PermanentStackSize, >IN EFI_PHYSICAL_ADDRESS TemporaryHeapBase, >IN EFI_PHYSICAL_ADDRESS PermanentHeapSize, >IN TEMPORARY_RAM_MIGRATION_CALLBACK Callback, >IN VOID *Context >) Hmm. I'll think about that for the new PPI. > Before the finalize of PI spec change regarding the RamMigration2 > change, I prefer to fix the EmulatorPkg boot crash ASAP using the > OVMF-like solution. > If you agree, I will send out the patch to let you review. You are right that it will take more time for a new PPI. But, I have almost finished my patches to fix the PEI Core with the old PPI. I'll try to send them out tonight. -Jordan ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch V3] MdeModulePkg/ReportStatusCodeLib: Avoid using AllocatePool if possible
From: Max Knutsen REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1114 V2: simplify the code logic. update if (!mHaveExitedBootServices && (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer)) { gBS->FreePool (StatusCodeData); } to if (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer) { gBS->FreePool (StatusCodeData); } V3: And the code below into the else condition (stack buffer is not enough) in /DxeReportStatusCodeLib/ReportStatusCodeLib.c if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) { return EFI_UNSUPPORTED; } When report status code with ExtendedData data, and the extended data can fit in the local static buffer, there is no need to use AllocatePool to hold the ExtendedData data. This patch is just to do the enhancement to avoid using AllocatePool. Cc: Star Zeng Cc: Jian J Wang Cc: Hao Wu Cc: Michael Turner Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../DxeReportStatusCodeLib/ReportStatusCodeLib.c | 15 +-- .../ReportStatusCodeLib.c | 9 +++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c index b28dc5c3bb..3bca0a94ee 100644 --- a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c +++ b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c @@ -494,24 +494,27 @@ ReportStatusCodeEx ( UINT64Buffer[(MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)) + 1]; ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0))); ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0))); - if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) { -return EFI_UNSUPPORTED; - } - // // Retrieve the current TPL // Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); gBS->RestoreTPL (Tpl); StatusCodeData = NULL; - if (Tpl <= TPL_NOTIFY) { + if (ExtendedDataSize <= (MAX_EXTENDED_DATA_SIZE - sizeof (EFI_STATUS_CODE_DATA))) { +// +// Use Buffer instead of allocating if possible. +// +StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer; + } else if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) { +return EFI_UNSUPPORTED; + } else if (Tpl <= TPL_NOTIFY){ // -// Allocate space for the Status Code Header and its buffer +// If Buffer is not big enough, allocate space for the Status Code Header and its buffer // gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)); } if (StatusCodeData == NULL) { diff --git a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c index b73103517a..75e2f88ad2 100644 --- a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c +++ b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c @@ -635,11 +635,14 @@ ReportStatusCodeEx ( if (mHaveExitedBootServices) { if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > MAX_EXTENDED_DATA_SIZE) { return EFI_OUT_OF_RESOURCES; } StatusCodeData = (EFI_STATUS_CODE_DATA *) StatusCodeBuffer; - } else { + } else if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > MAX_EXTENDED_DATA_SIZE) { +// +// Only use AllocatePool for larger ExtendedData. +// if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) { return EFI_UNSUPPORTED; } // @@ -648,10 +651,12 @@ ReportStatusCodeEx ( StatusCodeData = NULL; gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)); if (StatusCodeData == NULL) { return EFI_OUT_OF_RESOURCES; } + } else { +StatusCodeData = (EFI_STATUS_CODE_DATA *) StatusCodeBuffer; } // // Fill in the extended data header // @@ -678,11 +683,11 @@ ReportStatusCodeEx ( Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData); // // Free the allocated buffer // - if (!mHaveExitedBootServices) { + if (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer) { gBS->FreePool (StatusCodeData); } return Status; } -- 2.18.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] EmulatorPkg Unix Host Segmentation fault.
Jordan, > Study the PeiCore migration logic a bit more, I found since PeiCore > knows the exact size of new stack in permanent memory, it migrates > old stack to the top of new stack. > But the migration logic in above C code (since it doesn't know the > size of new stack, CopySize is the size of temporary memory) may copy > the old stack to the middle in new stack. Maybe your new RamMigration2 PPI needs to carry both the old and new stack/heap location and size. It helps: 1. migrate the old stack to top of new stack (instead of middle of new stack). 2. potentially reduce the size of memory that needs to be copied. TemporaryRamMigration ( IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_PHYSICAL_ADDRESS TemporaryStackBase, IN EFI_PHYSICAL_ADDRESS PermanentStackSize, IN EFI_PHYSICAL_ADDRESS TemporaryHeapBase, IN EFI_PHYSICAL_ADDRESS PermanentHeapSize, IN TEMPORARY_RAM_MIGRATION_CALLBACK Callback, IN VOID *Context ) Before the finalize of PI spec change regarding the RamMigration2 change, I prefer to fix the EmulatorPkg boot crash ASAP using the OVMF-like solution. If you agree, I will send out the patch to let you review. -- Thanks, Ray ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH v5 04/13] MdeModulePkg: Add GUID for LockBox to save storage dev to init in S3
Reviewed-by: Eric Dong > -Original Message- > From: Wu, Hao A > Sent: Friday, February 15, 2019 2:23 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Wang, Jian J ; > Dong, Eric > Subject: [PATCH v5 04/13] MdeModulePkg: Add GUID for LockBox to save > storage dev to init in S3 > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409 > > This commit will add the GUID definitions for LockBox which is used to save a > list of storage devices that need to get initialized during the S3 resume. > > The content of the LockBox will be a DevicePath structure that contains zero > or more DevicePath instances. Each instance denotes a storage device that > needs to get initialized during the S3 resume. > > The producers of the content of this LockBox will be drivers like > OpalPassword DXE driver. This kind of drivers requires some specific storage > devices to be initialized during the PEI phase of in S3 resume. > (For the OpalPassword case, it requires the managing devices to be > automatically unlocked during the S3 resume). > > The attribute of the LockBox should be set to > LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY. > > The consumers of the content of this LockBox will be PEI storage device > controller/bus drivers (e.g. NvmExpressPei) during S3 resume. This kind of > drivers can use the DevicePath instances stored in the LockBox to get a list > of > devices that need to get initialized. In such way, an on-demand > (partial) device enumeration/initialization can be performed to benefit the S3 > resume performance. > > Cc: Jian J Wang > Cc: Eric Dong > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Hao Wu > Reviewed-by: Ray Ni > --- > MdeModulePkg/MdeModulePkg.dec | 3 + > MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h | 64 > > 2 files changed, 67 insertions(+) > > diff --git a/MdeModulePkg/MdeModulePkg.dec > b/MdeModulePkg/MdeModulePkg.dec index 7f646d7702..a2130bc439 > 100644 > --- a/MdeModulePkg/MdeModulePkg.dec > +++ b/MdeModulePkg/MdeModulePkg.dec > @@ -422,6 +422,9 @@ >## Include/Guid/S3SmmInitDone.h >gEdkiiS3SmmInitDoneGuid = { 0x8f9d4825, 0x797d, 0x48fc, { 0x84, 0x71, > 0x84, 0x50, 0x25, 0x79, 0x2e, 0xf6 } } > > + ## Include/Guid/S3StorageDeviceInitList.h > + gS3StorageDeviceInitListGuid = { 0x310e9b8c, 0xcf90, 0x421e, { 0x8e, > + 0x9b, 0x9e, 0xef, 0xb6, 0x17, 0xc8, 0xef } } > + > [Ppis] >## Include/Ppi/AtaController.h >gPeiAtaControllerPpiGuid = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, > 0x7a, > 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }} > diff --git a/MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h > b/MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h > new file mode 100644 > index 00..bd300b2696 > --- /dev/null > +++ b/MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h > @@ -0,0 +1,64 @@ > +/** @file > + Define the LockBox GUID for list of storage devices need to be > +initialized in > + S3. > + > + Copyright (c) 2019, Intel Corporation. All rights reserved. > + > + This program and the accompanying materials are licensed and made > + available under the terms and conditions of the BSD License which > + accompanies this distribution. The full text of the license may be > + found at http://opensource.org/licenses/bsd-license.php > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > + > +**/ > + > +#ifndef __S3_STORAGE_DEVICE_INIT_LIST_H__ #define > +__S3_STORAGE_DEVICE_INIT_LIST_H__ > + > +#define S3_STORAGE_DEVICE_INIT_LIST \ > + { \ > +0x310e9b8c, 0xcf90, 0x421e, { 0x8e, 0x9b, 0x9e, 0xef, 0xb6, 0x17, > +0xc8, 0xef } \ > + } > + > +// > +// The LockBox will store a DevicePath structure that contains one or > +more // DevicePath instances. Each instance denotes a storage device > +that needs to // get initialized during the S3 resume. > +// > +// For example, if there is only one storage device stored in the list, > +the // content of this LockBox will be: > +// > +// +---+ > +// | DevPath Instance #1 | > +// | (Terminated by an End of Hardware Device Path node| > +// | with an End Entire Device Path sub-type) | > +// +---+ > +// > +// If there are n (n > 1) storage devices in the list, the content of > +this // LockBox will be: > +// > +// +---+ > +// | DevPath Instance #1 | > +// | (Terminated by an End of Hardware Device Path node| > +// | with an End This Instance of a Device Path sub-type) | // > ++---+ > +// | DevPath Instance #2 | > +// | (Terminated by an End of Hardware Device Path node| > +// | with an
Re: [edk2] [PATCH v5 03/13] MdeModulePkg: Add definitions for Storage Security Command PPI
Reviewed-by: Eric Dong > -Original Message- > From: Wu, Hao A > Sent: Friday, February 15, 2019 2:23 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Wang, Jian J ; > Dong, Eric > Subject: [PATCH v5 03/13] MdeModulePkg: Add definitions for Storage > Security Command PPI > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409 > > This commit will add the definitions for Storage Security Command (SSC) PPI. > This PPI will be be used to abstract mass storage devices to allow code > running in the PEI phase to send security protocol commands to mass storage > devices without specific knowledge of the type of device or controller that > manages the device. > > More specifically, the PPI will provide services to: > > * Get the number of mass storage devices managed by a instance of the SSC > PPI (by service 'GetNumberofDevices'); > * Get the identification information (DevicePath) of a managing mass > storage devices (by service 'GetDevicePath'); > * Send security protocol commands to mass storage devices (by services > 'ReceiveData' and 'SendData'). > > Cc: Jian J Wang > Cc: Eric Dong > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Hao Wu > Reviewed-by: Ray Ni > --- > MdeModulePkg/MdeModulePkg.dec | 3 + > MdeModulePkg/Include/Ppi/StorageSecurityCommand.h | 283 > > 2 files changed, 286 insertions(+) > > diff --git a/MdeModulePkg/MdeModulePkg.dec > b/MdeModulePkg/MdeModulePkg.dec index 8efb19e626..7f646d7702 > 100644 > --- a/MdeModulePkg/MdeModulePkg.dec > +++ b/MdeModulePkg/MdeModulePkg.dec > @@ -483,6 +483,9 @@ >## Include/Ppi/AtaAhciController.h >gEdkiiPeiAtaAhciHostControllerPpiGuid = { 0x61dd33ea, 0x421f, 0x4cc0, > { 0x89, 0x29, 0xff, 0xee, 0xa9, 0xa1, 0xa2, 0x61 } } > > + ## Include/Ppi/StorageSecurityCommand.h > + gEdkiiPeiStorageSecurityCommandPpiGuid= { 0x35de0b4e, 0x30fb, > 0x46c3, { 0xbd, 0x84, 0x1f, 0xdb, 0xa1, 0x58, 0xbb, 0x56 } } > + >## Include/Ppi/AtaPassThru.h >gEdkiiPeiAtaPassThruPpiGuid = { 0xa16473fd, 0xd474, 0x4c89, > { 0xae, > 0xc7, 0x90, 0xb8, 0x3c, 0x73, 0x86, 0x9 } } > > diff --git a/MdeModulePkg/Include/Ppi/StorageSecurityCommand.h > b/MdeModulePkg/Include/Ppi/StorageSecurityCommand.h > new file mode 100644 > index 00..cc1688dabb > --- /dev/null > +++ b/MdeModulePkg/Include/Ppi/StorageSecurityCommand.h > @@ -0,0 +1,283 @@ > +/** @file > + > + Copyright (c) 2019, Intel Corporation. All rights reserved. This > + program and the accompanying materials are licensed and made > + available under the terms and conditions of the BSD License which > + accompanies this distribution. The full text of the license may be > + found at http://opensource.org/licenses/bsd-license.php > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > + > +**/ > + > +#ifndef _EDKII_STORAGE_SECURITY_COMMAND_PPI_H_ > +#define _EDKII_STORAGE_SECURITY_COMMAND_PPI_H_ > + > +#include > + > +/// > +/// Global ID for the EDKII_PEI_STORAGE_SECURITY_CMD_PPI. > +/// > +#define EDKII_PEI_STORAGE_SECURITY_CMD_PPI_GUID \ > + { \ > +0x35de0b4e, 0x30fb, 0x46c3, { 0xbd, 0x84, 0x1f, 0xdb, 0xa1, 0x58, > +0xbb, 0x56 } \ > + } > + > +// > +// Forward declaration for the EDKII_PEI_STORAGE_SECURITY_CMD_PPI. > +// > +typedef struct _EDKII_PEI_STORAGE_SECURITY_CMD_PPI > +EDKII_PEI_STORAGE_SECURITY_CMD_PPI; > + > +// > +// Revision The revision to which the Storage Security Command interface > adheres. > +// All future revisions must be backwards compatible. > +// If a future version is not back wards compatible it is not the > same > GUID. > +// > +#define EDKII_STORAGE_SECURITY_PPI_REVISION 0x0001 > + > + > +/** > + Gets the count of storage security devices that one specific driver > detects. > + > + @param[in] This The PPI instance pointer. > + @param[out] NumberofDevicesThe number of storage security devices > discovered. > + > + @retval EFI_SUCCESS The operation performed successfully. > + @retval EFI_INVALID_PARAMETERThe parameters are invalid. > + > +**/ > +typedef > +EFI_STATUS > +(EFIAPI *EDKII_PEI_STORAGE_SECURITY_GET_NUMBER_DEVICES) ( > + IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI*This, > + OUT UINTN *NumberofDevices > + ); > + > +/** > + Gets the device path of a specific storage security device. > + > + @param[in] This The PPI instance pointer. > + @param[in] DeviceIndex Specifies the storage security device to > which > + the function wants to talk. Because the > driver > + that implements Storage Security Command > PPIs > + will manage multiple storage devices, the > PPIs > + that
Re: [edk2] [PATCH v5 02/13] MdeModulePkg: Add definitions for EDKII PEI ATA PassThru PPI
Reviewed-by: Eric Dong > -Original Message- > From: Wu, Hao A > Sent: Friday, February 15, 2019 2:23 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Wang, Jian J ; > Dong, Eric > Subject: [PATCH v5 02/13] MdeModulePkg: Add definitions for EDKII PEI ATA > PassThru PPI > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409 > > This commit will add the definitions for EDKII PEI ATA PassThru PPI. This PPI > will provide services that allow ATA commands to be sent to ATA devices > attached to an ATA controller in the PEI phase. > > More specifically, the PPI will provide services to: > > * Send ATA commands to an ATA device (by service 'PassThru'); > * Get the list of the attached ATA device on a controller (by services > 'GetNextPort' and 'GetNextDevice'); > * Get the identification information (DevicePath) of the underlying ATA > host controller (by service 'GetDevicePath'). > > Cc: Jian J Wang > Cc: Eric Dong > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Hao Wu > Reviewed-by: Ray Ni > --- > MdeModulePkg/MdeModulePkg.dec | 3 + > MdeModulePkg/Include/Ppi/AtaPassThru.h | 219 > 2 files changed, 222 insertions(+) > > diff --git a/MdeModulePkg/MdeModulePkg.dec > b/MdeModulePkg/MdeModulePkg.dec index 4411185073..8efb19e626 > 100644 > --- a/MdeModulePkg/MdeModulePkg.dec > +++ b/MdeModulePkg/MdeModulePkg.dec > @@ -483,6 +483,9 @@ >## Include/Ppi/AtaAhciController.h >gEdkiiPeiAtaAhciHostControllerPpiGuid = { 0x61dd33ea, 0x421f, 0x4cc0, > { 0x89, 0x29, 0xff, 0xee, 0xa9, 0xa1, 0xa2, 0x61 } } > > + ## Include/Ppi/AtaPassThru.h > + gEdkiiPeiAtaPassThruPpiGuid = { 0xa16473fd, 0xd474, 0x4c89, > { 0xae, > 0xc7, 0x90, 0xb8, 0x3c, 0x73, 0x86, 0x9 } } > + > [Protocols] >## Load File protocol provides capability to load and unload EFI image into > memory and execute it. ># Include/Protocol/LoadPe32Image.h > diff --git a/MdeModulePkg/Include/Ppi/AtaPassThru.h > b/MdeModulePkg/Include/Ppi/AtaPassThru.h > new file mode 100644 > index 00..78bdaef9e2 > --- /dev/null > +++ b/MdeModulePkg/Include/Ppi/AtaPassThru.h > @@ -0,0 +1,219 @@ > +/** @file > + > + Copyright (c) 2019, Intel Corporation. All rights reserved. This > + program and the accompanying materials are licensed and made > + available under the terms and conditions of the BSD License which > + accompanies this distribution. The full text of the license may be > + found at http://opensource.org/licenses/bsd-license.php > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > + > +**/ > + > +#ifndef _EDKII_ATA_PASS_THRU_PPI_H_ > +#define _EDKII_ATA_PASS_THRU_PPI_H_ > + > +#include > +#include > + > +/// > +/// Global ID for the EDKII_PEI_ATA_PASS_THRU_PPI. > +/// > +#define EDKII_PEI_ATA_PASS_THRU_PPI_GUID \ > + { \ > +0xa16473fd, 0xd474, 0x4c89, { 0xae, 0xc7, 0x90, 0xb8, 0x3c, 0x73, > +0x86, 0x9 } \ > + } > + > +// > +// Forward declaration for the EDKII_PEI_ATA_PASS_THRU_PPI. > +// > +typedef struct _EDKII_PEI_ATA_PASS_THRU_PPI > +EDKII_PEI_ATA_PASS_THRU_PPI; > + > +// > +// Revision The revision to which the ATA Pass Thru PPI interface adheres. > +// All future revisions must be backwards compatible. > +// If a future version is not back wards compatible it is not the > same > GUID. > +// > +#define EDKII_PEI_ATA_PASS_THRU_PPI_REVISION0x0001 > + > + > +/** > + Sends an ATA command to an ATA device that is attached to the ATA > controller. > + > + @param[in] This The PPI instance pointer. > + @param[in] Port The port number of the ATA device to > send > + the command. > + @param[in] PortMultiplierPortThe port multiplier port number of the > ATA > + device to send the command. > + If there is no port multiplier, then > specify > + 0x. > + @param[in,out] PacketA pointer to the ATA command to send > to > + the ATA device specified by Port and > + PortMultiplierPort. > + > + @retval EFI_SUCCESS The ATA command was sent by the host. For > + bi-directional commands, InTransferLength > bytes > + were transferred from InDataBuffer. For > write > + and bi-directional commands, > OutTransferLength > + bytes were transferred by OutDataBuffer. > + @retval EFI_NOT_FOUNDThe specified ATA device is not found. > + @retval EFI_INVALID_PARAMETERThe contents of Acb are invalid. The > ATA command > +
Re: [edk2] [PATCH v5 01/13] MdeModulePkg: Add definitions for ATA AHCI host controller PPI
Reviewed-by: Eric Dong > -Original Message- > From: Wu, Hao A > Sent: Friday, February 15, 2019 2:23 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Wang, Jian J ; > Dong, Eric > Subject: [PATCH v5 01/13] MdeModulePkg: Add definitions for ATA AHCI > host controller PPI > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409 > > This commit will add the definitions for ATA AHCI host controller PPI. The > purpose of the PPI in to provide: > > * MMIO base address > * Controller identification information (DevicePath) > > for ATA host controllers working under AHCI mode. > > Cc: Jian J Wang > Cc: Eric Dong > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Hao Wu > Reviewed-by: Ray Ni > --- > MdeModulePkg/MdeModulePkg.dec| 3 + > MdeModulePkg/Include/Ppi/AtaAhciController.h | 89 > > 2 files changed, 92 insertions(+) > > diff --git a/MdeModulePkg/MdeModulePkg.dec > b/MdeModulePkg/MdeModulePkg.dec index e5c32d15ed..4411185073 > 100644 > --- a/MdeModulePkg/MdeModulePkg.dec > +++ b/MdeModulePkg/MdeModulePkg.dec > @@ -480,6 +480,9 @@ >## Include/Ppi/NvmExpressHostController.h >gEdkiiPeiNvmExpressHostControllerPpiGuid = { 0xcae3aa63, 0x676f, 0x4da3, > { 0xbd, 0x50, 0x6c, 0xc5, 0xed, 0xde, 0x9a, 0xad } } > > + ## Include/Ppi/AtaAhciController.h > + gEdkiiPeiAtaAhciHostControllerPpiGuid = { 0x61dd33ea, 0x421f, 0x4cc0, > { 0x89, 0x29, 0xff, 0xee, 0xa9, 0xa1, 0xa2, 0x61 } } > + > [Protocols] >## Load File protocol provides capability to load and unload EFI image into > memory and execute it. ># Include/Protocol/LoadPe32Image.h > diff --git a/MdeModulePkg/Include/Ppi/AtaAhciController.h > b/MdeModulePkg/Include/Ppi/AtaAhciController.h > new file mode 100644 > index 00..2bdd53ff36 > --- /dev/null > +++ b/MdeModulePkg/Include/Ppi/AtaAhciController.h > @@ -0,0 +1,89 @@ > +/** @file > + > + Copyright (c) 2019, Intel Corporation. All rights reserved. This > + program and the accompanying materials are licensed and made > + available under the terms and conditions of the BSD License which > + accompanies this distribution. The full text of the license may be > + found at http://opensource.org/licenses/bsd-license.php > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > + > +**/ > + > +#ifndef _EDKII_ATA_AHCI_HOST_CONTROLLER_PPI_H_ > +#define _EDKII_ATA_AHCI_HOST_CONTROLLER_PPI_H_ > + > +#include > + > +/// > +/// Global ID for the EDKII_ATA_AHCI_HOST_CONTROLLER_PPI. > +/// > +#define EDKII_ATA_AHCI_HOST_CONTROLLER_PPI_GUID \ > + { \ > +0x61dd33ea, 0x421f, 0x4cc0, { 0x89, 0x29, 0xff, 0xee, 0xa9, 0xa1, > +0xa2, 0x61 } \ > + } > + > +// > +// Forward declaration for the EDKII_ATA_AHCI_HOST_CONTROLLER_PPI. > +// > +typedef struct _EDKII_ATA_AHCI_HOST_CONTROLLER_PPI > +EDKII_ATA_AHCI_HOST_CONTROLLER_PPI; > + > +/** > + Get the MMIO base address of ATA AHCI host controller. > + > + @param[in] This The PPI instance pointer. > + @param[in] ControllerId The ID of the ATA AHCI host controller. > + @param[out] MmioBar The MMIO base address of the controller. > + > + @retval EFI_SUCCESS The operation succeeds. > + @retval EFI_INVALID_PARAMETERThe parameters are invalid. > + @retval EFI_NOT_FOUNDThe specified ATA AHCI host controller not > found. > + > +**/ > +typedef > +EFI_STATUS > +(EFIAPI *EDKII_ATA_AHCI_HC_GET_MMIO_BAR) ( > + IN EDKII_ATA_AHCI_HOST_CONTROLLER_PPI*This, > + IN UINT8 ControllerId, > + OUT UINTN *MmioBar > + ); > + > +/** > + Get the device path of ATA AHCI host controller. > + > + @param[in] This The PPI instance pointer. > + @param[in] ControllerId The ID of the ATA AHCI host controller. > + @param[out] DevicePathLength The length of the device path in bytes > specified > + by DevicePath. > + @param[out] DevicePath The device path of ATA AHCI host > controller. > + This field re-uses EFI Device Path > Protocol as > + defined by Section 10.2 EFI Device Path > Protocol > + of UEFI 2.7 Specification. > + > + @retval EFI_SUCCESS The operation succeeds. > + @retval EFI_INVALID_PARAMETERThe parameters are invalid. > + @retval EFI_NOT_FOUNDThe specified ATA AHCI host controller not > found. > + @retval EFI_OUT_OF_RESOURCES The operation fails due to lack of > resources. > + > +**/ > +typedef > +EFI_STATUS > +(EFIAPI *EDKII_ATA_AHCI_HC_GET_DEVICE_PATH) ( > + IN EDKII_ATA_AHCI_HOST_CONTROLLER_PPI*This, > + IN UINT8 ControllerId, > + OUT UINTN
Re: [edk2] [PATCH v3] NetworkPkg/Ip6Dxe: Clean the invalid IPv6 configuration during driver start.
Reviewed-by: Siyuan Fu > -Original Message- > From: Wu, Jiaxin > Sent: Monday, February 18, 2019 9:15 AM > To: edk2-devel@lists.01.org > Cc: Michael Turner ; Ye, Ting > ; Fu, Siyuan ; Wu, Jiaxin > > Subject: [PATCH v3] NetworkPkg/Ip6Dxe: Clean the invalid IPv6 configuration > during driver start. > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1448 > > *v3: Change the if condition check to only clean the invalid configuration. > > *v2: Add the warning debug message. > > This patch is to clean the invalid data and continue to start IP6 driver. > > Cc: Michael Turner > Cc: Ye Ting > Cc: Fu Siyuan > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Wu Jiaxin > --- > NetworkPkg/Ip6Dxe/Ip6Driver.c | 26 ++ > 1 file changed, 22 insertions(+), 4 deletions(-) > > diff --git a/NetworkPkg/Ip6Dxe/Ip6Driver.c b/NetworkPkg/Ip6Dxe/Ip6Driver.c > index 4c607125a6..7a96315ccf 100644 > --- a/NetworkPkg/Ip6Dxe/Ip6Driver.c > +++ b/NetworkPkg/Ip6Dxe/Ip6Driver.c > @@ -585,12 +585,21 @@ Ip6DriverBindingStart ( > Ip6Cfg, > Ip6ConfigDataTypeManualAddress, > DataItem->DataSize, > DataItem->Data.Ptr > ); > -if (EFI_ERROR(Status) && Status != EFI_NOT_READY) { > - goto UNINSTALL_PROTOCOL; > +if (Status == EFI_INVALID_PARAMETER || Status == EFI_BAD_BUFFER_SIZE) { > + // > + // Clean the invalid ManualAddress configuration. > + // > + Status = Ip6Cfg->SetData ( > + Ip6Cfg, > + Ip6ConfigDataTypeManualAddress, > + 0, > + NULL > + ); > + DEBUG ((EFI_D_WARN, "Ip6DriverBindingStart: Clean the invalid > ManualAddress configuration.\n")); > } >} > >// >// If there is any default gateway address, set it. > @@ -601,12 +610,21 @@ Ip6DriverBindingStart ( > Ip6Cfg, > Ip6ConfigDataTypeGateway, > DataItem->DataSize, > DataItem->Data.Ptr > ); > -if (EFI_ERROR(Status)) { > - goto UNINSTALL_PROTOCOL; > +if (Status == EFI_INVALID_PARAMETER || Status == EFI_BAD_BUFFER_SIZE) { > + // > + // Clean the invalid Gateway configuration. > + // > + Status = Ip6Cfg->SetData ( > + Ip6Cfg, > + Ip6ConfigDataTypeGateway, > + 0, > + NULL > + ); > + DEBUG ((EFI_D_WARN, "Ip6DriverBindingStart: Clean the invalid Gateway > configuration.\n")); > } >} > >// >// ready to go: start the receiving and timer > -- > 2.17.1.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH v3] NetworkPkg/Ip6Dxe: Clean the invalid IPv6 configuration during driver start.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1448 *v3: Change the if condition check to only clean the invalid configuration. *v2: Add the warning debug message. This patch is to clean the invalid data and continue to start IP6 driver. Cc: Michael Turner Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Wu Jiaxin --- NetworkPkg/Ip6Dxe/Ip6Driver.c | 26 ++ 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/NetworkPkg/Ip6Dxe/Ip6Driver.c b/NetworkPkg/Ip6Dxe/Ip6Driver.c index 4c607125a6..7a96315ccf 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Driver.c +++ b/NetworkPkg/Ip6Dxe/Ip6Driver.c @@ -585,12 +585,21 @@ Ip6DriverBindingStart ( Ip6Cfg, Ip6ConfigDataTypeManualAddress, DataItem->DataSize, DataItem->Data.Ptr ); -if (EFI_ERROR(Status) && Status != EFI_NOT_READY) { - goto UNINSTALL_PROTOCOL; +if (Status == EFI_INVALID_PARAMETER || Status == EFI_BAD_BUFFER_SIZE) { + // + // Clean the invalid ManualAddress configuration. + // + Status = Ip6Cfg->SetData ( + Ip6Cfg, + Ip6ConfigDataTypeManualAddress, + 0, + NULL + ); + DEBUG ((EFI_D_WARN, "Ip6DriverBindingStart: Clean the invalid ManualAddress configuration.\n")); } } // // If there is any default gateway address, set it. @@ -601,12 +610,21 @@ Ip6DriverBindingStart ( Ip6Cfg, Ip6ConfigDataTypeGateway, DataItem->DataSize, DataItem->Data.Ptr ); -if (EFI_ERROR(Status)) { - goto UNINSTALL_PROTOCOL; +if (Status == EFI_INVALID_PARAMETER || Status == EFI_BAD_BUFFER_SIZE) { + // + // Clean the invalid Gateway configuration. + // + Status = Ip6Cfg->SetData ( + Ip6Cfg, + Ip6ConfigDataTypeGateway, + 0, + NULL + ); + DEBUG ((EFI_D_WARN, "Ip6DriverBindingStart: Clean the invalid Gateway configuration.\n")); } } // // ready to go: start the receiving and timer -- 2.17.1.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] Maintainers: add TPM2 reviewers for OvmfPkg
Hi Leif, On 2/11/19 1:06 PM, Leif Lindholm wrote: On Mon, Feb 11, 2019 at 01:53:43PM +0100, Laszlo Ersek wrote: OVMF can be built with a significant amount of TPM2 code now; add Marc-André and Stefan as Reviewers for TPM2-related patches. Keep the list of "R" entries alphabetically sorted. For this patch: Reviewed-by: Leif Lindholm However - unrelated sidenote: Julien, is that address still valid for you? I still have a linaro account. Although, I guess it would be best if we use my Arm e-mail for the EDK2 review. I will send a patch to change the address. Cheers, -- Julien Grall ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel