Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

8.9 MPAM: resource partitioning and monitoring

Shared caches and memory bandwidth are the main source of interference between workloads on a large SoC. A noisy VM evicts a latency-critical one from the SLC, or a DMA-heavy accelerator saturates a memory controller. MPAM (Memory System Resource Partitioning and Monitoring, FEAT_MPAM) addresses this in two halves:

  • The PE side is architectural and in DDI0487. Every memory request the PE issues is tagged with a label.
  • The memory-system side is specified in the separate MPAM architecture supplement. Memory System Components (MSCs) such as caches, interconnects and memory controllers read the label and apply per-label controls and monitors. The MSCs are programmed through MMIO.

The label carries no access control. MPAM decides how much of a resource a request may use, never whether it may access memory.

Versions: ID_AA64PFR0_EL1.MPAM (bits [43:40]) gives the major version and ID_AA64PFR1_EL1.MPAM_frac (bits [19:16]) the minor, giving v0.1, v1.0 or v1.1. FEAT_MPAM is usually described as a v8.4 feature, but DDI0487 also lists it as permitted in v8.2 implementations, and FEAT_MPAMv0p1 exists for such parts. See DDI0487 A2 for the exact permitted-from rules of each minor version.

The label: PARTID, PMG and the PARTID space

Label partWidth (field)Meaning
PARTIDup to 16 bits; max is MPAMIDR_EL1.PARTID_MAXPartition ID. MSCs index their control settings by it.
PMGup to 8 bits; max is MPAMIDR_EL1.PMG_MAXPerformance Monitoring Group: a sub-label within a PARTID, used only by monitors to split usage further. Controls ignore it.
PARTID spaceMPAM_NS, plus Root/Realm with RMESelects which of the MSC’s independent PARTID namespaces the request belongs to. Secure PARTID 5 and Non-secure PARTID 5 are different partitions.

Instruction fetches and data accesses carry separate labels: PARTID_I/PMG_I and PARTID_D/PMG_D in each register. So code and data of one workload can be given different cache shares.

PE registers

The PE generates the label from the register for the current Exception level:

RegisterUsed when executing atNotable fields
MPAM0_EL1EL0PARTID_I/D [15:0]/[31:16], PMG_I/D [39:32]/[47:40]
MPAM1_EL1 (MPAM1_EL12 under VHE)EL1 (and EL0 with GSTAPP_PLK)the same, plus MPAMEN (read-only mirror)
MPAM2_EL2EL2TRAPMPAM0EL1, TRAPMPAM1EL1, EnMPAMSM (SME), TIDR, ALTSP controls
MPAM3_EL3EL3MPAMEN (bit 63), TRAPLOWER (bit 62), SDEFLT, FORCE_NS, ALTSP controls

MPAM3_EL3.MPAMEN is the master enable. In MPAM2_EL2 and MPAM1_EL1, bit 63 is a read-only view of it. While MPAMEN == 0, every request carries the default PARTID and PMG (0) in its PARTID space, so the MSCs see a single partition.

MPAMIDR_EL1 describes the PE’s implementation:

FieldBitsMeaning
PARTID_MAX[15:0]Largest PARTID the PE can generate
HAS_HCR17Virtualization support: MPAMHCR_EL2, MPAMVPMV_EL2, MPAMVPM<n>_EL2
VPMR_MAX[20:18]Highest n for the MPAMVPM<n>_EL2 mapping registers
PMG_MAX[39:32]Largest PMG
HAS_ALTSP57Alternative PARTID spaces (RME)
HAS_TIDR58MPAM2_EL2.TIDR implemented
SP459Four PARTID spaces (Secure, Non-secure, Root, Realm) rather than two
HAS_FORCE_NS60MPAM3_EL3.FORCE_NS implemented
HAS_SDEFLT61MPAM3_EL3.SDEFLT implemented

The PE’s PARTID_MAX and each MSC’s MPAMF_IDR.PARTID_MAX are independent. Software must use the smallest common range. A PARTID larger than an MSC supports is an error at that MSC (reported through MPAMF_ESR and the MSC’s error interrupt), not a silent wrap.

Virtual PARTIDs

