Commit graph

36559 commits

Author SHA1 Message Date
Jiaqing Zhao
efdbf3c355 OvmfPkg/VirtioInputDxe: Add virtio mouse support
Virtio mouse devices report relative movements (EV_REL) and button
inputs. Add VirtioMouse.c implementing mouse capability probing,
EFI_SIMPLE_POINTER_PROTOCOL implementation and event handler that
converts VIRTIO_INPUT_EVENT into EFI_SIMPLE_POINTER_STATE.

The shared event dispatcher in VirtioInput.c now routes EV_REL events
and EV_KEY codes above MAX_KEYBOARD_CODE to the mouse handler, while
keycodes in [0, MAX_KEYBOARD_CODE] still go to the keyboard. A device
is now accepted when it provides a keyboard or a mouse, and the
EFI_SIMPLE_POINTER_PROTOCOL is installed on mouse-capable devices.

Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
2026-07-20 12:43:36 +00:00
Jiaqing Zhao
fd63e80508 OvmfPkg/VirtioInputDxe: Split keyboard logic into VirtioKeyboard.c
Move all keyboard-specific code including probing, initialization,
keycode translation and Simple Text Input (Ex) protocol implementation
into new VirtioKeyboard.c. VirtioInput.c retains only the shared virtio
transport, the input poll timer and the event dispatcher.

This is also the groundwork for the mouse and tablet support added in
later commits.

No functional change.

Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
2026-07-20 12:43:36 +00:00
Jiaqing Zhao
d0c42935e2 OvmfPkg/VirtioInputDxe: Add keyboard capability detection
Current driver produces the EFI_SIMPLE_TEXT_INPUT[_EX]_PROTOCOL
interfaces on every virtio-input device it binds. A virtio-input
device may however be a pointer device (mouse or tablet) that reports
no keyboard keys, in which case the keyboard protocols should not be
installed.

Add VirtioInputHasKeyboard() to check whether the virtio-input device
implements a keyboard by scanning the EV_KEY capability bitmap to see
if any keycodes between [0, MAX_KEYBOARD_CODE] is supported. A helper
function VirtioInputConfigQuerySize() is also added for fetching the
size of a virtio-input configuration sub-selection.

VirtioInputInit() now stores the result in Dev->HasKeyboard and fails
with EFI_UNSUPPORTED when no keyboard is present.

Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
2026-07-20 12:43:36 +00:00
Jiaqing Zhao
0fc04cff3b OvmfPkg/VirtioInputDxe: Fix Reset() function to only flush input state
According to UEFI specification, "the implementation of Reset is
required to clear the contents of any input queues resident in memory
used for buffering keystroke data and put the input stream in a known
empty state". So it should only reset the internal status of keyboard
driver, not the driver itself.

Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
2026-07-20 12:43:36 +00:00
Jiaqing Zhao
ae92eb78f6 OvmfPkg/IndustryStandard: Add type definitions for virtio input device
Add IndustryStandard/VirtioInput.h for virtio input device type
definitions defined in virtio 1.1 specification.
https://docs.oasis-open.org/virtio/virtio/v1.1/cs01/virtio-v1.1-cs01.html#x1-3390008

Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
2026-07-20 12:43:36 +00:00
Jiaqing Zhao
afe4360dd2 OvmfPkg, ArmVirtPkg: Rename VirtioKeyboardDxe to VirtioInputDxe
The virtio input device can be used to create virtual human interface
devices such as mice and tablets, not just keyboards. Rename
VirtioKeyboardDxe to VirtioInputDxe for adding virtio-mouse and
virtio-tablet support in following commits.

No functional change.

Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
2026-07-20 12:43:36 +00:00
Jiaqing Zhao
7cc22c4b5b OvmfPkg/VirtioKeyboardDxe: Declare internal functions as STATIC
The SimpleTextIn(Ex) protocol callbacks and IsKeyRegistered() are only
used within VirtioKeyboard.c. Declare them STATIC and remove the
declarations in VirtioKeyboard.h.

No functional change.

Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
2026-07-20 12:43:36 +00:00
Jiaqing Zhao
a1b3a6bd1f OvmfPkg/VirtioKeyboardDxe: Simplify WaitForKey event handling
Both WaitForKey and WaitForKeyEx event handler runs the same logic in
VirtioKeyboardWaitForKey(). Pass the VIRTIO_KBD_DEV pointer directly
as the event notify context so one function serves both events.

Also drop the erroneous assignment of VirtioKeyboardWaitForKey() to
Dev->Txt.WaitForKey, which stored a function pointer into the event
handle field and was immediately overwritten by CreateEvent().

No functional change.

Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
2026-07-20 12:43:36 +00:00
Jiaqing Zhao
ff355e4bdd OvmfPkg/VirtioKeyboardDxe: Fix typo in IsKeyRegistered()
Regsiter -> Register

No functional change.

Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
2026-07-20 12:43:36 +00:00
Jiaqing Zhao
0a74b3a4de OvmfPkg/VirtioKeyboardDxe: Drop unused functions and variables
VirtioKeyboardRingHasBuffer() and VIRTIO_KBD_DEV.KeyNotifyTimer are
defined but never called, drop them.

Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
2026-07-20 12:43:36 +00:00
Jiaqing Zhao
2c6e9e13d6 OvmfPkg/VirtioKeyboardDxe: Close WaitForKey(Ex) events in Uninit()
VirtioKeyboardInit() creates Txt.WaitForKey, TxtEx.WaitForKeyEx and
KeyReadTimer events, but VirtioKeyboardUninit() currently only closes
KeyReadTimer. Close the other two events to fix the leak.

Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
2026-07-20 12:43:36 +00:00
Jiaqing Zhao
a507ccdc6a OvmfPkg/VirtioKeyboardDxe: Fix RingMap check in UninitRing
UnmapSharedBuffer() should be called on a valid mapping. Fix the
inverted condition.

Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
2026-07-20 12:43:36 +00:00
Jiaqing Zhao
be0513a59a OvmfPkg/VirtioKeyboardDxe: Fix protocol uninstall in BindingStop
UninstallMultipleProtocolInterfaces() takes the handle by value rather
than pointer.

Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
2026-07-20 12:43:36 +00:00
Jakov Zauzolkov
1506c6da7b OvmfPkg: Replace BaseAcpiTimerLib with BaseRomAcpiTimerLib in PEI
The BaseAcpiTimerLib instance contains a static global variable,
'mAcpiTimerIoAddr', that caches the ACPI timer IO base address. As this
library executes during PEI phase prior to the PEIFV measurement into
PCR0, the value of the variable is included into the measurement. This
causes the PEIFV binary footprint to change, preventing a precomputation
of the expected value needed for remote attestation.

Fix this by using the BaseRomAcpiTimerLib in the PEI phase instead of
the BaseAcpiTimerLib. This library dynamically computes the required
address and does not introduce global variables, keeping the PEIFV
binary unchanged.

Co-authored-by: Simon Ott <simon.ott@aisec.fraunhofer.de>
Signed-off-by: Jakov Zauzolkov <jakov.zauzolkov@aisec.fraunhofer.de>
2026-07-20 12:18:38 +00:00
Luigi Leonardi
99942e3532 OvmfPkg/VirtMmCommunicationDxe: Fix NULL dereference of optional CommSize
VirtMmCommunication2Communicate() dereferences *CommSize in a DEBUG
statement before checking whether CommSize is NULL.  CommSize is an
optional parameter, so callers may legitimately pass NULL, causing a
NULL pointer dereference in debug builds.

Guard the dereference with a ternary so the DEBUG prints 0 when
CommSize is NULL.

Fixes: 9dd47eeea1 ("OvmfPkg: add new VirtMmCommunicationDxe driver")
Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
2026-07-20 11:57:09 +00:00
Luigi Leonardi
5dc785e7f6 OvmfPkg/VirtMmCommunicationDxe: Fix unchecked VirtMmGetProp return values
VirtMmHwFind() calls VirtMmGetProp() twice but does not assign the
return value to Status.  The subsequent EFI_ERROR(Status) checks test
the stale Status from LocateProtocol(), which always succeeds at that
point, so FDT lookup failures are silently ignored and the function
proceeds with uninitialised Ranges/Reg pointers.

Assign both VirtMmGetProp() return values to Status so the error
checks work as intended.

Fixes: 9dd47eeea1 ("OvmfPkg: add new VirtMmCommunicationDxe driver")
Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
2026-07-20 11:57:09 +00:00
Luigi Leonardi
048e36d5af OvmfPkg/VirtMmCommunicationDxe: Remove unused QemuX64.c
QemuX64.c implemented PIO-based MM communication for the uefi-vars-isa
device. It was already commented out in VirtMmCommunication.inf and is
not referenced by any build file. Remove the dead code.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
2026-07-20 11:57:09 +00:00
Michael G.A. Holland
264f812b70 CryptoPkg/BaseCryptLib: ML-DSA updates
Include validation check for Context and ContextSize in signature
function.
Updated ReadMe to show ML-DSA support

