v9.1.1
What's Changed
-
[REBASE \& FF] Apply Some Paging Updates @os-d (#309)
Change Details
## Description
This PR consists of 4 commits:
spin_locked_gcd: Mapped reserved regions
Map reserved regions similar to MMIO for now so they are mapped as R/W in the DXE page table. Some regions are accessed during DXE and need to be mapped to prevent a page fault.
spin_locked_gcd: Only Query First Page for Attributes
When deciding whether to map or remap a region, the GCD today queries the entire region to decide which operation to do and if remapping, which caching attributes to do. However, this is a wasted operation, because if the region is unmapped, we attempt to map and if this fails, it will bubble up a failure to us which is the same as we would do when failing the query. If it is a remap operation, the paging code does a query internally to ensure it can remap and then does the remap if the range is consistent. In the case of failure, remap will fail the same as if our original query failed and if it succeeds, then the range is consistent and we only need the cache attributes from the first entry in the range to persist.
This patch updates to only query the first page and update the logging in case of a paging error. This saves an unnecessary page table walk.
spin_locked_gcd: Unmap Memory on remove_memory_space
When a memory space is removed from the GCD, we need to unmap the pages in the page table, because DXE Core expects we will not be using this any longer and we cannot rely on a free operation to have done that, because other memory types such as MMIO and reserved which are not allocated/freed can be removed here.
Platforms may also then try to add the memory space back later and map it, which can fail if the region is already mapped.
This patch unmaps memory spaces when remove_memory_space is called unconditionally, we expect it to fail if the memory region is already mapped, but this is handled gracefully and execution continues.
spin_locked_gcd: Set Paging Attributes Per GCD Descriptor
When setting memory attributes, the GCD sets all GCD attributes and then moves to do the paging attributes as a whole. This works when the entire GCD operation succeeded, because that has guaranteed the GCD has a consistent view of that range of memory, however, in the case of failure this can create a torn state where the GCD is partially updated and the page table is not updated.
To avoid this torn state, the page table is updated after every GCD descriptor update.
- Impacts functionality?
- Impacts security?
- Breaking change?
- Includes tests?
- Includes documentation?
How This Was Tested
Tested on Q35, SBSA, and an Intel physical system.
Integration Instructions
N/A.
Full Changelog: v9.1.0...v9.1.1