Skip to content

Commit

Permalink
Merge changes I00780ed8,I94be29ac,I45d247bf into integration
Browse files Browse the repository at this point in the history
* changes:
  fix(runtime): do not filter out SMCCC_VERSION function id
  fix(runtime): disable MTE on id_aa64pfr1_el1 read
  fix(runtime): add isb after writes to cptr_el2 register
  • Loading branch information
soby-mathew authored and TrustedFirmware Code Review committed Mar 7, 2023
2 parents caf2726 + 5c4411b commit 5e994c4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/arch/include/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@
#define ID_AA64PFR0_EL1_AMU_SHIFT UL(44)
#define ID_AA64PFR0_EL1_AMU_WIDTH 4

/* ID_AA64PFR1_EL1 definitions */
#define ID_AA64PFR1_EL1_MTE_SHIFT UL(8)
#define ID_AA64PFR1_EL1_MTE_WIDTH UL(4)

/* ID_AA64MMFR0_EL1 definitions */
#define ID_AA64MMFR0_EL1_PARANGE_SHIFT U(0)
#define ID_AA64MMFR0_EL1_PARANGE_WIDTH UL(4)
Expand Down
5 changes: 4 additions & 1 deletion runtime/core/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ static bool handle_realm_rsi(struct rec *rec, struct rmi_rec_exit *rec_exit)

/* cppcheck-suppress unsignedPositive */
if (!IS_SMC32_PSCI_FID(function_id) && !IS_SMC64_PSCI_FID(function_id)
&& !IS_SMC64_RSI_FID(function_id)) {
&& !IS_SMC64_RSI_FID(function_id)
&& !(function_id == SMCCC_VERSION)) {

ERROR("Invalid RSI function_id = %x\n", function_id);
rec->regs[0] = SMC_UNKNOWN;
Expand Down Expand Up @@ -588,6 +589,7 @@ static bool handle_exception_sync(struct rec *rec, struct rmi_rec_exit *rec_exit
cptr |= INPLACE(CPTR_EL2_FPEN, CPTR_EL2_FPEN_NO_TRAP_11) |
INPLACE(CPTR_EL2_ZEN, CPTR_EL2_ZEN_NO_TRAP_11);
write_cptr_el2(cptr);
isb();

/*
* Save NS state, restore realm state, and set flag indicating
Expand All @@ -611,6 +613,7 @@ static bool handle_exception_sync(struct rec *rec, struct rmi_rec_exit *rec_exit
cptr &= ~MASK(CPTR_EL2_ZEN);
cptr |= INPLACE(CPTR_EL2_ZEN, CPTR_EL2_ZEN_TRAP_ALL_00);
write_cptr_el2(cptr);
isb();

/*
* Return 'true' indicating that this exception
Expand Down
2 changes: 2 additions & 0 deletions runtime/core/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ void rec_run_loop(struct rec *rec, struct rmi_rec_exit *rec_exit)
cptr &= ~MASK(CPTR_EL2_ZEN);
cptr |= INPLACE(CPTR_EL2_ZEN, CPTR_EL2_ZEN_NO_TRAP_11);
write_cptr_el2(cptr);
isb();

fpu_save_state(&rec->fpu_ctx.fpu);
if (ns_state->sve != NULL) {
Expand All @@ -330,6 +331,7 @@ void rec_run_loop(struct rec *rec, struct rmi_rec_exit *rec_exit)
cptr |= INPLACE(CPTR_EL2_FPEN, CPTR_EL2_FPEN_TRAP_ALL_00) |
INPLACE(CPTR_EL2_ZEN, CPTR_EL2_ZEN_TRAP_ALL_00);
write_cptr_el2(cptr);
isb();
rec->fpu_ctx.used = false;
}

Expand Down
11 changes: 10 additions & 1 deletion runtime/core/sysregs.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@
MASK(ID_AA64PFR0_EL1_AMU) | \
MASK(ID_AA64PFR0_EL1_SVE)

/*
* ID_AA64PFR1_EL1:
*
* Cleared fields:
* - Memory Tagging Extension is not implemented
*/
#define ID_AA64PFR1_EL1_CLEAR \
MASK(ID_AA64PFR1_EL1_MTE)

/*
* Handle ID_AA64XXX<n>_EL1 instructions
*/
Expand Down Expand Up @@ -163,7 +172,7 @@ static bool handle_id_sysreg_trap(struct rec *rec,
value = SYSREG_READ_CLEAR(PFR0);
break;
SYSREG_CASE(PFR1)
value = SYSREG_READ(PFR1);
value = SYSREG_READ_CLEAR(PFR1);
break;
/*
* TODO: not supported without SVE:
Expand Down

0 comments on commit 5e994c4

Please sign in to comment.