Commit graph

36559 commits

Author SHA1 Message Date
Chris Fernald
27ac8fac0b BaseTools: Add support for preserving build ID
Adds an optional flag that copies the GNU build-id note from the input
ELF file into the output PE/COFF firmware image as a dedicated ".bldid"
section. The build ID is emitted by the linker as a unique fingerprint
of the binary and allows custom post-build and debugging tools to
reliably match a firmware image against its corresponding unstripped
ELF and debug symbols, without relying on file names, timestamps, or
build paths.

This notable opts to use a non-standard section name ".bldid" to store
the build ID. This approach was chosen to keep genfw and the parsers simple
since the full "build-id" name would require redirecting the section name.
While this breaks from standard conventions, this is not impactful since
GenFW is already creating a non-standard artifact for the PE image with
the associated ELF symbol file.

Signed-off-by: Chris Fernald <chfernal@microsoft.com>
2026-07-22 18:06:03 +00:00
VarshitPandya
b551e8bb32 DynamicTablesPkg: Smbios Additional Information (Type 40)
Add a DynamicTables SMBIOS generator for the Additional Information
(Type 40) structure.

SMBIOS Type 40 provides additional information for fields in other
SMBIOS structures. Each Type 40 entry references an existing SMBIOS
record by handle and offset, provides an optional entry string, and
carries a supplemental field value.

The generator consumes one or more top-level CM objects, each referencing
a list of Additional Information entries. Each entry provides:
  - the CM object token of the referenced SMBIOS structure,
  - the referenced table generator ID,
  - the offset of the referenced field,
  - an optional entry string,
  - a token to a typed Additional Information Value object.

Example platform CM object layout:

  CM_ARCH_COMMON_ADDITIONAL_INFORMATION AdditionalInformation[] = {
    {
      REFERENCE_TOKEN (AdditionalInformation[0]),
      REFERENCE_TOKEN (AdditionalInformationEntry[0])
    }
  };

  CM_ARCH_COMMON_ADDITIONAL_INFORMATION_ENTRY
    AdditionalInformationEntry[] = {
      {
        REFERENCE_TOKEN (MemoryDeviceInfo[0]),
        CREATE_STD_SMBIOS_TABLE_GEN_ID (EStdSmbiosTableIdType17),
        OFFSET_OF (SMBIOS_TABLE_TYPE17, MemoryType),
        "DIMM0 memory type",
        REFERENCE_TOKEN (AdditionalInformationValue[0])
      }
    };

  CM_ARCH_COMMON_ADDITIONAL_INFORMATION_VALUE
    AdditionalInformationValue[] = {
      {
        sizeof (UINT8),
        {
          MemoryTypeDram
        }
      }
    };

The generator resolves referenced SMBIOS handles using CM object tokens
and table generator IDs. It validates the typed value objects, individual
entry lengths, and aggregate formatted record size. The maximum accepted
value length is controlled by PcdMaxAdditionalInformationValue.

Build the variable-length Type 40 formatted area and append the entry
strings to the SMBIOS string area.

Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
2026-07-22 14:40:20 +00:00
VarshitPandya
2bdb08ab00 DynamicTablesPkg: Add Additional Information CM objects
Add the Configuration Manager objects required to describe SMBIOS
Additional Information (Type 40) structures.

The top-level object references a list of Additional Information entries.
Each entry identifies a field in an existing SMBIOS structure and
references a typed value object containing the additional data.

Define the maximum value buffer size from the SMBIOS Type 40 formatted
length limit and add parsers for the new CM objects.

Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
2026-07-22 14:40:20 +00:00
Luigi Leonardi
35345c76a9 OvmfPkg/IntelTdx: Add memory debug logging support for TDX guests
OVMF already supports MemDebugLogLib for capturing firmware debug
output in a runtime memory buffer. Align the TDX peiless boot path
with OVMF by integrating the same library, so that TDX guests can
use memory-based debug logging.

In PeilessStartupLib, allocate a runtime buffer for the debug log
during PeilessStartup() and copy any early SEC-phase logs from
the pre-allocated FDF region into it.

Register the early debug log memory region in the TDX metadata as
TEMP_MEM so the TDX module accepts it during guest initialization.

Move PlatformDxe/Platform.inf from NCCFV to DXEFV because it
exposes the memory debug log HOB to the guest.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
2026-07-22 09:00:42 +00:00
Luigi Leonardi
e59458b658 OvmfPkg/MemDebugLogLib: Add MemDebugLogInit/Copy stubs to Null instance
The Null instance of MemDebugLogLib only provides MemDebugLogWrite(),
MemDebugLogPages(), and MemDebugLogEnabled(). Any module that
references MemDebugLogInit() or MemDebugLogCopy() cannot link against
the Null instance, forcing the feature to be gated at the build-system
level rather than at runtime.

Add no-op stubs for MemDebugLogInit() and MemDebugLogCopy().

This will be used by the following commit to add memory debug log
support in TDX.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
2026-07-22 09:00:42 +00:00
Jared Pan
4d5f8e68a1 MdeModulePkg/UsbBusDxe: BOS Descriptor Check for SS Devices
Some SuperSpeed-capable devices may fall back to High-Speed
mode and cause subsequent commands to fail.

[Suggested Solution]
Check the BOS descriptor to verify SuperSpeed support and
trigger a port reset if needed to re-enumerate the device
properly.

Signed-off-by: Marlboro Chuang <marlboro.chuang@dell.com>
Signed-off-by: Jared Pan <jared.pan@dell.com>
2026-07-22 07:25:57 +00:00
Jared Pan
ea275a48fa MdePkg/Usb: Add BOS Descriptor to support SuperSpeed Devices
[Suggested Solution]
Add the BOS descriptor structure and definition.

Signed-off-by: Marlboro Chuang <marlboro.chuang@dell.com>
Signed-off-by: Jared Pan <jared.pan@dell.com>
2026-07-22 07:25:57 +00:00
VarshitPandya
bcd168735f DynamicTablesPkg: Move common size definitions
Move SMBIOS_MAX_STRING_SIZE and CFMWS_MAX_INTERLEAVE_WAYS to the
common definitions near the top of ArchCommonNameSpaceObjects.h.

Document that SMBIOS_MAX_STRING_SIZE is an implementation-defined
Configuration Manager storage limit, including the terminating NULL,
rather than an SMBIOS specification limit. Also distinguish it from
the legacy SMBIOS_STRING_MAX_LENGTH definition used for SMBIOS 2.6
MIF compatibility.

Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
2026-07-21 15:18:26 +00:00
Sami Mujawar
74caea2956 ArmVirtPkg: Link VirtioMmioProbeLib to VirtioFdtDxe
Link VirtioMmioProbeLib to VirtioFdtDxe so that the Virtio MMIO
probe constructor maps the virtio-mmio ranges before the transport
driver accesses the device MMIO regions.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-07-21 10:25:17 +00:00
Sami Mujawar
422cc775a9 OvmfPkg: Introduce a Virtio MMIO probe lib
Introduce a Virtio MMIO probe library that discovers virtio-mmio
nodes from the FDT and maps their MMIO ranges before the virtio
transport driver creates virtio devices and accesses the device
MMIO regions.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-07-21 10:25:17 +00:00
Sami Mujawar
2f91cf9045 ArmVirtPkg: Refactor memory map configuration for Kvmtool Guest VM
Refactor the memory mapping configuration for Kvmtool Guest VM to
only setup the memory map for the System Memory, FV and the Serial
Port.

The memory mappings for he remaining devices are expected to be
configured by the respective drivers, this could be done as part
of the DXE drivers itself or using a Probe Library that adds the
device memory regions to the memory map.

The only special cases that remain are the System Memory, FV and
the Serial Port for which the memory mappings are created by the
KvmtoolVirtMemInfoLib. The memory mapping for the Serial port
is added as it is utilised for logging before the DXE driver
is loaded.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-07-21 10:25:17 +00:00
Sami Mujawar
2adf8dc56d ArmVirtPkg: Add early FDT 16550 serial port probe library
Fdt16550SerialPortHookLib does not provide a constructor and
expects SerialPortLib to call PlatformHookSerialPortInitialize().

Add an early FDT 16550 serial port probe library that invokes the
platform serial hook from its constructor. This allows the FDT to be
parsed early, the 16550 serial port base address to be extracted, and
the serial port PCD to be populated. It is needed during early boot so
the serial port memory map can be set up using the populated serial
port PCD.

The probe library wraps the hook call in its constructor instead of
reusing PlatformHookSerialPortInitialize() directly. This avoids
duplicate global definitions in modules that already link against the
PlatformHookLib instance.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-07-21 10:25:17 +00:00
Sami Mujawar
da1ccea67c OvmfPkg/FdtPciHostBridgeLib: Map PCI MMIO windows in GCD
Map the PCI MMIO32 and MMIO64 windows into the GCD memory
map after parsing the DT ranges property.

This makes the PCI memory apertures available as MMIO
regions.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-07-21 10:25:17 +00:00
Sami Mujawar
d46e38c5ea OvmfPkg/FdtPciHostBridgeLib: Use MapMmioLib for MMIO mapping
Replace the local GCD MMIO mapping helper with MapMmioMemory() when
mapping the PCI ECAM region and the translated I/O MMIO window.

This keeps the FDT PCI host bridge code aligned with the common MMIO
mapping helper and avoids duplicating AddMemorySpace() and
SetMemorySpaceAttributes() handling.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-07-21 10:25:17 +00:00
Sami Mujawar
9dcf9d317a ArmVirtPkg/KvmtoolRtcFdtClientLib: Use MapMmioLib for MMIO mapping
Replace the local RTC MMIO mapping sequence with MapMmioMemory(), while
keeping the explicit GCD allocation so the RTC page remains owned by the
driver image handle.

This reuses the common MMIO mapping path for GCD attributes.

Also update the incorrect error code documentation to reflect that
EFI_NOT_FOUND can be returned if the GCD space is not found and
drop the depex on gEfiCpuArchProtocolGuid as this is now done
by MapMmioLib which is where the Cpu Arch protocol is utilised.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-07-21 10:25:17 +00:00
Sami Mujawar
28526dbba3 ArmVirtPkg: Map GIC MMIO ranges before configuring GIC
Discover the GIC register ranges from the device tree and map them into
the GCD memory map before ArmGicDxe configures the interrupt controller.

Map the distributor and redistributor ranges for GICv3, and the
distributor and CPU interface ranges for GICv2, using MapMmioLib.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-07-21 10:25:17 +00:00
Sami Mujawar
b2b548c057 ArmVirtPkg: Include MapMmioLib in ArmVirt.dsc.inc
Add the MapMmioLib instance to the ArmVirt DXE_DRIVER library class
list so DXE drivers can map MMIO regions through the common helper.

Also add the runtime-driver library class mapping in ArmVirt.dsc.inc
so that runtime modules like KvmtoolRtcFdtClientLib can use
MapMmioLib.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-07-21 10:25:17 +00:00
Sami Mujawar
838240263a OvmfPkg/MapMmioLib: Support runtime drivers
Allow MapMmioLib to be consumed by DXE_RUNTIME_DRIVER modules.

MapMmioMemory() depends on DXE services, so it cannot map new
ranges after ExitBootServices(). Return EFI_ACCESS_DENIED when
called at runtime.

This allows runtime drivers such as
ArmVirtPkg/Library/KvmtoolRtcFdtClientLib to use MapMmioLib for
boot-time MMIO setup.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-07-21 10:25:17 +00:00
Sami Mujawar
760bb2d2fd OvmfPkg/MapMmioLib: Introduce a library for mapping MMIO regions
Introduce MapMmioLib to add MMIO regions to the GCD memory map.

MapMmioMemory() normalizes the requested range to page boundaries, adds
missing MMIO descriptors, and updates attributes for new and existing MMIO
descriptors. Existing descriptors of any other type are reported as
conflicts.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-07-21 10:25:17 +00:00
Sami Mujawar
084ce2b04b ArmVirtPkg: Clear TPIDR_EL0 before early HOB lookups
TPIDR_EL0 is used to hold the PrePi HOB list pointer, but its reset
value is unknown. Some early boot paths can call GetHobList() before
PrePiMain() creates and installs the HOB list.

