mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
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 <changyuanl@google.com> |
||
|---|---|---|
| .. | ||
| MpInitLibUp.c | ||
| MpInitLibUp.inf | ||
| MpInitLibUp.uni | ||