Branch: refs/heads/master
Home: https://github.com/tianocore/edk2
Commit: c422b3b97b69de7a0e5a79632d7b69cfc5c462b4
https://github.com/tianocore/edk2/commit/c422b3b97b69de7a0e5a79632d7b69cfc5c462b4
Author: Changyuan Lyu <[email protected]>
Date: 2026-03-02 (Mon, 02 Mar 2026)
Changed paths:
M UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
Log Message:
-----------
UefiCpuPkg/MpInitLibUp: Fix #UD exception due to NULL pointer deref
In MpInitLibUp, MpInitLibGetNumberOfProcessors() unconditionally
dereferences the NumberOfProcessors and NumberOfEnabledProcessors
parameters. However, the API specification marks both as OPTIONAL.
When callers (like InitializeExceptionStackSwitchHandlers in
UefiCpuPkg/CpuMpPei/CpuMpPei.c) pass NULL for NumberOfEnabledProcessors,
GCC's Link-Time Optimization (LTO) detects an unconditional NULL pointer
dereference. Since this is Undefined Behavior, GCC emits a 'ud2'
(Invalid Opcode) instruction at the dereference site. This leads to an
unexpected #UD exception during the boot process of uniprocessor guests
like TDX VMs.
This patch fixes the issue by adding appropriate NULL checks before
dereferencing the pointers. It also returns EFI_INVALID_PARAMETER if
both arguments are NULL, ensuring compliance with the MpInitLib
specification.
Signed-off-by: Changyuan Lyu <[email protected]>
To unsubscribe from these emails, change your notification settings at
https://github.com/tianocore/edk2/settings/notifications
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits