| 8cd9c18b | 08-Dec-2025 |
Boyan Karatotev <boyan.karatotev@arm.com> |
fix(cpufeat): prevent FEAT_AMU counters 2 and 3 from counting across worlds
FEAT_AMU has 4 architected counters. The lower 2, CPU_CYCLES and CNT_CYCLES, are not considered to be side channels due to
fix(cpufeat): prevent FEAT_AMU counters 2 and 3 from counting across worlds
FEAT_AMU has 4 architected counters. The lower 2, CPU_CYCLES and CNT_CYCLES, are not considered to be side channels due to their low resolution and general availability of the data elsewhere. As such, they are used for critical performance tuning and are expected to never be turned off or context switched when switching worlds.
The upper 2 counters, INST_RETIRED and STALL_BACKEND_MEM, are different. The data they provide is non-critical and expose new information that could be used as a timing side channel, especially of Secure world. This patch adds context switching of these two counters to prevent any such side channel.
This is not done for group 1 auxiliary counters as those are IMP DEF and are inaccessible by default unless overriden by the platform (with AMU_RESTRICT_COUNTERS).
Change-Id: Ib4b946abb810e36736cabb9b84cd837308b4e761 Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
show more ...
|
| 753c749c | 04-Dec-2025 |
Boyan Karatotev <boyan.karatotev@arm.com> |
fix(cpufeat): disable FEAT_AMU counters on context restore
The FEAT_AMU counters observe UNPREDICTABLE behaviour if written to while counting so they must be disabled first. Further, the save happen
fix(cpufeat): disable FEAT_AMU counters on context restore
The FEAT_AMU counters observe UNPREDICTABLE behaviour if written to while counting so they must be disabled first. Further, the save happens on the PE's powerdown path and the restore happens on the wakeup path so any disable will likely get lost on wakeup.
So add a disable from to the restore path. The restore path will usually have the AMU reset and as such all counters disabled. There is a chance though that the AMU might not have reset with the PE (which is IMPDEF) or a pabandon might have happened so also add a check to skip disabling the counters if they already are.
Even though reading AMU counters while they are enabled is perfectly permissible, keep the disable so that the snapshot of saved values is coherent. Otherwise, over many saves and restores, the values of the later read counters could get out of sync with the ones read earlier.
Change-Id: Iefe6de44f09d8659a6118d5fea40abf82c44be16 Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
show more ...
|
| f396aec8 | 09-Sep-2025 |
Arvind Ram Prakash <arvind.ramprakash@arm.com> |
feat(cpufeat): add support for FEAT_IDTE3
This patch adds support for FEAT_IDTE3, which introduces support for handling the trapping of Group 3 and Group 5 (only GMID_EL1) registers to EL3 (unless t
feat(cpufeat): add support for FEAT_IDTE3
This patch adds support for FEAT_IDTE3, which introduces support for handling the trapping of Group 3 and Group 5 (only GMID_EL1) registers to EL3 (unless trapped to EL2). IDTE3 allows EL3 to modify the view of ID registers for lower ELs, and this capability is used to disable fields of ID registers tied to disabled features.
The ID registers are initially read as-is and stored in context. Then, based on the feature enablement status for each world, if a particular feature is disabled, its corresponding field in the cached ID register is set to Res0. When lower ELs attempt to read an ID register, the cached ID register value is returned. This allows EL3 to prevent lower ELs from accessing feature-specific system registers that are disabled in EL3, even though the hardware implements them.
The emulated ID register values are stored primarily in per-world context, except for certain debug-related ID registers such as ID_AA64DFR0_EL1 and ID_AA64DFR1_EL1, which are stored in the cpu_data and are unique to each PE. This is done to support feature asymmetry that is commonly seen in debug features.
FEAT_IDTE3 traps all Group 3 ID registers in the range op0 == 3, op1 == 0, CRn == 0, CRm == {2–7}, op2 == {0–7} and the Group 5 GMID_EL1 register. However, only a handful of ID registers contain fields used to detect features enabled in EL3. Hence, we only cache those ID registers, while the rest are transparently returned as is to the lower EL.
This patch updates the CREATE_FEATURE_FUNCS macro to generate update_feat_xyz_idreg_field() functions that disable ID register fields on a per-feature basis. The enabled_worlds scope is used to disable ID register fields for security states where the feature is not enabled.
This EXPERIMENTAL feature is controlled by the ENABLE_FEAT_IDTE3 build flag and is currently disabled by default.
Signed-off-by: Arvind Ram Prakash <arvind.ramprakash@arm.com> Change-Id: I5f998eeab81bb48c7595addc5595313a9ebb96d5
show more ...
|