public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1 0/3] MdeModulePkg: Adding Dynamic Memory Protection Settings Libraries
@ 2023-06-09 20:25 Taylor Beebe
  2023-06-09 20:25 ` [PATCH v1 1/3] MdeModulePkg: Add DXE and MM Memory Protection Settings HOB Definitions Taylor Beebe
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Taylor Beebe @ 2023-06-09 20:25 UTC (permalink / raw)
  To: devel
  Cc: Taylor Beebe, Jian J Wang, Liming Gao, Dandan Bi, Ard Biesheuvel,
	Ray Ni, Oliver Smith-Denny, Michael Kubacki, Kun Qin, Sean Brogan

Memory protection settings are currently configured via FixedAtBuild
PCDs which resulted in a build-time configuration of memory mitigations.
To improve flexibility and compatibility, this patchset adds HOB definitions
and libraries required for configuring memory protection settings at runtime.

Once the PCD references in the codebase are replaced with references to the
memory protection HOB entries, platforms will need to produce a HOB of the format
defined in DxeMemoryProtectionSettings.h and MmMemoryProtectionSettings.h.
For example, to enable strict protections in DXE the platform could do the
following:

DXE_MEMORY_PROTECTION_SETTINGS DxeSettings = (DXE_MEMORY_PROTECTION_SETTINGS)DXE_MEMORY_PROTECTION_SETTINGS_DEBUG;
BuildGuidDataHob (&gDxeMemoryProtectionSettingsGuid, &DxeSettings, sizeof (DxeSettings));

Deviations from the preset configurations are also easy, and analogous profiles are
provided for SMM and Standalone MM. A future patch series will replace
references to the memory protection PCDs with references to the HOB entry in the
codebase.

With the PCDs, the NX setting for EfiConventionalMemory
is checked with a call like:
PcdGet64 (PcdDxeNxMemoryProtectionPolicy) & (1 << EfiConventionalMemory) != 0

Using the HOB, the NX setting for EfiConventionalMemory in the DXE environment
will be checked with a call like:
gDxeMps.NxProtectionPolicy.Fields.EfiConventionalMemory != 0

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Oliver Smith-Denny <osd@smith-denny.com>
Cc: Michael Kubacki <mikuback@linux.microsoft.com>
Cc: Kun Qin <kuqin12@gmail.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>

Taylor Beebe (3):
  MdeModulePkg: Add DXE and MM Memory Protection Settings HOB
    Definitions
  MdeModulePkg: Add MemoryProtectionHobLib Definitions and NULL Libs
  MdeModulePkg: Add Phase-Specific MemoryProtectionHobLib
    Implementations

 MdeModulePkg/Library/MemoryProtectionHobLib/DxeMemoryProtectionHobLib.c            | 182 +++++++
 MdeModulePkg/Library/MemoryProtectionHobLib/MmCommonMemoryProtectionHobLib.c       | 139 ++++++
 MdeModulePkg/Library/MemoryProtectionHobLib/SmmMemoryProtectionHobLib.c            |  37 ++
 MdeModulePkg/Library/MemoryProtectionHobLib/StandaloneMmMemoryProtectionHobLib.c   |  37 ++
 MdeModulePkg/Library/MemoryProtectionHobLibNull/DxeMemoryProtectionHobLibNull.c    |  33 ++
 MdeModulePkg/Library/MemoryProtectionHobLibNull/MmMemoryProtectionHobLibNull.c     |  33 ++
 MdeModulePkg/Include/Guid/DxeMemoryProtectionSettings.h                            | 503 ++++++++++++++++++++
 MdeModulePkg/Include/Guid/MmMemoryProtectionSettings.h                             | 239 ++++++++++
 MdeModulePkg/Include/Library/DxeMemoryProtectionHobLib.h                           |  36 ++
 MdeModulePkg/Include/Library/MmMemoryProtectionHobLib.h                            |  36 ++
 MdeModulePkg/Library/MemoryProtectionHobLib/DxeMemoryProtectionHobLib.inf          |  34 ++
 MdeModulePkg/Library/MemoryProtectionHobLib/SmmMemoryProtectionHobLib.inf          |  35 ++
 MdeModulePkg/Library/MemoryProtectionHobLib/StandaloneMmMemoryProtectionHobLib.inf |  36 ++
 MdeModulePkg/Library/MemoryProtectionHobLibNull/DxeMemoryProtectionHobLibNull.inf  |  25 +
 MdeModulePkg/Library/MemoryProtectionHobLibNull/MmMemoryProtectionHobLibNull.inf   |  26 +
 MdeModulePkg/MdeModulePkg.dec                                                      |  18 +
 MdeModulePkg/MdeModulePkg.dsc                                                      |  11 +
 17 files changed, 1460 insertions(+)
 create mode 100644 MdeModulePkg/Library/MemoryProtectionHobLib/DxeMemoryProtectionHobLib.c
 create mode 100644 MdeModulePkg/Library/MemoryProtectionHobLib/MmCommonMemoryProtectionHobLib.c
 create mode 100644 MdeModulePkg/Library/MemoryProtectionHobLib/SmmMemoryProtectionHobLib.c
 create mode 100644 MdeModulePkg/Library/MemoryProtectionHobLib/StandaloneMmMemoryProtectionHobLib.c
 create mode 100644 MdeModulePkg/Library/MemoryProtectionHobLibNull/DxeMemoryProtectionHobLibNull.c
 create mode 100644 MdeModulePkg/Library/MemoryProtectionHobLibNull/MmMemoryProtectionHobLibNull.c
 create mode 100644 MdeModulePkg/Include/Guid/DxeMemoryProtectionSettings.h
 create mode 100644 MdeModulePkg/Include/Guid/MmMemoryProtectionSettings.h
 create mode 100644 MdeModulePkg/Include/Library/DxeMemoryProtectionHobLib.h
 create mode 100644 MdeModulePkg/Include/Library/MmMemoryProtectionHobLib.h
 create mode 100644 MdeModulePkg/Library/MemoryProtectionHobLib/DxeMemoryProtectionHobLib.inf
 create mode 100644 MdeModulePkg/Library/MemoryProtectionHobLib/SmmMemoryProtectionHobLib.inf
 create mode 100644 MdeModulePkg/Library/MemoryProtectionHobLib/StandaloneMmMemoryProtectionHobLib.inf
 create mode 100644 MdeModulePkg/Library/MemoryProtectionHobLibNull/DxeMemoryProtectionHobLibNull.inf
 create mode 100644 MdeModulePkg/Library/MemoryProtectionHobLibNull/MmMemoryProtectionHobLibNull.inf

-- 
2.36.1.windows.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-09 20:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-09 20:25 [PATCH v1 0/3] MdeModulePkg: Adding Dynamic Memory Protection Settings Libraries Taylor Beebe
2023-06-09 20:25 ` [PATCH v1 1/3] MdeModulePkg: Add DXE and MM Memory Protection Settings HOB Definitions Taylor Beebe
2023-06-09 20:26 ` [PATCH v1 2/3] MdeModulePkg: Add MemoryProtectionHobLib Definitions and NULL Libs Taylor Beebe
2023-06-09 20:26 ` [PATCH v1 3/3] MdeModulePkg: Add Phase-Specific MemoryProtectionHobLib Implementations Taylor Beebe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox