Manish Pandey | f381680 | 2023-10-11 17:13:58 +0100 | [diff] [blame] | 1 | diff --git a/bl31/aarch64/runtime_exceptions.S b/bl31/aarch64/runtime_exceptions.S |
Boyan Karatotev | 1f4be38 | 2025-01-10 10:39:41 +0000 | [diff] [blame] | 2 | index 742380568..3638d9967 100644 |
Manish Pandey | f381680 | 2023-10-11 17:13:58 +0100 | [diff] [blame] | 3 | --- a/bl31/aarch64/runtime_exceptions.S |
| 4 | +++ b/bl31/aarch64/runtime_exceptions.S |
Boyan Karatotev | 1f4be38 | 2025-01-10 10:39:41 +0000 | [diff] [blame] | 5 | @@ -709,6 +709,14 @@ subtract_elr_el3: |
Manish Pandey | fb4b2ff | 2023-06-16 16:56:46 +0100 | [diff] [blame] | 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 |
Boyan Karatotev | 1f4be38 | 2025-01-10 10:39:41 +0000 | [diff] [blame] | 21 | index 6acd1b60f..11d23e0f1 100644 |
Manish Pandey | fb4b2ff | 2023-06-16 16:56:46 +0100 | [diff] [blame] | 22 | --- a/services/arm_arch_svc/arm_arch_svc_setup.c |
| 23 | +++ b/services/arm_arch_svc/arm_arch_svc_setup.c |
Boyan Karatotev | 1f4be38 | 2025-01-10 10:39:41 +0000 | [diff] [blame] | 24 | @@ -16,10 +16,30 @@ |
Manish Pandey | fb4b2ff | 2023-06-16 16:56:46 +0100 | [diff] [blame] | 25 | #include <plat/common/platform.h> |
Boyan Karatotev | 1f4be38 | 2025-01-10 10:39:41 +0000 | [diff] [blame] | 26 | #include <arch_features.h> |
| 27 | #include <arch_helpers.h> |
Manish Pandey | fb4b2ff | 2023-06-16 16:56:46 +0100 | [diff] [blame] | 28 | +#include <context.h> |
Boyan Karatotev | 1f4be38 | 2025-01-10 10:39:41 +0000 | [diff] [blame] | 29 | #include <lib/el3_runtime/context_mgmt.h> |
| 30 | |
Manish Pandey | fb4b2ff | 2023-06-16 16:56:46 +0100 | [diff] [blame] | 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 | +} |
Boyan Karatotev | 1f4be38 | 2025-01-10 10:39:41 +0000 | [diff] [blame] | 40 | + |
Manish Pandey | fb4b2ff | 2023-06-16 16:56:46 +0100 | [diff] [blame] | 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(); |
Manish Pandey | 98a8a55 | 2025-06-24 17:34:03 +0100 | [diff] [blame^] | 52 | return (int32_t)MAKE_SMCCC_VERSION(SMCCC_MAJOR_VERSION, SMCCC_MINOR_VERSION); |
Manish Pandey | fb4b2ff | 2023-06-16 16:56:46 +0100 | [diff] [blame] | 53 | } |
| 54 | |