Skip to content

[CHERRY-PICK] MdeModulePkg: Improved error handling in RuntimeDxe Variable drivers [Rebase & FF] - #1898

Draft
PaddyDeng-v wants to merge 1 commit into
microsoft:release/202608from
PaddyDeng-v:paddydeng-v-cp-edk2-harden-variable-smm-2608
Draft

[CHERRY-PICK] MdeModulePkg: Improved error handling in RuntimeDxe Variable drivers [Rebase & FF]#1898
PaddyDeng-v wants to merge 1 commit into
microsoft:release/202608from
PaddyDeng-v:paddydeng-v-cp-edk2-harden-variable-smm-2608

Conversation

@PaddyDeng-v

Copy link
Copy Markdown
Contributor

Description

Cherry-pick of tianocore/edk2 PR #12670 (commit 8bf75267f9311a8a66a3864ee71426c70bb288bb).

This PR improves error handling in the Variable SMM/DXE RuntimeDxe drivers by replacing
ASSERT_EFI_ERROR calls with proper error-returning handling. This ensures platforms with
ASSERT_DEADLOOP_ENABLED disabled handle initialization errors gracefully instead of
silently continuing.

Changes

  • Replace ASSERT_EFI_ERROR with if (EFI_ERROR(...)) + DEBUG + goto ErrorExit pattern
  • Add comprehensive ErrorExit cleanup paths in VariableServiceInitialize() and MmVariableServiceInitialize()
  • Remove inline cleanup from VariableCommonInitialize() error paths (callers handle cleanup)
  • Move gEfiVariableArchProtocolGuid installation to end of VariableServiceInitialize()
  • Add VariableClearNotifySmmReady() function for SMM notification cleanup

Conflict Resolution

  • VariableDxe.c: Preserved mu_basecore's InitializeVariablePolicyLocking call (MU_CHANGE)
    while wrapping it with proper error handling instead of ASSERT_EFI_ERROR.

How This Was Tested

Cherry-picked and conflict-resolved from upstream edk2 where it passed CI.

Integration Checklist

  • Impacts functionality?
  • Impacts security? (improved error handling)
  • Breaking change?
  • Includes tests?
  • Includes documentation?

Replace ASSERT_EFI_ERROR with proper error handling that returns
failure status codes. This ensures platforms with
ASSERT_DEADLOOP_ENABLED disabled handle errors gracefully.

(cherry picked from commit 8bf75267f9311a8a66a3864ee71426c70bb288bb)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@PaddyDeng-v
PaddyDeng-v marked this pull request as draft August 31, 2026 10:44
@apop5

Copy link
Copy Markdown
Collaborator

PaddyDeng-v

Please amend the commit to contain [Cherry-Pick] in the commit message title.

@makubacki

Copy link
Copy Markdown
Member

PaddyDeng-v

Please amend the commit to contain [Cherry-Pick] in the commit message title.

Also, same additional request mentioned in #1899 (review).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants