Skip to content

Commit

Permalink
Add EFI Event When Compatibility Mode is Triggered (#832)
Browse files Browse the repository at this point in the history
## Description

For a description of Memory Protection Compatibility Mode, see:
https://microsoft.github.io/mu/WhatAndWhy/enhancedmemoryprotection/

This PR adds an event which will be signaled when Compatibility Mode is
activated. Platforms can hook into this event to perform custom actions
when this mode is activated.

- [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 booting Q35 to shell.

## Integration Instructions

N/A
  • Loading branch information
TaylorBeebe authored Apr 27, 2024
1 parent 9345b79 commit 27f20fc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions MdeModulePkg/Core/Dxe/DxeMain.inf
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
gMuEventPreExitBootServicesGuid ## PRODUCES ## Event // MU_CHANGE
gDxeMemoryProtectionSettingsGuid ## CONSUMES ## HOB // MU_CHANGE
gMemoryProtectionSpecialRegionHobGuid ## CONSUMES ## HOB // MU_CHANGE
gCompatibilityModeActivatedEventGuid ## SOMETIMES_PRODUCES ## Event // MU_CHANGE

[Ppis]
gEfiVectorHandoffInfoPpiGuid ## UNDEFINED # HOB
Expand Down
1 change: 1 addition & 0 deletions MdeModulePkg/Core/Dxe/Misc/MemoryProtectionSupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -2884,6 +2884,7 @@ ActivateCompatibilityMode (
DisableNullDetection ();
UninstallMemoryAttributeProtocol ();
MapLegacyBiosMemoryRWX ();
CoreNotifySignalList (&gCompatibilityModeActivatedEventGuid);
}

/**
Expand Down
18 changes: 18 additions & 0 deletions MdeModulePkg/Include/Guid/CompatibilityModeActivatedEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @file
Event group triggered when Memory Protection Compatibility Mode is activated.
Platforms can hook into this event to perform follow up actions.
More information on Compatibility Mode: https://microsoft.github.io/mu/WhatAndWhy/enhancedmemoryprotection/
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef COMPATIBILITY_MODE_ACTIVATED_EVENT_H_
#define COMPATIBILITY_MODE_ACTIVATED_EVENT_H_

#define COMPATIBILITY_MODE_ACTIVATED_EVENT_GUID \
{ 0x209BA820, 0xCE32, 0x49E1, { 0x95, 0xAE, 0x39, 0x43, 0x3D, 0xEF, 0xD5, 0xEE } }

extern EFI_GUID gCompatibilityModeActivatedEventGuid;

#endif
5 changes: 5 additions & 0 deletions MdeModulePkg/MdeModulePkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,11 @@
# Include/Guid/MemoryProtectionSpecialRegionGuid.h
gMemoryProtectionSpecialRegionHobGuid = { 0xBFCC1325, 0x3BFE, 0x469A, { 0x9A, 0xAC, 0x0C, 0x99, 0x0E, 0x4E, 0xC9, 0xF1 } }

# MU_CHANGE
# This GUID is used to trigger the event group when the compatibility mode is activated.
# Include/Guid/CompatibilityModeActivatedEvent.h
gCompatibilityModeActivatedEventGuid = { 0x209BA820, 0xCE32, 0x49E1, { 0x95, 0xAE, 0x39, 0x43, 0x3D, 0xEF, 0xD5, 0xEE } }

## MSCHANGE END


Expand Down

0 comments on commit 27f20fc

Please sign in to comment.