edk2/ArmPkg/Include
Yeoreum Yun c83db74426 ArmPkg, StandaloneMmPkg: optimise memory permission change
In StandaloneMm, the allowed memory permission combinations are ROX, RO,
and RW.

At the initial stage, all regions are mapped as ROX.
When drivers are loaded for relocation, the image is first mapped as RW.

However, the current mechanism introduces significant overhead
when changing memory permissions. For example, when changing permissions
from ROX to RW, the process is performed in two steps:

  1. Clear the execute (X) permission (ROX → RO)
  2. Add the write (W) permission (RO → RW)

To execute step (1), the system first retrieves the permissions of
the target region. This may trigger multiple SMC calls,
depending on the permissions of the pages within that region.

This permission retrieval operation is redundant, as there is no need
to maintain an intermediate state. Nevertheless,
it can cause additional SMC calls and coherence operations
from the SPMC (e.g., TLB flushes).

Therefore, this redundant operation should be removed, and in most cases,
the memory permission should be updated with a single
“set memory permission” operation.

Note:
The ArmxxxMemoryRegionxxx() interfaces e.g. ArmSetMemoryRegionNoExec(),
etc. return success when the Length parameter is 0 as
the SectionHeader.Misc.VirtualSize could be 0 Length
like .reloc section:

  UpdateMmFoundationPeCoffPermissions: Section 2 of image at 0x7004000
                                       has 0x42000040 permissions
  UpdateMmFoundationPeCoffPermissions: Section 2 of image at 0x7004000
                                       has .reloc name
  api_ffa_mem_perm_set page_count 0
  ERROR: FFA_MEM_PERM_SET: page_count was zero

Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
2026-05-29 18:44:57 +00:00
..
Guid ArmPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
IndustryStandard ArmPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
Library ArmPkg, StandaloneMmPkg: optimise memory permission change 2026-05-29 18:44:57 +00:00
Ppi ArmPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
Protocol ArmPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00