A hypervisor should not let a guest choose physical PARTIDs, and it should not need to trap every guest write of MPAM1_EL1. With MPAMIDR_EL1.HAS_HCR == 1:

  • MPAMHCR_EL2.EL1_VPMEN (bit 1) and EL0_VPMEN (bit 0) mark MPAM1_EL1 and MPAM0_EL1 PARTIDs as virtual.
  • A virtual PARTID indexes the MPAMVPM0_EL2–MPAMVPM7_EL2 registers. Each holds four 16-bit physical PARTIDs, so there are up to 32 virtual PARTIDs. MPAMVPMV_EL2 holds one valid bit per entry. A virtual PARTID with no valid mapping falls back to a default physical PARTID rather than leaking the guest’s value; the exact rule is in the MPAMVPMV_EL2 description in DDI0487.
  • MPAMHCR_EL2.GSTAPP_PLK (bit 8) makes guest EL0 use the guest’s MPAM1_EL1 labels. This keeps a guest OS’s applications from choosing their own partition.
  • MPAMHCR_EL2.TRAP_MPAMIDR_EL1 (bit 31) and MPAM2_EL2.TIDR trap guest reads of MPAMIDR_EL1, so the hypervisor can present a reduced PARTID_MAX.

MPAM2_EL2.TRAPMPAM1EL1/TRAPMPAM0EL1 trap guest accesses to the MPAM registers for full emulation instead.

Secure, Root and Realm PARTID spaces

Each MSC has one MMIO configuration frame per PARTID space: _s (Secure), _ns (Non-secure) and, with four spaces, _rt (Root) and _rl (Realm). Each frame is reachable only by accesses in the matching physical address space. The Non-secure OS therefore cannot reconfigure the cache share of Secure PARTIDs. It also cannot monitor Secure usage through its own frame, which closes an obvious side channel.

On the PE:

  • MPAM3_EL3.SDEFLT forces Secure-state requests to PARTID 0 and PMG 0, useful when the Secure world has no MPAM-aware software.
  • MPAM3_EL3.FORCE_NS makes Secure-state requests use the Non-secure PARTID space (MPAM_NS = 1). This lets the Normal-world resource manager control Secure traffic too.
  • With FEAT_RME and HAS_ALTSP, the alternative PARTID space controls (MPAM3_EL3.ALTSP_HEN, ALTSP_HFC, ALTSP_EL3, RT_ALTSP_NS; MPAM2_EL2.ALTSP_HFC, ALTSP_EL2) let a Security state label requests in an alternative space instead of its primary one. For example, Realm or Root traffic can be labelled in a space the Non-secure host’s MPAM driver controls, so the host can budget its Realms without being able to touch Realm-space configuration. Which space the RMM uses is a CCA platform policy decision (12.4).

Security note: MPAM monitors are a measurement channel. A CSU monitor shows how many bytes of the cache a PARTID occupies, which an attacker can use as a coarse occupancy side channel. Don’t share a PARTID+PMG between mutually distrusting tenants if monitors are exposed to either. Make sure Secure/Realm traffic is labelled in a space whose monitors the Normal world cannot read, unless that is intended.

EL3 duties

MPAM3_EL3 resets with MPAMEN = 0 and TRAPLOWER = 1. Until EL3 changes it, any access to an MPAM System register from EL2 or EL1 traps to EL3 (EC 0x18). On a TF-A system:

  1. If ID_AA64PFR0_EL1.MPAM/MPAM_frac is non-zero, write MPAM3_EL3 with MPAMEN = 1 and TRAPLOWER = 0 for the worlds allowed to use MPAM. TF-A does this under ENABLE_FEAT_MPAM. Recent versions keep the setting per world, so Secure/Realm can stay trapped.
  2. Initialise MPAM2_EL2 (clear trap bits, PARTID 0) and MPAMHCR_EL2 before dropping to a hypervisor, since most of their fields reset to UNKNOWN values.
  3. Program the Secure (and Root/Realm) frames of every MSC that EL3 owns: at minimum, a sensible configuration for PARTID 0 in each space. MSC reset values are IMPLEMENTATION DEFINED, and the MPAM supplement does not promise that they leave the full resource available.
  4. Describe the MSCs to the OS: the ACPI MPAM table (MSC base, interrupts, the resource each controls and its location such as cache ID or memory proximity domain), or device tree.

Bring-up note: A kernel or hypervisor that probes MPAM on a platform where EL3 left TRAPLOWER = 1 takes an unexpected exception to EL3 on its first MRS MPAMIDR_EL1 or MPAM2_EL2 access. On TF-A this typically ends in a “unhandled exception” panic in BL31 with ESR_EL3.EC == 0x18. Either enable MPAM at EL3 or make sure the ID registers the OS sees (through an ID_AA64PFR* override or a firmware table) say it is absent.

