Skip to content

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

Open
PaddyDengAmi wants to merge 1 commit intomicrosoft:release/202511from
PaddyDengAmi:user/paddydeng/SubsectionPcdPollute
Open

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

Conversation

@PaddyDengAmi
Copy link
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

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>
Copy link
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)

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.

2 participants