feat(drtm): ensure that no SDEI event registered during dynamic launch

Ensured no SDEI event are registered during dynamic launch.

Signed-off-by: Manish Pandey <manish.pandey2@arm.com>
Change-Id: Ied3b2d389aa3d9a96ace9078581d5e691f0b38a7
diff --git a/services/std_svc/drtm/drtm_main.c b/services/std_svc/drtm/drtm_main.c
index 9237d82..bec4b72 100644
--- a/services/std_svc/drtm/drtm_main.c
+++ b/services/std_svc/drtm/drtm_main.c
@@ -26,6 +26,7 @@
 #include <lib/xlat_tables/xlat_tables_v2.h>
 #include <plat/common/platform.h>
 #include <services/drtm_svc.h>
+#include <services/sdei.h>
 #include <platform_def.h>
 
 /* Structure to store DRTM features specific to the platform. */
@@ -569,6 +570,13 @@
 		SMC_RET1(handle, ret);
 	}
 
+	/* Ensure that there are no SDEI event registered */
+#if SDEI_SUPPORT
+	if (sdei_get_registered_event_count() != 0) {
+		SMC_RET1(handle, DENIED);
+	}
+#endif /* SDEI_SUPPORT */
+
 	/*
 	 * Engage the DMA protections.  The launch cannot proceed without the DMA
 	 * protections due to potential TOC/TOU vulnerabilities w.r.t. the DLME
@@ -611,13 +619,6 @@
 	drtm_dl_reset_dlme_el_state(dlme_el);
 	drtm_dl_reset_dlme_context(dlme_el);
 
-	/*
-	 * TODO: Reset all SDEI event handlers, since they are untrusted.  Both
-	 * private and shared events for all cores must be unregistered.
-	 * Note that simply calling SDEI ABIs would not be adequate for this, since
-	 * there is currently no SDEI operation that clears private data for all PEs.
-	 */
-
 	drtm_dl_prepare_eret_to_dlme(&args, dlme_el);
 
 	/*