summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
Commit message (Collapse)AuthorAgeFilesLines
* MdeModulePkg: Initialize temp variable in VarCheckPolicyLibBret Barkelew2021-04-131-0/+1
| | | | | | | | | | | | | | | DumpVariablePolicy() will return EFI_INVALID_PARAMETER if the Buffer pointer is NULL and the indirect Size is anything but 0. Since this TempSize was not being initialized it is very likely that this sequence would not return the total buffer size as expected. Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=3310 Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
* MdeModulePkg/PiDxeS3BootScriptLib: Rename mAcpiS3Enable to avoid dup symbolMichael D Kinney2021-04-071-6/+5
| | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3297 Rename the global variable mAcpiS3Enable to mS3BootScriptAcpiS3Enable to avoid duplicate symbol errors from CLANGPDB tool change when PiDxeS3BootScriptLib from the MdeModulePkg is linked with PiSmmCpuDxeSmm from the UefiCpuPkg. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Eric Dong <eric.dong@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg: Consume MdeLibs.dsc.inc for RegisterFilterLibDandan Bi2021-03-311-1/+3
| | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3246 MdeLibs.dsc.inc was added for some basic/default library instances provided by MdePkg and RegisterFilterLibNull Library was also added into it as the first version of MdeLibs.dsc.inc. So update platform dsc to consume MdeLibs.dsc.inc for RegisterFilterLibNull which will be consumed by IoLib and BaseLib. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Acked-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg: Initialize local variable value before they are usedLiming Gao2021-03-252-0/+10
| | | | | | | | | | | BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3228 This change is to fix the false compiler error on GCC49 release build. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
* MdeModulePkg: VariableSmmRuntimeDxe: Added request unblock memory interfaceKun Qin2021-03-053-0/+44
| | | | | | | | | | | | | | | | This changes added usage of MmUnblockMemoryLib to explicitly request runtime cache regions(and its indicators) to be accessible from MM environment when PcdEnableVariableRuntimeCache is enabled. It will bring in compatibility with architectures that supports full memory blockage inside MM. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Kun Qin <kun.q@outlook.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Message-Id: <MWHPR06MB31026EA41F28F2CE12B68574F3969@MWHPR06MB3102.namprd06.prod.outlook.com>
* MdeModulePkg/UfsPassThruDxe: Improve Device initialization polling LoopBandaru, Purna Chandra Rao2021-03-052-5/+15
| | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=3217 Current Ufs Pass thru driver polls for 5us and return success even when the timeout occurs. There are cards that can take upto 600ms for Init and hence increased the time out for fDeviceInit polling loop. Signed-off-by: Bandaru <purna.chandra.rao.bandaru@intel.com> Cc: Mateusz Albecki <mateusz.albecki@intel.com> Cc: Ray Ni <ray.ni@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/UefiBootManagerLib: Put BootMenu at the end of BootOrderLi, Walon2021-02-251-2/+2
| | | | | | | | | | | | REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3135 When Boot Menu does not exist in the BootOrder, BmRegisterBootManagerMenu will create one into list. However, it should be put at the "end" of BootOrder instead of "start" of BootOrder. Replace 0 by -1 to adjust order of load options. Signed-off-by: Walon Li <walon.li@hpe.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
* MdeModulePkg/VariableStandaloneMm: Set PcdFlashNvStorageVariableBase to PcdIlias Apalodimas2021-02-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | Instead of running StMM in SPM, OP-TEE creates a new secure partition, which emulates SPM and isolates StMM from the rest of the Trusted Applications (TAs). We can then compile StMM as an FD image and run it in OP-TEE. With the addition of a new RPMB driver, we can leverage OP-TEE and store variables to an RPMB device. Since EDK2 upper layers expect byte addressable code, for the RPMB to work, we need to allocate memory and sync it with the hardware on read/writes. Since DynamicPCDs are not supported in that context we can only use PatchablePCDs. So let's switch them to Pcd instead of FixedPcd and accomodate the new driver. While at it, move the rest of the variables under Pcd section, instead of FixedPcd -- this is in line with how the variables are defined in the other Variable modules. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Acked-by: Ard Biesheuvel <ardb@kernel.org>
* MdeModulePkg/Library: Add HiiGetStringEx to UefiHiiLib for EDK2 RedfishAbner Chang2021-02-052-39/+119
| | | | | | | | | | | | | | | | | | Add HiiGetStringEx and leveraged by HiiGetString function to support getting string with the best language in optionally. This avoids the string in x-uefi language is misled to the language defined by "PlatformLang" or the "Supported Languages". This change is introduced to support x-uefi keyword language for configuring BIOS setting. Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com> Signed-off-by: Siyuan Fu <siyuan.fu@intel.com> Signed-off-by: Fan Wang <fan.wang@intel.com> Signed-off-by: Abner Chang <abner.chang@hpe.com> Cc: Dandan Bi <dandan.bi@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Nickle Wang <nickle.wang@hpe.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
* MdeModulePkg/TerminalDxe: Terminal fifo buffer overflow.gechao2021-02-031-1/+1
| | | | | | | | | | | | | | | | | | | Fix the bug of terminal fifo buffer overflow with UINT8 type. typedef struct { UINT8 Head; UINT8 Tail; UINT8 Data[RAW_FIFO_MAX_NUMBER + 1]; } RAW_DATA_FIFO; RAW_FIFO_MAX_NUMBER is 256. the data buffer size is 257 (Index from 0 to 256), but the max value of the index, Head or Tail (UINT8), is 255. That means the last data of the data buffer would be always empty if we use Head/Tail to output/input the data correctly. And because of the incorrect buffer size the FIFO full check "((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1)) == Head" would never meet. Signed-off-by: gechao <gechao@greatwall.com.cn> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* MdeModulePkg/PciBusDxe: Fix a bug in ProcessOptionRomLightAiden Park2021-02-021-6/+1
| | | | | | | | | | | | | The ProcessOptionRomLight() assumes that OpRom has already been processed in the previous full enumeration and updates AllOpRomProcessed flag to TRUE by default. However, this may not be applicable with other pre-stage boot firmwares. This will update AllOpRomProcessed flag properly by checking PciRomGetImageMapping(). Signed-off-by: Aiden Park <aiden.park@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
* MdeModulePkg: SmmSmiHandlerProfileLib: Support StandaloneMm InstanceKun Qin2021-02-017-84/+211
| | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3185 This change added support of SMI handler profile library router under StandaloneMm. This change replaces gSmst with gMmst. It also abstracts standalone and traditional MM driver entrypoints into separate files to allow maximal common implementations. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Kun Qin <kun.q@outlook.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg: ReportStatusCodeRouter: Support StandaloneMm RSC RouterKun Qin2021-02-017-55/+179
| | | | | | | | | | | | | | | | This change added support of RSC router under StandaloneMm. It replaces SMM version ReportStatusCode protocol definitions with MM version. This patch also switched to use gMmst instead of gSmst. Lastly, it abstracts standalone and traditional MM driver entrypoints into separate files to allow maximal common implementations. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Dandan Bi <dandan.bi@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Kun Qin <kun.q@outlook.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg: FirmwarePerformanceDataTable: Added StandaloneMm supportKun Qin2021-02-017-46/+281
| | | | | | | | | | | | | | | This change added support of FPDT driver under StandaloneMm. It replaces SMM version ReportStatusCode protocol with MM version. This patch also abstracts standalone and traditional MM interfaces into separate files to support each corresponding function prototypes and implementations. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Dandan Bi <dandan.bi@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Kun Qin <kun.q@outlook.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg: StatusCodeHandler: StatusCodeHandler driver in StandaloneMmKun Qin2021-02-019-45/+180
| | | | | | | | | | | | | | | | This change added support of StandaloneMm for StatusCodeHandler. It adds a new instance of StatusCodeHandler of MM_STANDALONE type, and abstracts the driver entrypoint into separate files, replaced gSmst with gMmst, and switched to MM version of RscHandlerProtocol. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Dandan Bi <dandan.bi@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Jiewen Yao <jiewen.yao@intel.com> Signed-off-by: Kun Qin <kun.q@outlook.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMmKun Qin2021-02-017-8/+178
| | | | | | | | | | | | | | | | This change added support of StandaloneMm for ReportStatusCodeLib. It adds a new instance of ReportStatusCodeLib for MM_STANDALONE type, and abstracts the references of gMmst and gSmst functionalities into separate files in order to link in proper Service Table for SMM core/drivers. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Dandan Bi <dandan.bi@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Jiewen Yao <jiewen.yao@intel.com> Signed-off-by: Kun Qin <kun.q@outlook.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg: SmmLockBoxSmmLib: Support StandaloneMm for SmmLockBoxLibKun Qin2021-02-017-53/+230
| | | | | | | | | | | | | | This change added support of StandaloneMm for SmmLockBoxLib. It replaces gSmst with gMmst to support both traditional MM and standalone MM. The contructor and desctructor functions are abstracted to support different function prototype definitions. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Eric Dong <eric.dong@intel.com> Signed-off-by: Kun Qin <kun.q@outlook.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/PciBusDxe: Handle BAR sizing fail in high 32bit of MEM64.Zarcd Zhong2021-01-181-0/+1
| | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3149 Address MEM64 BAR in type unknown if sizing fail in high 32bit. Cc: Ray Ni <ray.ni@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Zarcd Zhong <zarcd.zhong@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
* MdeModulePkg/FileExplorerLib: Add return value checkwenyi,xie via groups.io2021-01-151-5/+7
| | | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3113 According to FAT specification, the length of file path should not larger than 260. When the length exceed 260, function FatLocateOFile will return EFI_INVALID_PARAMETER and the parameter FileHandle will be NULL. Then on the top-level function?an exception happens when the NULL pointer is passed and be used. So adding return value check after calling LibGetFileHandleFromMenu, if return value is not success, stop calling LibFindFiles. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Dandan Bi <dandan.bi@intel.com> Cc: Eric Dong <eric.dong@intel.com> Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Dandan Bi <dandan.bi@intel.com>
* MdeModulePkg: Update UNI file for PCIe Resizable BAR CapabilityLuo, Heng2021-01-141-1/+7
| | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3138 PcdPcieResizableBarSupport was added in MdeModulePkg.dec, update UNI file as the documentation of the PCD. Cc: Ray Ni <ray.ni@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Heng Luo <heng.luo@intel.com> Acked-by: Laszlo Ersek <lersek@redhat.com> Acked-by: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
* MdeModulePkg: Change default value of PcdPcieResizableBarSupport to FALSELuo, Heng2021-01-141-1/+1
| | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3138 Change default value of PcdPcieResizableBarSupport to FALSE, avoid it impacts existing platforms. Cc: Ray Ni <ray.ni@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Heng Luo <heng.luo@intel.com> Acked-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
* MdeModulePkg Lzma: Update LZMA SDK version to 19.00Liu, WeiX C2021-01-0811-78/+163
| | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3101 New formal release in https://www.7-zip.org/sdk.html is 19.00. Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Wei Liu <weix.c.liu@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
* MdeModulePkg/Library/VarCheckLib: Allow SetVariable from SMMMichael D Kinney2021-01-071-1/+8
| | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3154 Update VarCheckLibSetVariableCheck() to allow locked variables to be updated if the RequestSource is VarCheckFromTrusted even if one or more variable check handlers return EFI_WRITE_PROTECTED. RequestSource is only set to VarCheckFromTrusted if the request is through the EFI_SMM_VARAIBLE_PROTOCOL. Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg BrotliCustomDecompressLib: Remove the duplicated functionsgaoliming2021-01-061-23/+0
| | | | | | | | | The same functions have been defined in BrotliDecUefiSupport.c. Signed-off-by: Liming Gao <gaoliming@byosoft.com.cn> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/ConSplitter: Change StdErr color to EFI_LIGHTGRAYSamer El-Haj-Mahmoud2021-01-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | ConSplitter is using EFI_LIGHTGRAY foreground color for ConOut and EFI_MAGENTA for StdErr consoles. This is impacting the DebugLib output on that same serial console (e.g. DebugLibSerialPort) after gEfiStandardErrorDeviceGuid is installed on that port. The impact also extends to Linux serial console output in OVMF because it inherits the color setting from the firmware. This is inconsistent and annoying, with MAGENTA being barely legible on a black background. Let's change StdErr default color to LIGHTGRAY for consistency and readability. This results in the same color being used for all consoles sharing the same serial port (ConOut, StdErr, DebugLib, OS console). Platforms wishing to distinguish the colors of consoles can do so in their own Platform BDS initialization. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Ard Biesheuvel <Ard.Biesheuvel@arm.com> Signed-off-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Pete Batard <pete@akeo.ie> Tested-by: Pete Batard <pete@akeo.ie> (On an RPi 4 platform where this was another annoyance)
* MdeModulePkg/Graphics: Fix spelling mistakesSamer El-Haj-Mahmoud2021-01-063-43/+43
| | | | | | | | | | | | | | Fix various spelling mistakes in GraphicsConsoleDxe, ConsPlitter, and SimpleTextOut header Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Ard Biesheuvel <Ard.Biesheuvel@arm.com> Cc: Pete Batard <pete@akeo.ie> Signed-off-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* MdeModulePkg/GraphicsConsoleDxe: Change default CursorVisible to FALSESamer El-Haj-Mahmoud2021-01-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | REF: https://github.com/pftf/RPi4/issues/115 GraphicsConsoleDxe defaults the ConOut Mode.CursorVisible to TRUE. However, the driver never draws the cursor during init. This results in the first call to disable the cursor (using ConOut->EnableCursor(FALSE)) to actually draw the cursor on the screen, as the logic in FlushCursor depends on the Mode.CursorVisible state to determine if it should draw or erase the cursor. Fix by changing the default CursorVisible in this driver to FALSE. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Ard Biesheuvel <Ard.Biesheuvel@arm.com> Cc: Pete Batard <pete@akeo.ie> Signed-off-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Pete Batard <pete@akeo.ie> Tested-by: Pete Batard <pete@akeo.ie> (On an RPi4 platform where we had this annoyance of an unwanted cursor displaying on top of the platform logo)
* MdeModulePkg/Bus/Pci/PciBusDxe: Support PCIe Resizable BAR CapabilityLuo, Heng2021-01-047-20/+241
| | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=313 Add PcdPcieResizableBarSupport to enable/disable PCIe Resizable BAR Capability fearture. Program the Resizable BAR Register if the device suports PCIe Resizable BAR Capability and PcdPcieResizableBarSupport is TRUE. Cc: Ray Ni <ray.ni@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Heng Luo <heng.luo@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
* MdeModulePkg/VarCheckPolicyLib: implement standalone MM versionMasahisa Kojima2020-12-237-10/+199
| | | | | | | | | | | | | | | | | This commit adds the VarCheckPolicyLib that will be able to execute in the context of standalone MM. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Co-authored-by: Kun Qin <kun.q@outlook.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
* MdeModulePkg/Universal/StatusCodeHandler: Fix a bug about log lostTan, Ming2020-12-223-17/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3126 1. If use PeiDxeDebugLibReportStatusCode as DebugLib, then some logs after ExitBootService() will be lost. 2. The root cause: 2.1 The original code will register an unregister function of gEfiEventExitBootServicesGuid, this unregister function will call EFI_RSC_HANDLER_PROTOCOL->Unregister and does not support log through serial port. 2.2 And some other drivers also register call back funtions of gEfiEventExitBootServicesGuid. 2.3 Then after the unregister function is called, other call back functions can't out log if them use RSC as DebugLib. 3. The DxeMain will report status code EFI_SW_BS_PC_EXIT_BOOT_SERVICES after notify all the call back functions of gEfiEventExitBootServicesGuid. 4. Solution: the StatusCodeHandlerRuntimeDxe.c will not register an unregister function of gEfiEventExitBootServicesGuid, but unregister it after receive the status code of EFI_SW_BS_PC_EXIT_BOOT_SERVICES. Cc: Dandan Bi <dandan.bi@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Ming Tan <ming.tan@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Dandan Bi <dandan.bi@intel.com>
* MdeModulePkg/PciSioSerialDxe: Flush Tx before config changeMichael D Kinney2020-12-191-1/+90
| | | | | | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=3114 Add logic to flush all UART transmit buffers if there is a config change from Reset(), SetAttributes() or SetControl(). Use a timeout in the flush operation, so the system can continue to boot if the transmit buffers can not be flushed for any reason. This change prevents lost characters on serial debug logs and serial consoles when a config change is made. It also prevents a UART from getting into a bad state or reporting error status due to characters being transmitted at the same time registers are updated with new communications settings. Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/Variable/RuntimeDxe: Add Variable Lock Protocol Unit TestsMichael D Kinney2020-12-153-0/+612
| | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=3111 Add host based unit tests for the multiple lock case using Variable Lock Protocol, Variable Policy Protocol, and mixes of Variable Lock Protocol and Variable Policy Protocol. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Bret Barkelew <Bret.Barkelew@microsoft.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
* MdeModulePkg/Variable/RuntimeDxe: Restore Variable Lock Protocol behaviorBret Barkelew2020-12-151-36/+59
| | | | | | | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=3111 The VariableLock shim currently fails if called twice because the underlying Variable Policy engine returns an error if a policy is set on an existing variable. This breaks existing code which expect it to silently pass if a variable is locked multiple times (because it should "be locked"). Refactor the shim to confirm that the variable is indeed locked and then change the error to EFI_SUCCESS and generate a DEBUG_ERROR message so the duplicate lock can be reported in a debug log and removed. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Bret Barkelew <Bret.Barkelew@microsoft.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
* MdeModulePkg: Fix SetMem parameter in OnigurumaUefiPortBaraneedharan Anbazhagan2020-12-141-1/+1
| | | | | | | | | | Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3085 Coding error in converting memset call to SetMem - Length and Value is not swapped on calling SetMem Signed-off-by: Baraneedharan Anbazhagan <anbazhagan@hp.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
* MdeModulePkg/FileExplorerLib: remove redundant null pointer checkwenyi xie2020-12-041-7/+3
| | | | | | | | | | | | | | | | | | | | | If "Info" is a valid pointer to an EFI_FILE_SYSTEM_VOLUME_LABEL structure, then "Info->VolumeLabel" denotes a valid array object. When the "Info->VolumeLabel" expression is evaluated, as seen in the LibFindFileSystem(), it is implicitly converted to (&Info->VolumeLabel[0]). Because the object described by the expression (Info->VolumeLabel[0]) is a valid CHAR16 object, its address can never compare equal to NULL. Therefore, the condition (Info->VolumeLabel == NULL) will always evaluate to FALSE. Substitute the constant FALSE into the "if" statement, and simplify the resultant code (eliminate the dead branch). Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Dandan Bi <dandan.bi@intel.com> Cc: Eric Dong <eric.dong@intel.com> Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
* MdeModulePkg: Fix undefined reference to memcpy with XCODE5Vitaly Cheptsov2020-12-043-8/+8
| | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3098 XCODE5 toolchain in NOOPT mode generates memcpy when trying to copy PEI_CORE_FV_HANDLE structure. This breaks OVMF compilation with XCODE5. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com> Signed-off-by: Vitaly Cheptsov <cheptsov@ispras.ru> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
* MdeModulePkg/VariablePolicyLib: Fix runtime panic in ValidateSetVariable()edk2-stable202011James Bottomley2020-11-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The current variable policy is allocated by AllocatePool(), which is boot time only. This means that if you do any variable setting in the runtime, the policy has been freed. Ordinarily this isn't detected because freed memory is still there, but when you boot the Linux kernel, it's been remapped so the actual memory no longer exists in the memory map causing a page fault. Fix this by making it AllocateRuntimePool(). For SMM drivers, the platform DSC is responsible for resolving the MemoryAllocationLib class to the SmmMemoryAllocationLib instance. In the SmmMemoryAllocationLib instance, AllocatePool() and AllocateRuntimePool() are implemented identically. Therefore this change is a no-op when the RegisterVariablePolicy() function is built into an SMM driver. The fix affects runtime DXE drivers only. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3092 Signed-off-by: James Bottomley <jejb@linux.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
* MdeModulePkg/LzmaCustomDecompressLib: catch 4GB+ uncompressed buffer sizesLaszlo Ersek2020-11-212-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The LzmaUefiDecompressGetInfo() function [MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c] currently silently truncates the UINT64 "DecodedSize" property of the compressed blob to the UINT32 "DestinationSize" output parameter. If "DecodedSize" is 0x1_0000_0100, for example, then the subsequent memory allocation (for decompression) will likely succeed (allocating 0x100 bytes only), but then the LzmaUefiDecompress() function (which re-fetches the uncompressed buffer size from the same LZMA header into a "SizeT" variable) will overwrite the buffer. Catch (DecodedSize > MAX_UINT32) in LzmaUefiDecompressGetInfo() at once. This should not be a practical limitation. (The issue cannot be fixed for 32-bit systems without spec modifications anyway, given that the "OutputSize" output parameter of EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL.ExtractSection() has type UINTN, not UINT64.) Cc: Dandan Bi <dandan.bi@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Philippe Mathieu-Daudé <philmd@redhat.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1816 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20201119115034.12897-2-lersek@redhat.com>
* MdeModulePkg/Core/Dxe: limit FwVol encapsulation section recursionLaszlo Ersek2020-11-214-2/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The DXE Core sets up a protocol notify function in its entry point, for instances of the Firmware Volume Block2 Protocol: DxeMain() [DxeMain/DxeMain.c] FwVolDriverInit() [FwVol/FwVol.c] Assume that a 3rd party UEFI driver or application installs an FVB instance, with crafted contents. The notification function runs: NotifyFwVolBlock() [FwVol/FwVol.c] installing an instance of the Firmware Volume 2 Protocol on the handle. (Alternatively, assume that a 3rd party application calls gDS->ProcessFirmwareVolume(), which may also produce a Firmware Volume 2 Protocol instance.) The EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() member performs "a depth-first, left-to-right search algorithm through all sections found in the specified file" (quoting the PI spec), as follows: FvReadFileSection() [FwVol/FwVolRead.c] GetSection() [SectionExtraction/CoreSectionExtraction.c] FindChildNode() [SectionExtraction/CoreSectionExtraction.c] FindChildNode() // recursive call FindChildNode() is called recursively for encapsulation sections. Currently this recursion is not limited. Introduce a new PCD (fixed-at-build, or patchable-in-module), and make FindChildNode() track the section nesting depth against that PCD. Cc: Dandan Bi <dandan.bi@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Philippe Mathieu-Daudé <philmd@redhat.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1743 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20201119105340.16225-3-lersek@redhat.com>
* MdeModulePkg/Core/Dxe: assert SectionInstance invariant in FindChildNode()Laszlo Ersek2020-11-211-6/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FindChildNode() has two callers: GetSection(), and FindChildNode() itself. - At the GetSection() call site, a positive (i.e., nonzero) SectionInstance is passed. This is because GetSection() takes a zero-based (UINTN) SectionInstance, and then passes Instance=(SectionInstance+1) to FindChildNode(). - For reaching the recursive FindChildNode() call site, a section type mismatch, or a section instance mismatch, is necessary. This means, respectively, that SectionInstance will either not have been decreased, or not to zero anyway, at the recursive FindChildNode() call site. Add two ASSERT()s to FindChildNode(), for expressing the (SectionSize>0) invariant. In turn, the invariant provides the explanation why, after the recursive call, a zero SectionInstance implies success. Capture it in a comment. Cc: Dandan Bi <dandan.bi@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20201119105340.16225-2-lersek@redhat.com>
* MdeModulePkg: Drop VarLock from RuntimeDxe variable driverBret Barkelew2020-11-175-48/+75
| | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=2522 Now that everything should be moved to VariablePolicy, drop support for the deprecated VarLock SMI interface and associated functions from variable RuntimeDxe. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Bret Barkelew <brbarkel@microsoft.com> Signed-off-by: Bret Barkelew <brbarkel@microsoft.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com> Acked-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg: Change TCG MOR variables to use VariablePolicyBret Barkelew2020-11-174-25/+82
| | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=2522 These were previously using VarLock, which is being deprecated. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Bret Barkelew <brbarkel@microsoft.com> Signed-off-by: Bret Barkelew <brbarkel@microsoft.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com> Acked-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg: Allow VariablePolicy state to delete protected variablesBret Barkelew2020-11-172-0/+12
| | | | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=2522 TcgMorLockSmm provides special protections for the TCG MOR variables. This will check IsVariablePolicyEnabled() before enforcing them to allow variable deletion when policy engine is disabled. Only allows deletion, not modification. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Bret Barkelew <brbarkel@microsoft.com> Signed-off-by: Bret Barkelew <brbarkel@microsoft.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com> Acked-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg: Connect VariablePolicy business logic to VariableServicesBret Barkelew2020-11-177-0/+670
| | | | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=2522 VariablePolicy is an updated interface to replace VarLock and VarCheckProtocol. Add connective code to publish the VariablePolicy protocol and wire it to either the SMM communication interface or directly into the VariablePolicyLib business logic. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Bret Barkelew <brbarkel@microsoft.com> Signed-off-by: Bret Barkelew <brbarkel@microsoft.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com> Acked-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
* MdeModulePkg: Define the VarCheckPolicyLib and SMM interfaceBret Barkelew2020-11-176-0/+460
| | | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=2522 VariablePolicy is an updated interface to replace VarLock and VarCheckProtocol. This is an instance of a VarCheckLib that is backed by the VariablePolicyLib business logic. It also publishes the SMM calling interface for messages from the DXE protocol. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Bret Barkelew <brbarkel@microsoft.com> Signed-off-by: Bret Barkelew <brbarkel@microsoft.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com> Acked-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg: Define the VariablePolicyHelperLibBret Barkelew2020-11-176-0/+614
| | | | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=2522 VariablePolicy is an updated interface to replace VarLock and VarCheckProtocol. Add the VariablePolicyHelperLib library, containing several functions to help with the repetitive process of creating a correctly structured and packed VariablePolicy entry. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Bret Barkelew <brbarkel@microsoft.com> Signed-off-by: Bret Barkelew <brbarkel@microsoft.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com> Acked-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg: Define the VariablePolicyLibBret Barkelew2020-11-1711-1/+1696
| | | | | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=2522 VariablePolicy is an updated interface to replace VarLock and VarCheckProtocol. Add the VariablePolicyLib library that implements the portable business logic for the VariablePolicy engine. Also add host-based CI test cases for the lib. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Bret Barkelew <brbarkel@microsoft.com> Signed-off-by: Bret Barkelew <brbarkel@microsoft.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com> Acked-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg: Define the VariablePolicy protocol interfaceBret Barkelew2020-11-173-1/+177
| | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=2522 VariablePolicy is an updated interface to replace VarLock and VarCheckProtocol. Add the VariablePolicy protocol interface header and add to the MdeModulePkg.dec file. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Bret Barkelew <brbarkel@microsoft.com> Signed-off-by: Bret Barkelew <brbarkel@microsoft.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com> Acked-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg DisplayEngineDxe: Correct the local variable name.gechao2020-11-121-8/+8
| | | | | Signed-off-by: gechao <gechao@greatwall.com.cn> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
* MdeModulePkg/AtaAtapiPassThru: Trace ATA packetsAlbecki, Mateusz2020-11-111-0/+94
| | | | | | | | | | | | | This simplify ATA driver debugging all ATA packets will be printed to debug port on DEBUG_VERBOSE level along with the packet execution status. Additionally failed packets and the failed packet execution status will be printed on DEBUG_ERROR level. Signed-off-by: Mateusz Albecki <mateusz.albecki@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com>