blob: 2c82364652fd8650f5c085a5820711785239b0a0 [file] [log] [blame]
Manish Pandeyf3816802023-10-11 17:13:58 +01001diff --git a/bl31/aarch64/runtime_exceptions.S b/bl31/aarch64/runtime_exceptions.S
Boyan Karatotev1f4be382025-01-10 10:39:41 +00002index 742380568..3638d9967 100644
Manish Pandeyf3816802023-10-11 17:13:58 +01003--- a/bl31/aarch64/runtime_exceptions.S
4+++ b/bl31/aarch64/runtime_exceptions.S
Boyan Karatotev1f4be382025-01-10 10:39:41 +00005@@ -709,6 +709,14 @@ subtract_elr_el3:
Manish Pandeyfb4b2ff2023-06-16 16:56:46 +01006 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
20diff --git a/services/arm_arch_svc/arm_arch_svc_setup.c b/services/arm_arch_svc/arm_arch_svc_setup.c
Boyan Karatotev1f4be382025-01-10 10:39:41 +000021index 6acd1b60f..11d23e0f1 100644
Manish Pandeyfb4b2ff2023-06-16 16:56:46 +010022--- a/services/arm_arch_svc/arm_arch_svc_setup.c
23+++ b/services/arm_arch_svc/arm_arch_svc_setup.c
Boyan Karatotev1f4be382025-01-10 10:39:41 +000024@@ -16,10 +16,30 @@
Manish Pandeyfb4b2ff2023-06-16 16:56:46 +010025 #include <plat/common/platform.h>
Boyan Karatotev1f4be382025-01-10 10:39:41 +000026 #include <arch_features.h>
27 #include <arch_helpers.h>
Manish Pandeyfb4b2ff2023-06-16 16:56:46 +010028+#include <context.h>
Boyan Karatotev1f4be382025-01-10 10:39:41 +000029 #include <lib/el3_runtime/context_mgmt.h>
30
Manish Pandeyfb4b2ff2023-06-16 16:56:46 +010031+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 Karatotev1f4be382025-01-10 10:39:41 +000040+
Manish Pandeyfb4b2ff2023-06-16 16:56:46 +010041 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 Pandey98a8a552025-06-24 17:34:03 +010052 return (int32_t)MAKE_SMCCC_VERSION(SMCCC_MAJOR_VERSION, SMCCC_MINOR_VERSION);
Manish Pandeyfb4b2ff2023-06-16 16:56:46 +010053 }
54