[PATCH] sptests/spfatal26: Use an illegal instruction

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Jul 19 13:37:31 UTC 2018


I thought about adding a _CPU_Illegal_instruction() function to 
<rtems/score/cpu.h>. But, do you want such a toxic function in a header 
file or librtemscpu.a? Now it is isolated in the test and can do no harm.

On 19/07/18 15:35, Joel Sherrill wrote:
> This looks like a good approach. If 0 is a valid instruction on
> some architecture, we can add a conditional.
>
> On Thu, Jul 19, 2018 at 5:55 AM, Sebastian Huber 
> <sebastian.huber at embedded-brains.de 
> <mailto:sebastian.huber at embedded-brains.de>> wrote:
>
>     On some architectures/simulators it is difficult to provoke an
>     exception with misaligned or illegal data loads.  Use an illegal
>     instruction instead.
>
>     Update #3433.
>     ---
>      testsuites/sptests/spfatal26/init.c | 10 +++++++++-
>      1 file changed, 9 insertions(+), 1 deletion(-)
>
>     diff --git a/testsuites/sptests/spfatal26/init.c
>     b/testsuites/sptests/spfatal26/init.c
>     index 1848659d6a..7d635f3b84 100644
>     --- a/testsuites/sptests/spfatal26/init.c
>     +++ b/testsuites/sptests/spfatal26/init.c
>     @@ -1,5 +1,5 @@
>      /*
>     - * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
>     + * Copyright (c) 2012, 2018 embedded brains GmbH.  All rights
>     reserved.
>       *
>       *  embedded brains GmbH
>       *  Obere Lagerstr. 30
>     @@ -24,6 +24,13 @@
>
>      const char rtems_test_name[] = "SPFATAL 26";
>
>     +static void provoke_illegal_instruction_exception( void )
>     +{
>     +#ifdef __riscv
>     +  __asm__ volatile (".word 0");
>     +#endif
>     +}
>     +
>      static void provoke_aligment_or_data_access_exception( void )
>      {
>        uintptr_t one = 1;
>     @@ -53,6 +60,7 @@ static void Init( rtems_task_argument arg )
>      {
>        TEST_BEGIN();
>
>     +  provoke_illegal_instruction_exception();
>        provoke_aligment_or_data_access_exception();
>
>        rtems_test_assert( 0 );
>     -- 
>     2.13.7
>
>     _______________________________________________
>     devel mailing list
>     devel at rtems.org <mailto:devel at rtems.org>
>     http://lists.rtems.org/mailman/listinfo/devel
>     <http://lists.rtems.org/mailman/listinfo/devel>
>
>

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list