Commit Graph

6383 Commits

Author SHA1 Message Date
Mike Beaton 95292a0f24 MdeModulePkg/VariablePolicyLib: Fix extraneous parentheses
Without this change we get:

  error: equality comparison with extraneous parentheses

when building on XCODE5.

Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
2024-09-27 16:57:36 +00:00
Phil Noh 21e8a85653 MdeModulePkg/TerminalDxe: Add VTUTF8 to Putty function key map
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4848

This patch is to support VTUTF8 type for Putty function key map.
In Putty, it is required for translating a stream of Unicode characters
for function keys on UTF8 correctly.

Signed-off-by: Phil Noh <Phil.Noh@amd.com>
2024-09-18 03:42:47 +00:00
Ken Lautner 964c22b8ea MdeModulePkg: Fix buffer overflow in MergeMemoryMap
Check that the next map entry is valid before dereferencing to merge the
guard pages. If the final entry is at the end of a page with no valid page
following it, then this can cause an access violation.

Signed-off-by: Kenneth Lautner <kenlautner3@gmail.com>
2024-09-13 07:53:57 +00:00
Oliver Smith-Denny 000b61eff8 MdeModulePkg: Add StackCheckLib
Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-09-13 03:58:46 +00:00
Oliver Smith-Denny 8f74b95a21 MdePkg: Move CompilerIntrinsicsLib from ArmPkg
As per the emailed RFC in
https://edk2.groups.io/g/devel/topic/rfc_move/107675828,
this patch moves CompilerIntrinsicsLib from ArmPkg to
MdePkg as this library provides compiler intrinsics, which
are industry standard.

This aligns with the goal of integrating ArmPkg into existing
packages: https://bugzilla.tianocore.org/show_bug.cgi?id=4121.

The newly placed CompilerIntrinsicsLib is added to MdeLibs.dsc.inc
as every DSC that builds ARM/AARCH64 needs this library added. The
old location is removed from every DSC in edk2 in this commit also
to not break bisectability with minimal hoop jumping.

Continuous-integration-options: PatchCheck.ignore-multi-package

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-09-12 19:36:59 +00:00
Ken Lautner babccb841d MdeModulePkg: Enable Data Terminal at end of serial
When a Serial device resets, the Modem Control Register Data Terminal
Ready and Request to Send need to be cleared also. Otherwise the
registers will be left in their previous state, and the connected device
will not be able to transmit data.

Signed-off-by: Kenneth Lautner <kenlautner3@gmail.com>
2024-09-12 05:44:38 +00:00
Jason1 Lin 03c8ec6ce2 MdeModulePkg/DxeCapsuleLibFmp: Check BootService Status to Use ESRT Cache
- In c36414b131 change, it was introduced
  the ReadyToBoot event check to prevent the boot service got called
  in runtime to cause the issue.

- In this patch introduced the ExitBootService event to replace it.
  It would be better to base on the BootService status to decide
  the source of ESRT table.

- Based on the BootService availability to decide,
  - Exit    : Use cache ESRT table in IF-condition
  - Not Exit: Use boot service to locate protocol in ELSE-condition

Co-authored-by: Dakota Chiang <dakota.chiang@intel.com>
Signed-off-by: Jason1 Lin <jason1.lin@intel.com>
2024-09-11 20:26:20 +00:00
Jason1 Lin dadd8c7a95 MdeModulePkg/DxeCapsuleLibFmp: Change the Event Notify to Cache ESRT Table
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4831

In this patch introduced the below changes,

[1] Add the event of system resource table installed callback.
      - Register the event in DxeRuntimeCapsuleLibConstructor ()
      - Unregister the event in DxeRuntimeCapsuleLibDestructor ()

[2] Migrate the event to update the module variable to cache ESRT table
    from ReadyToBoot to system resource table installed.

[3] Add the condition to free the pool of buffer when the "mEsrtTable"
    is not NULL.

Co-authored-by: Dakota Chiang <dakota.chiang@intel.com>
Signed-off-by: Jason1 Lin <jason1.lin@intel.com>
2024-09-11 20:26:20 +00:00
Mike Beaton 1328938560 MdeModulePkg/VariableRuntimeDxe: Fix VariablePolicyProtocol PRODUCES
If we search the codebase for &gEdkiiVariablePolicyProtocolGuid
we can find two drivers which install this policy:
VariableRuntimeDxe (installed in VariableDxe.c) and
VariableSmmRuntimeDxe (installed in VariablePolicySmmDxe.c).

The .inf file for VariableRuntimeDxe incorrectly lists the protocol
as CONSUMES in the comment, so change this to PRODUCES.

Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
2024-09-11 01:35:18 +00:00
ragavarshinib 253b3d678a MdeModulePkg/Core/Pei: Add error handling for Section Length
This patch breaks the section processing loop if an invalid section with zero SectionLength is encountered.

Signed-off-by: Ragavarshini B <ragavarshinib@ami.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Dhanaraj V <vdhanaraj@ami.com>
Cc: Sachin Ganesh <sachinganesh@ami.com>
2024-09-06 06:54:46 +00:00
Ken Lautner f0dc9e1504 MdeModulePkg: UefiBootManagerLib: Update assert condition
In BmFindBootOptionInVariable() we prevent passing a NULL pointer to
EfiBootManagerFindLoadOption().  However, it can accept a NULL pointer as
the second argument as long as count is zero.  This change updates the
assert condtion to only assert if the pointer is NULL and the count is
non-zero.

Signed-off-by: Kenneth Lautner <kenlautner3@gmail.com>
2024-09-05 06:52:09 +00:00
Rebecca Cran 03bc4252fb XhciDxe: Fail the start of malfunctioning XHCI controllers
Add missing error checking for malfunctioning XHCI controllers.

Signed-off-by: Rebecca Cran <rebecca@os.amperecomputing.com>
2024-09-05 05:37:42 +00:00
Ken Lautner 559affab2e MdeModulePkg: Fix redundant call to RestoreTpl()
Comments out a redundant call to RestoreTpl(). While this does not
technically violate spec on raise/restore TPL, TPL should already be at
the specified level. This extra call introduces an asymmetry between
RaiseTpl and RestoreTpl calls, which makes analysis of TPL correctness
more difficult and hampers certain non-standard TPL usages that some
platforms require.  Additionally, the two TPL variables were renamed to
provide context for each of them.

Signed-off-by: Kenneth Lautner <kenlautner3@gmail.com>
2024-09-04 00:53:54 +00:00
Ken Lautner b17ac09cc4 MdeModulePkg: Add extra RestoreTpl() call in DiskIo
Adds a call to RestoreTpl() in DiskIo2ReadWriteDisk(). While the current
implementation does not technically violate spec on raise/restore TPL,
this extra call ensures symmetry between RaiseTpl and RestoreTpl calls,
which makes analysis of TPL correctness simpler and permits certain
non-standard TPL usages that some platforms require.

Signed-off-by: Kenneth Lautner <kenlautner3@gmail.com>
2024-09-04 00:53:54 +00:00
Sureshkumar Ponnusamy 8504d2be17 MdeModulePkg/FaultTolerantWriteDxe: Fix buffer overrun issue
- This PR aims to  prevent a buffer overrun issue found in FtwGetLastWriteHeader
function.As per the current code, when there is a malformed blocks (with all bytes as 0s)
then `Offset += FTW_WRITE_TOTAL_SIZE (FtwHeader->NumberOfWrites,
FtwHeader->PrivateDataSize)` would access beyond FtwWorkSpaceSize.

- Also added the signature check to validate work space

