RelocDir->Size is a UINT32 value, and RelocDir->VirtualAddress is
also a UINT32 value. The current code in
PeCoffLoaderRelocateImageForRuntime does not check for overflow when
adding RelocDir->Size to RelocDir->VirtualAddress. This patch uses
SafeIntLib to ensure that the addition does not overflow.
Signed-off-by: Sachin Ganesh <sachinganesh@ami.com>
STATIC_ASSERT is #define'd to a compiler specific value, based on
built-in macros exposed by those compilers. If none of those are found,
an #error is raised.
This breaks the DTCPP build rule, which relies on the C preprocessor
for header file inclusion and value substitution, but doesn't define any
of the compiler macros we look for.
So drop the error case. If STATIC_ASSERT is used without a definition,
an error will be raised anyway.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
The clang compiler generates the following error
error: use of 'static_assert' without inclusion of <assert.h>
This is due to the use of the MSC Extension static_assert.
Use _Static_assert instead for clang and GNUC compilers.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
UEFI 2.10A Specification has added a new error case to
EFI_ATA_PASS_THRU_PROTOCOL.GetNextDevice API which handles
port multiplier not being connected to the Port.
Signed-off-by: Sachin Ganesh <sachinganesh@ami.com>
Clarifed the return status of EFI_FIRMWARE_MANAGEMENT_PROTOCOL.GetImage().
As intended in UEFI 2.10 Specification.
Signed-off-by: Sachin Ganesh <sachinganesh@ami.com>
Coverity is a static analysis tool. It detects the macro as an error
(case to incompatible type, cert_exp39_c_violation). The update resolves
the error and supports compliance with the static analysis tool.
Signed-off-by: Phil Noh <Phil.Noh@amd.com>
Some platforms require connecting storage media while booting to
network, or require enumerating storage protocols that were not initially
enumerated during BDS. This change adds a GUID to allow implementation
of boot manager's ConnectDeviceClass to connect storage media.
Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
These files are direct ports from the (identical) files:
MdeModulePkg\Bus\Ufs\UfsBlockIoPei\UfsHci.h
MdeModulePkg\Bus\Ufs\UfsPassThruDxe\UfsPassThruHci.h
Signed-off-by: Christopher Zurcher <christopher.zurcher@microsoft.com>
If USB device reports class specific descriptors, it is currently the job of
device driver to parse the configuration to find the class specific data.
The new library functions parse the configuration descriptor and return class
specific interface and class specific endpoint descriptors.
Also, these new functions allow to retrieve the data from non-default alternate
settings without performing a switch to this setting. Switching to the
alternate setting currently implies the execution of UsbSetInterface function
that performs USB control trnasfer.
In some cases this switch is not desirable so the new functions
UsbGetInterfaceDescriptorSetting and UsbGetEndpointDescriptorSetting come
in handy.
Signed-off-by: Oleg Ilyasov <olegi@ami.com>
Synchronize the changes about LoongArch64 in section 18.2.5 of UEFI2.11.
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Enable foreign images loading on LoongArch64 if the
EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL is present.
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Co-Authored-by: Dongyan Qian <qiandongyan@loongson.cn>
ArmCacheWritebackGranule should not return value higher than MAX_UINT32.
This change will allow the usage without architecture depenedent return
size.
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Kun Qin <kun.qin@microsoft.com>
Refine comments for EFI_STATUS_CODE_SPECIFIC_DATA_GUID .
Add the structs defined in this file for EFI_STATUS_CODE_SPECIFIC_DATA_GUID to comment.
Signed-off-by: Raymond Yang <yangrongwei@hotmail.com>
The GetRandomNumber functions in DxeRngLib can return success without
actually generating a random number. This occurs because there are code
paths through `GenerateRandomNumberViaNist800Algorithm` that do not
initialize the `Status` variable.
- Assume mFirstAlgo == MAX_UINTN (no secure algorithms available)
- Assume none of the secure algorithms have `Available` set.
- Assume PcdEnforceSecureRngAlgorithms is TRUE.
In this condition, the `Status` variable is never initialized, `Buffer`
data is never touched. It is fairly likely that Status is 0, so we can
return EFI_SUCCESS without writing anything to Buffer.
Fix is to set `Status = error_code` in this code path.
`EFI_SECURITY_VIOLATION` seems appropriate.
Signed-off-by: Doug Cook <idigdoug@gmail.com>
DebugLib PCDs are very important, but they're confusing and not
well-explained anywhere. Improve the documentation comments for them to
explain how they work and how they relate to each other.
Signed-off-by: Doug Cook <idigdoug@gmail.com>
With mSecureHashAlgorithms being static this should not be
needed any more.
Suggested-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Update Tpm12.h and Tpm20.h and not use c++ reserved keywords
operator and xor in C structures to support use of these
include files when building with a C++ compiler.
This patch removes the temporary use of anonymous unions and
warning 4201 disable for VS20xx tool chains to complete the
following field name changes:
* operator -> operator_
* xor -> xor_
NOTE: This is a non-backwards compatible change to Tpm12.h
and Tmp20.h. And consumers of these include files that access
the "operator" or "xor" fields must be updated.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Update Tpm12.h and Tpm20.h and not use c++ reserved keywords
operator and xor in C structures to support use of these
include files when building with a C++ compiler.
This patch temporarily introduces an anonymous union to add
operator_ and xor_ fields to support migration from the current
field names to the new field names.
Warning 4201 is disabled for VS20xx tool chains is a temporary
change to allow the use of anonymous unions.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Add definitions for the non-global page tables descriptor attribute, as
well as the E2H TCR bit, so that we can use them in the MMU code.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
As a BASE type library, some PEI drivers could link and use it.
Tcg2Pei.inf is an example. On edk2-stable202408 version, PEI drivers
that link the library include the global variable of mRdRandSupported.
The previous commit (c3a8ca7) that refers to the global variable actually
is found to influence the link status. Updating the global variable
in PEI drivers could affect the following issues.
PEI ROM Boot : Global variable is not updated
PEI RAM Boot : PEI FV integration/security check is failed
To address these issues, remove the global variable usage.
Signed-off-by: Phil Noh <Phil.Noh@amd.com>
The PCD token, PcdPciExpressBaseAddress is referred in the constructor.
If the token is defined as PcdsDynamic type, the PCD function that gets
the token value uses the gBS service to locate PCD protocol internally.
In this case, it is possible for the function to be called before
initializing gBS variable, then cause a system hang due to gBS variable.
Need to ensure the availability of gBS variable.
Signed-off-by: Phil Noh <Phil.Noh@amd.com>
These constants give the set of RES1 bits in CPTR_EL2, as 1s, and the
default value to use for CPTR_EL2 in order to enable all known (or
harmless) features but no unknown ones that require EL2 knowledge. This
will be used by ArmPlatformPkg in the following commit, separated due to
being different packages, even though the combined change is tiny.
Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com>
CP_FULL_ACCESS is a misnomer, we only enable access to SIMD/FP state,
and although the register's mnemonic is CPACR_EL1, its full name is
"Architectural Feature Access Control Register", with AArch64 having no
coprocessors like AArch32 did, so the "CP" is also not appropriate.
Rename it to show it's the default value we use on entry, and define it
in terms of the existing CPACR_FPEN_FULL rather than a magic constant
with the same value to more clearly document that fact. Also update
comments to reflect all this (including the CPTR_EL2 case).
Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com>
Now that the ResetVectors are USER_DEFINED modules, they will not
be linked against StackCheckLibNull, which were the only modules
causing issues. So, we can now remove the kludge we had before
and the requirement for every DSC to include StackCheckLibNull
for SEC modules and just apply StackCheckLibNull globally.
This also changes every DSC to drop the SEC definition of
StackCheckLibNull.
Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
Unit test checks if AppendDevicePathInstance() returns NULL.
In those cases, AppendDevicePathInstance() does not allocate
a device path, so the call to FreePool() must not be performed.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Includes changes across the repo for the following CodeQL rules:
- cpp/comparison-with-wider-type
- cpp/overflow-buffer
- cpp/redundant-null-check-param
- cpp/uselesstest
Co-authored-by: Taylor Beebe <tabeebe@microsoft.com>
Co-authored-by: kenlautner <85201046+kenlautner@users.noreply.github.com>
Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
[Issue Description]
CXL_ERROR_PCIE_DEV_ID in Cper.h was renamed to EFI_CXL_ERROR_PCIE_DEV_ID,
but EFI_CXL_COMPONENT_EVENT_LOG still uses previous name.
[Resolution]
Modify EFI_CXL_COMPONENT_EVENT_LOG to use EFI_CXL_ERROR_PCIE_DEV_ID
Signed-off-by: Sienski Piotr <piotr.sienski@intel.com>
[Issue Description]
In MdePkg/Include/Guid/Cper.h there are multiple definitions
regarding CXL that can do use EFI_ prefix in their names
[Resolution]
Rename these definitions in MdePkg/Include/Guid/Cper.h
Signed-off-by: Sienski Piotr <piotr.sienski@intel.com>
When building OvmfPkg in RELEASE mode in the XCODE5 toolchain, the
ASSERT_EFI_ERROR change prevents this error:
.../MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c:141:15:
error: variable 'Status' set but not used [-Werror,-Wunused-but-set-variable]
EFI_STATUS Status;
^
which is currently stopping the build.
When building in RELEASE mode in the CLANGPDB toolchain,the DEBUG macro
change prevents this error:
.../edk2/OvmfPkg/VirtioSerialDxe/VirtioSerial.c:28:22: error:
variable 'EventNames' is not needed and will not be
emitted [-Werror,-Wunneeded-internal-declaration]
STATIC CONST CHAR8 *EventNames[] = {
^
which is currently stopping the build.
CLANGDWARF produces the same error as CLANGPDB above, if
-Wno-unneeded-internal-declaration is removed from its build flags.
With the null DEBUG macro change, this warning suppression
can be removed from CLANGDWARF, which is considered a benefit
as it has the potential to catch real coding errors. This is
done in a subsequent commit.
This commit has the desirable side effect that we no longer require
(and cannot use) explicit `#ifndef MDEPKG_NDEBUG` around items only
used in DEBUG macros. This requires the ArmPkg change made here to
be in the same commit as the MdePkg changes.
Note: In common with existing macros in EDK II, including the pre-existing
and unchanged DEBUG/NOOPT versions of the macros which are modified here,
we use the standard approach of adding `do { ... } while (FALSE)` wrapping
to ensure that the macros behave correctly with surrounding code
(e.g. require a following ';' and do not combine in unexpected ways with
nearby conditionals).
Continuous-integration-options: PatchCheck.ignore-multi-package
Co-authored-by: Mikhail Krichanov <krichanov@ispras.ru>
Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
[Issue Description]
In MdePkg/Include/Guid/Cper.h there are missing multiple definitions
regarding CXL that can be found in UEFI 2.10 spec
chapters N.2.13 and N.2.14
[Resolution]
Add these definitions to MdePkg/Include/Guid/Cper.h
Signed-off-by: Sienski Piotr <piotr.sienski@intel.com>
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4496
PI spec defined the `Register` function input argument `Delay` as output.
However, this parameter should be used to define the minmal time delay
the callback should fire. Thus it should be an input parameter.
This change fixed the argument type.
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Co-authored-by: Mike Turner <mikeyt@pobox.com>
Co-authored-by: Sachin Ganesh <sachinganesh@ami.com>
Signed-off-by: Kun Qin <kuqin12@gmail.com>
Added comments to describe the storage location of DXE Services Table,
HOB List Table and PEI Vector Handoff Table.
As defined in PI 1.7 A Errata specification.
Cc: Felix Polyudov <felixp@ami.com>
Cc: Dhanaraj V <vdhanaraj@ami.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Sachin Ganesh <sachinganesh@ami.com>
Clarified comments regarding the usage of RegisterContext parameter of
Register() API in EFI_MM_SX_DISPATCH_PROTOCOL.
As defined in the PI 1.7 A Errata specification.
Cc: Felix Polyudov <felixp@ami.com>
Cc: Dhanaraj V <vdhanaraj@ami.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Sachin Ganesh <sachinganesh@ami.com>