MSCs and their MMIO interface

Each MSC exposes a feature page with ID registers, and the configuration and monitor registers behind a selector:

Discovery    MPAMF_IDR            PARTID_MAX, PMG_MAX, HAS_CPOR_PART, HAS_CCAP_PART,
                                  HAS_MBW_PART, HAS_PRI_PART, HAS_MSMON, HAS_RIS,
                                  HAS_PARTID_NRW, EXT, SP4 ...
             MPAMF_CPOR_IDR       CPBM_WD: cache-portion bitmap width
             MPAMF_CCAP_IDR       cache-capacity control resolution
             MPAMF_MBW_IDR        bandwidth control types and resolution
             MPAMF_MSMON_IDR      MSMON_CSU, MSMON_MBWU present
Configure    MPAMCFG_PART_SEL     PARTID_SEL [15:0], INTERNAL [16], RIS [27:24]
             MPAMCFG_CPBM<n>      cache-portion bitmap: which portions PARTID may allocate in
             MPAMCFG_CMAX         maximum fraction of cache capacity
             MPAMCFG_MBW_MIN/MAX  minimum / maximum bandwidth fractions
             MPAMCFG_MBW_PBM      bandwidth-portion bitmap
             MPAMCFG_PRI          internal / downstream priority
Monitor      MSMON_CFG_MON_SEL    select monitor instance (and RIS)
             MSMON_CFG_CSU_FLT/CTL   PARTID/PMG filter, match enables, EN
             MSMON_CSU            NRDY [31], VALUE [30:0] in bytes
             MSMON_CFG_MBWU_FLT/CTL, MSMON_MBWU(_L)   bandwidth usage in bytes
Errors       MPAMF_ESR, MPAMF_ECR   PARTID/PMG out of range, monitor errors

The programming model: write MPAMCFG_PART_SEL.PARTID_SEL, then write that PARTID’s control registers. HAS_RIS MSCs contain several resources (for example a cache and its memory port) chosen by RIS. With PARTID narrowing (HAS_PARTID_NRW), the MSC has fewer internal PARTIDs than request PARTIDs, and MPAMCFG_INTPARTID maps request PARTIDs onto them. Monitors report NRDY while their value is not yet meaningful, for example right after configuration or a cache power transition. Software must not treat an NRDY read as zero.

Controls are policies, and their effect is partly IMPLEMENTATION DEFINED. A cache-portion bitmap restricts where a PARTID may allocate, not what it may hit. Lines already resident stay until evicted, so a new partitioning takes effect gradually. Bandwidth limits are enforced over an implementation-defined window (MPAMCFG_MBW_WINWD where implemented) and are approximate.

Where MSCs sit in a CMN mesh

The label must travel with the request to every MSC. On CHI, requests carry MPAM fields (PartID, PerfMonGroup and the NS/space indication) from the RN-F through the mesh. Typical MSC placement in a CMN-based SoC:

  • DSU L3 (where the DSU implements MPAM): partitioning of the cluster-shared cache.
  • HN-F / SLC slices: each HN-F slice is usually a separate MSC, or one resource instance (RIS) of a combined MSC, with portion or capacity control and CSU monitors. To partition the SLC, every slice must be programmed identically, because addresses hash across all of them.
  • Memory controllers (behind SN-F): bandwidth controls and MBWU monitors.
  • I/O and accelerators: requests that enter through an RN-I or the SMMU get labels from the SMMU (STE/CD MPAM fields, with SMMU MPAM support) or from fixed per-port defaults.
  • Across chiplets: CHI C2C or CXL links must carry the label. If the bridge drops it, all remote traffic arrives as PARTID 0, and partitioning of the remote die’s SLC and DRAM silently stops working (8.3).

The exact CHI field set depends on the CHI issue and the CMN product. Check the interconnect TRM for which HN-F and SN components implement MPAM controls versus monitors only.