Signed-off-by: Michael G.A. Holland <michael.holland@intel.com>
2026-07-20 11:34:40 +00:00
Shubham Kumar
dc52b0c75b FmpDevicePkg/FmpDxe: Reduce NV variable reads for FMP state
In PopulateDescriptor(), each FMP device previously called
GetFmpControllerState() multiple times through individual getter
functions (GetVersionFromVariable, GetLowestSupportedVersionFromVariable,
etc.), each performing a separate GetVariable() call to read the same
FmpControllerState NV variable.

Rename the getter functions to *FromFmpControllerState and simplify
them to pure field extractors that take a required FMP_CONTROLLER_STATE
pointer. Each getter extracts the field value if the state is non-NULL
and the field is valid, returning a default otherwise. No getter calls
GetFmpControllerState() internally.

PopulateDescriptor() now calls GetFmpControllerState() once and passes
the result to all getters, then frees it after the last use. This
eliminates redundant NV reads when the variable exists and avoids
repeated failed reads and error messages when the variable does not
exist.

Signed-off-by: Shubham Kumar <kumarshubha@microsoft.com>
2026-07-20 05:44:52 +00:00
Michael G.A. Holland
5309cdb92c CryptoPkg/BaseCryptLib: EdDsa updates
Include validation checks for Context and ContextSize in
sign and verify functions.
Returned FALSE for EdDsaGeneratePubKey.
Updated ReadMe to show EdDsa support

Signed-off-by: Michael G.A. Holland <michael.holland@intel.com>
2026-07-20 03:23:22 +00:00
Kun Qin
8f5a348a9d MdePkg: BaseMemoryLib: Add memory barrier to SetMem
The implementation adds a toolchain-specific compiler barriers to
discourage reordering under aggressive optimization around memory
setting operations.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2026-07-18 15:04:29 +00:00
Vincent Gatine
21b358b81d ShellPkg/Pci: Restore BAR informations
Restore informations lost in the pci shell command.

sbsa-ref Host Bridge:

```
 Cache Line Size(C): 00                 Latency Timer(D): 00
 Header Type(0E):    00, Single function, PCI device
 Class: Bridge Device - Host/PCI bridge -
+Base Address Registers(10):
+  (None)
+Expansion ROM Disabled(30)
+
+Cardbus CIS ptr(28):   00000000
+Sub VendorID(2C):          1AF4      Subsystem ID(2E):      1100
+Capabilities Ptr(34):        00
+Interrupt Line(3C):          FF      Interrupt Pin(3D):       00
+Min_Gnt(3E):                 00      Max_Lat(3F):             00
```
sbsa-ref Ethernet Controller:

```
 Cache Line Size(C): 00                 Latency Timer(D): 00
 Header Type(0E):    00, Single function, PCI device
 Class: Network Controller - Ethernet controller -
+Base Address Registers(10):
+     Start_Address  Type  Space    Prefetchable?     Size             Limit
+  --------------------------------------------------------------------------
+          81060000  Mem   32 bits  No             00020000          8107FFFF
+          81040000  Mem   32 bits  No             00020000          8105FFFF
+              0000  I/O                               0020              001F
+          81080000  Mem   32 bits  No             00004000          81083FFF
+  --------------------------------------------------------------------------
+Expansion ROM Disabled(30)
+
+Cardbus CIS ptr(28):   00000000
+Sub VendorID(2C):          8086      Subsystem ID(2E):      0000
+Capabilities Ptr(34):        C8
+Interrupt Line(3C):          FF      Interrupt Pin(3D):       01
+Min_Gnt(3E):                 00      Max_Lat(3F):             00

 Pci Express device capability structure:
 CapID( 0):          10            NextCap Ptr( 1):    A0
```

Signed-off-by: Vincent Gatine <vincent.gatine@sipearl.com>
2026-07-17 22:58:58 +00:00
Michael Kubacki
a59064933f BaseTools/Trim.py: Strip "#pragma once" from inlined ASL content
When Trim processes an ASL file (`--asl-file`), it textually inlines
the body of every `Include()`'d file directly into the constructed
preprocessor input, once per include site.

Its has duplicate protection in the form of a circular-include stack
(`gIncludedAslFile`), that prevents A->B->A cycles. But, as far as
the script is concerned, each `Include()` is a unique include site.

Various combinations of includes and file types are possible and
handled slightly differently.

Starting with file types as defined in
BaseTools\Conf\build_rule.template:

- `.aslc`, `.act` files fall under `Acpi-Table-Code-File` and are
  compiled, linked, and processed by genfw.
- `.asl`, `.Asl`, and `.ASL` files fall in `Acpi-Source-Language-File`
  and are processed by Trim:
  1. `Trim --asl-file` to produce a single combined .i file with
     includes inlined.
  2. `ASLPP` (ASL preprocessor, a C preprocessor) on the output of
     Trim to produce a .iii file with all macros expanded and
     conditional branches resolved. AutoGen.h is also included and
     processed here to resolve fixed PCD values if needed.
  3. `Trim --source-code` which takes the pre-processed .iii file and
     produces a .iiii file with content like linemarkers cleaned up.
  4. The ACPI compiler compiles the .iiii file to produce AML bytecode
     in a .aml file.

Because the `.aslc`/`.act` files are directly passed to normal C
processing tools, they are not part of the Trim change made in this
commit and the remainder of this message focuses on the ACPI Source
Language File case.

ASL files can use either an ASL `Include()` directive or a C-style
`#include` directive. In addition, different file types may be
included such as a `.asl` file or a `.h` file.

`Trim` handles these cases differently:

- For ASL `Include()` directives, `Trim` inlines the content of the
  included file directly into the output at the include site. This is
  done for all included ASL files regardless of their extension. The
  inlining is purely textual and does not attempt to resolve or
  preserve any preprocessor directives such as `#pragma once` or
  include guards.
- For C-style `#include` directives, `Trim` checks the file extension
  of the included file. If the file is an ASL file (`.asl` or `.asi`),
  `Trim` treats the file the same as the `Include()` case. Otherwise,
  `Trim` passes the directive through verbatim to the output, allowing
  the downstream C preprocessor (`ASLPP`) to handle it according to
  normal C preprocessor rules.

This creates a situtation in which the resulting `.i` might include:

- Inlined file content (from a `.asl` or `.h` file) depending on the
  include type and file extension.
- Verbatim `#include` directives for non-ASL files which will be
  processed by the C preprocessor.

Focusing on the "inlined" case, historically `.h` files would have
traditional C include guards (`#ifndef`/`#define`, `#endif`). However,
files might also include `#pragma once` as a guard.

In that case, the inlined content of the `.i` file could contain
multiple `#pragma once` directives, one per include site. When the
C preprocessor (`ASLPP`) processes the `.i` file, it sees multiple
`#pragma once` directives in what it considers the main file, and
could emit a warning like the following from gcc:

  warning: '#pragma once' in main file [-Wpragma-once-outside-header]

The remainder of this commit message describes the change made to
address this warning.

This change strips "#pragma once" lines on the ASL content path in
`DoInclude()` in `Trim.py` so the directive is removed before it
reaches the C preprocessor.

  - "#include" directives for non-ASL files are still passed through
    verbatim for the C preprocessor to resolve where the contents of
    those .h files might contain "#pragma once" or traditional guards.
  - Traditional include guards are untouched and continue to behave as
    before where multiple include sites might inline the same content
    in the .i file before reaching the C preprocessor.

The change:

In the case that a file is inlined with a `#pragma once` directive,
the directive is stripped from the inlined content which prevents the
warning.

This is considered acceptable because it only removes the
`#pragma once` directive from the inlined content for these specific
cases. So, the `.i` file might contain multiple inlined copies of the
same header content (like always in this inline case) but without the
`#pragma once` directives. Because actual C content was already not
processed or trimmed out (e.g. `typedef struct`) duplicate content is
not considered to be a problem (`#define` multiple times is not a
problem for the C preprocessor).

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-07-17 21:50:16 +00:00
VarshitPandya
74b8bfd953 MdeModulePkg: Add definition for 64 bit ACPI GAS
Add a macro definition for defining ACPI Generic Address Space for QWORD
memory.

Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
2026-07-17 18:31:43 +00:00
Girish Mahadevan
9b583dfc4b DynamicTablesPkg: Smbios System Information (Type 1)
Generator for Smbios System Information table (Type 1).

Co-authored-by: Dat Mach <dmach@nvidia.com>
Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
2026-07-17 11:12:25 +00:00
Girish Mahadevan
7ac27b187e DynamicTablesPkg: Add System Information CM object and parser
Add EArchCommonObjSystemInfo to ArchCommonNameSpaceObjects.h and a
corresponding parser entry in ConfigurationManagerObjectParser.c.

Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
2026-07-17 11:12:25 +00:00
kowsiks
2fc0e060ef BaseTools/build.py: Use full source file path for dependency generation
During Silent build,NMAKE suppresses the command echo entirely.
As a result, the only output in ProcOut is the
MSVC compiler’s output lines.
Without the command echo, there is no full path in the output to
identify which source file is currently being compiled.
For unique basenames this is not an issue, but for namesake files
(for example, AmdSev.c located in different directories),
it is impossible to determine which file’s includes are being listed.

This change improves dependency generation for MSVC builds by introducing
explicit handling for source files with duplicate basenames
(namesake sources). A new variable current_source_abs is added to
consistently track the resolved absolute path of the active source file
instead of repeatedly recomputing it from SourceFileAbsPathMap.
To correctly resolve namesake files in silent builds
(where compiler commands are not echoed), a namesake_queue is introduced,
which preserves source ordering and sequentially maps basename occurrences
to their corresponding full paths.
Additionally, a cc_cmd_in_output flag is implemented to detect the presence
of compiler command lines in the output stream; when present,
source paths are derived directly from command-line arguments, otherwise
the queue-based resolution is used. This ensures correct mapping of
basenames to absolute paths across the silent builds, fixing incorrect
dependency generation when multiple source files share the same name.

Signed-off-by: Kowsik S <kowsiks@ami.com>
2026-07-17 10:54:11 +00:00
Qihang Gao
9fcb50d56c MdePkg/UefiDevicePathLib: Check allocated buffer before use
The allocated buffer NewStr should be checked if it's NULL to avoid
null pointer dereference.

Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
2026-07-17 09:45:38 +00:00
Qihang Gao
fa461abf8a MdePkg/UefiDevicePathLib: Fix the potential memory leak issue
The function DevPathToTextUsbWWID() allocates NewStr when the input
SerialNumber lacks a null terminator. However, this allocated memory
is never freed after use, resulting in a memory leak.

This patch adds the missing FreePool() for NewStr before the function
returns, ensuring that the allocated buffer is properly freed and
eliminating the potential leak.

Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
2026-07-17 09:45:38 +00:00
Phil Noh
c70637de12 MdeModulePkg/PciBusDxe: Honor SpecificFlag for PMem64 in UpdatePciInfo
When UpdatePciInfo() downgrades a PciBarTypePMem64 BAR to a 32-bit type
via EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL, it unconditionally
assigns PciBarTypePMem32 regardless of SpecificFlag, placing the BAR in
the prefetchable bridge window even when the platform intended the
non-prefetchable window.

The ACPI resource descriptor's SpecificFlag field encodes the intended
prefetchability of the constrained resource, using the bit:
EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE.

Fix this by checking the bit in SpecificFlag to select PciBarTypePMem32 or
PciBarTypeMem32, consistent with DumpPpbPaddingResource() in
PciEnumeratorSupport.c that uses the bit as the sole discriminator
between the two 32-bit BAR types.

Signed-off-by: Phil Noh <Phil.Noh@amd.com>
2026-07-17 09:03:00 +00:00
Tuan Phan
3613891d77 SecurityPkg/RngDxe: Support RISCV64
Add RISCV64 to the list of valid architectures.

Signed-off-by: Tuan Phan <tuan.phan@oss.qualcomm.com>
2026-07-17 05:23:45 +00:00
Tuan Phan
fb42b39a7d SecurityPkg/RngDxe: Replace Intel-specific with arch-neutral comments
The RngDxe driver and its non-AArch64 support files still contained
comments and descriptions referring to Intel Secure Key technology,
RDRAND/RDSEED instructions, and the Intel DRNG implementation guide.

These references are no longer accurate because the driver obtains
random data through the platform-provided RngLib abstraction rather
than relying on Intel-specific CPU features. Update the comments and
descriptions to use architecture-neutral language that better reflects
the current implementation.

Signed-off-by: Tuan Phan <tuan.phan@oss.qualcomm.com>
2026-07-17 05:23:45 +00:00
Joey Vagedes
3fec625408 SecurityPkg: Add Google Test MockSecureBootVariableLib
Add Google Test Mock library header and implementation for
SecureBootVariableLib to allow simple mocking for host based unit tests
that utilize the Google Test framework.

Signed-off-by: Joey Vagedes <joey.vagedes@gmail.com>
2026-07-16 17:50:01 +00:00
Dongyan Qian
3a4556803d DynamicTablesPkg: Enable LoongArch64 table generation
Add LOONGARCH64 support to DynamicTablesPkg by adding it to the existing
common component build list, adding the LoongArch64 DynamicTableManagerDxe
source, and enabling the SMBIOS generators used by current LoongArch
platforms.

Keep DynamicTableFactoryDxe generator registration architecture-specific.
The LoongArch64 factory instance links selected NULL generator libraries so
their constructors register the generators at runtime.

LoongArch64-specific tables can use AcpiRawLib initially and move to
dedicated LoongArch64 generators in follow-up patches.

Signed-off-by: Dongyan Qian <qiandongyan@loongson.cn>
2026-07-16 07:10:30 +00:00
Dongyan Qian
8046280304 DynamicTablesPkg: Move SMBIOS generators to common components
The SMBIOS generators are architecture-neutral standalone components. They
are currently listed only for AARCH64. Move them to the existing common
component section so every supported architecture receives the same package
build coverage.

Keep the DynamicTableFactoryDxe registration architecture-specific.
Its NULL library list determines the generators registered at runtime.

Signed-off-by: Dongyan Qian <qiandongyan@loongson.cn>
2026-07-16 07:10:30 +00:00
Dongyan Qian
f5254b5c23 DynamicTablesPkg/Smbios: Fix X64 build warnings
Moving the standalone SMBIOS generators to the common component section
adds them to the X64 build. VS2022 reports narrowing warnings for native-
width, wide, or enum values converted to fixed-width SMBIOS fields. These
warnings are treated as errors under /WX.

Use UINTN for the Type 7 table-list count and index. Add bounds checks for
the Type 4 processor counts and Type 7 cache level where CM-derived values
could exceed the corresponding SMBIOS fields, and make the remaining
intended conversions explicit in the Type 4, Type 7, Type 16, Type 17,
Type 19, and Type 44 generators.

This rejects out-of-range processor counts and cache levels instead of
silently truncating them, while preserving the existing behavior for valid
configuration data.

Signed-off-by: Dongyan Qian <qiandongyan@loongson.cn>
2026-07-16 07:10:30 +00:00
Dongyan Qian
9e83101fdf DynamicTablesPkg/Smbios: Use EFIAPI for extended callbacks
The SMBIOS_TABLE_GENERATOR_BUILD_TABLEEX and
SMBIOS_TABLE_GENERATOR_FREE_TABLEEX callback types do not specify EFIAPI.
The Type 37 implementations specify it, while the other extended callback
implementations follow the omission in the shared types.

For X64 GCC builds, BaseTools/Conf/tools_def.template adds
-DEFIAPI=__attribute__((ms_abi)). Therefore, callbacks marked with EFIAPI
use the Microsoft x64 ABI, while unannotated callback types use the
compiler default ABI. If the two sides differ, the caller and callee use
different argument registers, and GCC rejects the function pointer
assignment.

This mismatch remained hidden while the standalone Type 37 generator was
built only for AARCH64. Moving the SMBIOS generators to the common
component section adds X64 build coverage and exposes it.

Add EFIAPI to the extended callback types and all matching implementations.
This follows the ACPI generator callback convention and provides the ABI
prerequisite for expanding the SMBIOS standalone build coverage.

Signed-off-by: Dongyan Qian <qiandongyan@loongson.cn>
2026-07-16 07:10:30 +00:00
Alexander Gryanko
1dc6b5e3dd SecurityPkg: added image verification tests for signed images
Previous changes introduced tests for unsigned
images verified by hash entries in DB/DBX. This commit adds
tests covering verification of signed images, including
certificate chain validation as well as cases where image
hashes are checked against entries in DB/DBX.

Signed-off-by: Alexander Gryanko <xpahos@gmail.com>
2026-07-16 02:33:17 +00:00
Alexander Gryanko
7668d8854f SecurityPkg: added image verification test using DB hash
The part of DxeImageVerificationHandler responsible for
verifying the image location source has already been
implemented. This commit implements tests for verifying
images in cases where the image has no signature, but
there is a hash record for this file in DB/DBX.