Clear TPIDR_EL0 at the SEC entry point so those early lookups see NULL
rather than an invalid pointer.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-07-21 10:25:17 +00:00
Michael G.A. Holland
2b842a2081 CryptoPkg/BaseCryptLib: Add SLH-DSA Support
Created SLH-DSA API functions to configure public and private keys for
SLH-DSA algorithm.  This will allow users to sign and verify with
SLH-DSA.  Unit tests were added to confirm operation of the API.

Signed-off-by: Michael G.A. Holland <michael.holland@intel.com>
2026-07-21 09:17:50 +00:00
DC-Damien
6a9c048ba5 MdeModulePkg/UsbBusPei: Use dynamic buffer for USB configuration data
USB devices whose configuration descriptor TotalLength exceeds 1024
bytes (e.g. IR cameras with large descriptor tables) previously hit
an EFI_DEVICE_ERROR hard-limit and failed to enumerate in PEI.

Replace the fixed array with a UINT8 * pointer and dynamically
allocate the exact amount of memory required via
PeiServicesAllocatePool() after the TotalLength is learned from the
initial 4-byte descriptor probe.

Signed-off-by: Damien Chen <damien.chen@dell.com>
2026-07-21 03:50:20 +00:00
Michael Kubacki
0adb357ab7 BREAKING-CHANGES.md: Add changes prior to process during 202608 dev period
This file was added as part of the new TianoCore EDK II breaking
changes process defined in the following RFC:

https://github.com/tianocore/tianocore-wiki.github.io/blob/main/rfc/text/0001-rfc-process.md

In order to make the file accurate for the upcoming edk2-stable202605
stable tag, this commit adds all breaking changes that have been
merged into the master branch since the last stable tag
(edk2-stable202605).

Because these changes did not follow the full process, they do not
have some required information like tracking issues.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-07-21 03:30:46 +00:00
Jared Pan
a933771361 UefiPayloadPkg/DxeHobLib: Add lazy initialization for gHobList
This change adds dynamic initialization of gHobList in GetHobList() to handle cases where library constructors are executed before DxeHobListLibConstructor.

Issue:
On ARM platforms using ArmMmuBaseLib, the ArmMmuBaseLibConstructor calls GetFirstGuidHob() before xeHobListLibConstructor has initialized gHobList, causing an ASSERT.

Root Cause:
ArmMmuBaseLib's constructor uses HobLib functions, but UefiPayloadPkg's DxeHobLib assumes gHobList is already initialized by DxeHobListLib's constructor.

Solution:
Add the same lazy initialization pattern already used in MdePkg/Library/DxeHobLib, which dynamically retrieves the HOB list from the System Configuration Table if gHobList is NULL.

This change:
- Aligns behavior with MdePkg/Library/DxeHobLib
- Has no impact on existing functionality
- Improves robustness for ARM platforms

Signed-off-by: Jared Pan <jared.pan@dell.com>
2026-07-21 02:14:02 +00:00
Sunil V L
f539e44fe4 DynamicTablesPkg/RiscV: Fix unused variables warnings
Either use the variables or get rid of them.

Signed-off-by: Sunil V L <sunilvl@oss.qualcomm.com>
2026-07-21 00:18:25 +00:00
Sunil V L
c5e42e7942 DynamicTablesPkg/RiscV: Fix ISA string copy in RiscVIntcParser
The IsaStringInfoParser() routine currently sets the ISA string length
to PropSize + 1 and used AsciiStrCpyS() with PropSize + 1 as the
destination size. This could lead to incorrect length handling and
potential buffer issues.

Update the code to:
- Set IsaStringInfo.Length to PropSize (actual property size).
- Use MAX_ISA_STRING_LENGTH as the destination buffer size when
  copying the ISA string.
- Check the return status of AsciiStrCpyS() and abort with an error
  message if the copy fails.

This ensures safe string handling and prevents buffer overflow or
truncation when parsing ISA strings.

Reported-by: Zhenyu Liu <lzy00419@outlook.com>
Signed-off-by: Sunil V L <sunilvl@oss.qualcomm.com>
2026-07-21 00:18:25 +00:00
Rebecca Cran
97665a4ef0 MdeModulePkg: Bump the default SMBIOS version to 3.8
Commit 7f505d377b in 2024 added the
Type 4 field SocketType. Bump the default SMBIOS version to 3.8
in order for the larger table size to be valid.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
2026-07-21 00:02:39 +00:00
Rebecca Cran
08dd5e921c ArmPkg: Add SMBIOS Type 4 SocketType handling
The SMBIOS Type 4 field SocketType was added in commit
7f505d377b in 2024. This
caused the table size to be invalid when platforms specify
versions of SMBIOS before 3.8.

