Minor bug in libmisc

Maksim Kozlov maksim.e.kozlov at gmail.com
Wed Jan 23 16:23:18 UTC 2019


Hi,

I encountered an error when tried launch 'top' command from RTEMS Sell:

SHLL [/] # top

*** FATAL ***
fatal source: 0 (INTERNAL_ERROR_CORE)
fatal code: 38 (INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT)
RTEMS version: 5.0.0.97cce5c9a18563f58aadc2af1049957420ad561d-modified
RTEMS tools: 7.4.0 20181206 (RTEMS 5, RSB
0bb29a38fb73342c3c25c6917884e08f7386a6f4, Newlib
dc6e94551f09d3a983afd571478d)
executing thread ID: 0x08a010004
executing thread name: CPlt
Idle loop start...

After some investigation, I found out that this occurs because lazy
floating point switch mechanism triggered here:

040536d4 <_vfprintf_r>:

 40537a0:       03 01 01 b4     sethi  %hi(0x406d000), %g1
 40537a4:       c0 27 bf 54     clr  [ %fp + -172 ]
 40537a8:       d1 18 63 58     ldd  [ %g1 + 0x358 ], %f8
 40537ac:       c0 27 bf 50     clr  [ %fp + -176 ]
 40537b0:       25 01 01 b5     sethi  %hi(0x406d400), %l2
 40537b4:       c0 27 be ac     clr  [ %fp + -340 ]
 40537b8:       d1 3f be b8     std  %f8, [ %fp + -328 ]
 40537bc:       c0 27 be a0     clr  [ %fp + -352 ]

and after following check in cpukit/score/cpu/sparc/syscall.S we get
mentioned error

/* Ensure that we are a proper floating point thread */
cmp    %l6, 0
be    .Lillegal_use_of_floating_point_unit
 ld    [%l4 + %lo(SPARC_THREAD_CONTROL_REGISTERS_FP_CONTEXT_OFFSET)], %l6

This is because in rtems_task_create(), at first, was swapped modes and
attributes, and, at second, was not enabled FP flag. So, I hope the
attached small patch resolves this.
--
Best regards,
Maksim Kozlov

>From d48f4c13c61a9287ddf55b33564ce4816e77f40b Mon Sep 17 00:00:00 2001
From: Maksim E. Kozlov <maksim.e.kozlov at gmail.com>
Date: Wed, 23 Jan 2019 15:17:44 +0300
Subject: [PATCH] libmisc: Fix swapped parameters and enable floating point
 usage.

---
 cpukit/libmisc/cpuuse/cpuusagetop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/libmisc/cpuuse/cpuusagetop.c
b/cpukit/libmisc/cpuuse/cpuusagetop.c
index 8e0063bc88..c4bfa704d1 100644
--- a/cpukit/libmisc/cpuuse/cpuusagetop.c
+++ b/cpukit/libmisc/cpuuse/cpuusagetop.c
@@ -530,8 +530,8 @@ void rtems_cpu_usage_top_with_plugin(
   name = rtems_build_name('C', 'P', 'l', 't');

   sc = rtems_task_create (name, priority, 4 * 1024,
-                          RTEMS_NO_FLOATING_POINT | RTEMS_LOCAL,
                           RTEMS_PREEMPT | RTEMS_TIMESLICE | RTEMS_NO_ASR,
+                          RTEMS_FLOATING_POINT | RTEMS_LOCAL,
                           &id);

   if (sc != RTEMS_SUCCESSFUL)
--
2.17.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20190123/af308e77/attachment.html>


More information about the devel mailing list