<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 18, 2021 at 11:32 AM Gedare Bloom <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, Feb 17, 2021 at 12:30 PM Sebastian Huber<br>
<<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>> wrote:<br>
><br>
> Ensure that no invalid modes are set during ASR processing.<br>
><br>
> Update #4244.<br>
> ---<br>
>  cpukit/rtems/src/signalcatch.c | 27 +++++++++++++++++++++++++++<br>
>  1 file changed, 27 insertions(+)<br>
><br>
> diff --git a/cpukit/rtems/src/signalcatch.c b/cpukit/rtems/src/signalcatch.c<br>
> index 8ee22e5ec1..da56d26dc5 100644<br>
> --- a/cpukit/rtems/src/signalcatch.c<br>
> +++ b/cpukit/rtems/src/signalcatch.c<br>
> @@ -22,7 +22,10 @@<br>
>  #endif<br>
><br>
>  #include <rtems/rtems/signalimpl.h><br>
> +#include <rtems/rtems/modesimpl.h><br>
>  #include <rtems/rtems/tasksdata.h><br>
> +#include <rtems/score/schedulerimpl.h><br>
> +#include <rtems/score/smpimpl.h><br>
>  #include <rtems/score/threadimpl.h><br>
><br>
>  RTEMS_STATIC_ASSERT( RTEMS_DEFAULT_MODES == 0, _ASR_Create_mode_set );<br>
> @@ -37,7 +40,31 @@ rtems_status_code rtems_signal_catch(<br>
>    ASR_Information    *asr;<br>
>    ISR_lock_Context    lock_context;<br>
><br>
> +#if defined(RTEMS_SMP) || CPU_ENABLE_ROBUST_THREAD_DISPATCH == TRUE<br>
> +  if (<br>
> +    _Modes_Get_interrupt_level( mode_set ) != 0<br>
> +#if CPU_ENABLE_ROBUST_THREAD_DISPATCH == FALSE<br>
> +      && _SMP_Need_inter_processor_interrupts()<br>
> +#endif<br>
> +  ) {<br>
> +    return RTEMS_NOT_IMPLEMENTED;<br>
> +  }<br>
> +#endif<br>
> +<br>
>    executing = _Thread_State_acquire_for_executing( &lock_context );<br>
> +<br>
> +#if defined(RTEMS_SMP)<br>
add a brief comment here, the logic a little complicated with<br>
double-negatives, e.g.,<br>
/* Check for non-preempt mode requested with a scheduler that does not<br>
support non-preemption */<br></blockquote><div><br></div><div>I think I have seen a very similar check in other places. Can this combination <br></div><div>of logic be turned into a macro which has a better name?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> +  if (<br>
> +    !_Modes_Is_preempt( mode_set ) &&<br>
> +      !_Scheduler_Is_non_preempt_mode_supported(<br>
no indent (align the !)<br>
<br>
> +        _Thread_Scheduler_get_home( executing )<br>
> +      )<br>
> +  ) {<br>
> +    _Thread_State_release( executing, &lock_context );<br>
> +    return RTEMS_NOT_IMPLEMENTED;<br>
> +  }<br>
> +#endif<br>
> +<br>
>    api = executing->API_Extensions[ THREAD_API_RTEMS ];<br>
>    asr = &api->Signal;<br>
>    asr->handler = asr_handler;<br>
> --<br>
> 2.26.2<br>
><br>
> _______________________________________________<br>
> devel mailing list<br>
> <a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
> <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div></div>