Update ProcessorSubClassDxe to handle fetching the string for the
socket type including calling into OemMiscLib to retrieve it.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
2026-07-21 00:02:39 +00:00
Sami Mujawar
3fa842faf9 ArmVirtPkg: Add Crypto helper library for Boot Sync
Introduce a helper library that implements wrappers for the
cryptographic functionality required by the Arm Boot Sync
Blocks protocol implementation.

This library implements the following:
 - Key Exchange: ECDH key using the ECC Curve-P384
 - Key Derivation: SHA512 HMAC-based Extract-and-Expand HKDF
 - Encryption/Decryption: AEAD AES-GCM authenticated encryption
                          and decryption

Also register the library class in ArmVirtPkg.dec, wire the
instance into the KvmTool guest firmware and update the CI YAML
file to add CryptoPkg/CryptoPkg.dec as an acceptable dependency.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
2026-07-20 23:02:37 +00:00
Richard Lyu
0e13e105c6 BREAKING-CHANGES.md: Document GptLib library class addition
Per the Breaking Change and Release Process RFC, a non-removal breaking
change must add an entry to BREAKING-CHANGES.md in the PR that introduces
the change.

Add the entry for the new GptLib library class dependency under
edk2-stable202608, Source-Level Breaking Changes, Changes without Removal.

Signed-off-by: Richard Lyu <richard.lyu@suse.com>
2026-07-20 21:50:57 +00:00
Richard Lyu
b1029265b1 MdeModulePkg/GptLib: Add host-based unit tests for malformed GPT input
Extend the GptLib host-based tests with negative cases that guard the
security hardening in PartitionValidGptTable(), PartitionCheckGptEntry()
and PartitionRestoreGptTable() against future regressions. These tests
exercise the shared parser, not the specific fix itself.

The new cases drive the parser with malformed GPT structures that an
attacker may present: bad signature/revision, header-size boundaries,
CRC corruption, MyLBA replay, zero/non-power-of-two entry sizes, LBA
multiplication overflow, out-of-range and overlapping entries, and
restore failure on write-protected media. The INF file header is
updated to note the added malformed coverage.

Signed-off-by: Richard Lyu <richard.lyu@suse.com>
2026-07-20 21:50:57 +00:00
Richard Lyu
77585e5004 MdeModulePkg/GptLib: Add host-based unit tests for valid GPT behavior
Add the positive-path host-based tests for the shared GptLib parser
(extracted as part of the parser security hardening), ensuring the
tightened checks in PartitionValidGptTable(), PartitionCheckGptEntry()
and PartitionRestoreGptTable() do not falsely reject well-formed GPTs.

The tests run against an in-memory mock disk and cover accepted
primary/backup headers, boundary but legal header/entry sizes, correct
entry-status flagging on valid entries, and primary/backup restore
round-trips.

Signed-off-by: Richard Lyu <richard.lyu@suse.com>
2026-07-20 21:50:57 +00:00
Richard Lyu
b65fd21591 SecurityPkg/DxeTpmMeasureBootLib: Use GptLib parser
TcgMeasureGptTable() reads the primary GPT header directly from LBA 1
and validates it with field checks only: no header CRC32, no
partition-entry-array CRC32 and no backup fallback. This is the same
divergence between the measured and the parsed partition table that
CVE-2024-13745 reports against DxeTpm2MeasureBootLib, and the tracking
issue lists both libraries as affected.

Mirror the DxeTpm2MeasureBootLib fix: select the GPT header to measure
via the shared GptLib parser. Validate the current primary GPT or, when
it is invalid, validate the backup and the header at its AlternateLBA.
Do not extend PCR[5] if no valid header can be selected.

