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>
In preparation for the MarkdownLintCheck plugin being added to the
repo, this change defaults the plugin to `AuditOnly` mode in each
package. This allows package maintainers to enable the plugin as they
see fit.
Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
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>
Move the ACPI table helper macros from EmbeddedPkg's AcpiLib.h to
MdeModulePkg's AcpiHelperMacros.h.
These macros describe ACPI data initializers and do not depend on the
AcpiLib library interface. Keeping them in AcpiLib.h forces users that
only need the macros to include the AcpiLib library header unnecessarily.
Place the macros in a common MdeModulePkg public header so ACPI table
producers can include the macro definitions directly without implying
use of AcpiLib.
The companion edk2-platforms change is:
"Global: Include AcpiHelperMacros.h for ACPI helper macros"
Tested:
DynamicTablesPkg: X64/AARCH64 DEBUG/RELEASE/NOOPT
MdeModulePkg: X64/AARCH64 DEBUG/RELEASE/NOOPT
EmbeddedPkg: X64/AARCH64 DEBUG/RELEASE/NOOPT
Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
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>
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>
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>
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>
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>
GBL (Generic Bootloader) is Google's UEFI-based bootloader for Android.
It runs as an EFI application and delegates board- and platform-specific
operations to the underlying firmware through GBL-defined EFI protocols.
This patch adds only the header definitions (GUIDs, revisions and
interfaces) for those protocols, covering Android Verified Boot, AVF,
A/B boot-control, boot-memory, debug, Fastboot (and its transport) and
OS configuration.
For details, see:
https://cs.android.com/android/kernel/superproject/+/common-android-mainline:bootable/libbootloader/gbl/README.md
Co-authored-by: David Pursell <dpursell@google.com>
Co-authored-by: Dov Shlachter <dovs@google.com>
Co-authored-by: Jakob Vukalović <jakobvukalovic@google.com>
Co-authored-by: Kelvin Zhang <zhangkelvin@google.com>
Co-authored-by: Ram Muthiah <rammuthiah@google.com>
Co-authored-by: Sergii Parubochyi <sergiip@google.com>
Co-authored-by: Yecheng Zhao <zyecheng@google.com>
Co-authored-by: Yi-Yo Chiang <yochiang@google.com>
Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
This reverts commit 57230fff6b.
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>
In AndroidFastbootTransportTcpDxe driver, gEfiSimpleTextOutProtocolGuid
appears twice in [Procotols] section, so remove the duplicate one.
Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
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>
Per
https://edk2.groups.io/g/devel/topic/move_armlib_to_baselib/118541649,
this commit moves ArmLib to MdePkg and updates all consumers.
The only change to ArmLib itself is to remove ArmPkg.dec from
the inf.
Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
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>
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>
The Uni file standard specifies that comments begin with the
characters "//". The following files contained incorrectly
formatted C-style comments and have been updated:
EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefHii.uni
EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformHii.uni
EmbeddedPkg/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxeHii.uni
The problems were identified during testing of the parser
https://github.com/xpahos/edk2-idea.
Signed-off-by: Alexander Gryanko <xpahos@gmail.com>
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>
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>
Replacing the non-ASCII characters with ASCII characters fixes build failures onWindows systems using non-English locales. These characters trigger MSVC warningC4819 (“file contains a character that cannot be represented in the current codepage”), which becomes an error when /WX is enabled.
Cc: Sachin Ganesh <sachinganesh@ami.com>
Signed-off-by: dhiineshm <dhiineshm@ami.com>
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>
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>
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>
Both LOONGARCH64 and RISCV64 platforms make use of modules in
EmbeddedPkg, for example in OvmfPkg. So add them as supported
architectures for the package to simplify build tests.
Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
The DXE_SAL_DRIVER module type was introduced to support
Itanium (IPF) platforms. Since support for Itanium processors has been
dropped, the instances of DXE_SAL_DRIVER have been removed.
Ref: [3cb0a311cb]
Cc: Sachin Ganesh <sachinganesh@ami.com>
Signed-off-by: Sathya Ravichandran <sathyar@ami.com>
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>
There is a possibility to retrieve user input keystroke data stored in the
queue buffer via the EFI_SIMPLE_TEXT_INPUT_PROTOCOL pointer. To prevent
exposure of the password string, clear the queue buffer by filling it
with zeros after reading.
Signed-off-by: Nick Wang <nick.wang@insyde.com>
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>
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>
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>
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>
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>
Move Fdt Table Guid from EmbeddedPkg to MdePkg to avoid
unnecessary dependencies on EmbeddedPkg for packages like
ShellPkg. This change may affect modules dependent on
EmbeddedPkg but not on MdePkg, which is unlikely.
Also, per 8c721d6, MdePkg has a more refined implementation
of Fdt as compared to the EmbeddedPkg which was the initial
implementation.
Not moving gFdtVariableGuid since it'll be moved to platform
code.
Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Prachotan Bathi <prachotan.bathi@arm.com>
In HardwareInterrupt2.h the define for the protocol does not match the definition
of the protocol in the dec file. The definition in the dec file is 32898322-2da1-474a-baaa-f3f7cf569470
where in the definition the define is 32898322-2d1a-474a-baaa-f3f7cf569470 and the string
is even less correct with various bit swaps.
This commit changes all the strings and definitions to be consistent with the dec definition.
Signed-off-by: Chris Fernald <chfernal@microsoft.com>
MdePkg has a more refined implementation of Fdt as compared
to the EmbeddedPkg which was the initial implementation, hence
moving the Fdt Guid from EmbeddedPkg to MdePkg.
Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Akshay Behl <cap2k4@rivosinc.com>
Co-authored-by: Dhaval Sharma <dhaval@rivosinc.com>
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>
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>
KEYBOARD_TIMER_INTERVAL is used as TriggerTime parameter of
gBS->SetTimer() function. TriggerTime parameter represents the number of
100ns units, so number 500000 indicates 0.05s.
Signed-off-by: Gao Qihang <gaoqihang@loongson.cn>
PrePiLib.h is missing the header file that defines
the structures used in the file.
For example:
- EFI_PEI_FV_HANDLE
- EFI_PEI_FILE_HANDLE
Signed-off-by: Doug Flick <dougflick@microsoft.com>
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>
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>
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>
As an implementation of an industry specification-defined interface,
ArmSmcLib is more appropriately placed in MdePkg.
This update relocates both the header definition and the implementation
of ArmSmcLib to MdePkg, thereby supporting the monitor call primitives
for all other packages that depend on this interface.
Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Kun Qin <kun.qin@microsoft.com>