Skip to content

Commit

Permalink
Merge "fix(cm): change back owning security state when a feature is d…
Browse files Browse the repository at this point in the history
…isabled" into integration
  • Loading branch information
odeprez authored and TrustedFirmware Code Review committed Jan 14, 2025
2 parents d0658e6 + 13f4a25 commit 9ac82c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
13 changes: 4 additions & 9 deletions lib/extensions/spe/spe.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,14 @@ void spe_disable(cpu_context_t *ctx)
u_register_t mdcr_el3_val = read_ctx_reg(state, CTX_MDCR_EL3);

/*
* MDCR_EL3.NSPB: set to 0x2. After, Non-Secure state owns
* the Profiling Buffer and accesses to Statistical Profiling and Profiling
* Buffer control registers at EL2 and EL1 generate Trap exceptions to EL3.
* Profiling is disabled in Secure and Realm states.
*
* MDCR_EL3.NSPBE: Don't care as it was cleared during spe_enable and setting
* this to 1 does not make sense as NSPBE{1} and NSPB{0b0x} is RESERVED.
* MDCR_EL3.{NSPB,NSPBE} = 0b00, 0b0
* Disable access of profiling buffer control registers from lower ELs
* in any security state. Secure state owns the buffer.
*
* MDCR_EL3.EnPMSN (ARM v8.7): Clear the bit to trap access of PMSNEVFR_EL1
* from EL2/EL1 to EL3.
*/
mdcr_el3_val &= ~(MDCR_NSPB(MDCR_NSPB_EL1) | MDCR_EnPMSN_BIT);
mdcr_el3_val |= MDCR_NSPB(MDCR_NSPB_EL3);
mdcr_el3_val &= ~(MDCR_NSPB(MDCR_NSPB_EL1) | MDCR_NSPBE_BIT | MDCR_EnPMSN_BIT);
write_ctx_reg(state, CTX_MDCR_EL3, mdcr_el3_val);
}

Expand Down
5 changes: 2 additions & 3 deletions lib/extensions/trbe/trbe.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ void trbe_disable(cpu_context_t *ctx)
u_register_t mdcr_el3_val = read_ctx_reg(state, CTX_MDCR_EL3);

/*
* MDCR_EL3.{NSTBE,NSTB} = 0b0, 0b10
* MDCR_EL3.{NSTBE,NSTB} = 0b0, 0b00
* Disable access of trace buffer control registers from lower ELs in
* any security state. Non-secure owns the buffer.
* any security state. Secure state owns the buffer.
*/
mdcr_el3_val &= ~(MDCR_NSTB(MDCR_NSTB_EL1));
mdcr_el3_val &= ~(MDCR_NSTBE_BIT);
mdcr_el3_val |= MDCR_NSTB(MDCR_NSTB_EL3);
write_ctx_reg(state, CTX_MDCR_EL3, mdcr_el3_val);
}

Expand Down

0 comments on commit 9ac82c4

Please sign in to comment.