Signed-off-by: Alexander Gryanko <xpahos@gmail.com>
2026-07-16 02:33:17 +00:00
Alexander Gryanko
ef2996c667 MdePkg: added mock for InstallConfigurationTable
InstallConfigurationTable is used in the AddImageExeInfo
call and is necessary for outputting information about
the binary file in case of an error. Mock has been added
for the DxeImageVerificationHandler subroutine.

Signed-off-by: Alexander Gryanko <xpahos@gmail.com>
2026-07-16 02:33:17 +00:00
Michael D Kinney
ae023dbe99 BaseTools/Tests: Update TC6 for backward-compatible rebase behavior
Update the test decision matrix and TC6 expected result to reflect
the backward-compatible ForceRebase logic: when ForceRebase=TRUE and
no files have the ,XIP suffix (XipFileCount==0), all files are
rebased using the legacy behavior rather than skipping all files.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-07-15 21:37:05 +00:00
Michael D Kinney
0347d3b711 BaseTools/GenFv: Preserve legacy rebase behavior when Xip is unused
Add XipFileCount to FV_INFO to track how many files have the ,XIP
suffix. Update FfsRebase() to only apply selective XIP rebase when
XipFileCount > 0. When no files have the ,XIP suffix (XipFileCount
== 0), preserve the legacy ForceRebase=TRUE behavior of rebasing all
files. This maintains backward compatibility for existing platforms
that use FvForceRebase=TRUE without any Xip rules.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-07-15 21:37:05 +00:00
Kun Qin
fe89a63da4 OvmfPkg: MmControlPei: Fix QEMU does not send MMI to all cores
Because there was no negotiation, the SMM controller from QEMU will not
broadcast the SMI to all cores, causing only the BSP getting interrupted
into MMI.

This change fixed the issue by invoking the negotiation routine and
program the register to enable broadcasting.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2026-07-15 20:29:12 +00:00
abuthahirm
7442655403 NetworkPkg/UefiPxeBcDxe: Fix CopyMem destination in PxeBcDhcp6CallBack
When caching the DHCPv6 discover packet to Mode->DhcpDiscover in
PxeBcDhcp6CallBack, the destination was incorrectly specified as
Mode->DhcpDiscover.Dhcpv4 (the DHCPv4 union member). Change it to
Mode->DhcpDiscover to correctly reference the union and avoid
type confusion when copying a DHCPv6 packet.

Signed-off-by: Abuthahir M <abuthahirm@ami.com>
2026-07-14 18:10:05 +00:00
abuthahirm
a589f6fe03 NetworkPkg/Ip6Dxe: Add NULL check for InterfaceId before dereference
In Ip6ProcessRouterAdvertise, IpSb->InterfaceId is dereferenced in
CopyMem to form a stateless address. Add a guard to ensure
IpSb->InterfaceId is not NULL before entering the block, preventing
a potential NULL pointer dereference.

Signed-off-by: Abuthahir M <abuthahirm@ami.com>
2026-07-14 18:10:05 +00:00
abuthahirm
d21677e0bc NetworkPkg/Ip6Dxe: Move neighbor table cleanup before MNP teardown
In Ip6CleanService, Ip6FreeNeighborEntry may attempt to send packets via
MNP. Defensively move the neighbor table cleanup to occur before MNP
teardown so that the MNP child handle and its resources remain valid
during neighbor entry cleanup.

Signed-off-by: Abuthahir M <abuthahirm@ami.com>
2026-07-14 18:10:05 +00:00
abuthahirm
bc15a87b74 NetworkPkg/Dhcp6Dxe: Defensively check for NULL Config in Dhcp6UpdateIaInfo
Replace the ASSERT (Instance->Config != NULL) in Dhcp6UpdateIaInfo with
an explicit NULL check that returns EFI_DEVICE_ERROR. Also add a
complementary guard in Dhcp6GenerateIaCb alongside the existing check
for Instance->IaCb.Ia. These are defensive changes to prevent potential
NULL pointer dereferences.

Signed-off-by: Abuthahir M <abuthahirm@ami.com>
2026-07-14 18:10:05 +00:00
Michael G.A. Holland
0f07c187d0 CryptoPkg/BaseCryptLib: Add ML-DSA Support
Created ML-DSA API functions to configure public and private keys for
ML-DSA algorithm.  This will allow users to sign and verify with ML-DSA.
Unit tests were add to confirm operation of the API.

