Skip to content

Commit

Permalink
Add Unaccepted Memory Type to Memory Protection Struct Definitions (#634
Browse files Browse the repository at this point in the history
)

## Description

EDK2 added EfiUnacceptedMemoryType to the memory type list. This update
adds this memory type to the DXE and MM memory protection structs. This
update also increments the versions of the MM and DXE memory protection
settings structs, so platforms must update and rebuild all modules to
ensure version consistency.

- [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 on Q35 using the memory protection test app.

## Integration Instructions

Modules which use the memory protection HOB libraries will need to be
rebuilt to ensure version consistency between mu_basecore and consuming
modules.
  • Loading branch information
TaylorBeebe authored and kenlautner committed Dec 18, 2023
1 parent 97c9345 commit 182ed60
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
15 changes: 14 additions & 1 deletion MdeModulePkg/Include/Guid/DxeMemoryProtectionSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ typedef union {
UINT8 EfiMemoryMappedIOPortSpace : 1;
UINT8 EfiPalCode : 1;
UINT8 EfiPersistentMemory : 1;
UINT8 EfiUnacceptedMemoryType : 1;
UINT8 OEMReserved : 1;
UINT8 OSReserved : 1;
} Fields;
Expand All @@ -64,7 +65,7 @@ typedef union {

typedef UINT8 DXE_MEMORY_PROTECTION_SETTINGS_VERSION;

#define DXE_MEMORY_PROTECTION_SETTINGS_CURRENT_VERSION 4 // Current iteration of DXE_MEMORY_PROTECTION_SETTINGS
#define DXE_MEMORY_PROTECTION_SETTINGS_CURRENT_VERSION 5 // Current iteration of DXE_MEMORY_PROTECTION_SETTINGS

//
// Memory Protection Settings struct
Expand Down Expand Up @@ -218,6 +219,7 @@ extern GUID gDxeMemoryProtectionSettingsGuid;
.Fields.EfiMemoryMappedIOPortSpace = 1, \
.Fields.EfiPalCode = 1, \
.Fields.EfiPersistentMemory = 0, \
.Fields.EfiUnacceptedMemoryType = 1, \
.Fields.OEMReserved = 1, \
.Fields.OSReserved = 1 \
}, \
Expand All @@ -237,6 +239,7 @@ extern GUID gDxeMemoryProtectionSettingsGuid;
.Fields.EfiMemoryMappedIOPortSpace = 1, \
.Fields.EfiPalCode = 1, \
.Fields.EfiPersistentMemory = 0, \
.Fields.EfiUnacceptedMemoryType = 1, \
.Fields.OEMReserved = 1, \
.Fields.OSReserved = 1 \
}, \
Expand All @@ -256,6 +259,7 @@ extern GUID gDxeMemoryProtectionSettingsGuid;
.Fields.EfiMemoryMappedIOPortSpace = 1, \
.Fields.EfiPalCode = 1, \
.Fields.EfiPersistentMemory = 0, \
.Fields.EfiUnacceptedMemoryType = 1, \
.Fields.OEMReserved = 1, \
.Fields.OSReserved = 1 \
}, \
Expand Down Expand Up @@ -304,6 +308,7 @@ extern GUID gDxeMemoryProtectionSettingsGuid;
.Fields.EfiMemoryMappedIOPortSpace = 0, \
.Fields.EfiPalCode = 0, \
.Fields.EfiPersistentMemory = 0, \
.Fields.EfiUnacceptedMemoryType = 0, \
.Fields.OEMReserved = 0, \
.Fields.OSReserved = 0 \
}, \
Expand All @@ -323,6 +328,7 @@ extern GUID gDxeMemoryProtectionSettingsGuid;
.Fields.EfiMemoryMappedIOPortSpace = 0, \
.Fields.EfiPalCode = 0, \
.Fields.EfiPersistentMemory = 0, \
.Fields.EfiUnacceptedMemoryType = 0, \
.Fields.OEMReserved = 0, \
.Fields.OSReserved = 0 \
}, \
Expand All @@ -342,6 +348,7 @@ extern GUID gDxeMemoryProtectionSettingsGuid;
.Fields.EfiMemoryMappedIOPortSpace = 1, \
.Fields.EfiPalCode = 1, \
.Fields.EfiPersistentMemory = 1, \
.Fields.EfiUnacceptedMemoryType = 1, \
.Fields.OEMReserved = 0, \
.Fields.OSReserved = 0 \
}, \
Expand Down Expand Up @@ -389,6 +396,7 @@ extern GUID gDxeMemoryProtectionSettingsGuid;
.Fields.EfiMemoryMappedIOPortSpace = 0, \
.Fields.EfiPalCode = 0, \
.Fields.EfiPersistentMemory = 0, \
.Fields.EfiUnacceptedMemoryType = 0, \
.Fields.OEMReserved = 0, \
.Fields.OSReserved = 0 \
}, \
Expand All @@ -408,6 +416,7 @@ extern GUID gDxeMemoryProtectionSettingsGuid;
.Fields.EfiMemoryMappedIOPortSpace = 0, \
.Fields.EfiPalCode = 0, \
.Fields.EfiPersistentMemory = 0, \
.Fields.EfiUnacceptedMemoryType = 0, \
.Fields.OEMReserved = 0, \
.Fields.OSReserved = 0 \
}, \
Expand All @@ -427,6 +436,7 @@ extern GUID gDxeMemoryProtectionSettingsGuid;
.Fields.EfiMemoryMappedIOPortSpace = 1, \
.Fields.EfiPalCode = 1, \
.Fields.EfiPersistentMemory = 1, \
.Fields.EfiUnacceptedMemoryType = 1, \
.Fields.OEMReserved = 0, \
.Fields.OSReserved = 0 \
}, \
Expand Down Expand Up @@ -473,6 +483,7 @@ extern GUID gDxeMemoryProtectionSettingsGuid;
.Fields.EfiMemoryMappedIOPortSpace = 0, \
.Fields.EfiPalCode = 0, \
.Fields.EfiPersistentMemory = 0, \
.Fields.EfiUnacceptedMemoryType = 0, \
.Fields.OEMReserved = 0, \
.Fields.OSReserved = 0 \
}, \
Expand All @@ -492,6 +503,7 @@ extern GUID gDxeMemoryProtectionSettingsGuid;
.Fields.EfiMemoryMappedIOPortSpace = 0, \
.Fields.EfiPalCode = 0, \
.Fields.EfiPersistentMemory = 0, \
.Fields.EfiUnacceptedMemoryType = 0, \
.Fields.OEMReserved = 0, \
.Fields.OSReserved = 0 \
}, \
Expand All @@ -511,6 +523,7 @@ extern GUID gDxeMemoryProtectionSettingsGuid;
.Fields.EfiMemoryMappedIOPortSpace = 0, \
.Fields.EfiPalCode = 0, \
.Fields.EfiPersistentMemory = 0, \
.Fields.EfiUnacceptedMemoryType = 0, \
.Fields.OEMReserved = 0, \
.Fields.OSReserved = 0 \
}, \
Expand Down
7 changes: 6 additions & 1 deletion MdeModulePkg/Include/Guid/MmMemoryProtectionSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ typedef union {
UINT8 EfiMemoryMappedIOPortSpace : 1;
UINT8 EfiPalCode : 1;
UINT8 EfiPersistentMemory : 1;
UINT8 EfiUnacceptedMemoryType : 1;
UINT8 OEMReserved : 1;
UINT8 OSReserved : 1;
} Fields;
} MM_HEAP_GUARD_MEMORY_TYPES;

typedef UINT8 MM_MEMORY_PROTECTION_SETTINGS_VERSION;

#define MM_MEMORY_PROTECTION_SETTINGS_CURRENT_VERSION 1 // Current iteration of MM_MEMORY_PROTECTION_SETTINGS
#define MM_MEMORY_PROTECTION_SETTINGS_CURRENT_VERSION 2 // Current iteration of MM_MEMORY_PROTECTION_SETTINGS

//
// Memory Protection Settings struct
Expand Down Expand Up @@ -137,6 +138,7 @@ extern GUID gMmMemoryProtectionSettingsGuid;
.Fields.EfiMemoryMappedIOPortSpace = 0, \
.Fields.EfiPalCode = 0, \
.Fields.EfiPersistentMemory = 0, \
.Fields.EfiUnacceptedMemoryType = 0, \
.Fields.OEMReserved = 0, \
.Fields.OSReserved = 0 \
}, \
Expand All @@ -156,6 +158,7 @@ extern GUID gMmMemoryProtectionSettingsGuid;
.Fields.EfiMemoryMappedIOPortSpace = 0, \
.Fields.EfiPalCode = 0, \
.Fields.EfiPersistentMemory = 0, \
.Fields.EfiUnacceptedMemoryType = 0, \
.Fields.OEMReserved = 0, \
.Fields.OSReserved = 0 \
} \
Expand Down Expand Up @@ -189,6 +192,7 @@ extern GUID gMmMemoryProtectionSettingsGuid;
.Fields.EfiMemoryMappedIOPortSpace = 0, \
.Fields.EfiPalCode = 0, \
.Fields.EfiPersistentMemory = 0, \
.Fields.EfiUnacceptedMemoryType = 0, \
.Fields.OEMReserved = 0, \
.Fields.OSReserved = 0 \
}, \
Expand All @@ -208,6 +212,7 @@ extern GUID gMmMemoryProtectionSettingsGuid;
.Fields.EfiMemoryMappedIOPortSpace = 0, \
.Fields.EfiPalCode = 0, \
.Fields.EfiPersistentMemory = 0, \
.Fields.EfiUnacceptedMemoryType = 0, \
.Fields.OEMReserved = 0, \
.Fields.OSReserved = 0 \
} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ GetDxeMemoryTypeSettingFromBitfield (
return HeapGuardMemoryType.Fields.EfiPalCode;
case EfiPersistentMemory:
return HeapGuardMemoryType.Fields.EfiPersistentMemory;
case EfiUnacceptedMemoryType:
return HeapGuardMemoryType.Fields.EfiUnacceptedMemoryType;
default:
return FALSE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ GetMmMemoryTypeSettingFromBitfield (
return HeapGuardMemoryType.Fields.EfiPalCode;
case EfiPersistentMemory:
return HeapGuardMemoryType.Fields.EfiPersistentMemory;
case EfiUnacceptedMemoryType:
return HeapGuardMemoryType.Fields.EfiUnacceptedMemoryType;
default:
return FALSE;
}
Expand Down

0 comments on commit 182ed60

Please sign in to comment.