From af2c9ecdf1b68c6243f6d23e26d0281d182d3b45 Mon Sep 17 00:00:00 2001 From: Jeenu Viswambharan Date: Wed, 17 Jan 2018 12:30:11 +0000 Subject: SDEI: Allow platforms to define explicit events The current macros only allow to define dynamic and statically-bound SDEI events. However, there ought be a mechanism to define SDEI events that are explicitly dispatched; i.e., events that are dispatched as a result of a previous secure interrupt or other exception This patch introduces SDEI_EXPLICIT_EVENT() macro to define an explicit event. They must be placed under private mappings. Only the priority flags are allowed to be additionally specified. Documentation updated. Change-Id: I2e12f5571381195d6234c9dfbd5904608ad41db3 Signed-off-by: Jeenu Viswambharan --- include/services/sdei.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include/services') diff --git a/include/services/sdei.h b/include/services/sdei.h index ce9a008c..ee3531cb 100644 --- a/include/services/sdei.h +++ b/include/services/sdei.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -52,6 +52,7 @@ #define _SDEI_MAPF_SIGNALABLE_SHIFT 3 #define _SDEI_MAPF_PRIVATE_SHIFT 4 #define _SDEI_MAPF_CRITICAL_SHIFT 5 +#define _SDEI_MAPF_EXPLICIT_SHIFT 6 /* SDEI event 0 */ #define SDEI_EVENT_0 0 @@ -81,9 +82,12 @@ */ #define SDEI_MAPF_DYNAMIC BIT(_SDEI_MAPF_DYNAMIC_SHIFT) #define SDEI_MAPF_BOUND BIT(_SDEI_MAPF_BOUND_SHIFT) +#define SDEI_MAPF_EXPLICIT BIT(_SDEI_MAPF_EXPLICIT_SHIFT) #define SDEI_MAPF_SIGNALABLE BIT(_SDEI_MAPF_SIGNALABLE_SHIFT) #define SDEI_MAPF_PRIVATE BIT(_SDEI_MAPF_PRIVATE_SHIFT) + +#define SDEI_MAPF_NORMAL 0 #define SDEI_MAPF_CRITICAL BIT(_SDEI_MAPF_CRITICAL_SHIFT) /* Indices of private and shared mappings */ @@ -114,6 +118,9 @@ #define SDEI_DEFINE_EVENT_0(_intr) \ SDEI_PRIVATE_EVENT(SDEI_EVENT_0, _intr, SDEI_MAPF_SIGNALABLE) +#define SDEI_EXPLICIT_EVENT(_event, _pri) \ + SDEI_EVENT_MAP(_event, 0, _pri | SDEI_MAPF_EXPLICIT | SDEI_MAPF_PRIVATE) + /* * Declare shared and private entries for each core. Also declare a global * structure containing private and share entries. -- cgit v1.2.3 From cdb6ac94ecb3c4caa784cd4d7580cf6252146196 Mon Sep 17 00:00:00 2001 From: Jeenu Viswambharan Date: Fri, 16 Feb 2018 12:07:48 +0000 Subject: SDEI: Make dispatches synchronous SDEI event dispatches currently only sets up the Non-secure context before returning to the caller. The actual dispatch only happens upon exiting EL3 next time. However, for various error handling scenarios, it's beneficial to have the dispatch happen synchronously. I.e. when receiving SDEI interrupt, or for a successful sdei_dispatch_event() call, the event handler is executed; and upon the event completion, dispatcher execution resumes after the point of dispatch. The jump primitives introduced in the earlier patch facilitates this feature. With this patch: - SDEI interrupts and calls to sdei_dispatch_event prepares the NS context for event dispatch, then sets a jump point, and immediately exits EL3. This results in the client handler executing in Non-secure. - When the SDEI client completes the dispatched event, the SDEI dispatcher does a longjmp to the jump pointer created earlier. For the caller of the sdei_dispatch_event() in particular, this would appear as if call returned successfully. The dynamic workaround for CVE_2018_3639 is slightly shifted around as part of related minor refactoring. It doesn't affect the workaround functionality. Documentation updated. NOTE: This breaks the semantics of the explicit dispatch API, and any exiting usages should be carefully reviewed. Change-Id: Ib9c876d27ea2af7fb22de49832e55a0da83da3f9 Signed-off-by: Jeenu Viswambharan --- include/services/sdei.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/services') diff --git a/include/services/sdei.h b/include/services/sdei.h index ee3531cb..79d1d065 100644 --- a/include/services/sdei.h +++ b/include/services/sdei.h @@ -183,6 +183,6 @@ uint64_t sdei_smc_handler(uint32_t smc_fid, void sdei_init(void); /* Public API to dispatch an event to Normal world */ -int sdei_dispatch_event(int ev_num, unsigned int preempted_sec_state); +int sdei_dispatch_event(int ev_num); #endif /* __SDEI_H__ */ -- cgit v1.2.3