edk2/StandaloneMmPkg/Library
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
..
MmPlatformHobProducerLibNull StandaloneMmPkg: Produce gMmStatusCodeUseSerialHobGuid HOB 2025-03-27 02:28:30 +00:00
SmmLockBoxMmDependency StandaloneMmPkg: Add LockBox Dependency Library 2024-07-31 19:49:24 +00:00
StandaloneMmCoreHobLib StandaloneMmPkg: Drop ARM32 Support 2025-09-25 22:04:10 +00:00
StandaloneMmCoreMemoryAllocationLib StandaloneMmPkg/Core: pass HOB list in MMRAM to library constructor 2025-02-24 03:24:08 +00:00
StandaloneMmExtractGuidedSectionLib StandaloneMmPkg: introduce StandaloneMmExtractGuidedSectionLib 2025-01-17 14:55:42 +00:00
StandaloneMmHobLib StandaloneMmPkg: Drop ARM32 Support 2025-09-25 22:04:10 +00:00
StandaloneMmMemLib StandaloneMmPkg: Replace include guards with #pragma once 2026-02-23 21:01:28 +00:00
StandaloneMmMemoryAllocationLib StandaloneMmPkg: Drop ARM32 Support 2025-09-25 22:04:10 +00:00
StandaloneMmPeCoffExtraActionLib ArmPkg, StandaloneMmPkg: optimise memory permission change 2026-05-29 18:44:57 +00:00
VariableMmDependency StandaloneMmPkg: Drop ARM32 Support 2025-09-25 22:04:10 +00:00