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

Check if the non-MMRAM buffer is valid in API MmIsBufferOutsideMmValid of StandaloneMmMemLib. #6225

Merged
merged 6 commits into from
Nov 5, 2024

Conversation

td36
Copy link
Contributor

@td36 td36 commented Sep 20, 2024

Description

This PR include code to

  1. Check if the non-MMRAM buffer is inside valid non-mmram range in API MmIsBufferOutsideMmValid of StandaloneMmMemLib.
  2. Remove unnecessary check in API MmIsBufferOutsideMmValid of StandaloneMmMemLib.

Previously, the API MmIsBufferOutsideMmValid only checks if the input buffer is overlapped with MMRAM range. Currently, in the new standalone MM infrastructure, we limit the non-MMRAM access to the ranges reported by the resource HOB. To meet the new design, in this API, we cache all the memory ranges reported by the resource HOB and check if the input buffer is inside valid non-MMRAM ranges reported by the resource HOB.

How This Was Tested

Tested in Intel internal server platform with the X86 standalone MM env and successfully booted into shell

@td36 td36 marked this pull request as draft September 20, 2024 09:00
@td36 td36 force-pushed the dev/duntan/memlib branch 3 times, most recently from 08671b5 to 8c77569 Compare September 23, 2024 07:09
@td36 td36 changed the title Dev/duntan/memlib Check if the non-MMRAM buffer is valid in API MmIsBufferOutsideMmValid of StandaloneMmMemLib. Sep 23, 2024
@td36 td36 marked this pull request as ready for review September 25, 2024 08:15
@td36 td36 force-pushed the dev/duntan/memlib branch 2 times, most recently from 80622ed to 872d5d0 Compare September 27, 2024 06:48
@td36 td36 force-pushed the dev/duntan/memlib branch 4 times, most recently from b709130 to ad1eaf7 Compare October 24, 2024 01:55
@jiaxinwu
Copy link
Member

others good to me.

@td36 td36 force-pushed the dev/duntan/memlib branch 3 times, most recently from d57afa5 to e6f1a2f Compare November 4, 2024 09:39
@td36 td36 force-pushed the dev/duntan/memlib branch 2 times, most recently from 4313335 to 04a454f Compare November 5, 2024 07:39
Remove unneeded check MmIsBufferOutsideMmValid() when
StandaloneMmCore checks if the BS data memory described
by a memory allocation HOB needs to be migrated to Mmram.

Currently, the API MmIsBufferOutsideMmValid() return TRUE
when input memory range belongs to non-Mmram memory. Now
the API will be changed in following 5 commits to return
TRUE when a memory range belongs to non-Mmram memroy and
the memory is inside a range described by resource HOB.
This may cause PF when some SMI handler access the memory
from a memory allocation HOB that is not migrated.

To solve this issue, we can directly remove the check
MmIsBufferOutsideMmValid() and always migrate the BS data
memory described by a memory allocation HOB to Mmram.

Signed-off-by: Dun Tan <[email protected]>
Add a internal header file for StandaloneMmMemLib.
Move some common reference and declaration into
StandaloneMmMemLibInternal.h.

Signed-off-by: Dun Tan <[email protected]>
Check if the non-MMRAM buffer is inside valid non-mmram
range in API MmIsBufferOutsideMmValid of StandaloneMmMemLib.

Previously, the API only checks if the input buffer is
overlapped with MMRAM range. Currently, in the new standalone
MM infrastructure, we limit the non-MMRAM access to the ranges
reported by the resource HOB. To meet the new design, in this
API, we cache all the memory ranges reported by the resource
HOB and check if the input buffer is inside valid non-MMRAM
ranges reported by the resource HOB.

Signed-off-by: Dun Tan <[email protected]>
Separate a function called InitializeMmHobList() to gather
all the operations related to initializing HOB. It doesn't
change any code logic.

Signed-off-by: Dun Tan <[email protected]>
Check if the all the resource HOB in the input HOB list of
MmCore entry only covers non-Mmram ranges. The Resource HOB
is to describe the accessible non-Mmram range. All Resource
HOB should not overlap with any Mmram range.

Signed-off-by: Dun Tan <[email protected]>
Remove unnecessary check in API MmIsBufferOutsideMmValid of
StandaloneMmMemLib.

The API is used to check if a input buffer is outside MMRAM and
inside a valid non-MMRAM range. Previously, the API only checks
if the input buffer is
 overlapped with MMRAM range. In the last
commit, we add logic to check if the input buffer is inside valid
non-MMRAM 
ranges reported by the resource HOB. Since the resource
HOB only covers valid non-MMRAM ranges, we doesn't need to check
if the input buffer is inside the MMRAM anymore.

Signed-off-by: Dun Tan <[email protected]>
@niruiyu niruiyu added the push Auto push patch series in PR if all checks pass label Nov 5, 2024
@mergify mergify bot merged commit 836942f into tianocore:master Nov 5, 2024
126 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
push Auto push patch series in PR if all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants