CPB, DB, and CDB structs to use DMA-able memory.
Updates the overall SNP_DRIVER allocation to use AllocatePool() instead of PciIo->AllocateBuffer(). This moves this struct out of DMA-able memory.
Allocates the PXE_CDB struct as a pointer instead, using PciIo->AllocateBuffer() for DMA-able memory.
End result:
CPB, DB, and CDB are allocated with individual PciIo->AllocateBuffer() calls with a size of 4096 for CPB and DB. and sizeof(PXE_CDB) for CDB.
Each of these members point to locations within the Allocated Buffer, and all of these pointers are at-least
8-Byte aligned.
SNP_DRIVER is allocated with AllocatePool()
In the SNP_DRIVER structure, the PXE_CDB member is changed to a pointer so we can allocate it with PciIo->AllocateBuffer()
Signed-off-by: Eeshan Londhe <eeshanlondhe@microsoft.com>
Added debug trace messages on LocateProtocol failure for
gEfiDxeSmmReadyToLockProtocolGuid. Returned device error in case of
EfiCreateProtocolNotifyEvent failure.
Removed ASSERT due to if condition.
Signed-off-by: Arun Subramanian Baskaran <arun.subramanian.baskaran@intel.com>
In StandaloneMmPkg/Core/Dispatcher.c, a comment referred to SMRAM.
SMRAM is specific to the x86 architecture.
The StandaloneMmPkg is designed to be architecture-agnostic.
This commit updates the comment to use the more generic term MMRAM
(Management Mode RAM) to better reflect the nature of the package.
Signed-off-by: Damien Chen <inkfan130924783@gmail.com>
Memory Attributes Table needs to be updated to contain executable
permissions for UEFI runtime drivers loaded after EndOfDxe.
Fixes a regression introduced by bb248a9.
Signed-off-by: Vitaly Cheptsov <vit9696@protonmail.com>
Add the missing parser for EArchCommonObjTpm2DeviceInfo.
This missing parser causing assert for EArchCommonObjMcfgPciConfigSpaceInfo
and EArchCommonObjPciRootPortInfo parser.
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
This change introduces support for root port devices and their
corresponding _PRT (PCI Routing Table) entries in the PCIe SSDT.
Updates the PCIe SSDT generator to detect and use the root port token.
When available, the generator reads the configuration and creates device
entries with appropriate _PRT tables.
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Adds RootPortInfoToken to PCIe config space object to
support addition of root port devices in PCIE SSDT.
Updates the ConfigurationManagerObjectParser to include the new token.
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Introduce new architecture common namespace object
for PCIe root ports in the DynamicTables package.
This object holds information:
- PCIe root port address in device and function format
- Reference token information to the PCIe routing table object
- Slot number information for the root port
Also updates ConfigurationManagerObjectParser to parse
the new object and populate the relevant fields.
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
- Adds AcpiMcfgLib library to X64 DynamicTableFactoryDxe
- Adds AcpiSpcrLib library to X64 DynamicTableFactoryDxe
- Adds AcpiSsdtPcieLib library to X64 DynamicTableFactoryDxe
- Rearrage the libraries in alphabetical order
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
X64 platforms supports WordIo and uncached PCIe resources.
Hence, include WordIo and uncached PCIe resources in _CRS.
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Following the APs now always initializing separate exception
stacks, this commit always initializes a separate exception
stack for the BSP as well. Previously, this was only enabled
when PcdCpuStackGuard was set.
However, even when a stack guard page is not present,
stack overflows can still occur and corrupt the stack; if an
exception is taken here, it is still valuable to have a separate
exception stack for sanity.
Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
Currently, CpuExceptionHandlerLibNull returns EFI_UNSUPPORTED for
InitializeSeparateExceptionStacks. However, CpuMpPei, CpuDxe, and
DXE Core are all moving to call this function unconditionally and
expect it returns success. As such, the null lib is updated to
return success.
This fixes a hang on EmulatorPkg where DXE Core asserts if this
function returns an error.
Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
TR is used to enable a separate safe stack when a stack overflow occurs.
When PEI starts up the APs, TR is non-zero and so each processor has its
own GDT. TR is an offset into the GDT and so points to a different TSS
entry in each AP.
There is a small window in early DXE after MpInitLibInitialize() is
called where:
- TR is non-zero because it has been inherited from the PEI phase
- TR is not restored to 0
- The APs are all switched to using the BSP's GDT
- SaveVolatileRegisters() is called from ApWakeupFunction() before the
APs go to sleep, which saves the non-zero TR value to
CpuMpData->CpuData[].VolatileRegisters.Tr, cause TR to point to the
same TSS entry in the BSP's GDT
- The next time the APs are woken up, RestoreVolatileRegisters() is
called from ApWakeupFunction() which would attempt to load the non-zero
TR value into the actual task register, which creates a race condition
to a #GP fault because loading the task register sets the busy bit in
the TSS descriptor and a #GP fault occurs if the busy bit is already
set when loading the task register.
To avoid this issue, the task register is only loaded if TR is non-zero
and the TSS descriptor is valid and not busy. HW sets the busy bit and
does not clear it. edk2 does not clear the busy bit, so the BSP's TSS
descriptor will be marked busy forever and the APs will not load the
task register until they have their own GDT/TSS set up.
Co-authored-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
Today, CpuMpPei and CpuDxe only initialize separate exception
stacks for the APs when PcdCpuStackGuard is enabled so that
if a stack overflow occurs, hitting the guard page, the exception
can be handler with a separate stack.
However, this operation also creates a separate GDT for each AP.
This is a safer option than all APs sharing the BSP's GDT because
there are issues with concurrent access to the structures contained
within. Furthermore, even when a stack guard page is not present,
stack overflows can still occur and corrupt the stack; if an
exception is taken here, it is still valuable to have a separate
exception stack for sanity.
This commit updates CpuMpPei and CpuDxe to always create separate
exception stacks for the APs (and therefore separate GDTs).
Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
`PageStartAddress` variable was not set correctly because the encryption bit
was not considered, which broke the page walk logic.
Get the bitmask and mask the encryption bit.
Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
Added "PublishTables()" and "SdtNotifyAcpiList()" for completing
AddTableToList behavior in the InstallAcpiTableFromAcpiSiliconHob().
Signed-off-by: George Liao <george.liao@intel.com>
Clearing wrong memory content after allocated memory for XSDT,
which caused AcpiSdtProtocol cannot be installed and
unexpected behavior.
According to the UEFI spec and commit message of "PCD switch to
avoid using ACPI reclaim memory", so need to add this support in the
InstallAcpiTableFromAcpiSiliconHob().
1. Fixed memory corruption issue in the
InstallAcpiTableFromAcpiSiliconHob().
2. Added "PCD switch to avoid using ACPI reclaim memory" support in
the InstallAcpiTableFromAcpiSiliconHob().
Signed-off-by: George Liao <george.liao@intel.com>
This commit allocated an ACPI NVS buffer in PEI:
cdc1a88272
This is a RT visible memory type that remains fragmented against the
overall `EfiACPIMemoryNVS` memory bucket allocated by the DXE Core.
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
- Str is not being used in FvHeader.py
- Removed import of ast.Str as it was removed in Python 3.14.
- Ensures compatibility with Python 3.14 and later.
- https://docs.python.org/3/whatsnew/3.14.html#id9
This addresses ImportError caused by removal of deprecated AST classes
including ast.Str.
Signed-off-by: Ashraf Ali S <ashraf.ali.s@intel.com>
Building the C BaseTools using Clang on a Windows system that has the Python
interpreter installed to a path that contains spaces (for example
C:\Program Files\Python314\python.exe) currently fails.
This change adds quoting to fix that issue.
Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
[Issue] : There is no DLINK_FLAGS definition for CLANGPDB,
leading to potential discrepancies in build alignments
[Resolution] : This change adds a CLANGPDB line for DLINK_FLAGS.
Maintaining the alignment with existing standards in place for
other compiler packages.
Signed-off-by: Deepak5x <deepakx.singh@intel.com>
[Issue] : There is no DLINK_FLAGS definition for CLANGPDB,
leading to potential discrepancies in build alignments
[Resolution] : This change adds a CLANGPDB line for DLINK_FLAGS.
Maintaining the alignment with existing standards in place for
other compiler packages.
Signed-off-by: Deepak5x <deepakx.singh@intel.com>
[Issue] : There is no DLINK_FLAGS definition for CLANGPDB,
leading to potential discrepancies in build alignments
[Resolution] : This change adds a CLANGPDB line for DLINK_FLAGS.
Maintaining the alignment with existing standards in place for
other compiler packages.
Signed-off-by: Deepak5x <deepakx.singh@intel.com>
[Issue] : There is no DLINK_FLAGS definition for CLANGPDB,
leading to potential discrepancies in build alignments
[Resolution] : This change adds a CLANGPDB line for DLINK_FLAGS.
Maintaining the alignment with existing standards in place for
other compiler packages.
Signed-off-by: Deepak5x <deepakx.singh@intel.com>
[Issue] : There is no DLINK_FLAGS definition for CLANGPDB,
leading to potential discrepancies in build alignments
[Resolution] : This change adds a CLANGPDB line for DLINK_FLAGS.
Maintaining the alignment with existing standards in place for
other compiler packages.
Signed-off-by: Deepak5x <deepakx.singh@intel.com>
Commit 43e306806e added
EFIGcdMemoryTypeUnaccepted (as it was later renamed) to be
returned in the EFI_MEMORY_MAP. However, it did not add it
to the number of entries calculation, so if any
EfiGcdMemoryTypeUnaccepted entries exist in the GCD they will
overflow the EFI_MEMORY_MAP buffer provided by the bootloader.
This resolves that by accounting for unaccepted entries in
the number of entries calculation.
Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
* Remove redundant /DLL option from MSFT
* Use VERSION_STRING from [Defines] section to set
the PE/COFF optional header image version fields.
The use of the MSFT linker /VERSION option is
removed and replaced with the GenFw --image-version
option to use same method for all tool chains and
provide better error checking.
* Add CLANGPDB tool chain family support that matches
MSFT settings.
* Add GCC family tool chain support that overrides
OBJCOPY_STRIPFLAGS to nothing to prevent symbols
from being stripped from PRM Modules so the
PRM Export Descriptor Structure can be found by
GENFW when the --prm option is used.
* Remove all -Wl, options that are not compatible
across all support tool chains. This also removes
the need to list the PRM Export Descriptor Structure
and PRM Handler APIs in the INF file and instead
depend in GENFW with --prm option to find these
symbols and generate the PE/COFF DLL export section.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Use _MSC_EXTENSIONS instead of _MSC_VER when MSC specific
extensions are required such as __declspec(dllexport).
CLANGPDB builds do not set _MSC_VER but CLANGPDB builds
in Windows and Linux do support use of MSC specific
extensions.
Add PRM_EXPORT_DESCRIPTOR macro that provides attributes
required to make sure the PRM Export Descriptor Structure
is not optimized away by the compiler/linker.
PRM_EXPORT_API can not be used for this because the
attributes for code and data may be different with
different tool chains.
For GCC/CLANGDWARF tool chains, PRM_EXPORT_DESCRIPTOR
sets the 'used' and 'section(.prmexportdescriptor)'
attributes and depends on the GCC linker script
to make sure the `.prmexportdescriptor` section is
preserved.
Fix incorrect location of ; in PRM_MODULE_EXPORT()
macro that was found by CLANG.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Update GCC linker script to always keep .prmexportdescriptor
sections and merge them into the .data section.
The .prmexportdescriptor section is only used by PRM modules
for the PRM Export Descriptor Structure that must be kept
in the final image to support adding the PRM Export
Descriptor Structure and its associated PRM Handlers APIs
to a PE/COFF DLL Export section.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Add --image-version option that takes a version value
of the form MMMM.mmmm where MMMM and mmmm are decimal
values < 65536. The MMMM and mmmm values are used to
set the PE/COFF optional header fields MajorImageVersion
and MinorImageVersion.
If MMMM or mmmm are larger than 65535, then generate
Error() condition.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
When --prm is specified, a search for the symbol with the
name PRM_MODULE_EXPORT_DESCRIPTOR_NAME is performed. If
the symbol is not found, then GENFW generates an exception
due to a loop with a terminal count of -1.
Update logic to not search for PRM Handler symbols if the
PRM_MODULE_EXPORT_DESCRIPTOR_NAME was not found and add
an Error() message when --prm is specified and
PRM_MODULE_EXPORT_DESCRIPTOR_NAME was not found.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
edk2 commit 3bd5c994c8 added usage
of EFI_MEMORY_ATTRIBUTE_MASK to edk2. However, it applied it
incorrectly to some places that should instead use
EFI_MEMORY_ACCESS_MASK. EFI_MEMORY_ACCESS_MASK contains the actual
HW page table access attributes (read protect, read only, no-execute),
whereas EFI_MEMORY_ATTRIBUTE_MASK contains the access attributes in
addition to some virtual attributes (special purpose and cpu crypto).
The GCD has a behavior where if SetMemorySpaceAttributes() is called
with only virtual attributes set, it will not call into CpuDxe to
change the attributes; 0 is a valid page table attribute set (it means
RWX). However, after the above change, this behavior was altered so
that if EFI_MEMORY_SP or EFI_MEMORY_CPU_CRYPTO is applied, in attempt
to just update these virtual attributes, the GCD will call into CpuDxe
and apply RWX instead, which is not the intention of the caller.
One other place this was done incorrectly was in CoreGetMemoryMap,
but that was fixed in f1567720b1.
SetUefiImageMemoryAttributes() is also updated here because that
logic was copied from the check the GCD has about whether to call
CpuDxe or not. Now that the GCD has been corrected, this also
needs to be corrected.
Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
Currently the FMMT tool supports CRC32 GUID section (Ref. GuidTools.py).
But it is found that there are errors for the FV with CRC32 section.
For example, the errors are checked on the following commands.
--v : Show FV information except for the FV
--a : Show "Target Fv not found!!!" when adding an FFS file to the FV
--d : Show "Target Ffs not found!!!" when deleting an FFS file in the FV
They are caused by the mismatch for CRC32 section data between the FMMT
and GenCrc32 tools. The FMMT tool returns CRC32 section data without CRC
checksum field (4 bytes). The GenCrc32 tool (with -d option, verify CRC32
value for the input file) requires CRC32 section data including CRC
checksum field (4 bytes).
Fix the issue through adjusting the section data to include CRC checksum
field. Currently DataOffset field for CRC32 GUID section is reported as
0x1C differently (GUID Section header length: 0x18 + Checksum field: 0x4).
Instead of DataOffset field that includes CRC checksum field, configure
the section data based on the offset from section header length (0x18)
that was previously calculated. This update enables GUID sections to use
the same offset consistently.
Signed-off-by: Phil Noh <Phil.Noh@amd.com>
Currently, only SCSI attached CDROMs are marked as read only
SCSI devices. Write failures have been seen to occur when a
read only disk is attached as a SCSI device, because the device
is never queried for its write protected state and the disk is
listed as writeable.
This adds a new mode sense query to determine if a SCSI disk is
write protected. If so, the proper BlockIO media property is set
to read only, to ensure that all layers know this is a read only
disk.
Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
ATA_CMD_MODE_SENSE6 is used to query certain properties of
an ATA device, including its write protection state. This
definition will be used in the next commit of this series to
query if a SCSI disk is write protected.
Signed-off-by: Oliver Smith-Denny <osde@microsoft.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>
Set BUILD_TIME_EPOCH to the current UTC timestamp if not already present
in the environment.
Use the resulting value to print the "Build start time:" message.
Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
The function CheckEnvVariable in fact checks several environment
variables. And the comment at its invocation enumerates a specific set of
variables, which defeats half the point of abstracting it out into a
helper function.
Rename the function to the plural form and turn the comment into a list
of examples.
Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
Add prints for SMBIOS Type 2 "Number of Contained Object Handles" and
"Contained Object Handles" fields.
Signed-off-by: Cassandra Lam <Cassandra.Lam@amd.com>
The IoMmu keeps a pool of pre-allocated shared buffers in various sizes
to serve requests. Usage is tracked in a bitmap.
The bitmap masks for the 1M and 2M buffer pools are incorrect, causing
the same buffers getting handed out repeatedly, causing corrupted device
accesses.
The masks needs to be kept in sync with mReservedMemRanges below.
This sets the correct values for:
- RESERVED_MEM_BITMAP_1M_MASK = (1 << 14) = 0x4000
- RESERVED_MEM_BITMAP_2M_MASK = (1 << 15) | (1 << 16) = 0x18000
Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Linux/GCC host-based unit test application builds use a
default stack size of 8MB. Windows/VS20xx and Windows/CLANGPDB
host-based unit test application builds use a default stack size
of 1MB. This can allow Linux unit tests to pass and Windows unit
tests to fail with stack overflow if large local variables are
used. ASAN increases stack usage, so this condition can occur
more frequently when ASAN enabled.
Update MSFT and CLANGPDB for host-based unit tests to use a
default stack size of 8MB so all tool chains use the same
default stack size for host-based unit tests.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Currently, there is no mechanism for platforms to enable or disable
support for EmbeddedDrivers in capsule updates. This patch introduces
a new PCD, PcdEmbeddedDriverSupport, allowing platforms to explicitly
control whether capsules containing EmbeddedDrivers are supported.
This ensures capsules with embedded drivers are rejected on platforms
that do not support them.
This is a breaking change.By default, PcdEmbeddedDriverSupport
is set to FALSE which disables embedded driver support in capsule updates
across all platforms unless explicitly enabled.
Platforms must opt-in by setting the PcdEmbeddedDriverSupport to TRUE
in order to enable support for capsules containing embedded drivers.
Signed-off-by: Pavithra Gurulingappa <gpavithr@qti.qualcomm.com>