Skip to content

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

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

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

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

@PaddyDeng-v PaddyDeng-v reopened this Oct 1, 2026
@mu-automation

mu-automation Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

⌛ QEMU Validation Pending

QEMU validation is pending on successful CI completion.

Note: Any previous results are available in this comment's edit history.

This comment was automatically generated by the Mu QEMU PR Validation workflow.

…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 2c1425a to 4453115 Compare October 1, 2026 06:51
@PaddyDeng-v

Copy link
Copy Markdown
Contributor Author

Re-open this PR since release/202608 is ready to take PR

@PaddyDeng-v
PaddyDeng-v marked this pull request as ready for review October 1, 2026 07:06
@codecov-commenter

Codecov Comments Bot (codecov-commenter) commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/202608@587366f). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...versal/Variable/RuntimeDxe/VariableTraditionalMm.c 0.00% 4 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##             release/202608    #1898   +/-   ##
=================================================
  Coverage                  ?    1.00%           
=================================================
  Files                     ?      633           
  Lines                     ?   228233           
  Branches                  ?      648           
=================================================
  Hits                      ?     2290           
  Misses                    ?   225911           
  Partials                  ?       32           
Flag Coverage Δ
MdeModulePkg 1.00% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

4 participants