Signed-off-by: Sureshkumar Ponnusamy <sponnusamy@microsoft.com>
2024-09-03 20:29:02 +00:00
xieyuanh eaf78e43f2 MdeModulePkg: Enable VarCheckHiiLibStandaloneMm.
Enable VarCheckHiiLibStandaloneMm.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.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: Dandan Bi <dandan.bi@intel.com>

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
2024-09-02 17:26:58 +00:00
xieyuanh df58def118 MdeModulePkg: Add VarCheckHiiLibStandaloneMm.
This library is designed for handling variable HII checks within the
Standalone MMm environment. It includes the functions
dedicated to registering handlers that process information received
from VarCheckHiiLibMmDependency.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.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: Dandan Bi <dandan.bi@intel.com>

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
2024-09-02 17:26:58 +00:00
xieyuanh 02f6774803 MdeModulePkg: Move DUMP_VAR_CHECK_HII in common file
No functional changes.
Move DUMP_VAR_CHECK_HII in common file

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.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: Dandan Bi <dandan.bi@intel.com>

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
2024-09-02 17:26:58 +00:00
xieyuanh 45cf57ce79 MdeModulePkg: Relocate VarCheckHiiInternalDumpHex, VarCheckHiiQuestion
Move VarCheckHiiInternalDumpHex and VarCheckHiiQuestion to the common
file.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.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: Dandan Bi <dandan.bi@intel.com>

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
2024-09-02 17:26:58 +00:00
xieyuanh 3956f4e392 MdeModulePkg: Wrap SetVariableCheckHandlerHii as a common API
Rename SetVariableCheckHandlerHii and wrap it as a common API to
facilitate the usage in the following patches.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.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: Dandan Bi <dandan.bi@intel.com>

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
2024-09-02 17:26:58 +00:00
xieyuanh db43a80c10 MdeModulePkg: Rename VarCheckHiiLibNullClass as VarCheckHiiLib.
No functional changes.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.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: Dandan Bi <dandan.bi@intel.com>

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
2024-09-02 17:26:58 +00:00
xieyuanh 5718c9b06f MdeModulePkg: Modified BuildVarCheckHiiBin parameter to IN OUT.
Change the Size parameter of BuildVarCheckHiiBin from OUT to an
input-output parameter.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.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: Dandan Bi <dandan.bi@intel.com>

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
2024-09-02 17:26:58 +00:00
xieyuanh ee1e163a2f MdeModulePkg: Enable VarCheckHiiLibMmDependency
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
2024-09-02 17:26:58 +00:00
xieyuanh 6b3ac9cbf8 MdeModulePkg: Add VarCheckHiiLibMmDependency library.
VarCheckHiiLibMmDependency retrieve data (mVarCheckHiiBin) at the end
of the DXE phase, and pass the acquired data to the
VarCheckHiiLibStandaloneMm through a communication protocol.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.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: Dandan Bi <dandan.bi@intel.com>

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
2024-09-02 17:26:58 +00:00
xieyuanh 4aea90ea53 MdeModulePkg: Relocation of mVarCheckHiiBin declaration
Relocate the declaration of mVarCheckHiiBin to support for standalone
MM modules utilizing the same mVarCheckHiiBin.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.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: Dandan Bi <dandan.bi@intel.com>

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
2024-09-02 17:26:58 +00:00
Wei6 Xu 91853ca6a5 MdeModulePkg/VariableStandaloneMm: Notify variable write ready in MM
In Standalone MM, there is no notification to MM drivers that variable
write is ready. Install gSmmVariableWriteGuid into MM handle database
for the notification.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
2024-09-02 12:43:49 +08:00
Wei6 Xu 5aa6842715 MdeModulePkg/VariableStandaloneMm: Fix TCG MOR secure feature issue
According to TCG's Platform Reset Attack Mitigation spec, the OS should
never create the MOR variable, only read and write it.
But some OSes (Fedora 24 and 25) don't follow the TCG's Platform Reset
Attack Mitigation spec and unintentionally create MOR variable.

The commit fda8f631ed added function
VariableHaveTcgProtocols() to check against Tcg/Tcg2 protocol to infer
whether the MOR variable is created by platform firmware or not. If not,
delete the variable created by OS and lock the variable to avoid OS to
create it.

But in VariableStandaloneMm, VariableHaveTcgProtocols() always returns
FALSE, it causes TCG MOR secure feature does not work in standalone MM
environment.

As Fedora 24 and 25 are EOL today, directly returns TRUE in the function
VariableHaveTcgProtocols() for VariableStandaloneMm, and rename the
function to VariableIsMorVariableLegitimate() to make it more obvious
what the narrow use-case is for which it exists.

Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
2024-08-30 13:18:08 +00:00
Xiaoqiang Zhang 0596e5fa05 MdeModulePkg: CoreValidateHandle Optimization
REF : https://bugzilla.tianocore.org/show_bug.cgi?id=4817