Signed-off-by: Richard Lyu <richard.lyu@suse.com>
2026-07-20 21:50:57 +00:00
Richard Lyu
070c9026f7 MdeModulePkg/PartitionDxe: Abort on primary GPT recovery failure
When the primary GPT is invalid, PartitionInstallGptChildHandles()
restores it from the backup and re-validates it. Both the restore write
and the re-validation can fail (e.g. write-protected media, or a backup
AlternateLBA pointing beyond the device), yet the existing code only logs
the failure and parses partitions from a known-invalid PrimaryHeader.

Abort GPT processing when either the restore or the validation fails, so
partitions are only ever parsed from a validated primary GPT. The backup
recovery branch is left unchanged, as the primary is already validated.

A device with an unrecoverable primary GPT now installs no child handles
instead of using an invalid header. This keeps the table PartitionDxe uses
in sync with the one DxeTpm2MeasureBootLib measures into PCR[5].

Ref: https://seclists.org/oss-sec/2026/q2/727
Signed-off-by: Richard Lyu <richard.lyu@suse.com>
2026-07-20 21:50:57 +00:00
Richard Lyu
45732edfff MdeModulePkg/GptLib: Validate GPT header fields before use
PartitionValidGptTable() checked the signature, header CRC32, MyLBA, the
entry-array CRC32 and the entry-array size overflow, but not several other
UEFI-mandated GPT header constraints. DxeTpm2MeasureBootLib used to enforce
these via Tpm2SanitizeEfiPartitionTableHeader(); once it switched to this
shared parser, the checks were lost on the path.

Also reject a header unless Header.Revision is GPT_HEADER_REVISION_V1,
HeaderSize is at least the 92-byte minimum, NumberOfPartitionEntries is
non-zero, SizeOfPartitionEntry is 128 * 2^n, and PartitionEntryLBA *
BlockSize cannot overflow. The "entries lie before FirstUsableLBA" rule is
intentionally omitted, as this routine also validates the backup header
whose entry array follows the usable region.

This restores the validation the measurement path lost and, because GptLib
is shared, tightens PartitionDxe the same way: malformed headers are now
rejected and the parse and measure paths stay identical.

Ref: https://seclists.org/oss-sec/2026/q2/727
Signed-off-by: Richard Lyu <richard.lyu@suse.com>
2026-07-20 21:50:57 +00:00
Richard Lyu
1840729929 UefiPayloadPkg: Resolve GptLib library class
GptLib is a new library class consumed both by PartitionDxe (built by
essentially every platform) and by DxeTpm2MeasureBootLib. Any platform DSC
that builds either module must resolve the GptLib library class, otherwise
the build fails with "Instance of library class [GptLib] is not found".

Resolve GptLib in UefiPayloadPkg/UefiPayloadPkg.dsc, which builds
PartitionDxe.

Out-of-tree platforms consuming either module need the same one-line
resolution.

Signed-off-by: Richard Lyu <richard.lyu@suse.com>
2026-07-20 21:50:57 +00:00
Richard Lyu
cb6dcca337 OvmfPkg: Resolve GptLib library class
GptLib is a new library class consumed both by PartitionDxe (built by
essentially every platform) and by DxeTpm2MeasureBootLib. Any platform DSC
that builds either module must resolve the GptLib library class, otherwise
the build fails with "Instance of library class [GptLib] is not found".

Resolve GptLib in each OVMF DSC. Every OVMF DSC builds PartitionDxe.
IntelTdx, LoongArchVirt and RiscVVirt additionally link
DxeTpm2MeasureBootLib directly; AmdSev, Bhyve, CloudHv, Microvm,
OvmfPkgX64 and OvmfPkgIa32X64 pull it in through
OvmfTpmSecurityStub.dsc.inc.

Out-of-tree platforms consuming either module need the same one-line
resolution.

Signed-off-by: Richard Lyu <richard.lyu@suse.com>
2026-07-20 21:50:57 +00:00
Richard Lyu
78c5050bb2 EmulatorPkg: Resolve GptLib library class
GptLib is a new library class consumed both by PartitionDxe (built by
essentially every platform) and by DxeTpm2MeasureBootLib. Any platform DSC
that builds either module must resolve the GptLib library class, otherwise
the build fails with "Instance of library class [GptLib] is not found".

Resolve GptLib in EmulatorPkg/EmulatorPkg.dsc, which builds PartitionDxe.

