Skip to content

Commit 9dd5d9e

Browse files
author
Jiaxin Wu
committed
Refine the each section format
Signed-off-by: Jiaxin Wu <[email protected]>
1 parent 0096140 commit 9dd5d9e

File tree

3 files changed

+39
-39
lines changed

3 files changed

+39
-39
lines changed

1_mm_introduction.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
3030
-->
3131

32-
# MM Introduction
32+
# 1 MM Introduction
3333

34-
## SMM and MM Overview
34+
## 1.1 SMM and MM Overview
3535

3636
This section describes the main differences between Traditional SMM and Standalone MM. A detailed comparison of the Traditional MM and Standalone MM load process is described in the PI Specification sections "Initializing Management Mode in MM Traditional Mode" and "Initializing Management Mode in Standalone Mode" respectively.
3737

@@ -52,12 +52,12 @@ MM Driver:
5252
- Module type is `MM_STANDALONE`. The entry point of an updatable MM driver follows the PI specification `MM_IMAGE_ENTRY_POINT`.
5353
- A Standalone MM driver must only refer to MM servers.
5454
- Launches early in the PEI phase.
55-
- Two rounds of dispatch depend on the `gEventMmDispatchGuid` event. Refer to section **MM Driver Dispatch** for details.
56-
- Cannot access any non-MMRAM memory unless the `MmUnblockMemoryRequest()` API is called for the non-MMRAM memory. Refer to section **Non-MMRAM Access** for details.
57-
- Uses MM self-owned HOBs. Refer to section **MM HOBs** for details.
58-
- Early memory protection in PEI: `StandaloneMmCore` installs the `EDKII_PI_SMM_MEMORY_ATTRIBUTES_TABLE` once the second round of dispatch finishes. Refer to section **Memory Protection** for details.
55+
- Two rounds of dispatch depend on the `gEventMmDispatchGuid` event. Refer to section **1.2 MM Driver Dispatch** for details.
56+
- Cannot access any non-MMRAM memory unless the `MmUnblockMemoryRequest()` API is called for the non-MMRAM memory. Refer to section **1.4 Non-MMRAM Access** for details.
57+
- Uses MM self-owned HOBs. Refer to section **1.5 MM HOBs** for details.
58+
- Early memory protection in PEI: `StandaloneMmCore` installs the `EDKII_PI_SMM_MEMORY_ATTRIBUTES_TABLE` once the second round of dispatch finishes. Refer to section **1.7 Memory Protection** for details.
5959

60-
## MM Driver Dispatch
60+
## 1.2 MM Driver Dispatch
6161

6262
For traditional SMM drivers, they are dispatched within multiple rounds: The dispatch is hooked on the `gEfiEventDxeDispatchGuid` event, which is signaled by DXE Core when DXE Core finishes one round of dispatch.
6363

@@ -71,7 +71,7 @@ The following flow chart describes the MM driver dispatch flow:
7171
![MM Driver Dispatch Flow](./media/image1.jpg)
7272
###### Figure 1: MM Driver Dispatch Flow
7373

74-
## MM Communication Buffer
74+
## 1.3 MM Communication Buffer
7575

7676
MM communication buffer is specific memory regions used for communication between the Non-MM and MM environment.
7777

@@ -89,7 +89,7 @@ Every communication flow is as follows where steps #2, #3, and #4 run inside MM:
8989

9090
By following the above, the `CommBuffer` used by the Communication PPI/Protocol is referred to as the **Primary Buffer**. Additionally, other non-MMRAM memory for specific MM driver usage are termed **Non-Primary Buffer**. Those buffer can be pointed from the MM HOBs, or pointed from the `CommBuffer`. Both the Primary Buffer and Non-Primary Buffer used by MM drivers should be validated for accessibility before use.
9191

92-
## Non-MMRAM Access
92+
## 1.4 Non-MMRAM Access
9393

9494
Any memory outside of the MMRAM (non-MMRAM) that needs to be accessed by MMI handlers must be explicitly declared as "Unblock Mem" through `MmUnblockMemoryRequest()` (`MdePkg/Include/Library/MmUnblockMemoryLib.h`).
9595

@@ -100,13 +100,13 @@ Requirements for marking the non-MMRAM as "Unblocked":
100100

101101
`StandaloneMmIpl` builds the corresponding `EFI_HOB_RESOURCE_DESCRIPTOR` in the MM HOB list for all unblocked non-MMRAM memory access. Any non-MMRAM memory region that is not described by `EFI_HOB_RESOURCE_DESCRIPTOR` in the MM HOB list is not accessible from SMM mode.
102102

