[PATCH 11/13] rtems: New errors for rtems_signal_catch()

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Feb 17 19:30:26 UTC 2021


Ensure that no invalid modes are set during ASR processing.

Update #4244.
---
 cpukit/rtems/src/signalcatch.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/cpukit/rtems/src/signalcatch.c b/cpukit/rtems/src/signalcatch.c
index 8ee22e5ec1..da56d26dc5 100644
--- a/cpukit/rtems/src/signalcatch.c
+++ b/cpukit/rtems/src/signalcatch.c
@@ -22,7 +22,10 @@
 #endif
 
 #include <rtems/rtems/signalimpl.h>
+#include <rtems/rtems/modesimpl.h>
 #include <rtems/rtems/tasksdata.h>
+#include <rtems/score/schedulerimpl.h>
+#include <rtems/score/smpimpl.h>
 #include <rtems/score/threadimpl.h>
 
 RTEMS_STATIC_ASSERT( RTEMS_DEFAULT_MODES == 0, _ASR_Create_mode_set );
@@ -37,7 +40,31 @@ rtems_status_code rtems_signal_catch(
   ASR_Information    *asr;
   ISR_lock_Context    lock_context;
 
+#if defined(RTEMS_SMP) || CPU_ENABLE_ROBUST_THREAD_DISPATCH == TRUE
+  if (
+    _Modes_Get_interrupt_level( mode_set ) != 0
+#if CPU_ENABLE_ROBUST_THREAD_DISPATCH == FALSE
+      && _SMP_Need_inter_processor_interrupts()
+#endif
+  ) {
+    return RTEMS_NOT_IMPLEMENTED;
+  }
+#endif
+
   executing = _Thread_State_acquire_for_executing( &lock_context );
+
+#if defined(RTEMS_SMP)
+  if (
+    !_Modes_Is_preempt( mode_set ) &&
+      !_Scheduler_Is_non_preempt_mode_supported(
+        _Thread_Scheduler_get_home( executing )
+      )
+  ) {
+    _Thread_State_release( executing, &lock_context );
+    return RTEMS_NOT_IMPLEMENTED;
+  }
+#endif
+
   api = executing->API_Extensions[ THREAD_API_RTEMS ];
   asr = &api->Signal;
   asr->handler = asr_handler;
-- 
2.26.2



More information about the devel mailing list