Commit Graph

6350 Commits

Author SHA1 Message Date
Zhang Hongbin 82d2f6b3c3 MdeModulePkg/SmmCommunicationBufferDxe: Re-use FixedCommBuffer
SmmCommunicationBufferDxe need to re-use FixedCommBuffer from
MmCommBuffer HOB which created under PEI stage.

Signed-off-by: Hongbin1 Zhang <hongbin1.zhang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
2024-08-28 15:25:27 +00:00
Hongbin1 Zhang 45098bf1b8 MdeModulePkg/MdeModulePkg.dec: Add PcdMmCommBufferPages PCD
PcdMmCommBufferPages is to specify the page count allocated for
the MM communication buffer.

Signed-off-by: Hongbin1 Zhang <hongbin1.zhang@intel.com>
Co-authored-by: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Co-authored-by: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Cc: Dun Tan <dun.tan@intel.com>
Cc: Yuanhao Xie <yuanhao.xie@intel.com>
2024-08-28 15:25:27 +00:00
Hongbin1 Zhang ff04469d33 MdeModulePkg: Add MM Communication Buffer definition
The MM communicate buffer facilitates data sharing between non-MM
and MM code.
The MM IPL code allocates a "fixed" runtime type memory as the MM
communication buffer, and communicates its address and size to MM
Core via MmCommBuffer GUIDed HOB.
Here, "fixed" implies that the buffer's location remains constant
throughout the boot process.
Data is exchanged between the MM Communication PPI/Protocol and a
software MMI handler using this fixed MM communication buffer.

Signed-off-by: Hongbin1 Zhang <hongbin1.zhang@intel.com>
Co-authored-by: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Co-authored-by: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Cc: Dun Tan <dun.tan@intel.com>
Cc: Yuanhao Xie <yuanhao.xie@intel.com>
2024-08-28 15:25:27 +00:00
Mike Maslenkin 1cc0fae8d9 MdeModulePkg/RamDiskDxe: fix memory leak on error path.
This patch fixes a leak of memory allocated for the RAM disk in cases
when an error occurred while reading contents of a file from disk
or RamDiskRegister() returned some error condition.

Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
2024-08-26 05:32:42 +00:00
John Schock 472be4d139 MdeModulePkg ConPlatform: Support IAD-style USB input devices.
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>
2024-08-06 03:24:40 +00:00
Sean Brogan 9df400fd4d MdeModulePkg: NvmExpressDxe: Add Timeout Status Codes
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>
2024-07-31 04:09:49 +00:00
Jason1 Lin f8f34edd9d MdeModulePkg/UfsPassThruDxe: Migrate UFS Initial Completion Timeout to PCD
- 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>
2024-07-30 20:55:09 +00:00
Jason1 Lin 5289ad177d MdeModulePkg/UfsBlockIoPei: Migrate UFS Initial Completion Timeout to PCD
- 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>
2024-07-30 20:55:09 +00:00
Jason1 Lin bc1c890e8e MdeModulePkg: Add the PcdUfsInitialCompletionTimeout in DEC File
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>
2024-07-30 20:55:09 +00:00
Awiral Shrivastava 5b08df03f8 MdeModulePkg: Optimize PEI Core Migration Algorithm
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>
2024-07-30 13:51:41 +00:00
Dun Tan 43e2395c1b MdeModulePkg: fix issue caused by uninitialized variable
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>
2024-07-29 06:43:27 +00:00
Sean Brogan d7e36ccbbd MdeModulePkg: Add NVMe Long Delay Time Events
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>
2024-07-27 01:32:21 +00:00
George Liao 03ad59e631 MdeModulePkg: Consume SOC related ACPI table from ACPI Silicon HOB
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>
2024-07-26 17:12:18 +00:00
Dmitry Antipov ffc09b51cb MdeModulePkg: Remove EFI_MEMORY_* Defines
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>
2024-07-26 03:08:20 +00:00
Michael Kubacki 469f29fe76 MdeModulePkg/VariablePolicyLib: Use wildcard character constant
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>
2024-07-22 11:52:02 +00:00
Bret Barkelew 489e4a60ea MdeModulePkg/SmiHandlerProfileInfo: Include profile SMI in profile
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>
2024-07-18 19:22:36 +00:00
Kun Qin cee9d1b16b MdeModulePkg: DxeCore: Fix Use-After-Free guard causing page fault
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>
2024-07-17 20:56:50 +00:00
Jason1 Lin 11c50d6ca1 MdeModulePkg/UfsBlockIoPei: Wait fDeviceInit Be Cleared by Devices
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
    - 95ad8f7f6a
    - c5740f3606