Out-of-tree platforms consuming either module need the same one-line
resolution.

Signed-off-by: Richard Lyu <richard.lyu@suse.com>
2026-07-20 21:50:57 +00:00
Richard Lyu
2b27f795ec ArmVirtPkg: Resolve GptLib library class
GptLib is a new library class consumed both by PartitionDxe (built by
essentially every platform) and by DxeTpm2MeasureBootLib. Any platform DSC
that builds either module must resolve the GptLib library class, otherwise
the build fails with "Instance of library class [GptLib] is not found".

Resolve GptLib once in ArmVirtPkg/ArmVirt.dsc.inc for the whole ArmVirt
family, whose platforms build PartitionDxe and, for ArmVirtQemu, link
DxeTpm2MeasureBootLib.

Out-of-tree platforms consuming either module need the same one-line
resolution.

Signed-off-by: Richard Lyu <richard.lyu@suse.com>
2026-07-20 21:50:57 +00:00
Richard Lyu
7c12d4359a SecurityPkg/DxeTpm2MeasureBootLib: Use GptLib parser
The previous commit introduced GptLib by extracting PartitionDxe's GPT
parsing and validation code. It provides a shared implementation for edk2
components that need to parse and validate GPT data consistently.

Update DxeTpm2MeasureBootLib to use GptLib when selecting on-disk GPT
data for measurement. Validate the current primary GPT or, when it is
invalid, validate the backup and the header at its AlternateLBA. Do not
extend PCR[5] if no valid header can be selected. The measurement therefore
uses GPT data read from disk at measurement time and applies the shared
parser and validation logic.

Ref: https://seclists.org/oss-sec/2026/q2/727
Signed-off-by: Richard Lyu <richard.lyu@suse.com>
2026-07-20 21:50:57 +00:00
Richard Lyu
00a865d595 MdeModulePkg/GptLib: Extract shareable GPT parser into a library
As reported in CVE-2024-13745 via oss-sec, DxeTpm2MeasureBootLib can
measure a partition table that differs from the one parsed by the
PartitionDxe driver.

To address this, the more complete GPT parsing logic from PartitionDxe
is extracted into a standalone GptLib library so it can be
shared between PartitionDxe and DxeTpm2MeasureBootLib. This ensures
that the exact same partition table measured into PCR[5] is the one
parsed and used by the system. PartitionDxe behavior is unchanged.

Ref: https://seclists.org/oss-sec/2026/q2/727
Signed-off-by: Richard Lyu <richard.lyu@suse.com>
2026-07-20 21:50:57 +00:00
Kun Qin
2938b830f6 SecurityPkg: Tpm over FFA: FFA_RUN command should use the returned ID
As the FFA function now returns the target ID properly, instead of
hardcoding the FFA_RUN target ID being the TPM SP, we use the parsed
ID to issue the FFA_RUN.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2026-07-20 19:13:15 +00:00
Kun Qin
ed21313ac7 ArmPkg: MmCommunication: FFA run should use the returned ID
As the FFA function now returns the target ID properly, instead of
hardcoding the FFA_RUN target ID being the STMM, we use the parsed
ID to issue the FFA_RUN.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2026-07-20 19:13:15 +00:00
Kun Qin
89c6073683 MdePkg,MdeModulePkg: ArmFfaLib: Expand to include first 4 registers
The direct message arguments stripped off the header, making the
underlying FF-A function interface to lose information when it comes to
certain return code, i.e. FFA_YIELD and FFA_INTERRUPT.

This change adds back the header field for this purpose so that the
callers can decide how to act on the corresponding return codes.

It then populates the header field for this purpose in FFA direct
message functions so that the callers can decide how to act on the
corresponding return codes.

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

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2026-07-20 19:13:15 +00:00
Chris Fernald
6f2b09986b ArmPkg: Handle FFA_BUSY response for MM communication
MM communicate is used at runtime, and the secure partition it is
communicating with may provide services access through other means then
the UEFI runtime services. As such, the MM communication library must not
assume that the partition will be in the waiting state. Instead it must
handle the case where the partition is busy and retry the communication
to some limit.

Signed-off-by: Chris Fernald <chfernal@microsoft.com>
2026-07-20 19:13:15 +00:00
Luigi Leonardi
af41063d81 OvmfPkg: document DebugLevel runtime config
Add documentation for the DebugLevel runtime config that sets the
verbosity of the serial debug log level on ArmVirt.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
2026-07-20 16:53:45 +00:00
Luigi Leonardi
f4bbef1dd7 ArmVirtPkg: introduce compile and runtime control of serial debug log level
Add a new PCD `PcdSerialDebugPrintErrorLevel` that overrides the verbosity
set in `DebugPrintErrorLevel` for the serial port debug output and does
not affect memory debug logging.

Accepted values are:
- "silent": DEBUG_ERROR only
- "verbose": use the `DebugPrintErrorLevel` value.
- a hex bitmask (e.g. "0x80000040").

This PCD value can be overridden at runtime using the fw_cfg entry
"opt/org.tianocore/DebugLevel" without rebuilding the firmware.

The runtime override takes priority over the compile-time one. When
neither is set, the serial output uses the compiled-in
PcdDebugPrintErrorLevel.

SEC and PEI_CORE phases do not support this override because they run
from flash, where global variables are not available. Supporting it
would require parsing the device tree on every debug write to locate
the fw_cfg device and read the DebugLevel value — unnecessary overhead
given the low volume of logs in those phases.

ParseSerialDebugLevel() is duplicated as a STATIC function in Flash.c
and PlatformPeiLib.c rather than shared via a header, because EDK2
coding style forbids function definitions in headers. A dedicated
library class would be excessive for a small helper with only two
consumers.

Example QEMU command line:

  -fw_cfg name=opt/org.tianocore/DebugLevel,string=silent
  -fw_cfg name=opt/org.tianocore/DebugLevel,string=verbose
  -fw_cfg name=opt/org.tianocore/DebugLevel,string=0x80000000

Suggested-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
2026-07-20 16:53:45 +00:00
Luigi Leonardi
84690e91a4 OvmfPkg/QemuFwCfgSimpleParserLib: export QemuFwCfgGetAsString()
Make QemuFwCfgGetAsString() a public EFIAPI entry point instead of
a STATIC helper, so it can be used by consumers that need the raw
fw_cfg string value rather than a parsed boolean or integer.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
2026-07-20 16:53:45 +00:00
FangSheng Huang
6c6d0a72c2 OvmfPkg/PlatformPei: retain SoftReserved memory under SEV-SNP
Soft Reserved (Specific Purpose Memory) regions carry the
EFI_RESOURCE_ATTRIBUTE_SPECIAL_PURPOSE attribute, which the OS sees as
EFI_MEMORY_SP (E820 Soft Reserved).  Under SEV-SNP this does not reach the
guest: AmdSevSnpInitialize() changes every EFI_RESOURCE_SYSTEM_MEMORY HOB
above 4GB to EFI_RESOURCE_MEMORY_UNACCEPTED, and AcceptAllMemory() later
re-adds the region as plain system memory without EFI_MEMORY_SP, so the
guest sees ordinary RAM instead of Soft Reserved.

Exclude SPECIAL_PURPOSE regions from the unaccepted conversion so they keep
the EFI_RESOURCE_SYSTEM_MEMORY type and are pre-validated in place, like
sub-4GB memory.

Signed-off-by: FangSheng Huang <FangSheng.Huang@amd.com>
2026-07-20 13:58:25 +00:00
Jiaqing Zhao
9e3e68218c OvmfPkg/VirtioInputDxe: Add virtio tablet support
Virtio tablet devices report absolute coordinates (EV_ABS) and button
inputs. Add VirtioTablet.c implementing tablet capability probing,
EFI_ABSOLUTE_POINTER_PROTOCOL implementation and event handler that
converts VIRTIO_INPUT_EVENT into EFI_ABSOLUTE_POINTER_STATE.

The axis ranges advertised by EFI_ABSOLUTE_POINTER_MODE are read from
the device's abs_info for ABS_X and ABS_Y.

The shared event dispatcher in VirtioInput.c now routes EV_ABS events
and EV_KEY codes above MAX_KEYBOARD_CODE to the tablet handler.

Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
2026-07-20 12:43:36 +00:00