summaryrefslogtreecommitdiff
path: root/EmbeddedPkg/Library
AgeCommit message (Collapse)AuthorFilesLines
2026-09-03EmbeddedPkg: PrePiHobLib: Don't Duplicate Stack Hob Mem AllocOliver Smith-Denny1-13/+9
Currently, PrePiHobLib will produce two memory allocation HOBs for the stack, based on the behavior it copied from DxeIpl. This is an incorrect description of handoff state. This commit follows the DxeIpl logic change to only produce a single memory allocation HOB for the new stack. The difference is that PrePiHobLib does not preserve the old stack region and instead frees it. That behavior is preserved. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-08-12EmbeddedPkg/AcpiLib: Fix memory corruption in AcpiAmlObjectUpdateIntegeredk2-stable202608Johnny.Fan1-3/+55
The original implementation of AcpiAmlObjectUpdateInteger had a critical bug when updating integer objects that were encoded with AML_ZERO_OP(0x00) or AML_ONE_OP(0x01), which are 1-byte optimized encodings. When the caller tried to update such an object to a value other than 0 or 1, the code would: 1. Overwrite the opcode byte with the new value's LSB 2. This changed the opcode itself, e.g. 0x0B becomes AML_WORD_PREFIX 3. Subsequent AML bytes (name segments of following objects) get misinterpreted as integer data 4. Result: silent AML structure is silently corrupted, causing the OS to fail parsing ACPI tables and eventually crash. The fix: 1. Only allow 0 -> 0 or 1 updates using the original 1-byte encoding 2. For any other value, explicitly fail with a diagnostic 3. Provide clear debug instructions on how to fix the ASL source Reviewed-by: jie.fu <jie.fu@cixtech.com> Signed-off-by: Johnny.Fan <Johnny.Fan@cixtech.com>
2026-06-24EmbeddedPkg: PrePiLib: Fix uninitialized variable warningsTuan Phan1-7/+7
In FfsProcessSection(), delete CompressionSectionHeaderSize and move CompressedData to avoid the compiler warning without changing functional behavior. Signed-off-by: Tuan Phan <tuan.phan@oss.qualcomm.com>
2026-06-13EmbeddedPkg, OvmfPkg: Produce FV3 HOBs for Extracted FVsOliver Smith-Denny2-16/+38
EmbeddedPkg's PrePiLib and OvmfPkg's PeilessStartupLib (which uses PrePiLib) only produce FV2 HOBs for extracted FVs. However, FV3 HOBs have superceded FV2 HOBs for describing extracted FVs. This commit updates both of these libs to also produce FV3 HOBs, following PEI's pattern of producing an FV, FV2, and FV3 HOB for each extracted FV. Eventually, only FV3 HOBs will be produced, so this paves the way for that. Continuous-integration-options: PatchCheck.ignore-multi-package Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-06-13EmbeddedPkg, OvmfPkg: PrePiLib: Use Correct FvName in FV2 HOB ProductionDmitry Antipov2-5/+10
PrePiLib is incorrectly producing FV2 HOBs. The FvName field of the FV2 HOB is intended to be the parent FV's name. This way the HOB consumer phase can identify when an FV has already been extracted: if the file name of the extracted FV and the parent FV name match in the FV2 HOB. With the incorrect FvName, DXE will re-extract the already extracted FV, which can be a large performance hit (some platforms we have seen ~1 second). This requires an update to FfsProcessFvFile to pass the parent FV handle through so the FV2 HOB can be correctly produced. OvmfPkg consumers are also updated. Continuous-integration-options: PatchCheck.ignore-multi-package Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-06-13EmbeddedPkg: PrePiLib: Zero Volume Info Buffer Before WritingOliver Smith-Denny1-1/+1
FfsGetVolumeInfo() in PrePiLib does not zero the VolumeInfo buffer before writing to it. However, it has some fields that are expected to be zero if certain conditions are not met. For example, the FvName is expected to be all 0's if the extended header is not present in the FV. Currently, the FvName field will point to garbage if the caller does not zero the buffer first. Flip the expectation and have FfsGetVolumeInfo() zero the buffer before it writes to it. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-06-13EmbeddedPkg: PrePiLib: Skip Extracting if FV3 HOB FoundOliver Smith-Denny1-10/+16
PrePiLib only searches for the existence of an FV2 HOB to determine if an FV has already been extracted. However, FV2 HOBs have been superceded by FV3 HOBs for describing extracted FVs. This commit updates PrePiLib to check for the existence of either an FV2 or FV3 HOB for this FV and skips extracting if either is found. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-06-13EmbeddedPkg: PrePi.h: Drop Duplicate HOB DefintionsOliver Smith-Denny1-11/+1
PrePi.h has some duplicate HOB definitions from HobLib.h. Instead of redefining them, use HobLib.h. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-06-09EmbeddedPkg: Replace manual alignment checks with helper macrosMingjie Shen1-6/+6
Replace manual alignment checks with IS_ALIGNED() and ADDRESS_IS_ALIGNED(). Convert the following bitmask and modulo forms: - ((E & ((PowOf2Expr) - ONE)) == ZERO) - ((E & ((PowOf2Expr) - ONE)) != ZERO) - ((E % (PowOf2Expr)) == ZERO) - ((E % (PowOf2Expr)) != ZERO) to the corresponding helper macro forms: + IS_ALIGNED (E, PowOf2Expr) + !IS_ALIGNED (E, PowOf2Expr) PowOf2Expr is limited to known power-of-two expressions, including SIZE_* and BASE_* macros, EFI_PAGE_SIZE, CPU_STACK_ALIGNMENT, RUNTIME_PAGE_ALLOCATION_GRANULARITY, sizeof() of UEFI integer types (e.g. BOOLEAN, CHAR16, UINT32, UINTN) and pointer types, and 1 << E1 expressions. Address checks that cast the checked value to UINTN are written with ADDRESS_IS_ALIGNED(). The change was generated with the Coccinelle semantic patch below. ```smpl @power_of_2_expr@ expression PowOf2Expr; expression E1; typedef BOOLEAN, CHAR8, CHAR16, INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, UINT64, INTN, UINTN; type ScalarType = { BOOLEAN, CHAR8, CHAR16, INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, UINT64, INTN, UINTN }; type AnyType; type PointerType = AnyType *; idexpression ScalarType ScalarValue; idexpression PointerType PointerValue; constant SizeBase =~ "^(SIZE|BASE)_(1|2|4|8|16|32|64|128|256|512)[KMGTPE]B$"; constant NamedPowerOf2 =~ "^(EFI_PAGE_SIZE|CPU_STACK_ALIGNMENT|RUNTIME_PAGE_ALLOCATION_GRANULARITY)$"; constant ONE = {1, 1U, 1u}; @@ ( ( SizeBase | NamedPowerOf2 | ONE << E1 | sizeof (ScalarType) | sizeof (PointerType) | sizeof (ScalarValue) | sizeof (PointerValue) ) & PowOf2Expr ) @aligned depends on power_of_2_expr disable is_zero,isnt_zero@ expression E; expression power_of_2_expr.PowOf2Expr; constant ONE = {1, 1U, 1u}; constant ZERO = {0, 0U, 0u}; @@ ( ((E & (E - ONE)) == ZERO) | - ((E & ((PowOf2Expr) - ONE)) == ZERO) + IS_ALIGNED (E, PowOf2Expr) | ((E & (E - ONE)) != ZERO) | - ((E & ((PowOf2Expr) - ONE)) != ZERO) + !IS_ALIGNED (E, PowOf2Expr) | - ((E % (PowOf2Expr)) == ZERO) + IS_ALIGNED (E, PowOf2Expr) | - ((E % (PowOf2Expr)) != ZERO) + !IS_ALIGNED (E, PowOf2Expr) ) @address_is_aligned@ typedef UINTN; expression *Address; expression Alignment; @@ - IS_ALIGNED ((UINTN) Address, Alignment) + ADDRESS_IS_ALIGNED (Address, Alignment) @normalize_aligned disable paren expression@ expression E, SZ; @@ ( - (IS_ALIGNED (E, SZ)) + IS_ALIGNED (E, SZ) | - (!IS_ALIGNED (E, SZ)) + !IS_ALIGNED (E, SZ) ) @normalize_macro_args disable paren expression@ expression E, SZ; @@ ( - IS_ALIGNED ((E), SZ) + IS_ALIGNED (E, SZ) | - IS_ALIGNED (E, (SZ)) + IS_ALIGNED (E, SZ) ) ``` Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2026-05-06Revert "ArmPlatformPkg,EmbeddedPkg,MdeModulePkg: Move RealTimeClockLib ..."Ard Biesheuvel2-2/+0
This reverts commit 57230fff6b39a665485be1bd43ec608d412ba6fb. RealTimeClockLib is not a generic library class that is intended to be used widely to get access to the RTC when the associated runtime services are not available in the calling context. The purpose of RealTimeClockLib is to abstract the underlying hardware access from the generic RealTimeClockRuntimeDxe driver, which backs the runtime services. This means it does not belong in a different package; it belongs in the same package as the driver. Continuous-integration-options: PatchCheck.ignore-multi-package Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2026-04-21EmbeddedPkg: Add missing FreeAlignedPages() implementationSami Mujawar1-0/+34
The PrePiMemoryAllocationLib supports AllocateAlignedPages(), however is missing the corresponding FreeAlignedPages(). Although the FreeAlignedPages() in PrePiMemoryAllocationLib does not support the ability to free pages in the PrePei Memory Allocator and the allocated memory is lost, it would be good to have an empty implementation of FreeAlignedPages() so that implementations utilises the correct deallocation function. Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-04-13EmbeddedPkg/PrePiLib: Prevent overread with FFS size macrosGowtham M1-8/+6
Symptom:Unsafe typecasting may lead to out‑of‑bound memory access RootCause: FileSize and FileLength are declared as UINT32 and masked with 0x00FFFFFF to store only the lower 24 bits. Although this approach yields the correct result, it introduces a potential risk due to unsafe typecasting and dereferencing. Solution: Using the predefined macro FFS_FILE_SIZE() from MdePkg\Include\Pi\PiFirmwareFile.h, which safely performs the same operation by reconstructing the size using individual byte access. This commit also addresses the fix for coverity isssue "OVERRUN" Cc: Sachin Ganesh <sachinganesh@ami.com> Signed-off-by: Gowtham M <gowthamm@ami.com>
2026-03-02EmbeddedPkg: align Inf file headers with INF Spec standardAlexander Gryanko2-14/+14
The Inf file standard specifies that comments begin with the characters "#". The following files contained incorrectly formatted C-style comments and have been updated: EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.inf EmbeddedPkg/Library/NorFlashInfoLib/NorFlashInfoLib.inf The problems were identified during testing of the parser https://github.com/xpahos/edk2-idea. Signed-off-by: Alexander Gryanko <xpahos@gmail.com>
2026-02-24EmbeddedPkg: Replace include guards with #pragma onceMichael Kubacki1-4/+1
Replace traditional `#ifndef`/`#define`/`#endif` include guards with `#pragma` once. `#pragma once` is a widely supported preprocessor directive that prevents header files from being included multiple times. It is supported by all toolchains used to build edk2: GCC, Clang/LLVM, and MSVC. Compared to macro-based include guards, `#pragma once`: - Eliminates the risk of macro name collisions or copy/paste errors where two headers inadvertently use the same guard macro. - Eliminate inconsistency in the way include guard macros are named (e.g., some files use `__FILE_H__`, others use `FILE_H_`, etc.). - Reduces boilerplate (three lines replaced by one). - Avoids polluting the macro namespace with guard symbols. - Can improve build times as the preprocessor can skip re-opening the file entirely, rather than re-reading it to find the matching `#endif` ("multiple-include optimization"). - Note that some compilers may already optimize traditional include guards, by recognzining the idiomatic pattern. This change is made acknowledging that overall portability of the code will technically be reduced, as `#pragma once` is not part of the C/C++ standards. However, this is considered acceptable given: 1. edk2 already defines a subset of supported compilers in BaseTools/Conf/tools_def.template, all of which have supported `#pragma once` for over two decades. 2. There have been concerns raised to the project about inconsistent include guard naming and potential macro collisions. Approximate compiler support dates: - MSVC: Supported since Visual C++ 4.2 (1996) - GCC: Supported since 3.4 (2004) (http://gnu.ist.utl.pt/software/gcc/gcc-3.4/changes.html) - Clang (LLVM based): Since initial release in 2007 Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-02-11EmbeddedPkg/PrePiMemoryAllocationLib: Update memory hob page alignmentAntaeus Kleinert-Strand1-10/+39
When allocating Runtime memory the MemoryAllocation HOB's length needs to meet the alignment requirements of Runtime memory. On AARCH64 architectures this alignment is not the default of 4KB. Instead it is set by the RUNTIME_PAGE_ALLOCATION_GRANULARITY definition, which is 64KB. This change enforces the RUNTIME alignment as part of generating the MemoryAllocationHob for runtime memory types. Signed-off-by: Antaeus Kleinert-Strand <antklein@microsoft.com>
2026-01-23EmbeddedPkg/AndroidBootImgLib: Fix typo in Buffer parameter descriptionDongyan Qian1-1/+1
The comment for the Buffer parameter incorrectly said "then no the size" instead of "then the size". This patch fixes the typo only; no functional changes. Signed-off-by: Dongyan Qian <qiandongyan@loongson.cn>
2026-01-22EmbeddedPkg/Library/VirtualRealTimeClockLib: Fix type mismatchMichael D Kinney1-2/+2
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-01-15EmbeddedPkg: PrePiMemoryAllocationLib: Add AllocateCopyPoolOliver Smith-Denny1-0/+37
ArmVirtPkg uses PrePiMemoryAllocationLib and PeiServicesLib in the same module. PeiServicesLib depends on MemoryAllocationLib, fulfilled by PrePiMemoryAllocationLib in this instance. However, PeiServicesLib uses AllocateCopyPool() which is not provided in PrePiMemoryAllocationLib. CLANGPDB AARCH64 finds this as a link error. Other toolchains are optimizing the call out since that code path is not used in this module. This adds AllocateCopyPool() to PrePiMemoryAllocationLib to satisfy the dependency. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-01-15EmbeddedPkg: PrePiHobLib: Add Library/Protocol DependenciesOliver Smith-Denny1-0/+4
CLANGPDB AARCH64 catches that PrePiHobLib doesn't correctly list the library classes and protocols it uses. This resolves that. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2025-10-16EmbeddedPkg/VirtualRealTimeClockLib: Use SOURCE_DATE_EPOCHMichael D Kinney2-8/+2
Change VirtualRealTimeClockLib.inf to use SOURCE_DATE_EPOCH instead of Linux only shell command. This allows this library to be used in Windows build environments. Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2025-09-26EmbeddedPkg: Drop ARM32 SupportOliver Smith-Denny2-11/+0
edk2 is dropping support for the ARM32 architecture. This commit removes ARM32 code from EmbeddedPkg. This also drops irrelevant VALID_ARCHITECTURES comments from infs that are not arch specific. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2025-09-12EmbeddedPkg/PrePiLib: minor cleanup in FfsProcessSection ()Leif Lindholm1-8/+8
Drop an else wrapper in FfsProcessSection () on the other side of an if-statemenmt that is an error return. Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2025-09-12EmbeddedPkg/PrePiLib: eliminate unneeded variable in FfsProcessSection ()Leif Lindholm1-9/+5
The "Found" variable provided only a deferred form of success handling, so eliminate it to improve readability. Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2025-09-12EmbeddedPkg/PrePiLib: refactor FfsProcessSection ()Leif Lindholm1-60/+122
Create some helper functions to make FfsProcessSection at least halfway readable by both humans and compilers. Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2025-09-08ArmPlatformPkg,EmbeddedPkg,MdeModulePkg: Move RealTimeClockLib headerINDIA\sachinganesh2-0/+2
RealTimeClockLib is an architectural implementation that is not restricted to the embedded segment or any platform in particular. So the header has been moved to MdeModulePkg. And the package has been added to the relevant INF files. Continuous-integration-options: PatchCheck.ignore-multi-package Signed-off-by: Sachin Ganesh <sachinganesh@ami.com>
2025-07-08EmbeddedPkg/PrePiMemoryAllocationLib: Add reserved memory allocationsVishal Oliyil Kunnil1-0/+74
PrePiMemoryAllocationLib does not implement functions to allocate EfiMemoryReservedType. These are implemented in other instances of MemoryAllocationLib (Dxe, Uefi, PiSmmCore, SmmMemory). Add AllocateReservedPages() and AllocateAlignedReservedPages() functions to make it consistent with other MemoryAllocationLib intstances. Signed-off-by: Vishal Oliyil Kunnil <vishalo@qti.qualcomm.com>
2025-06-26EmbeddedPkg/TimeBaseLib: aligning year with UEFI specificationPankaj Kumar Singh1-2/+2
According to the UEFI Specification version 2.11, the valid range for the Year field in the EFI_TIME structure is from 1900 to 9999. Currently IsTimeValid() checks a restricted range 2000 - 2099. Update range in TimeBaseLib.c to match UEFI specification. Signed-off-by: Pankaj Singh <pansing@qti.qualcomm.com>
2025-06-02EmbeddedPkg: delete ancient libfdt semi-integrationLeif Lindholm15-4270/+0
With all in-tree users migrated, finally delete this. Any out-of-tree users need to migrate to MdePkg BaseFdtLib. Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2025-04-30ArmVirtPkg,DynamicTablesPkg,EmbeddedPkg,OvmfPkg: use MdePkg BaseFdtLibLeif Lindholm1-16/+16
Migrate these packages to use the up-to-date BaseFdtLib instead of the EmbeddedPkg relic that is going away. Continuous-integration-options: PatchCheck.ignore-multi-package Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2025-04-18EmbeddedPkg: Add two new APIs in PrePiHobLibDun Tan1-0/+55
This commit is to add two new APIs in EmbeddedPkg PrePiHobLib: 1.The GetNextMemoryAllocationGuidHob () returns the next instance of the Memory Allocation HOB with the matched GUID from a starting HOB pointer. 2.The TagMemoryAllocationHobWithGuid () searchs the HOB list for the Memory Allocation HOB with a matching base address and set the Name GUID. Then the instance of the tagged Memory Allocation HOB with matched base address is returned. Signed-off-by: Dun Tan <dun.tan@intel.com>
2025-01-15EmbeddedPkg: CodeQL Fixes.Vineel Kovvuri[MSFT]2-1/+4
Makes changes to comply with alerts raised by CodeQL. Most of the issues here fall into the following two categories: 1. Potential use of uninitialized pointer. 2. Inconsistent integer width in comparison. Co-authored-by: Taylor Beebe <taylor.d.beebe@gmail.com> Co-authored-by: Ken Lautner <kenlautner3@gmail.com> Co-authored-by: Bret Barkelew <bret@corthon.com> Signed-off-by: Vineel Kovvuri[MSFT] <vineelko@microsoft.com>
2024-11-27EmbeddedPkg: reduce "Found ACPI table" messages from ERROR to INFORebecca Cran1-1/+1
The "Found ACPI table" messages are informative and don't indicate an error, so reduce the debug level from DEBUG_ERROR to DEBUG_INFO. Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
2024-11-11EmbeddedPkg/PrePiHobLib: Remove Non-RT Types from Mem Type Info HOBMichael Kubacki2-16/+3
Removes the following types from the memory type information HOB produced: - `EfiBootServicesCode` - `EfiBootServicesData` - `EfiLoaderCode` - `EfiLoaderData` This follows the guidance in the whitepaper "A Tour Beyond BIOS Memory Map and Practices in UEFI BIOS". https://github.com/tianocore-docs/Docs/raw/master/White_Papers/A_Tour_Beyond_BIOS_Memory_Map_And_Practices_in_UEFI_BIOS_V2.pdf "NOTE: We recommend a platform only define the ReservedMemory, ACPINvs, ACPIReclaim, RuntimeCode, RuntimeData in Memory Type Information table, because OSes only request these regions to be consistent. There is no need to add BootServicesCode, BootServicesData, LoaderCode, LoaderData in memory type information table, because these regions will not be reserved during S4 resume." Since these memory types are not tracked in memory type information any longer it also reduces the number of resets that may need to occur to update memory type buckets that are not needed. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-09-27EmbeddedPkg: add missing BaseLib/BaseMemoryLib declarationsLeif Lindholm2-0/+2
Add missing includes of BaseMemoryLib.h and declaration of BaseLib/BaseMemoryLib dependencies hidden by use of EmbeddedPkg FdtLib, which is being deleted. Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
2024-09-05EmbeddedPkg/PrePiHobLib: Fix SetBootMode return valueVishal Oliyil Kunnil1-1/+1
After updating Doxygen, we can see that SetBootMode returns the BootMode instead of status code as it should, fix it to return status. Signed-off-by: Vishal Oliyil Kunnil <quic_vishalo@quicinc.com>
2024-09-05EmbeddedPkg/PrePiHobLib: Align Doxygen comment between code and headerVishal Oliyil Kunnil1-12/+5
The Doxygen comment for SetBootMode and GetBootMode in PrePiHobLib/Hob.c does not match declaration in PrePiLib.h. The C file has it wrong. Align the text to match the header. Signed-off-by: Vishal Oliyil Kunnil <quic_vishalo@quicinc.com>
2024-08-30EmbeddedPkg: Improve LocateAndInstallAcpiFromFvConditionalRebecca Cran1-41/+45
LocateAndInstallAcpiFromFvConditional was always returning EFI_SUCCESS even when it failed to find `AcpiFile`. Fix that, and improve the layout by checking if an error occurred and breaking earlier. Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
2024-08-01EmbeddedPkg: Fix some spelling mistakes found by cspellRebecca Cran1-1/+1
When cspell is installed (via `npm install cspell`), CI checks for spelling mistakes. There are currently a very large number of them: some are genuine mistakes while others are words or acryonyms that cspell doesn't know. Fix a few of the misspellings in EmbeddedPkg. Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
2024-07-31EmbeddedPkg: Retire EfiResetSystemLib and ResetRuntimeDxeArd Biesheuvel2-121/+0
Retire the ancient reset runtime DXE in EmbeddedPkg, and the associated EfiResetSystemLib library class and template implementation. These are incomplete and have been superseded by a generic implementation in MdeModulePkg. Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-07-30EmbeddedPkg: NonCoherentDmaLib: Set EFI_MEMORY_XP Capability on DMA BufferOliver Smith-Denny1-4/+32
Commit 8984fba2f22a2cd44e1189403e3553f447b82852 added setting the EFI_MEMORY_XP attribute on DMA buffers. However, it did not ensure that the XP capability was set on that region. This patch adds setting the XP capability before attempting to set the attribute. If setting the capability fails, it defaults to the old behavior of not setting the XP bit. Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-07-23EmbeddedPkg: Mark DMA Memory Allocations XP By DefaultOliver Smith-Denny1-2/+2
When allocating memory for a non-coherent DMA device, 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-coherent DMA device. Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-07-04EmbeddedPkg/VirtualRealTimeClockLib: Support SOURCE_DATE_EPOCHChun-Yi Lee1-1/+1
RISC-V ovmf used VirtualRealTimeClockLib but the default epoch is a compilation time. It causes that the RISC-V ovmf binary image is NOT reproducible. This patch added the support of SOURCE_DATE_EPOCH by printenv command. If SOURCE_DATE_EPOCH be found then we use it as BUILD_EPOCH. Otherwise we run date command for setting BUILD_EPOCH. For distributions want a reproducible RISC-V ovmf image, they should export SOURCE_DATE_EPOCH environment variable before building ovmf. References: https://reproducible-builds.org/docs/source-date-epoch/ Cc: Pete Batard <pete@akeo.ie> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: "Lee, Chun-Yi" <jlee@suse.com>
2024-02-09EmbeddedPkg: compiler error due to arithmetic operation on void pointerJayaprakash N1-1/+1
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4668 This commit fixes the issue reported in the BZ4668. The EmbeddedPkg fails to compile with a compiler error generated due to invalid/illegal arithmetic operation on void pointers. It has been fixed by using explicit type conversion of the void pointer to UINTN. Cc: Rebecca Cran <rebecca@bsdio.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Leif Lindholm <quic_llindhol@quicinc.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Abner Chang <abner.chang@amd.com> Cc: Jayaprakash N <n.jayaprakash@intel.com> Signed-off-by: Jayaprakash N <n.jayaprakash@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ard Biesheuvel <ardb+tianocore@kernel.org> Acked-by: Michael D Kinney <michael.d.kinney@intel.com>
2024-01-26EmbeddedPkg/Hob: Integer Overflow in CreateHob()Gua Guo1-0/+43
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4166 Fix integer overflow in various CreateHob instances. Fixes: CVE-2022-36765 The CreateHob() function aligns the requested size to 8 performing the following operation: ``` HobLength = (UINT16)((HobLength + 0x7) & (~0x7)); ``` No checks are performed to ensure this value doesn't overflow, and could lead to CreateHob() returning a smaller HOB than requested, which could lead to OOB HOB accesses. Reported-by: Marc Beatove <mbeatove@google.com> Cc: Leif Lindholm <quic_llindhol@quicinc.com> Reviewed-by: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Abner Chang <abner.chang@amd.com> Cc: John Mathew <john.mathews@intel.com> Authored-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Gua Guo <gua.guo@intel.com>
2024-01-03EmbeddedPkg/PrePiMemoryAllocationLib: Add ReallocatePoolJeff Brasen via groups.io1-0/+57
Add implementation of ReallocatePool which is defined in the MemoryAllocationLib header file to allow components to not need special handling for PrePi module types. Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
2023-11-30EmbeddedPkg: Allow longer android kernel command lineAshish Singhal2-2/+3
AndroidBootImgLib allows for platforms to append to kernel command line but does not allow for the overall kernel command line to go beyond the limit set by the image header. Address this limitation by adding a pcd where platform can tell how many extra characters they expect on their platform in addition to what the image header specifies. Signed-off-by: Ashish Singhal <ashishsingha@nvidia.com> Reviewed-by: Abner Chang <abner.chang@amd.com>
2023-11-30EmbeddedPkg: Fix Android Boot Command Line Length BugAshish Singhal1-13/+18
Curently, AndroidBootImgLib expects input kernel command line to never exceed 256 unicode characters where the image header allows for 512 ascii characters. If image header allows 512 ascii characters, similar number of unicode characters should be allowed at the minimum. Signed-off-by: Ashish Singhal <ashishsingha@nvidia.com> Reviewed-by: Abner Chang <abner.chang@amd.com>
2023-10-20EmbeddedPkg/NorFlashInfoLib: Update norflash device listJohn Chew1-1/+10
Update Gigadevice norflash list: gd25q16, gd25q32, gd25q64, gd25lq64c, gd25q128, gd25lq128, gd25q256 Add Silicon Kaiser norflash list: sk25lp128 Signed-off-by: John Chew <yuinyee.chew@starfivetech.com> Acked-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-10-18EmbeddedPkg/VirtualRealTimeClockLib: drop LibRtcVirtualNotifyEventLaszlo Ersek1-18/+0
The RealTimeClockLib class header in edk2 mistakenly declares a function called LibRtcVirtualNotifyEvent(). No component ever calls this function crossing module boundaries; all RealTimeClockLib instances in edk2 and edk2-platforms are supposed to register (and do register) their SetVirtualAddressMap() notification functions. In particular, VirtualRealTimeClockLib *itself* doesn't even use LibRtcVirtualNotifyEvent() -- the function is defined with an empty body, clearly in an understandable, but misguided, attempt, to conform to the (bogus) library interface. Remove the function. Build-tested only (with "RiscVVirtQemu.dsc"). Cc: Abner Chang <abner.chang@amd.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Daniel Schaefer <git@danielschaefer.me> Cc: Leif Lindholm <quic_llindhol@quicinc.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4564 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20231012091057.108728-5-lersek@redhat.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2023-10-18EmbeddedPkg/TemplateRealTimeClockLib: drop LibRtcVirtualNotifyEventLaszlo Ersek1-24/+0
The RealTimeClockLib class header in edk2 mistakenly declares a function called LibRtcVirtualNotifyEvent(). No component ever calls this function crossing module boundaries; all RealTimeClockLib instances in edk2 and edk2-platforms are supposed to register (and do register) their SetVirtualAddressMap() notification functions. In particular, TemplateRealTimeClockLib *itself* doesn't even use LibRtcVirtualNotifyEvent() -- the function is defined with an empty body, clearly in an understandable, but misguided, attempt, to conform to the (bogus) library interface. Remove the function. Build-tested only (with "EmbeddedPkg.dsc"). Cc: Abner Chang <abner.chang@amd.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Daniel Schaefer <git@danielschaefer.me> Cc: Leif Lindholm <quic_llindhol@quicinc.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4564 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20231012091057.108728-4-lersek@redhat.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>