[rtems-central commit] spec: Improve bad thread dispatch validation

Sebastian Huber sebh at rtems.org
Wed Apr 17 09:27:23 UTC 2024


Module:    rtems-central
Branch:    master
Commit:    05f8d633dfd206486b822a654b9d8f8f1957af93
Changeset: http://git.rtems.org/rtems-central/commit/?id=05f8d633dfd206486b822a654b9d8f8f1957af93

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Mar  7 09:29:01 2024 +0100

spec: Improve bad thread dispatch validation

---

 spec/score/val/fatal.yml | 68 +++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 59 insertions(+), 9 deletions(-)

diff --git a/spec/score/val/fatal.yml b/spec/score/val/fatal.yml
index d5e414ab..09664807 100644
--- a/spec/score/val/fatal.yml
+++ b/spec/score/val/fatal.yml
@@ -1,12 +1,12 @@
 SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
 copyrights:
-- Copyright (C) 2021 embedded brains GmbH & Co. KG
+- Copyright (C) 2021, 2024 embedded brains GmbH & Co. KG
 enabled-by: true
 links: []
 test-actions:
 - action-brief: |
     Construct a task with a task body which returns.  Check that the right
-    fatal error occurs.
+    fatal error occurred.
   action-code: |
     rtems_id     id;
     unsigned int counter;
@@ -26,9 +26,10 @@ test-actions:
   - role: validation
     uid: ../thread/req/fatal-thread-exitted
 - action-brief: |
-    Construct a task which performs a thread dispatch with maskable interrupts
-    disabled.  Check that the right fatal error occurs or no fatal error
-    occurs.
+    Construct a task which performs a direct thread dispatch with maskable
+    interrupts disabled.  Where robust thread dispatching is required, check
+    that the right fatal error occurred, otherwise check that no fatal error
+    occurred.
   action-code: |
     rtems_id     id;
     unsigned int counter;
@@ -37,7 +38,44 @@ test-actions:
     SetSelfPriority( PRIO_NORMAL );
     counter = ResetFatalInfo( ctx );
     id = CreateTask( "BENV", PRIO_HIGH );
-    StartTask( id, ISRDisabledThreadDispatchTask, NULL );
+    StartTask( id, ISRDisabledDirectThreadDispatchTask, NULL );
+
+    #if CPU_ENABLE_ROBUST_THREAD_DISPATCH == FALSE
+    if ( rtems_configuration_get_maximum_processors() > 1 ) {
+    #endif
+      T_eq_uint( GetFatalCounter( ctx ), counter + 1 );
+      T_eq_int( ctx->source, INTERNAL_ERROR_CORE );
+      T_eq_ulong( ctx->code, INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT );
+    #if CPU_ENABLE_ROBUST_THREAD_DISPATCH == FALSE
+    } else {
+      T_eq_uint( GetFatalCounter( ctx ), counter );
+    }
+    #endif
+
+    RestoreRunnerPriority();
+    SetFatalHandler( NULL, NULL );
+  checks: []
+  links:
+  - role: validation
+    uid: ../thread/req/fatal-bad-thread-dispatch-environment-ipi
+  - role: validation
+    uid: ../thread/req/fatal-bad-thread-dispatch-environment-robust
+  - role: validation
+    uid: ../thread/req/thread-dispatch-isr-disabled
+- action-brief: |
+    Construct a task which performs an on demand thread dispatch with maskable
+    interrupts disabled.  Where robust thread dispatching is required, check
+    that the right fatal error occurred, otherwise check that no fatal error
+    occurred.
+  action-code: |
+    rtems_id     id;
+    unsigned int counter;
+
+    SetFatalHandler( FatalBadThreadDispatchEnvironment, ctx );
+    SetSelfPriority( PRIO_NORMAL );
+    counter = ResetFatalInfo( ctx );
+    id = CreateTask( "BENV", PRIO_HIGH );
+    StartTask( id, ISRDisabledOnDemandThreadDispatchTask, NULL );
 
     #if CPU_ENABLE_ROBUST_THREAD_DISPATCH == FALSE
     if ( rtems_configuration_get_maximum_processors() > 1 ) {
@@ -63,7 +101,8 @@ test-actions:
     uid: ../thread/req/thread-dispatch-isr-disabled
 - action-brief: |
     Construct a task which performs a direct thread dispatch with a thread
-    dispatch level not equal to one.  Check that the right fatal error occurs.
+    dispatch level not equal to one.  Check that the right fatal error
+    occurred.
   action-code: |
     rtems_id     id;
     unsigned int counter;
@@ -238,10 +277,11 @@ test-support: |
   {
     Fatal( source, code, arg );
     _ISR_Set_level( 0 );
-    _Thread_Dispatch_direct_no_return( _Per_CPU_Get() );
+    _Thread_Dispatch_unnest( _Per_CPU_Get() );
+    rtems_task_exit();
   }
 
-  static void ISRDisabledThreadDispatchTask( rtems_task_argument arg )
+  static void ISRDisabledDirectThreadDispatchTask( rtems_task_argument arg )
   {
     rtems_interrupt_level level;
 
@@ -251,6 +291,16 @@ test-support: |
     rtems_task_exit();
   }
 
+  static void ISRDisabledOnDemandThreadDispatchTask( rtems_task_argument arg )
+  {
+    rtems_interrupt_level level;
+
+    (void) arg;
+    rtems_interrupt_local_disable( level );
+    (void) level;
+    SetSelfPriority( PRIO_VERY_HIGH );
+  }
+
   static void FatalBadThreadDispatchDisableLevel(
     rtems_fatal_source source,
     rtems_fatal_code   code,



More information about the vc mailing list