Validation note: Confirming that partitioning takes effect needs a three-part test, because register read-back proves only that the MMIO write landed.

  1. Label check. Run a workload with a known PARTID+PMG, configure a CSU monitor at the target MSC to match exactly that PARTID+PMG, and confirm MSMON_CSU.VALUE rises from zero. If it stays at zero, the label is not arriving. Look for a wrong PARTID space (MPAM_NS, FORCE_NS, ALTSP), MPAMEN still 0, virtual PARTID mapping, or a bridge dropping the field.
  2. Control check. Run a cache-thrashing aggressor in PARTID A and a pointer-chasing victim in PARTID B sized to fit the SLC. Measure the victim’s latency, or its LL_CACHE_MISS_RD (0x37) / L3D_CACHE_REFILL (0x2A) PMU counts where implemented, with a shared bitmap and then with disjoint MPAMCFG_CPBM bitmaps. Expect the victim’s miss rate to fall to near its solo value. CSU for A should plateau at its share of capacity.
  3. Bandwidth check. Set MPAMCFG_MBW_MAX for a streaming PARTID and compare MBWU or memory-controller counters against the configured fraction. Expect approximate enforcement over the window, not exact.

Run all three for every MSC instance (every HN-F slice, every memory channel, every chiplet), and repeat after a cluster power cycle. MSC state may be in a power domain that loses its configuration.

Checkpoint

Q8.9.1 A Normal-world kernel programs disjoint cache-portion bitmaps in the SLC MSCs’ Non-secure frames for PARTIDs 1 and 2. CSU monitors in the Non-secure frame matching PARTID 1 read zero while the workload runs, even though MPAM1_EL1 reads PARTID 1. EL3 set MPAMEN = 1. Which explanation is most consistent?

  • A. CSU monitors only count instruction fetches, so PARTID_D traffic is invisible
  • B. The cache-portion bitmap has stopped PARTID 1 from hitting in the cache
  • C. The requests are not arriving in the Non-secure PARTID space with PARTID 1. For example, a hypervisor enabled EL1_VPMEN and the virtual PARTID maps to another physical PARTID
  • D. CSU monitors need PMG_MAX == 0
Answer

C. A monitor that stays at zero means no requests match its filter at that MSC. The usual causes are a label problem: virtual-to-physical PARTID mapping, the wrong PARTID space, a bridge dropping the label, or a PMG mismatch in the monitor filter. Option B misunderstands bitmaps: they limit where a PARTID can allocate, not whether it hits, and a restricted PARTID still occupies the portions it is allowed.

Read more: Arm ARM (DDI0487), MPAMHCR_EL2, MPAMVPMn_EL2, MPAMVPMV_EL2; MPAM architecture supplement, CSU monitors

Q8.9.2 A TF-A port for an MPAM-capable SoC does not set ENABLE_FEAT_MPAM. Linux boots, detects MPAM from ID_AA64PFR0_EL1, and reads MPAMIDR_EL1. What happens?

  • A. The access traps to EL3, because MPAM3_EL3.TRAPLOWER resets to 1, and BL31 has no handler for it
  • B. The read returns zeros, because MPAM is disabled
  • C. The read is UNDEFINED at EL1 and Linux gets an Undefined Instruction exception
  • D. It works, because TRAPLOWER only affects MPAM3_EL3 itself
Answer

A. TRAPLOWER resets to 1 and traps all MPAM System register accesses from ELs lower than EL3. EL3 firmware must clear it, or hide MPAM from the OS. MPAMEN == 0 affects only the labels on requests, not register accessibility (so B is wrong). The registers exist because FEAT_MPAM is implemented, so the access is not UNDEFINED.

Read more: Arm ARM (DDI0487), MPAM3_EL3.TRAPLOWER; TF-A build option ENABLE_FEAT_MPAM

Q8.9.3 An SoC has 16 HN-F slices, each an SLC MSC. A tester programs MPAMCFG_CPBM for PARTID 3 on slice 0 only, limiting it to a quarter of the portions, and sees almost no change in PARTID 3’s total SLC occupancy. Why?

  • A. Cache-portion partitioning only takes effect after a DC CISW on every PE
  • B. Physical addresses are hashed across all slices, so only about 1/16 of PARTID 3’s lines are in slice 0. The other 15 slices are still unrestricted
  • C. PARTID 3 exceeds MPAMF_IDR.PARTID_MAX, so the write was ignored
  • D. CPBM only applies to the Secure PARTID space
Answer

B. An SLC distributed across HN-F slices is partitioned only when every slice gets the same control settings. MPAM controls are per-MSC. Option A is wrong because bitmaps limit future allocation and need no CMO, although existing lines drain gradually. Option C would show up as an MSC error (MPAMF_ESR), and nothing suggests it here.

Read more: MPAM architecture supplement, cache portion partitioning; your CMN TRM, HN-F MPAM support