Signed-off-by: Michael G.A. Holland <michael.holland@intel.com>
2026-07-14 03:26:52 +00:00
Mingjie Shen
96c9f8f372 UefiPayloadPkg: Fix incorrect EfiPciWidth* enum literals
In arguments of EFI_PCI_IO_PROTOCOL member functions, replace the
EfiPciWidth* enum literals from
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH with the matching
EfiPciIoWidth* values from EFI_PCI_IO_PROTOCOL_WIDTH.

This keeps the call sites aligned with the protocol they actually use.
The old values were copied from EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL code,
so they obscured the intent of the calls and relied on an explicit
cast.

This mimics commit 8ba64a9a94 ("UefiPayloadPkg: Fix build failure with
CLANGPDB").

Generated by coccinelle script.

``` smpl
@initialize:python@
@@

def to_pci_io_width(name):
    return name.replace("EfiPciWidth", "EfiPciIoWidth", 1)

@normalize@
typedef EFI_PCI_IO_PROTOCOL;
typedef EDKII_PCI_DEVICE_PPI;
type T =~ "^EFI_PCI_IO_PROTOCOL_WIDTH$";
EFI_PCI_IO_PROTOCOL *x;
EDKII_PCI_DEVICE_PPI *y;
identifier bad =~ "EfiPciWidth(Uint|FifoUint|FillUint)(8|16|32|64)";
identifier top_op =~ "^(PollMem|PollIo|CopyMem)$";
identifier space =~ "^(Mem|Io|Pci)$";
identifier rw =~ "^(Read|Write)$";
fresh identifier good = script:python(bad) { to_pci_io_width(bad) };
expression first;
expression list rest;
@@
(
  x->top_op
|
  y->PciIo.top_op
|
  x->space.rw
|
  y->PciIo.space.rw
) (
  first,
- (T)bad
+ good
  ,
  rest
  )
```

Verified with:
- `build -p UefiPayloadPkg/UefiPayloadPkg.dsc -a IA32 -a X64 -b DEBUG -t GCC -D BOOTLOADER=SBL`
- temporary IA32 PEIM harness that compiled X86_BuildFdtLib.c

Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2026-07-14 00:06:22 +00:00
Mingjie Shen
049dc848c4 MdeModulePkg: Fix incorrect EfiPciWidth* enum literals
In arguments of EFI_PCI_IO_PROTOCOL member functions, replace the
EfiPciWidth* enum literals from
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH with the matching
EfiPciIoWidth* values from EFI_PCI_IO_PROTOCOL_WIDTH.

This keeps the call sites aligned with the protocol they actually use.
The old values were copied from EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL code,
so they obscured the intent of the calls and relied on an explicit
cast.

This mimics commit 8ba64a9a94 ("UefiPayloadPkg: Fix build failure with
CLANGPDB").

Generated by coccinelle script.

``` smpl
@initialize:python@
@@

def to_pci_io_width(name):
    return name.replace("EfiPciWidth", "EfiPciIoWidth", 1)

@normalize@
typedef EFI_PCI_IO_PROTOCOL;
typedef EDKII_PCI_DEVICE_PPI;
type T =~ "^EFI_PCI_IO_PROTOCOL_WIDTH$";
EFI_PCI_IO_PROTOCOL *x;
EDKII_PCI_DEVICE_PPI *y;
identifier bad =~ "EfiPciWidth(Uint|FifoUint|FillUint)(8|16|32|64)";
identifier top_op =~ "^(PollMem|PollIo|CopyMem)$";
identifier space =~ "^(Mem|Io|Pci)$";
identifier rw =~ "^(Read|Write)$";
fresh identifier good = script:python(bad) { to_pci_io_width(bad) };
expression first;
expression list rest;
@@
(
  x->top_op
|
  y->PciIo.top_op
|
  x->space.rw
|
  y->PciIo.space.rw
) (
  first,
- (T)bad
+ good
  ,
  rest
  )
```

Verified with:
- `build -p MdeModulePkg/MdeModulePkg.dsc -m MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf -a IA32 -b DEBUG -t GCC`
- `build -p MdeModulePkg/MdeModulePkg.dsc -m MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf -a X64 -b DEBUG -t GCC`

Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2026-07-14 00:06:22 +00:00