Skip to content

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

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

[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?

@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).

…iable drivers

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

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Paddy Deng (AMI US Holdings Inc) <v-dengpaddy@microsoft.com>
(cherry picked from commit 8bf75267f9311a8a66a3864ee71426c70bb288bb)
@PaddyDeng-v
PaddyDeng-v force-pushed the paddydeng-v-cp-edk2-harden-variable-smm-2608 branch from bd7a9f0 to 2c1425a Compare September 3, 2026 06:00
@PaddyDeng-v

Copy link
Copy Markdown
Contributor Author

Hi Michael Kubacki (@makubacki) and Aaron (@apop5) ,

Thanks for reviewing this draft. I created this first because the original edk2 PR was merged after stable tag 202608. But it seems MU_BASECORE's 202608 branch is not ready for PR.
Should I keep this draft and wait for 202608 is ready, or drop this one and we will include it from 202511?

@makubacki

Copy link
Copy Markdown
Member

Hi Michael Kubacki (Michael Kubacki (@makubacki)) and Aaron (Aaron (@apop5)) ,

Thanks for reviewing this draft. I created this first because the original edk2 PR was merged after stable tag 202608. But it seems MU_BASECORE's 202608 branch is not ready for PR. Should I keep this draft and wait for 202608 is ready, or drop this one and we will include it from 202511?

PaddyDeng-v, this would naturally be cherry-picked onto the 202608 branch for the reason you mentioned. Unless there is a strong reason it's needed in 2511, I suggest sticking to that.

@PaddyDeng-v

Copy link
Copy Markdown
Contributor Author

Closing this PR since the change will cherry picked as part of 202611

@PaddyDeng-v PaddyDeng-v closed this Sep 4, 2026
@makubacki

Michael Kubacki (makubacki) commented Sep 4, 2026

Copy link
Copy Markdown
Member

PaddyDeng-v, sorry if there was a misunderstanding, but I believe you should leave this PR open because you want the change in 202608, right? What I meant in "naturally be cherry-picked onto the 202608 branch" in my previous message is that it would be cherry-picked into 2608 (as you've done here) and not 2511 (as you did in the other PR) since 2608 is the upcoming release branch.

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