summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
Commit message (Collapse)AuthorAgeFilesLines
* MdeModulePkg ConPlatform: Support IAD-style USB input devices.John Schock2024-08-061-3/+18
| | | | | | | | | | | | | | | | | | Some multi-function input devices (e.g. combo keyboard and mouse) present as IAD-style devices (https://www.usb.org/defined-class-codes, https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/usb-interface-association-descriptor). Historically, multi-function devices would report a DeviceClass of 0, indicating that interface matching should be done on the interface descriptor rather than the global device descriptor. IAD-style devices us DeviceClass of 0xEF, so they don't match MatchUsbClass() for keyboard (DeviceClass=3, SubClass=1, Proto=1). If they are treated as if they had a DeviceClass of zero, which is more traditional for legacy multi-function devices, then the interface descriptors are used instead and these types of devices will "just work" without needing to add a custom USB device path to ConIn. Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
* MdeModulePkg: NvmExpressDxe: Add Timeout Status CodesSean Brogan2024-07-311-0/+2
| | | | | | | Add Report status code events to Nvme to trigger when timeouts occur. This improves traceability when critical errors happen. Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
* MdeModulePkg/UfsPassThruDxe: Migrate UFS Initial Completion Timeout to PCDJason1 Lin2024-07-303-7/+8
| | | | | | | - Remove the hardcoded definition (UFS_INIT_COMPLETION_TIMEOUT) - Migrate the UFS initial completion timeout into PCD value Signed-off-by: Jason1 Lin <jason1.lin@intel.com>
* MdeModulePkg/UfsBlockIoPei: Migrate UFS Initial Completion Timeout to PCDJason1 Lin2024-07-303-7/+7
| | | | | | | - Remove the hardcoded definition (UFS_INIT_COMPLETION_TIMEOUT) - Migrate the UFS initial completion timeout into PCD value Signed-off-by: Jason1 Lin <jason1.lin@intel.com>
* MdeModulePkg: Add the PcdUfsInitialCompletionTimeout in DEC FileJason1 Lin2024-07-301-0/+5
| | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4820 - Add the PCD to indicate the UFS device initialize completion time - Default value of this PCD value is 600ms Signed-off-by: Jason1 Lin <jason1.lin@intel.com>
* MdeModulePkg: Optimize PEI Core Migration AlgorithmAwiral Shrivastava2024-07-303-9/+47
| | | | | | | | | | | | | | | | | | | | | REF : https://bugzilla.tianocore.org/show_bug.cgi?id=4750 Migrate the FV that doesn't contain the currently executing PEI Core when permanent memory is initialized but PEI Core is still potentially running from faster memory (Tepmorary RAM). This may reduce the time required to migrate FVs to permanent memory. The FV containing PEI Core is migrated after the PEI Core reentry when it is executed from permanent memory. This may or may not improve performance depending on the behavior of temporary RAM and the actual performance changes must be measured with the feature enabled and disabled. This migration algorithm is only used for FVs specified in the gEdkiiMigrationInfoGuid HOB and built with flag FLAGS_FV_MIGRATE_BEFORE_PEI_CORE_REENTRY. Signed-off-by: Awiral Shrivastava <awiral.shrivastava@intel.com>
* MdeModulePkg: fix issue caused by uninitialized variableDun Tan2024-07-291-0/+1
| | | | | | | | | | | | | | | | | | | This patch is to fix issue caused by uninitialized local variable in Pei/Variable.c. In the fucntion CalculateHobVariableCacheSize(), the local variable VARIABLE_STORE_INFO StoreInfo is used without initialization. When the uninitialized variable is passed to CalculateAuthVarStorageSize() and GetNextVariablePtr(), the field StoreInfo->FtwLastWriteData might be a uninitialized non-zero value. Then the code execution will access the invalid address StoreInfo->FtwLastWriteData->TargetAddress. This might cause issue. So in this commit, the local variable VARIABLE_STORE_INFO StoreInfo is initialized by a ZeroMem() before use. Signed-off-by: Dun Tan <dun.tan@intel.com>
* MdeModulePkg: Add NVMe Long Delay Time EventsSean Brogan2024-07-275-2/+38
| | | | | | | | Fire an event if a long delay occurs when starting an NVMe device. This can be used by platforms to draw pictures on the screen or take other actions to notify a user or move boot forward. Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
* MdeModulePkg: Consume SOC related ACPI table from ACPI Silicon HOBGeorge Liao2024-07-264-0/+129
| | | | | | | | | | REF : https://bugzilla.tianocore.org/show_bug.cgi?id=4787 If ACPI Silicon Hob has been found from entry of AcpiTableDxe driver, that means SOC related ACPI tables been pass to the DXE phase by HOB. Each SOC related ACPI tables will be install. Signed-off-by: George Liao <george.liao@intel.com>
* MdeModulePkg: Remove EFI_MEMORY_* DefinesDmitry Antipov2024-07-261-16/+0
| | | | | | | Now that all of the EFI_MEMORY_* defines live in the EFI_MEMORY_TYPE enum, remove the old defines. Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
* MdeModulePkg/VariablePolicyLib: Use wildcard character constantMichael Kubacki2024-07-221-2/+2
| | | | | | | | Makes the `#` character used for comparison against wildcard characters in `CHAR16` strings to be prefixed with `L` so the character is treated as a wide character constant. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
* MdeModulePkg/SmiHandlerProfileInfo: Include profile SMI in profileBret Barkelew2024-07-181-4/+13
| | | | | | | Includes the profiler SMI in the profile itself for completeness. Co-authored-by: Michael Kubacki <michael.kubacki@microsoft.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
* MdeModulePkg: DxeCore: Fix Use-After-Free guard causing page faultKun Qin2024-07-171-23/+28
| | | | | | | | | | | | | | | | REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2411 With Use-After-Free heap guard feature enabled, the DxeCore would blindly attempt to "level-up" when the `GuardAllFreedPages` inspect a non-max level table entry from the last loop. This could cause the next round of inspection to dereference a potentially null pointer and as such causing a page fault. This change adds a null pointer check to prevent such case from happening. Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Kun Qin <kun.qin@microsoft.com>
* MdeModulePkg/UfsBlockIoPei: Wait fDeviceInit Be Cleared by DevicesJason1 Lin2024-07-173-7/+105
| | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4655 [Feature Description] - UFS device would clear fDeviceInit flag once the device initialization is completed. - This change is polling to check the flag is cleared or not with specific timeout (UFS_INIT_COMPLETION_TIMEOUT - 600ms). - This behavior is the same as UfsPassThruDxe module. [Notes] - This change included as a partial of below SHA1-ID - 95ad8f7f6a6c84ef46a96a8ba852afed805d1ca3 - c5740f360636479fb91681093b1dee1cc366075c Signed-off-by: Jason1 Lin <jason1.lin@intel.com>
* MdeModulePkg/Core/DxeIplPeim: Enhance Code in DxeIplFindDxeCore FunctionJason1 Lin2024-07-171-3/+10
| | | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4653 In DxeIplFindDxeCore function, there exists different behavior between Debug and Release built BIOS. This change is used to unify both of the code flow and fix the potential overflow of "Instance" variable. In this change, [1] Move the ASSERT_EFI_ERROR (Status) in failure to find DxeCore in any firmware volume condition. [2] Break the while-loop when not found required DxeCore. This would make the Instance variable not overflow in while-loop. [3] Add the CpuDeadLoop () in the end of the function and do not return since DxeCore is mandatory for the following booting to hand-off the PEI phase to DXE phase. [4] In case of the CpuDeadLoop () is de-assert by debugger, return the NULL pointer. Signed-off-by: Jason1 Lin <jason1.lin@intel.com>
* MdeModulePkg/SmiHandlerProfileInfo: Declare correct XML encodingMichael Kubacki2024-07-171-1/+1
| | | | | | | The code prints wide strings, so the content should be "utf-16" rather than "utf-8". Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
* MdeModulePkg/RuntimeResetSystemLib: Make global staticMichael Kubacki2024-07-121-2/+2
| | | | | | | | Makes the `mInternalRT` global static in this library instance to avoid conflicting with other code such as a global variable with the same name in MdePkg/Library/UefiRuntimeLib. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
* MdeModulePkg: Remove PeiAllocatePool() AssertKun Qin2024-07-101-2/+0
| | | | | | | | | Removes an assert if PeiAllocatePool() fails to allocate memory to defer error handling to the caller so the error can be handled gracefully or asserted at that location which is more specific to the call that led to the allocation. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
* MdeModulePkg: Add HobPrintLib instanceWei6 Xu2024-07-073-0/+504
| | | | | | | | | | | | The HobPrintLib prints all HOB info from the HOB list. The code is abstracted from UefiPayloadPkg/UefiPayloadEntry/PrintHob.c. Cc: Guo Dong <guo.dong@intel.com> Cc: Sean Rhodes <sean@starlabs.systems> Cc: James Lu <james.lu@intel.com> Cc: Gua Guo <gua.guo@intel.com> Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
* MdeModulePkg: Add HobPrintLib header fileWei6 Xu2024-07-072-0/+50
| | | | | | | | | | Interface PrintHobList() is added to dump all HOBs info in the HobList. Caller could specify a custom HOB print handler to replace the default print handler when calling the interface. Cc: Ray Ni <ray.ni@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
* MdeModulePkg/VariableSmm: Fix NonPrimary Buffer check issueJiaxin Wu2024-07-075-13/+14
| | | | | | | | | | | | | | | | | | VariableSmmIsBufferOutsideSmmValid function is to check the buffer is outside SMM or not. This patch fix the issue that always return true for MM. Meanwhile, this patch renames VariableSmmIsBufferOutsideSmmValid to VariableSmmIsNonPrimaryBufferValid. Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Ray Ni <ray.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Hongbin1 Zhang <hongbin1.zhang@intel.com> Cc: Wei6 Xu <wei6.xu@intel.com> Cc: Dun Tan <dun.tan@intel.com> Cc: Yuanhao Xie <yuanhao.xie@intel.com>
* MdeModulePkg/VariableSmm: Add func for Primary Buffer valid checkJiaxin Wu2024-07-074-6/+57
| | | | | | | | | | | | | | | | | Add a new function (VariableSmmIsPrimaryBufferValid) to check Primary Buffer valid or not. original function (VariableSmmIsBufferOutsideSmmValid) is used to check the buffer outside MMRAM. Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Ray Ni <ray.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Hongbin1 Zhang <hongbin1.zhang@intel.com> Cc: Wei6 Xu <wei6.xu@intel.com> Cc: Dun Tan <dun.tan@intel.com> Cc: Yuanhao Xie <yuanhao.xie@intel.com>
* MdeModulePkg/VarCheckPolicyLib: Fix buffer valid check for MMJiaxin Wu2024-07-071-1/+1
| | | | | | | | | | | | | | | | For MM, the MM Handlers do not need to validate the buffer if it is the CommBuffer passed from MmCore through the MmiHandler() parameter. Return TRUE directly in this case. Fix buffer valid check for MM in this patch. Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Ray Ni <ray.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Hongbin1 Zhang <hongbin1.zhang@intel.com> Cc: Wei6 Xu <wei6.xu@intel.com> Cc: Dun Tan <dun.tan@intel.com> Cc: Yuanhao Xie <yuanhao.xie@intel.com>
* MdeModulePkg/VarCheckPolicyLib: Update buffer valid check func nameJiaxin Wu2024-07-074-13/+19
| | | | | | | | | | | | | | | | | | | | | | | | In the MdeModulePkg/VarCheckPolicyLib, the Primary Buffer (CommBuffer) check function has been updated to match the buffer validation behavior. For SMM, the SMM Handlers is to validate the buffer outside MMRAM. For MM, the MM Handlers do not need to validate the buffer if it is the CommBuffer passed from MmCore through the MmiHandler() parameter. Return TRUE directly in this case. Existing code is incorrect for the MM check. This will be fixed in the following patch. There is no function impact. Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Ray Ni <ray.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Hongbin1 Zhang <hongbin1.zhang@intel.com> Cc: Wei6 Xu <wei6.xu@intel.com> Cc: Dun Tan <dun.tan@intel.com> Cc: Yuanhao Xie <yuanhao.xie@intel.com>
* MdeModulePkg/FaultTolerantWriteSmm: Update buffer valid check func nameJiaxin Wu2024-07-074-22/+16
| | | | | | | | | | | | | | | | | | | | | | | In the MdeModulePkg/FaultTolerantWriteSmm, the Primary Buffer (CommBuffer) check function has been updated to match the buffer validation behavior: For SMM, the SMM Handlers is to validate the buffer outside MMRAM. For MM, the MM Handlers do not need to validate the buffer if it is the CommBuffer passed from MmCore through the MmiHandler() parameter. Return TRUE directly in this case. There is no function impact. Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Ray Ni <ray.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Hongbin1 Zhang <hongbin1.zhang@intel.com> Cc: Wei6 Xu <wei6.xu@intel.com> Cc: Dun Tan <dun.tan@intel.com> Cc: Yuanhao Xie <yuanhao.xie@intel.com>
* MdeModulePkg/StandaloneMmReportStatusCodeLib: Support MM_CORE_STANDALONEJiaxin Wu2024-07-051-1/+1
| | | | | | Support the module type for MM_CORE_STANDALONE Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
* MdeModulePkg/NvmExpressDxe: use format "0x%lx" for UINT64 values.Mike Maslenkin2024-07-041-3/+3
| | | | | Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
* MdeModulePkg/NvmExpressDxe: fix format used for Eui64 conversionMike Maslenkin2024-07-041-1/+1
| | | | | | | | Eui64 is a 64 bit value, so the "L" or "l" is required for format specifier, otherwise only lower 32 bit will be converted. Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
* MdeModulePkg/UsbBusDxe: USB issue fix when the port resetBritton Chesley2024-07-031-1/+26
| | | | | | | | | | | | | | | | BZ #4456 Fixed a bug which led to an ASSERT due to the USB device context being maintained after a port reset, but the underlying XHCI context was uninitialized. Specifically, Xhc->UsbDevContext is freed after a reset and only re-allocates the default [0] enpoint transfer ring. In order to avoid a memory leak, device enumeration is performed after freeing the necessary buffers. This allocates the Xhc->UsbDevContext for all endpoints of the USB device. Signed-off-by: Britton Chesley <Brit.Chesley@amd.com>
* MdeModulePkg/DisplayEngineDxe: Support "^" and "V" key on pop-up formGaurav Pandya2024-06-261-0/+42
| | | | | | | | BZ #4790 Support "^" and "V" key stokes on the pop-up form. Align the implementation with key support on the regular HII form. Signed-off-by: Gaurav Pandya <gaurav.pandya@amd.com>
* MdeModulePkg/ImagePropertiesRecordLib: Reduce debug levelNhi Pham2024-06-261-1/+1
| | | | | | | | | | | The presense of PdbPointer (PDB file name) is not an error. Hence, the debug message should be categorized as VERBOSE or INFO. However, the DEBUG_VERBOSE is more appropriate since the PDB file name is already output by the PeCoffLoaderRelocateImageExtraAction() function with the inline "add-symbol-file" when a platform uses the library instance DebugPeCoffExtraActionLib. Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
* MdeModulePkg: Avoid efi memory allocation for SP memoryDhaval2024-06-191-0/+7
| | | | | | | | | | | | | | | HBM/CXL memory systems are treated as special purpose memories. In many cases it is desirable not to use special purpose memory for regular edk2 usages as these memories (HBm/CXL) are either meant for special purposes or are less reliable to be used. Until such memory systems evolve and we have better clarity from UEFI spec, avoid using them for edk2 boot memory purposes. Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Oliver Smith-Denny <osde@linux.microsoft.com> Signed-off-by: Dhaval Sharma <dhaval@rivosinc.com> Co-authored-by: Tim Wawrzynczak <tim@rivosinc.com>
* MdeModulePkg/DxeCapsuleLibFmp: Fix compilation errorNhi Pham2024-06-192-2/+2
| | | | | | | | | | | | | | The commit "MdeModulePkg/DxeCapsuleLibFmp: Fix crash if no ESRT is found" leads to a compilation error in MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf. The issue occurs because the variable mDxeCapsuleLibReadyToBootEvent which is declared as extern does not exist, while it is defined in DxeCapsuleRuntime.c, a file not included in DxeCapsuleLib.inf. This patch is to fix this by moving the variable defintion to DxeCapsuleLib.c and declare it as extern in DxeCapsuleRuntime.c. Reported-by: Gua Guo <gua.guo@intel.com> Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
* MdeModulePkg/Core/Pei: Install MigrateTempRamPpiZhihao Li2024-06-186-5/+41
| | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4716 Migrate FSP-T/M binary from temporary RAM to permanent RAM before NEM tear down. Tcg module will use permanent address of FSP-T/M for measurement. In MdeModulePkg, PeiCore installs mMigrateTempRamPpi if PcdMigrateTemporaryRamFirmwareVolumes is True before NEM tear down and after permanent memory ready. Cc: Chasel Chiu <chasel.chiu@intel.com> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com> Cc: Duggapu Chinni B <chinni.b.duggapu@intel.com> Cc: Chen Gang C <gang.c.chen@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Zhihao Li <zhihao.li@intel.com>
* MdeModulePkg:Add global variable mVariableRtCacheInfoDun Tan2024-06-171-58/+51
| | | | | | | | | Add global variable mVariableRtCacheInfo to save the content in gEdkiiVariableRuntimeCacheInfoHobGuid. With this new global variable, 7 global variables can be removed. Signed-off-by: Dun Tan <dun.tan@intel.com>
* MdeModulePkg: Refine InitVariableCache()Dun Tan2024-06-171-100/+94
| | | | | | | | | | | Refine the code logic in InitVariableCache(). In this commit, three times calling of InitVariableCache() for different type cache are merged into one calling. This commit is to make the code looks cleaner and doesn't change any code functionality. Signed-off-by: Dun Tan <dun.tan@intel.com>
* MdeModulePkg:Remove the usage of PcdEnableVariableRuntimeCacheDun Tan2024-06-172-7/+7
| | | | | | | | Remove the usage of PcdEnableVariableRuntimeCache. We can use the existence of gEdkiiVariableRuntimeCacheInfoHobGuid to indicate if variable runtime cache is enabled or not. Signed-off-by: Dun Tan <dun.tan@intel.com>
* MdeModulePkg:Consume gEdkiiVariableRuntimeCacheInfoHobGuidDun Tan2024-06-172-74/+55
| | | | | | | | | | | | | | | | | | Consume gEdkiiVariableRuntimeCacheInfoHobGuid in VariableSmmRuntimeDxe driver to initialize the following variable cache related buffer: *mVariableRuntimeHobCacheBuffer *mVariableRuntimeNvCacheBuffer *mVariableRuntimeVolatileCacheBuffer *mVariableRuntimeCachePendingUpdate *mVariableRuntimeCacheReadLock *mHobFlushComplete The code to to allocate and unblock the buffer for different type cache in VariableSmmRuntimeDxe is also removed in this commit. Signed-off-by: Dun Tan <dun.tan@intel.com>
* MdeModulePkg:Remove unneed FreePages for RuntimeHobCacheBufferDun Tan2024-06-171-7/+3
| | | | | | | | | Remove unneed FreePages() for RuntimeHobCacheBuffer which is allocated in PEI phase. So the global variable mVariableRuntimeHobCacheBufferSize also can be removed. Signed-off-by: Dun Tan <dun.tan@intel.com>
* MdeModulePkg:Remove unnecessary global variablesDun Tan2024-06-171-7/+7
| | | | | | | | | Remove the two unnecessary global variables and replace them by two local variables: mVariableRuntimeNvCacheBufferSize mVariableRuntimeVolatileCacheBufferSize Signed-off-by: Dun Tan <dun.tan@intel.com>
* MdeModulePkg:Create gEdkiiVariableRuntimeCacheInfoHobGuidDun Tan2024-06-173-2/+310
| | | | | | | | | | | | | Install the callback of gEfiPeiMemoryDiscoveredPpiGuid to create gEdkiiVariableRuntimeCacheInfoHobGuid in VariablePei module. When PcdEnableVariableRuntimeCache is TRUE, the callback will be installed to allocate the needed buffer for different type variable runtime cache, unblock the buffer and build this HOB. Then the runtime cache buffer address and size will be saved in the HOB content. Signed-off-by: Dun Tan <dun.tan@intel.com>
* MdeModulePkg:Add new gEdkiiVariableRuntimeCacheInfoHobGuidDun Tan2024-06-172-0/+64
| | | | | | | | | | | | | | | | | This commit defines VARIABLE_RUNTIME_CACHE_INFO HOB. The HOB is used to store the address and size of the buffer that will be used for variable runtime service when the PcdEnableVariableRuntimeCache is TRUE. In following patches, when PcdEnableVariableRuntimeCache is TRUE, VariablePei module will install a callback of gEfiPeiMemoryDiscoveredPpiGuid to allocate needed buffer for different type cache, unblock the buffer and build HOB. Then VariableSmmRuntimeDxe driver will consume the gEdkiiVariableRuntimeCacheInfoHobGuid to initialize the variable runtime cache related content. Signed-off-by: Dun Tan <dun.tan@intel.com>
* MdeModulePkg/DxeCapsuleLibFmp: Fix crash if no ESRT is foundNhi Pham2024-06-072-0/+17
| | | | | | | | | | | | The ESRT table is not required in UEFI firmware. In such cases, the table may not be present in the UEFI Configuration Table. The mEsrtTable is to check if the IsNestedFmpCapsule() function is invoked at runtime to determine whether to use gEsrtManagementProtocolGuid or the ESRT table from the Configuration Table. Unfortunately, the check does not cover situations where the ESRT is not present, potentially resulting in a kernel crash. This patch is intended to fix this issue. Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
* MdeModulePkg: In RemoveTableFromRsdt don't read from unallocated memoryRebecca Cran2024-06-071-4/+4
| | | | | | | Instead of copying from unallocated memory in RemoveTableFromRsdt, do a CopyMem followed by ZeroMem. Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
* MdeModulePkg: Warn if out of flash space when writing variablesOliver Steffen2024-06-071-0/+2
| | | | | | | | | | | | Emit a DEBUG_WARN message if there is not enough flash space left to write/update a variable. This condition is currently not logged appropriately in all cases, given that full variable store can easily render the system unbootable. This new message helps identifying this condition. Signed-off-by: Oliver Steffen <osteffen@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
* MdeModulePkg/HiiDatabaseDxe: Remove assert for VarStoreId = 0Jeff Brasen2024-06-061-2/+3
| | | | | | | | | | | | | | It is legal for the VarStoreId of a question to be 0 per the UEFI spec: "Specifies the identifier of a previously declared variable store to use when storing the question’s value. A value of zero indicates no associated variable store." Instead of hitting an assert just skip this question as there is no value to return. Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
* MdeModulePkg/HiiDatabaseDxe: Avoid struct assignmentArd Biesheuvel2024-06-041-4/+5
| | | | | | | | | | | | Struct assignments are not permitted in EDK2, as they may be converted by the compiler into calls to the 'memcpy' intrinsic, which is not guaranteed to be available in EDK2. So replace the assignment with a call to CopyMem (), and -while at it- replace the loop with a single CopyMem () call, as the loop operates on items that are contiguous in memory. Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
* MdeModulePkg:Remove MpService2Ppi field in SMM_S3_RESUME_STATEDun Tan2024-06-041-2/+1
| | | | | | | | | | | | | | | This MpService2Ppi field in SMM_S3_RESUME_STATE is used to wakeup AP to do the CPU initialization during smm s3 boot when the execution mode of PEI and DXE are the same. Currently, in CpuS3.c of smm cpu driver, BSP doesn't need to wakeup AP anymore. The initialization for AP will be done in S3Resume.c before transfer to CpuS3.c of smm cpu driver. So we can remove the MpService2Ppi field in SMM_S3_RESUME_STATE. Signed-off-by: Dun Tan <dun.tan@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
* MdeModulePkg: Add gEdkiiS3MtrrSettingGuidDun Tan2024-06-041-1/+4
| | | | | | | | | | | | Add gEdkiiS3MtrrSettingGuid a new GUID for s3 MTRR setting. This GUID will be used to save MTRR_SETTINGS at EndOfDxe by LockBox and restore at S3 boot PEI phase for s3 usage. Signed-off-by: Dun Tan <dun.tan@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
* MdeModulePkg: Update GCD attribute conversion to support SP attributeDu Lin2024-06-021-0/+1
| | | | | | | Add a new entry into GCD attribute conversion table to convert EFI_RESOURCE_ATTRIBUTE_SPECIAL_PURPOSE to EFI_MEMORY_SP. Signed-off-by: Du Lin <du.lin@intel.com>