Skip to content

Commit 702ec3d

Browse files
TaylorBeebeos-d
authored andcommitted
Implement Memory Attribute Protocol Installation Policy Option (#200)
## Description Linux shim currently incorrectly uses the UEFI memory attribute protocol causing a fault. The broken shim does not have the NXCOMPAT flag, so compatibility mode can be used to uninstall the protocol when it is loaded. For flexibility, this patch implements the policy configuration option to allow ARM platforms to choose not to install the protocol. - [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 on SBSA by running the DxePagingAuditTestApp with the protocol policy set to TRUE and FALSE ## Integration Instructions N/A
1 parent f0ce81f commit 702ec3d

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

ArmPkg/Drivers/CpuDxe/CpuDxe.c

+18-2
Original file line numberDiff line numberDiff line change
@@ -331,14 +331,30 @@ CpuDxeInitialize (
331331
RemapUnusedMemoryNx ();
332332
}
333333

334+
// MU_CHANGE [START]: Only install Memory Attribute Protocol if policy is enabled
334335
Status = gBS->InstallMultipleProtocolInterfaces (
335336
&mCpuHandle,
336337
&gEfiCpuArchProtocolGuid,
337338
&mCpu,
338-
&gEfiMemoryAttributeProtocolGuid,
339-
&mMemoryAttribute,
339+
// &gEfiMemoryAttributeProtocolGuid,
340+
// &mMemoryAttribute,
340341
NULL
341342
);
343+
ASSERT_EFI_ERROR (Status);
344+
345+
if (gDxeMps.InstallMemoryAttributeProtocol) {
346+
Status = gBS->InstallMultipleProtocolInterfaces (
347+
&mCpuHandle,
348+
&gEfiMemoryAttributeProtocolGuid,
349+
&mMemoryAttribute,
350+
NULL
351+
);
352+
if (EFI_ERROR (Status)) {
353+
DEBUG ((DEBUG_ERROR, "Failed to install Memory Attribute Protocol!\n"));
354+
}
355+
}
356+
357+
// MU_CHANGE [END]
342358

343359
//
344360
// Make sure GCD and MMU settings match. This API calls gDS->SetMemorySpaceAttributes ()

0 commit comments

Comments
 (0)