You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/10/17 15:53:40 UTC
[incubator-nuttx-apps] branch master updated: Fix
note_syscall_leave_s to avoid unaligned access
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 007033f Fix note_syscall_leave_s to avoid unaligned access
007033f is described below
commit 007033f2958ff6bb9eca4f894ee46bc44b00fdc9
Author: Nakamura, Yuuichi <Yu...@sony.com>
AuthorDate: Fri Oct 16 23:08:48 2020 +0900
Fix note_syscall_leave_s to avoid unaligned access
---
system/sched_note/note_main.c | 51 +++++++++++++++++++++++++++++++++++--------
system/trace/trace_dump.c | 21 ++++++++++++++++--
2 files changed, 61 insertions(+), 11 deletions(-)
diff --git a/system/sched_note/note_main.c b/system/sched_note/note_main.c
index d81708b..ad656e1 100644
--- a/system/sched_note/note_main.c
+++ b/system/sched_note/note_main.c
@@ -457,6 +457,7 @@ static void dump_notes(size_t nread)
{
FAR struct note_spinlock_s *note_spinlock =
(FAR struct note_spinlock_s *)note;
+ FAR void *spinlock;
if (note->nc_length != sizeof(struct note_spinlock_s))
{
@@ -466,6 +467,21 @@ static void dump_notes(size_t nread)
return;
}
+ spinlock = (FAR void *)
+ ((uintptr_t)note_spinlock->nsp_spinlock[0]
+ + ((uintptr_t)note_spinlock->nsp_spinlock[1] << 8)
+#if UINTPTR_MAX > UINT16_MAX
+ + ((uintptr_t)note_spinlock->nsp_spinlock[2] << 16)
+ + ((uintptr_t)note_spinlock->nsp_spinlock[3] << 24)
+#if UINTPTR_MAX > UINT32_MAX
+ + ((uintptr_t)note_spinlock->nsp_spinlock[4] << 32)
+ + ((uintptr_t)note_spinlock->nsp_spinlock[5] << 40)
+ + ((uintptr_t)note_spinlock->nsp_spinlock[6] << 48)
+ + ((uintptr_t)note_spinlock->nsp_spinlock[7] << 56)
+#endif
+#endif
+ );
+
switch (note->nc_type)
{
#ifdef CONFIG_SMP
@@ -476,7 +492,7 @@ static void dump_notes(size_t nread)
"priority %u\n",
(unsigned long)systime, (unsigned int)pid,
(unsigned int)note->nc_cpu,
- note_spinlock->nsp_spinlock,
+ spinlock,
(unsigned int)note_spinlock->nsp_value,
(unsigned int)note->nc_priority);
}
@@ -489,7 +505,7 @@ static void dump_notes(size_t nread)
"priority %u\n",
(unsigned long)systime, (unsigned int)pid,
(unsigned int)note->nc_cpu,
- note_spinlock->nsp_spinlock,
+ spinlock,
(unsigned int)note_spinlock->nsp_value,
(unsigned int)note->nc_priority);
}
@@ -502,7 +518,7 @@ static void dump_notes(size_t nread)
"priority %u\n",
(unsigned long)systime, (unsigned int)pid,
(unsigned int)note->nc_cpu,
- note_spinlock->nsp_spinlock,
+ spinlock,
(unsigned int)note_spinlock->nsp_value,
(unsigned int)note->nc_priority);
}
@@ -515,7 +531,7 @@ static void dump_notes(size_t nread)
"priority %u\n",
(unsigned long)systime, (unsigned int)pid,
(unsigned int)note->nc_cpu,
- note_spinlock->nsp_spinlock,
+ spinlock,
(unsigned int)note_spinlock->nsp_value,
(unsigned int)note->nc_priority);
}
@@ -527,7 +543,7 @@ static void dump_notes(size_t nread)
"%08lx: Task %u wait for spinlock=%p value=%u "
"priority %u\n",
(unsigned long)systime, (unsigned int)pid,
- note_spinlock->nsp_spinlock,
+ spinlock,
(unsigned int)note_spinlock->nsp_value,
(unsigned int)note->nc_priority);
}
@@ -538,7 +554,7 @@ static void dump_notes(size_t nread)
syslog(LOG_INFO,
"%08lx: Task %u has spinlock=%p value=%u priority %u\n",
(unsigned long)systime, (unsigned int)pid,
- note_spinlock->nsp_spinlock,
+ spinlock,
(unsigned int)note_spinlock->nsp_value,
(unsigned int)note->nc_priority);
}
@@ -550,7 +566,7 @@ static void dump_notes(size_t nread)
"%08lx: Task %u unlocking spinlock=%p value=%u "
"priority %u\n",
(unsigned long)systime, (unsigned int)pid,
- (unsigned int)note->nc_cpu,
+ spinlock,
(unsigned int)note_spinlock->nsp_value,
(unsigned int)note->nc_priority);
}
@@ -562,13 +578,15 @@ static void dump_notes(size_t nread)
"%08lx: Task %u abort wait on spinlock=%p value=%u "
"priority %u\n",
(unsigned long)systime, (unsigned int)pid,
- note_spinlock->nsp_spinlock,
+ spinlock,
(unsigned int)note_spinlock->nsp_value,
(unsigned int)note->nc_priority);
}
break;
#endif
}
+ break;
+ }
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
@@ -596,6 +614,7 @@ static void dump_notes(size_t nread)
{
FAR struct note_syscall_leave_s *note_sysleave =
(FAR struct note_syscall_leave_s *)note;
+ uintptr_t result;
if (note->nc_length != sizeof(struct note_syscall_leave_s))
{
@@ -605,10 +624,24 @@ static void dump_notes(size_t nread)
return;
}
+ result = (uintptr_t)note_sysleave->nsc_result[0]
+ + ((uintptr_t)note_sysleave->nsc_result[1] << 8)
+#if UINTPTR_MAX > UINT16_MAX
+ + ((uintptr_t)note_sysleave->nsc_result[2] << 16)
+ + ((uintptr_t)note_sysleave->nsc_result[3] << 24)
+#if UINTPTR_MAX > UINT32_MAX
+ + ((uintptr_t)note_sysleave->nsc_result[4] << 32)
+ + ((uintptr_t)note_sysleave->nsc_result[5] << 40)
+ + ((uintptr_t)note_sysleave->nsc_result[6] << 48)
+ + ((uintptr_t)note_sysleave->nsc_result[7] << 56)
+#endif
+#endif
+ ;
+
syslog(LOG_INFO,
"%08lx: Task %u Leave SYSCALL %d: %" PRIdPTR "\n",
(unsigned long)systime, (unsigned int)pid,
- note_sysleave->nsc_nr, note_sysleave->nsc_result);
+ note_sysleave->nsc_nr, result);
}
break;
#endif
diff --git a/system/trace/trace_dump.c b/system/trace/trace_dump.c
index a2f3243..bc936dd 100644
--- a/system/trace/trace_dump.c
+++ b/system/trace/trace_dump.c
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <inttypes.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
@@ -459,6 +460,7 @@ static int trace_dump_one(FAR FILE *out,
{
FAR struct note_syscall_leave_s *nsc;
FAR struct trace_dump_task_context_s *tctx;
+ uintptr_t result;
/* Exclude the case of syscall issued by an interrupt handler and
* nested syscalls to correct tracecompass display.
@@ -491,9 +493,24 @@ static int trace_dump_one(FAR FILE *out,
}
trace_dump_header(out, note, ctx);
- fprintf(out, "sys_%s -> 0x%x\n",
+
+ result = (uintptr_t)nsc->nsc_result[0]
+ + ((uintptr_t)nsc->nsc_result[1] << 8)
+#if UINTPTR_MAX > UINT16_MAX
+ + ((uintptr_t)nsc->nsc_result[2] << 16)
+ + ((uintptr_t)nsc->nsc_result[3] << 24)
+#if UINTPTR_MAX > UINT32_MAX
+ + ((uintptr_t)nsc->nsc_result[4] << 32)
+ + ((uintptr_t)nsc->nsc_result[5] << 40)
+ + ((uintptr_t)nsc->nsc_result[6] << 48)
+ + ((uintptr_t)nsc->nsc_result[7] << 56)
+#endif
+#endif
+ ;
+
+ fprintf(out, "sys_%s -> 0x%" PRIxPTR "\n",
g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED],
- nsc->nsc_result);
+ result);
}
break;
#endif