Manish Pandey | fb4b2ff | 2023-06-16 16:56:46 +0100 | [diff] [blame^] | 1 | diff --git a/bl31/aarch64/ea_delegate.S b/bl31/aarch64/ea_delegate.S |
| 2 | index c6790a2f9..c67fa30ee 100644 |
| 3 | --- a/bl31/aarch64/ea_delegate.S |
| 4 | +++ b/bl31/aarch64/ea_delegate.S |
| 5 | @@ -256,6 +256,14 @@ skip_loop_ctr: |
| 6 | sub x28, x28, #4 |
| 7 | skip_smc_check: |
| 8 | msr elr_el3, x28 |
| 9 | + mrs x30, spsr_el3 |
| 10 | + /* Clear PSTATE.A bit so that tftf can take SError */ |
| 11 | + bic x30, x30, # (1 << 8) |
| 12 | + msr spsr_el3, x30 |
| 13 | + /* Route IRQ to be routed to tftf again */ |
| 14 | + mrs x30, scr_el3 |
| 15 | + bic x30, x30, SCR_IRQ_BIT |
| 16 | + msr scr_el3, x30 |
| 17 | ldp x28, x29, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X28] |
| 18 | ldr x30, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_LR] |
| 19 | exception_return |
| 20 | diff --git a/services/arm_arch_svc/arm_arch_svc_setup.c b/services/arm_arch_svc/arm_arch_svc_setup.c |
| 21 | index bb042c70e..a4b488005 100644 |
| 22 | --- a/services/arm_arch_svc/arm_arch_svc_setup.c |
| 23 | +++ b/services/arm_arch_svc/arm_arch_svc_setup.c |
| 24 | @@ -14,9 +14,30 @@ |
| 25 | #include <services/arm_arch_svc.h> |
| 26 | #include <smccc_helpers.h> |
| 27 | #include <plat/common/platform.h> |
| 28 | +#include <context.h> |
| 29 | +#include <lib/el3_runtime/context_mgmt.h> |
| 30 | + |
| 31 | +static void modify_scr_el3_irq(void) |
| 32 | +{ |
| 33 | + u_register_t scr_el3; |
| 34 | + cpu_context_t *ctx = cm_get_context(NON_SECURE); |
| 35 | + el3_state_t *el3_ctx = get_el3state_ctx(ctx); |
| 36 | + scr_el3 = read_ctx_reg(el3_ctx, CTX_SCR_EL3); |
| 37 | + scr_el3 |= SCR_IRQ_BIT; |
| 38 | + write_ctx_reg(el3_ctx, CTX_SCR_EL3, scr_el3); |
| 39 | +} |
| 40 | |
| 41 | static int32_t smccc_version(void) |
| 42 | { |
| 43 | + /* |
| 44 | + * This function is called tftf as part of testing SError reflection |
| 45 | + * from EL3 to lower EL. |
| 46 | + * Temporarily target tftf IRQ to EL3, trigger IRQ in tftf while SError |
| 47 | + * is pending which will cause lower EL IRQ handler in EL3, on finding |
| 48 | + * a pending SError EL3 will reflect back to tftf also in ret path make |
| 49 | + * sure SCR_EL3.IRQ is cleared so that IRQ is now handled in lower EL |
| 50 | + */ |
| 51 | + modify_scr_el3_irq(); |
| 52 | return MAKE_SMCCC_VERSION(SMCCC_MAJOR_VERSION, SMCCC_MINOR_VERSION); |
| 53 | } |
| 54 | |