103-
## MM HOBs
103+
## 1.5 MM HOBs
104104

105105
PEI HOBs are used by the traditional SMM. The lifecycle of traditional SMM HOBs is limited to the boot phase, and once entering the runtime phase, HOBs can no longer be accessed or used in the SMM. In contrast, Standalone MM is designed to maintain the validity of its self-owned HOBs throughout the entire lifecycle, including the runtime phase.
106106

107107
`StandaloneMmIpl` is not required to pass the entire PEI HOB list to the SMM foundation. Instead, it must create and pass a specific subset of HOBs that are essential for the operation of the Standalone MM environment. Overall, MM self-owned HOBs can be divided into two categories: **MM Foundation HOBs** and **MM Platform HOBs**.
108108

109-
### MM Foundation HOBs
109+
### 1.5.1 MM Foundation HOBs
110110

111111
The MM Foundation HOBs are a set of HOBs that are created by the common logic within the `StandaloneMmIpl`. These HOBs provide the necessary information about the firmware environment and memory regions that the MM Core and drivers will interact with. The following HOBs are created by `StandaloneMmIpl` common logic; hence, they should **NOT** be created by the platform part:
112112

@@ -123,33 +123,33 @@ The MM Foundation HOBs are a set of HOBs that are created by the common logic wi
123123
- Single GUIDed (`gEfiAcpiVariableGuid`) HOB to identify the S3 data root region in x86.
124124
- Single GUIDed (`gMmStatusCodeUseSerialHobGuid`) HOB to describe whether the status code uses the serial port or not.
125125

126-
### MM Platform HOBs
126+
### 1.5.2 MM Platform HOBs
127127

128128
In addition to the MM Foundation HOBs, the `StandaloneMmIpl` will consume the `MmPlatformHobProducerLib/CreateMmPlatformHob()` to create platform-specific HOBs that are necessary for the Standalone MM environment. These HOBs provide information and configuration details that are unique to the platform on which the system is running. The creation of these HOBs ensures that the MM environment is properly configured to interact with the platform's hardware and firmware features.
129129

130-
## Communication between SMM/Non-SMM
130+
## 1.6 Communication between SMM/Non-SMM
131131
The following mechanisms are provided for communication between SMM and Non-SMM:
132132

133133
1. Using `CommBuffer` with Protocol `EFI_MM_COMMUNICATION_PROTOCOL` or PPI `EFI_PEI_MM_COMMUNICATION_PPI`:
134134
- Requires dependency on the `EFI_MM_COMMUNICATION_PROTOCOL` or `EFI_PEI_MM_COMMUNICATION_PPI`.
135135
- Triggers an SMI when sharing data between SMM and Non-SMM code.
136136

137137
2. Using "Unblock Mem":
138-
- Must meet the usage requirements. Refer to the **Non-MMRAM Access** section for details.
138+
- Must meet the usage requirements. Refer to section **1.4 Non-MMRAM Access** for details.
139139

140140
3. Using MM Guided HOBs:
141141
- For data sizes < 64KB: Embed the data directly into the HOB.
142142

143143
Option #1 is suitable when the data cannot be finalized before launching MM or when the data flow is bidirectional between SMM and Non-SMM code. Option #2 is necessary for ASL code to pass data to the SW SMI handler. It is also an alternative solution to avoid triggering an SMI for latency considerations. Option #3 is ideal when the data size is small than 64K and it can be finalized before launching MM and the data flow is unidirectional between SMM and Non-SMM code.
144144

145-
But in cases where silicon initialization code does not want to rely on the communication PPI, the data size to be passed to MM exceeds 64KB, and the memory cannot be runtime-accessible due to the requirement for Runtime Non-SMM invisibility, then options #1 and #2 are not applicable. Option #3 requires splitting the data into multiple Guided HOBs, which increases code complexity due to the need to reassemble the data in MM. To simplify this, a fourth solution was introduced:
145+
But in cases where silicon initialization code does not want to rely on the communication PPI, the data size to be passed to MM exceeds 64KB, and the memory cannot be runtime-accessible due to the requirement for Runtime Non-SMM invisibility, then options #1 and #2 are not applicable. Option #3 requires splitting the data into multiple Guided HOBs, which increases code complexity due to the need to reassemble the data in MM. To simplify this, a fourth method was introduced as below:
146146

147147
4. Using MM Memory Allocation HOBs with BSData and Non-Zero GUID:
148148
- Memory Producer (PEIM): Create a Memory Allocation HOB pointing to a BSData memory region and assign a Non-Zero GUID to the corresponding HOB.
149149
- MM Core: Migrate the Memory Allocation HOB into MMRAM by copying the data from Non-MMRAM to MMRAM. Refer to `MigrateMemoryAllocationHobs()` in `Edk2/StandaloneMmPkg/Core/StandaloneMmCore.c`.
150150
- Memory Consumer (MM Drivers): Retrieve the memory from the Memory Allocation HOB using its assigned Non-Zero GUID.
151151

152-
## Memory Protection
152+
## 1.7 Memory Protection
153153

154154
The `PiSmmCpuStandaloneMm` driver creates a page table used in MM mode according to the `EFI_HOB_RESOURCE_DESCRIPTOR` in the MM HOB list. The newly created page table controls memory accessibility in MM.
155155

2_smm_to_mm_porting_guide.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
3030
-->
3131

32-
# SMM to MM Porting Guide
32+
# 2 SMM to MM Porting Guide
3333

34-
## Porting Design Overview
34+
## 2.1 Porting Design Overview
3535

3636
This section provides instructions on how to convert traditional SMM drivers to MM drivers. A traditional SMM driver may need to be split into one or more drivers when transitioning to a Standalone MM driver:
3737

@@ -46,7 +46,7 @@ The figure below illustrates how to convert a traditional SMM driver to an MM dr
4646
![SMM to MM Conversion](./media/image2.jpg)
4747
###### Figure 2: SMM to MM Conversion
4848

49-
## Checkpoints in Converted MM Driver
49+
## 2.2 Checkpoints in Converted MM Driver
5050

5151
To ensure the converted Standalone MM driver is functional, the following checkpoints should be verified:
5252

@@ -58,14 +58,14 @@ To ensure the converted Standalone MM driver is functional, the following checkp
5858

5959
2. **Checkpoint 2: Confirm Necessary HOBs Have Been Migrated to MM HOB Database**
6060

61-
Refer to section **MM HOBs** for details.
61+
Refer to section **1.5 MM HOBs** for details.
6262
**Note**: HOB creation cannot depend on the end of the PEI notify event if the HOB needs to be accessed in MM. This is because the `StandaloneMmIpl` PEIM is dispatched before the end of PEI, leaving no opportunity for the IPL to migrate newly created HOBs to the MM HOB database.
6363

6464
3. **Checkpoint 3: Check Dependencies on `gBS`, `gDS`, `gRT`, or ACPI-Related Services**
6565

6666
If the original SMM driver depends on DXE protocols (e.g., `gBS` or `gDS`), it can only be used during the DXE phase. And ACPI tables must be installed during the DXE phase.
6767

68-
1. **Checkpoint 4: Check Access to Non-MMRAM**
68+
4. **Checkpoint 4: Check Access to Non-MMRAM**
6969

7070
Non-MMRAM access typically falls into the following cases:
7171
- **Case 1**: Accessing a HOB that contains a pointer or address pointing to non-MMRAM.
@@ -75,13 +75,13 @@ To ensure the converted Standalone MM driver is functional, the following checkp
7575
- **Case 3**: The registered SMI handler uses `gMmst->MmiHandlerRegister(SmiHandler, NULL, ...)` or MM Child Dispatch protocols (e.g., `SwDispatch->Register`).
7676
If it accesses any non-MMRAM buffer, use `MmUnblockMemoryRequest()` in the PEI phase before the `StandaloneMmIpl` entry point.
7777

78-
2. **Checkpoint 5: Validate Primary & Non-Primary Buffers**
78+
5. **Checkpoint 5: Validate Primary & Non-Primary Buffers**
7979

80-
Refer to section **Non-MMRAM Access** for definitions of Primary and Non-Primary Buffers. Both types of buffers used by MM drivers should be validated for accessibility before use:
80+
Refer to section **1.3 MM Communication Buffer** for definitions of Primary and Non-Primary Buffers. Both types of buffers used by MM drivers should be validated for accessibility before use:
8181
- Use `XXXIsPrimaryBufferValid()` to validate the `CommBuffer`.
8282
- Use `XXXIsNonPrimaryBufferValid()` to validate non-MMRAM memory pointed from the `CommBuffer` or MM HOB.
8383

84-
## Sample: SMM to MM Conversion
84+
## 2.3 Sample: SMM to MM Conversion
8585

8686
The Tcg2 SMM and MM modules will be used as a sample to highlight the key points to consider when converting a traditional SMM module to an MM module:
8787

@@ -127,7 +127,7 @@ The Tcg2 SMM and MM modules will be used as a sample to highlight the key points
127127

128128
The `mTcgNvs` global variable in the Tcg2 SMM module plays a crucial role in TPM operations, especially when updating the ACPI table and handling SMI callback functions.
129129
`mTcgNvs` is the operation region in the TCG ACPI table and must be a non-MMRAM memory buffer pointed from the `CommBuffer`.
130-
According to Section **Non-MMRAM Access**, it must be unblocked using `MmUnblockMemoryRequest()`.
130+
According to Section **1.4 Non-MMRAM Access**, it must be unblocked using `MmUnblockMemoryRequest()`.
131131
The related operation can be found in the `BuildTcg2AcpiCommunicateBufferHob()` function in `Edk2\SecurityPkg\Tcg\Tcg2Config\Tcg2ConfigPei.inf`.
132132

133133
7. **Check Primary & Non-Primary Buffer Validity**

SUMMARY.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@
3333

3434
* [Standalone MM Getting Started Guide](README.md)
3535

36-
* [MM Introduction](1_mm_introduction.md#mm-introduction)
37-
* [SMM and MM Overview](1_mm_introduction.md#smm-and-mm-overview)
38-
* [MM Driver Dispatch](1_mm_introduction.md#mm-driver-dispatch)
39-
* [MM Communication Buffer](1_mm_introduction.md#mm-communication-buffer)
40-
* [Non-MMRAM Access](1_mm_introduction.md#non-mmram-access)
41-
* [MM HOBs](1_mm_introduction.md#mm-hobs)
42-
* [MM Foundation HOBs](1_mm_introduction.md#mm-foundation-hobs)
43-
* [MM Platform HOBs](1_mm_introduction.md#mm-platform-hobs)
44-
* [Communication between SMM/Non-SMM](1_mm_introduction.md#communication-between-smmnon-smm)
45-
* [Memory Protection](1_mm_introduction.md#memory-protection)
36+
* [1 MM Introduction](1_mm_introduction.md#1-mm-introduction)
37+
* [1.1 SMM and MM Overview](1_mm_introduction.md#11-smm-and-mm-overview)
38+
* [1.2 MM Driver Dispatch](1_mm_introduction.md#12-mm-driver-dispatch)
39+
* [1.3 MM Communication Buffer](1_mm_introduction.md#13-mm-communication-buffer)
40+
* [1.4 Non-MMRAM Access](1_mm_introduction.md#14-non-mmram-access)
41+
* [1.5 MM HOBs](1_mm_introduction.md#15-mm-hobs)
42+
* [1.51 MM Foundation HOBs](1_mm_introduction.md#151-mm-foundation-hobs)
43+
* [1.52 MM Platform HOBs](1_mm_introduction.md#152-mm-platform-hobs)
44+
* [1.6 Communication between SMM/Non-SMM](1_mm_introduction.md#16-communication-between-smmnon-smm)
45+
* [1.7 Memory Protection](1_mm_introduction.md#17-memory-protection)
4646

47-
* [SMM to MM Porting Guide](2_smm_to_mm_porting_guide.md#smm-to-mm-porting-guide)
48-
* [Porting Design Overview](2_smm_to_mm_porting_guide.md#porting-design-overview)
49-
* [Checkpoints in Converted MM Driver](2_smm_to_mm_porting_guide.md#checkpoints-in-converted-mm-driver)
50-
* [Sample: SMM to MM Conversion](2_smm_to_mm_porting_guide.md#sample-smm-to-mm-conversion)
47+
* [2 SMM to MM Porting Guide](2_smm_to_mm_porting_guide.md#2-smm-to-mm-porting-guide)
48+
* [2.1 Porting Design Overview](2_smm_to_mm_porting_guide.md#21-porting-design-overview)
49+
* [2.2 Checkpoints in Converted MM Driver](2_smm_to_mm_porting_guide.md#22-checkpoints-in-converted-mm-driver)
50+
* [2.3 Sample: SMM to MM Conversion](2_smm_to_mm_porting_guide.md#23-sample-smm-to-mm-conversion)
5151

5252
---
5353

0 commit comments

Comments
 (0)