Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHERRY-PICK] Cherry-pick Changes/Fixes from 202311 to 202302 #827

Merged

Conversation

…emory (microsoft#822)

## Description

The Memory Attributes Table is generated by fetching the EFI memory map
and splitting entries which contain loaded images so DATA and CODE
sections have separate descriptors. The splitting is done via a call to
SplitTable() which
marks image DATA sections with the EFI_MEMORY_XP attribute and CODE
sections with the EFI_MEMORY_RO attribute when
splitting. After this process, there may still be EfiRuntimeServicesCode
regions which did not have their attributes set because they are not
part of loaded images.

This patch updates the MAT EnforceMemoryMapAttribute logic to set the
access attributes of runtime memory regions which are not part of loaded
images (have not had their access attributes set). The attributes of the
code regions will be read-only and no-execute because the UEFI spec
dictates that runtime code regions should only contain loaded EFI
modules.

Refs:
1.
https://edk2.groups.io/g/devel/topic/patch_v1_mdemodulepkg/105570114?p=,,,20,0,0,0::recentpostdate/sticky,,,20,2,0,105570114
2.
https://edk2.groups.io/g/devel/topic/mdemodulepkg_fix_mat/105477564?p=,,,20,0,0,0::recentpostdate/sticky,,,20,2,0,105477564

- [x] Impacts functionality?
- **Functionality** - Does the change ultimately impact how firmware
functions?
- Examples: Add a new library, publish a new PPI, update an algorithm,
...
- [x] Impacts security?
- **Security** - Does the change have a direct security impact on an
application,
    flow, or firmware?
  - Examples: Crypto algorithm change, buffer overflow fix, parameter
    validation improvement, ...
- [x] Breaking change?
- **Breaking change** - Will anyone consuming this change experience a
break
    in build or boot behavior?
- Examples: Add a new library class, move a module to a different repo,
call
    a function in a new library class in a pre-existing module, ...
- [ ] Includes tests?
  - **Tests** - Does the change include any explicit test code?
  - Examples: Unit tests, integration tests, robot tests, ...
- [ ] Includes documentation?
- **Documentation** - Does the change contain explicit documentation
additions
    outside direct code modifications (and comments)?
- Examples: Update readme file, add feature readme file, link to
documentation
    on an a separate Web page, ...

## How This Was Tested

Tested by Intel EDK2 consumers and on Q35

## Integration Instructions

Project Mu consumers which allocate EfiRuntimeServicesCode regions
outside of the PE loader may experience a break. If runtime executable
code is necessary, this should be done via a loaded EFI module and not a
random allocated buffer. If the EfiRuntimeServicesCode buffer only needs
to be writable, then a buffer of type EfiRuntimeServicesData should be
used instead.
## Description

If only a single module was being built instead of a platform DSC, the
build scripts would not generate the random stack cookie values. On
clean builds, this causes an error to be reported during the autogen
process.

This PR updates build.py so the code path taken on module builds will
generate the random stack cookie values.

- [x] Impacts functionality?
- **Functionality** - Does the change ultimately impact how firmware
functions?
- Examples: Add a new library, publish a new PPI, update an algorithm,
...
- [ ] Impacts security?
- **Security** - Does the change have a direct security impact on an
application,
    flow, or firmware?
  - Examples: Crypto algorithm change, buffer overflow fix, parameter
    validation improvement, ...
- [ ] Breaking change?
- **Breaking change** - Will anyone consuming this change experience a
break
    in build or boot behavior?
- Examples: Add a new library class, move a module to a different repo,
call
    a function in a new library class in a pre-existing module, ...
- [ ] Includes tests?
  - **Tests** - Does the change include any explicit test code?
  - Examples: Unit tests, integration tests, robot tests, ...
- [ ] Includes documentation?
- **Documentation** - Does the change contain explicit documentation
additions
    outside direct code modifications (and comments)?
- Examples: Update readme file, add feature readme file, link to
documentation
    on an a separate Web page, ...

## How This Was Tested

Tested by specifying a build module on Q35.

## Integration Instructions

N/A
@TaylorBeebe TaylorBeebe changed the base branch from release/202311 to release/202302 April 24, 2024 20:34
@github-actions github-actions bot added the language:python Pull requests that update Python code label Apr 24, 2024
@TaylorBeebe TaylorBeebe enabled auto-merge (rebase) April 24, 2024 20:47
@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2024

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 1.01%. Comparing base (337190c) to head (ae50a08).

Files Patch % Lines
MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c 0.00% 10 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##           release/202302     #827      +/-   ##
==================================================
- Coverage            1.01%    1.01%   -0.01%     
==================================================
  Files                1278     1278              
  Lines              325527   325529       +2     
  Branches             4779     4780       +1     
==================================================
  Hits                 3316     3316              
- Misses             322172   322174       +2     
  Partials               39       39              
Flag Coverage Δ
MdeModulePkg 0.72% <0.00%> (-0.01%) ⬇️
MdePkg 3.61% <ø> (ø)
NetworkPkg 0.00% <ø> (ø)
PolicyServicePkg 30.20% <ø> (ø)

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.

## Description

This PR adds the required .asm files for compiling StackCheckLib with
MSVC for an ARM or AARCH64 target. This PR also updates the stack check
failure instruction for AARCH64 to SVC instead of SMC. Ref:
https://developer.arm.com/documentation/dui0489/i/arm-and-thumb-instructions/svc?lang=en
 
- [x] Impacts functionality?
- **Functionality** - Does the change ultimately impact how firmware
functions?
- Examples: Add a new library, publish a new PPI, update an algorithm,
...
- [x] Impacts security?
- **Security** - Does the change have a direct security impact on an
application,
    flow, or firmware?
  - Examples: Crypto algorithm change, buffer overflow fix, parameter
    validation improvement, ...
- [ ] Breaking change?
- **Breaking change** - Will anyone consuming this change experience a
break
    in build or boot behavior?
- Examples: Add a new library class, move a module to a different repo,
call
    a function in a new library class in a pre-existing module, ...
- [ ] Includes tests?
  - **Tests** - Does the change include any explicit test code?
  - Examples: Unit tests, integration tests, robot tests, ...
- [ ] Includes documentation?
- **Documentation** - Does the change contain explicit documentation
additions
    outside direct code modifications (and comments)?
- Examples: Update readme file, add feature readme file, link to
documentation
    on an a separate Web page, ...

## How This Was Tested

Tested by building mu_crypto_release with VS2022.

## Integration Instructions

N/A
@TaylorBeebe TaylorBeebe changed the title [CHERRY-PICK] Pull In Fixes from 202311 [CHERRY-PICK] Cherry-pick Changes/Fixes from 202311 to 202302 Apr 24, 2024
@TaylorBeebe TaylorBeebe merged commit ea4b8b5 into microsoft:release/202302 Apr 24, 2024
42 checks passed
@TaylorBeebe TaylorBeebe deleted the cherry_pick_2311_fixes branch April 24, 2024 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language:python Pull requests that update Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants