arm-trusted-firmware/include
Boyan Karatotev 83ec7e452c perf(amu): greatly simplify AMU context management
The current code is incredibly resilient to updates to the spec and
has worked quite well so far. However, recent implementations expose a
weakness in that this is rather slow. A large part of it is written in
assembly, making it opaque to the compiler for optimisations. The
future proofness requires reading registers that are effectively
`volatile`, making it even harder for the compiler, as well as adding
lots of implicit barriers, making it hard for the microarchitecutre to
optimise as well.

We can make a few assumptions, checked by a few well placed asserts, and
remove a lot of this burden. For a start, at the moment there are 4
group 0 counters with static assignments. Contexting them is a trivial
affair that doesn't need a loop. Similarly, there can only be up to 16
group 1 counters. Contexting them is a bit harder, but we can do with a
single branch with a falling through switch. If/when both of these
change, we have a pair of asserts and the feature detection mechanism to
guard us against pretending that we support something we don't.

We can drop contexting of the offset registers. They are fully
accessible by EL2 and as such are its responsibility to preserve on
powerdown.

Another small thing we can do, is pass the core_pos into the hook.
The caller already knows which core we're running on, we don't need to
call this non-trivial function again.

Finally, knowing this, we don't really need the auxiliary AMUs to be
described by the device tree. Linux doesn't care at the moment, and any
information we need for EL3 can be neatly placed in a simple array.

All of this, combined with lifting the actual saving out of assembly,
reduces the instructions to save the context from 180 to 40, including a
lot fewer branches. The code is also much shorter and easier to read.

Also propagate to aarch32 so that the two don't diverge too much.

Change-Id: Ib62e6e9ba5be7fb9fb8965c8eee148d5598a5361
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
2025-02-25 08:50:46 +00:00
..
arch perf(amu): greatly simplify AMU context management 2025-02-25 08:50:46 +00:00
bl1 refactor(bl1): clean up bl2 layout calculation 2024-04-26 09:00:12 +00:00
bl2 BL2_AT_EL3: Enable pointer authentication support 2019-02-27 11:58:09 +00:00
bl2u Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
bl31 Merge "refactor(sdei): use common create_spsr() in SDEI library" into integration 2024-03-14 21:17:45 +01:00
bl32 feat(cm): test integrity of el1_ctx registers 2024-11-08 11:05:13 +00:00
common feat(rmm): add PCIe IO info to Boot manifest 2025-02-11 15:10:49 +00:00
drivers Merge changes from topic "jw/gic-lca-support" into integration 2025-02-20 17:17:35 +01:00
dt-bindings fix(dt-bindings): update STM32MP2 clock and reset bindings 2024-06-27 17:17:35 +02:00
export feat(tbbr): add image id for backup GPT 2023-10-27 08:31:54 -05:00
lib perf(amu): greatly simplify AMU context management 2025-02-25 08:50:46 +00:00
plat Merge changes from topic "memory_bank" into integration 2025-02-12 10:49:42 +01:00
services feat(rmm): add PCIe IO info to Boot manifest 2025-02-11 15:10:49 +00:00
tools_share fix(tc): add SCP_BL2 to RSE measured boot 2024-06-13 15:53:10 +02:00