Before entering BIOS setup, CoreValidateHandle function executed
over 600,000 times during BDS phase on latest 8S server platform.
In CoreValidateHandle function, current implementation will go
through the doubly-linked list handle database in each call, and
this will have big impact on boot performance.
The optimization is using Red-black tree to store the EFI handle
address when insert each EFI handle into the handle database, and
remove the handle from Red-black tree if the handle is removed
from the handle database. CoreValidateHandle function changed to
go through the Red-black tree.
After verification on latest 8S server platform, BDS boot time can
save 20s+ after this change.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Andrew Fish <afish@apple.com>
Tested-by: Xiaoqiang Zhang <xiaoqiang.zhang@intel.com>
2024-08-30 11:42:41 +00:00
Ray Robles b6c4708c4d MdeModulePkg/Bus/Pci/NvmExpressDxe: Nvm Express Media Sanitize Protocol.
Implementation of MEDIA_SANITIZE_PROTOCOL for NIST
purge/clear actions with mapping to NVM Express native
commands.

Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
2024-08-29 18:51:07 +00:00
Oliver Smith-Denny 1169122c6f MdeModulePkg NonDiscoverablePciDeviceIo: MMIO Memory XP By Default
When allocating memory for a non-discoverable PCI device's IO, the
current core code removes the XP attribute, allowing code to execute
from that region. This is a security vulnerability and unneeded. This
change updates to mark the region as XP when allocating memory for the
non-discoverable PCI device.

These allocations in this function are limited to `EfiBootServicesData`
and `EfiRuntimeServicesData`, which we expect to be XP.

Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
2024-08-29 16:11:40 +00:00
Oliver Smith-Denny 01735bbe4a MdeModulePkg: Gcd: Only Update gMemoryMap Attributes if Correct GCD Type
Currently whenever gDS->SetMemorySpaceCapabilities() is called, it
attempts to set the corresponding attributes in the gMemoryMap
descriptor. However, gMemoryMap only contains entries from GCD types
EfiGcdMemoryTypeSystemMemory and EfiGcdMemoryTypeMoreReliable, so
for all other types a failure is reported in the code. This is a
failure that is expected, so it does not provide value and can
lead to real failures being ignored.

This patch updates the gDS->SetMemorySpaceCapabilities() code to
only call into updating gMemoryMap if the GCD type is SystemMemory
or MoreReliable, to avoid spurious errors being reported. This
also avoids the expensive operation of searching through gMemoryMap
for entries we know we will fail to find.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-08-29 12:30:12 +00:00
Oliver Smith-Denny bb248a9509 MdeModulePkg: MAT Set RO/XP on Code/Data Sections Outside Image Memory
The Memory Attributes Table is generated by fetching the EFI memory map
and splitting entries which contain loaded images so DATA and CODE
sections have separate descriptors. The splitting is done via a call to
SplitTable() which
marks image DATA sections with the EFI_MEMORY_XP attribute and CODE
sections with the EFI_MEMORY_RO attribute when
splitting. After this process, there may still be EfiRuntimeServicesCode
regions which did not have their attributes set because they are not
part of loaded images.

This patch updates the MAT EnforceMemoryMapAttribute logic to set the
access attributes of runtime memory regions which are not part of loaded
images (have not had their access attributes set). The attributes of the
code regions will be read-only and no-execute because the UEFI spec
dictates that runtime code regions should only contain loaded EFI
modules.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4832

Refs:
1.
https://edk2.groups.io/g/devel/topic/patch_v1_mdemodulepkg/105570114?p=,,,20,0,0,0::recentpostdate/sticky,,,20,2,0,105570114
2.
https://edk2.groups.io/g/devel/topic/mdemodulepkg_fix_mat/105477564?p=,,,20,0,0,0::recentpostdate/sticky,,,20,2,0,105477564

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-08-29 08:47:26 +00:00
Oliver Smith-Denny 254641f342 MdeModulePkg: MAT: Do Not Set EfiMemoryMappedIo[PortSpace] Attrs
Per UEFI spec 2.10 section 4.6.3 EFI_MEMORY_ATTRIBUTES_TABLE,

"The Memory Attributes Table is currently used to describe memory
protections that may be applied to the EFI Runtime code and data
by an operating system or hypervisor. Consumers of this table must
currently ignore entries containing any values for Type except for
EfiRuntimeServicesData and EfiRuntimeServicesCode to ensure
compatibility with future uses of this table."

However, the current MAT code also enforces attributes for
EfiMemoryMappedIo and EfiMemoryMappedIoPortSpace, which it should
not be. Per
https://edk2.groups.io/g/devel/topic/patch_v1_mdemodulepkg/105570114?p=,,,20,0,0,0::recentpostdate/sticky,,,20,2,0,105570114,
it was suggested to remove these types from the MAT logic.

This patch removes EfiMemoryMappedIo and EfiMemoryMappedIoPortSpace
from the MAT logic in accordance with the UEFI spec.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-08-29 08:47:26 +00:00
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