Signed-off-by: Jason1 Lin <jason1.lin@intel.com>
2024-07-17 18:03:35 +00:00
Jason1 Lin b3441e0100 MdeModulePkg/Core/DxeIplPeim: Enhance Code in DxeIplFindDxeCore Function
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>
2024-07-17 05:46:12 +00:00
Michael Kubacki 6b4dd3625b MdeModulePkg/SmiHandlerProfileInfo: Declare correct XML encoding
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>
2024-07-17 01:06:00 +00:00
Michael Kubacki f122c6f639 MdeModulePkg/RuntimeResetSystemLib: Make global static
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>
2024-07-12 02:03:12 +00:00
Kun Qin f91211049c MdeModulePkg: Remove PeiAllocatePool() Assert
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>
2024-07-10 02:10:37 +00:00
Wei6 Xu d5b03d5fba MdeModulePkg: Add HobPrintLib instance
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>
2024-07-07 10:12:36 +00:00
Wei6 Xu 19bcc73213 MdeModulePkg: Add HobPrintLib header file
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>
2024-07-07 10:12:36 +00:00
Jiaxin Wu 0986faad97 MdeModulePkg/VariableSmm: Fix NonPrimary Buffer check issue
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>
2024-07-07 08:40:03 +00:00
Jiaxin Wu 8befdb1441 MdeModulePkg/VariableSmm: Add func for Primary Buffer valid check
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>
2024-07-07 08:40:03 +00:00
Jiaxin Wu acfdb6771c MdeModulePkg/VarCheckPolicyLib: Fix buffer valid check for MM
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>
2024-07-07 08:40:03 +00:00
Jiaxin Wu c0021d31f8 MdeModulePkg/VarCheckPolicyLib: Update buffer valid check func name
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>
2024-07-07 08:40:03 +00:00
Jiaxin Wu 67d3be644f MdeModulePkg/FaultTolerantWriteSmm: Update buffer valid check func name
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>
2024-07-07 08:40:03 +00:00
Jiaxin Wu 22d0babd33 MdeModulePkg/StandaloneMmReportStatusCodeLib: Support MM_CORE_STANDALONE
Support the module type for MM_CORE_STANDALONE

Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
2024-07-05 14:52:00 +00:00
Mike Maslenkin 4e36bed812 MdeModulePkg/NvmExpressDxe: use format "0x%lx" for UINT64 values.
Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2024-07-04 14:56:42 +00:00
Mike Maslenkin 4f73eef838 MdeModulePkg/NvmExpressDxe: fix format used for Eui64 conversion
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>
2024-07-04 14:56:42 +00:00
Britton Chesley ed07a2bb11 MdeModulePkg/UsbBusDxe: USB issue fix when the port reset
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>
2024-07-03 12:23:26 +00:00
Gaurav Pandya ae09721a65 MdeModulePkg/DisplayEngineDxe: Support "^" and "V" key on pop-up form
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>
2024-06-26 16:21:24 +00:00
Nhi Pham 89377ece8f MdeModulePkg/ImagePropertiesRecordLib: Reduce debug level
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>
2024-06-26 12:40:30 +00:00
Dhaval 4d4f569924 MdeModulePkg: Avoid efi memory allocation for SP memory
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>
2024-06-19 13:12:40 +08:00
Nhi Pham 26a30abdd0 MdeModulePkg/DxeCapsuleLibFmp: Fix compilation error
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>
2024-06-19 08:53:42 +08:00
Zhihao Li 176b9d41f8 MdeModulePkg/Core/Pei: Install MigrateTempRamPpi
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>
2024-06-18 07:23:19 +00:00
Dun Tan 128513afcd MdeModulePkg:Add global variable mVariableRtCacheInfo
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>
2024-06-17 13:42:43 +00:00
Dun Tan 081df0ec20 MdeModulePkg: Refine InitVariableCache()
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>
2024-06-17 13:42:43 +00:00
Dun Tan 92974e3d18 MdeModulePkg:Remove the usage of PcdEnableVariableRuntimeCache
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>
2024-06-17 13:42:43 +00:00
Dun Tan 689f415a49 MdeModulePkg:Consume gEdkiiVariableRuntimeCacheInfoHobGuid
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>
2024-06-17 13:42:43 +00:00
Dun Tan c1c2e474a2 MdeModulePkg:Remove unneed FreePages for RuntimeHobCacheBuffer
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>
2024-06-17 13:42:43 +00:00
Dun Tan 645d9f6f8d MdeModulePkg:Remove unnecessary global variables
Remove the two unnecessary global variables and
replace them by two local variables:
  mVariableRuntimeNvCacheBufferSize
  mVariableRuntimeVolatileCacheBufferSize

Signed-off-by: Dun Tan <dun.tan@intel.com>
2024-06-17 13:42:43 +00:00
Dun Tan d8f513de3e MdeModulePkg:Create gEdkiiVariableRuntimeCacheInfoHobGuid
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>
2024-06-17 13:42:43 +00:00
Dun Tan 025a95b7ed MdeModulePkg:Add new gEdkiiVariableRuntimeCacheInfoHobGuid
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>
2024-06-17 13:42:43 +00:00
Nhi Pham c36414b131 MdeModulePkg/DxeCapsuleLibFmp: Fix crash if no ESRT is found
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>
2024-06-07 15:20:42 +00:00
Rebecca Cran 8c826be35c MdeModulePkg: In RemoveTableFromRsdt don't read from unallocated memory
Instead of copying from unallocated memory in RemoveTableFromRsdt, do a
CopyMem followed by ZeroMem.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
2024-06-07 11:35:47 +00:00
Oliver Steffen 80b59ff832 MdeModulePkg: Warn if out of flash space when writing variables
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>
2024-06-07 03:57:02 +00:00
Jeff Brasen 65b0d08786 MdeModulePkg/HiiDatabaseDxe: Remove assert for VarStoreId = 0
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>
2024-06-06 05:41:00 +00:00