Skip to content

[CHERRYPICK] BaseTools: Prevent Subsection PCDs from polluting global expressions#1654

Merged
makubacki merged 1 commit intomicrosoft:release/202511from
PaddyDengAmi:user/paddydeng/SubsectionPcdPollute
Mar 24, 2026
Merged

[CHERRYPICK] BaseTools: Prevent Subsection PCDs from polluting global expressions#1654
makubacki merged 1 commit intomicrosoft:release/202511from
PaddyDengAmi:user/paddydeng/SubsectionPcdPollute

Conversation

@PaddyDengAmi
Copy link
Copy Markdown
Contributor

@PaddyDengAmi PaddyDengAmi commented Feb 25, 2026

Description

The PCD value defined in module subsections can be added to global PCD database. Therefore the unsolved expressions, even belongs to the global scope, can incorrectly refer to the value from module subsection.

This only happens when the referred PCD has no value assignment in the platform dsc file. Which also should raise an error.

This PR cherry-picks tianocore/edk2#12009


  • Impacts functionality?
  • Impacts security?
  • Breaking change?
  • Includes tests?
  • Includes documentation?

How This Was Tested

Use test code from PaddyDengAmi/edk2@8673d40
Run test_build.bat after setting up edk2 build environment.

Check the produced build_report.log, the value of PcdIpmiKcsIoBaseAddress in both HelloWorld.inf instances are polluted by gEfiMdePkgTokenSpaceGuid.PcdIpmiSsifSmbusSlaveAddr|2 in the subsection.

Compares to build_report_gPcd.log, which produced by TestPkg_gPcd.dsc that has a proper global value of PcdIpmiSsifSmbusSlaveAddr, the subsection override of PcdIpmiSsifSmbusSlaveAddr|2 only affects this PCD itself.
All value evaluated by gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsIoBaseAddress|gEfiMdePkgTokenSpaceGuid.PcdIpmiSsifSmbusSlaveAddr are not affected and correctly refer to PcdIpmiSsifSmbusSlaveAddr|1 in global scope.

After applying the change of this PR, the build for TestPkg.dsc will fail due to gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsIoBaseAddress|gEfiMdePkgTokenSpaceGuid.PcdIpmiSsifSmbusSlaveAddr is referring PcdIpmiSsifSmbusSlaveAddr which is not given a default value in this dsc and raising an error:

D:\work\edk2\TestPkg.dsc(36): error 3000: The PCD should be FeatureFlag type or FixedAtBuild type: [gEfiMdePkgTokenSpaceGuid.PcdIpmiSsifSmbusSlaveAddr].
        PCD [gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsIoBaseAddress] Value "gEfiMdePkgTokenSpaceGuid.PcdIpmiSsifSmbusSlaveAddr"

Integration Instructions

N/A

Copy link
Copy Markdown
Member

@makubacki makubacki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please amend the commit message with the following as the last line in the commit message:

(cherry picked from commit c2915d24a1832138b5f680b31612bf6198adfb5f)

@PaddyDengAmi PaddyDengAmi force-pushed the user/paddydeng/SubsectionPcdPollute branch from 9188f4a to 8f2549f Compare March 10, 2026 02:18
@PaddyDengAmi
Copy link
Copy Markdown
Contributor Author

@makubacki Updated. Thanks for reminder!

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (release/202511@7e09c47). Learn more about missing BASE report.

Additional details and impacted files
@@                Coverage Diff                @@
##             release/202511    #1654   +/-   ##
=================================================
  Coverage                  ?    2.21%           
=================================================
  Files                     ?     1633           
  Lines                     ?   419626           
  Branches                  ?     4949           
=================================================
  Hits                      ?     9308           
  Misses                    ?   410243           
  Partials                  ?       75           
Flag Coverage Δ
FmpDevicePkg 9.53% <ø> (?)
MdeModulePkg 1.58% <ø> (?)
MdePkg 5.44% <ø> (?)
NetworkPkg 0.55% <ø> (?)
PolicyServicePkg 30.42% <ø> (?)
SecurityPkg 1.61% <ø> (?)
UefiCpuPkg 4.79% <ø> (?)
UnitTestFrameworkPkg 11.70% <ø> (?)

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

☔ View full report in Codecov by Sentry.
📢 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.

@PaddyDengAmi
Copy link
Copy Markdown
Contributor Author

Hi @makubacki ,

If no further question, could you help to merge this PR? Thanks.

The PCD value defined in module subsections can be added to global PCD
database. Therefore the unsolved expressions, even belongs to the global
scope, can incorrectly refer to the value from module subsection.

This only happens when the referred PCD has no value assignment in the
platform dsc file. Which also should raise an error.

Signed-off-by: Paddy Deng <paddydeng@ami.com>
(cherry picked from commit c2915d2)
@makubacki makubacki force-pushed the user/paddydeng/SubsectionPcdPollute branch from 8f2549f to 2858f6d Compare March 24, 2026 01:24
@makubacki makubacki enabled auto-merge (rebase) March 24, 2026 01:24
@makubacki makubacki merged commit e0ab04d into microsoft:release/202511 Mar 24, 2026
56 checks passed
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