summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2020-03-29 20:43:15 +0200
committerEugene Syromyatnikov <evgsyr@gmail.com>2020-03-29 20:44:23 +0200
commit6fedfc350c3ebdf13d5c2b03184d795c23edc3b0 (patch)
tree3359c66d45a3d1d5d0346927222e53c33ffd80f1
parent62affd87ed2656d944c594b9e523e5d2d731141b (diff)
downloadstrace-esyr/next-ng2.tar.gz
powerpc: decode spu_run and spu_create syscallsesyr/next-ng2
-rw-r--r--Makefile.am1
-rw-r--r--linux/powerpc/syscallent.h4
-rw-r--r--linux/powerpc64/syscallent.h4
-rw-r--r--spu.c147
-rw-r--r--xlat/spu_create_flags.in6
-rw-r--r--xlat/spu_run_events.in6
-rw-r--r--xlat/spu_run_status_flags.in9
7 files changed, 173 insertions, 4 deletions
diff --git a/Makefile.am b/Makefile.am
index 88ede1dc7..8bbda1c51 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -312,6 +312,7 @@ strace_SOURCES = \
sockaddr.c \
socketutils.c \
sparc.c \
+ spu.c \
sram_alloc.c \
stat.c \
stat.h \
diff --git a/linux/powerpc/syscallent.h b/linux/powerpc/syscallent.h
index 2e7efa4c4..9a0a5582f 100644
--- a/linux/powerpc/syscallent.h
+++ b/linux/powerpc/syscallent.h
@@ -305,8 +305,8 @@
[275] = { 0, TD, SEN(inotify_init), "inotify_init" },
[276] = { 3, TD|TF, SEN(inotify_add_watch), "inotify_add_watch" },
[277] = { 2, TD, SEN(inotify_rm_watch), "inotify_rm_watch" },
-[278] = { 3, 0, SEN(printargs), "spu_run" },
-[279] = { 4, 0, SEN(printargs), "spu_create" },
+[278] = { 3, 0, SEN(spu_run), "spu_run" },
+[279] = { 4, 0, SEN(spu_create), "spu_create" },
[280] = { 6, TD, SEN(pselect6), "pselect6" },
[281] = { 5, TD, SEN(ppoll), "ppoll" },
[282] = { 1, TP, SEN(unshare), "unshare" },
diff --git a/linux/powerpc64/syscallent.h b/linux/powerpc64/syscallent.h
index 4f96778ae..a6ce972c5 100644
--- a/linux/powerpc64/syscallent.h
+++ b/linux/powerpc64/syscallent.h
@@ -305,8 +305,8 @@
[275] = { 0, TD, SEN(inotify_init), "inotify_init" },
[276] = { 3, TD|TF, SEN(inotify_add_watch), "inotify_add_watch" },
[277] = { 2, TD, SEN(inotify_rm_watch), "inotify_rm_watch" },
-[278] = { 3, 0, SEN(printargs), "spu_run" },
-[279] = { 4, 0, SEN(printargs), "spu_create" },
+[278] = { 3, 0, SEN(spu_run), "spu_run" },
+[279] = { 4, 0, SEN(spu_create), "spu_create" },
[280] = { 6, TD, SEN(pselect6), "pselect6" },
[281] = { 5, TD, SEN(ppoll), "ppoll" },
[282] = { 1, TP, SEN(unshare), "unshare" },
diff --git a/spu.c b/spu.c
new file mode 100644
index 000000000..c20835d9e
--- /dev/null
+++ b/spu.c
@@ -0,0 +1,147 @@
+/*
+ * PowerPC SPU-specific syscalls decoders.
+ *
+ * Copyright (c) 2018 The strace developers.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "defs.h"
+
+#if defined POWERPC || defined POWERPC64
+
+/* defined in arch/powerpc/include/asm/spu.h */
+#include "xlat/spu_create_flags.h"
+#include "xlat/spu_run_events.h"
+#include "xlat/spu_run_status_flags.h"
+
+SYS_FUNC(spu_create)
+{
+ /* pathname */
+ printpath(tcp, tcp->u_arg[0]);
+
+ /* flags */
+ tprints(", ");
+ printflags_ex(tcp->u_arg[1], "SPU_CREATE_???", XLAT_STYLE_VERBOSE,
+ spu_create_flags, NULL);
+
+ /* mode */
+ tprints(", ");
+ print_numeric_umode_t(tcp->u_arg[2]);
+
+ /* neighbor_fd */
+ if (tcp->u_arg[1] & SPU_CREATE_AFFINITY_SPU) {
+ tprints(", ");
+ printfd(tcp, tcp->u_arg[3]);
+ }
+
+ return RVAL_DECODED | RVAL_FD;
+}
+
+static const char *
+sprint_spu_status(unsigned long status)
+{
+ enum {
+ SPU_STOP_STATUS_SHIFT = 16,
+ SPU_STOP_STATUS_MASK = 0x3fff,
+
+ SPU_STATUS_MASK = (1 << SPU_STOP_STATUS_SHIFT) - 1,
+ SPU_STOP_MASK_SHIFTED = SPU_STOP_STATUS_MASK
+ << SPU_STOP_STATUS_SHIFT;
+ };
+
+ static char outstr[spu_run_status_flags->flags_strsz
+ + sizeof("|0x3fff<<SPU_STOP_STATUS_SHIFT|")
+ + sizeof(status) * 2 + 2];
+
+ const unsigned long st = status & spu_run_status_flags->flags_mask;
+ const unsigned long stop = 0;
+ const char *flags;
+ char *p = outstr;
+
+ /* As this is intended for auxstr, we don't have to support xlat
+ * styles */
+ flags = sprintflags_ex("", spu_run_status_flags, status, "",
+ XLAT_STYLE_ABBREV);
+
+ if (!flags && !(status - st))
+ return NULL;
+
+ if (flags)
+ p = xappendstr(outstr, p, "%s|", flags);
+
+ if (st & SPU_STATUS_STOPPED_BY_STOP) {
+ stop = status & SPU_STOP_MASK_SHIFTED;
+ p = xappendstr(outstr, p, "|%#x<<SPU_STOP_STATUS_SHIFT",
+ stop >> SPU_STOP_STATUS_SHIFT);
+ }
+
+ if (status - st - stop)
+ p = xappendstr(outstr, p, "|%#x", status - st - stop);
+
+ return outstr;
+}
+
+SYS_FUNC(spu_run)
+{
+ uint32_t val;
+
+ if (entring(tcp)) {
+ /* fd */
+ printfd(tcp, tcp->u_arg[0]);
+
+ /* [in, out] uint32_t *npc */
+ tprints(", ");
+ if (!umove_or_printaddr(tcp, tcp->u_arg[1], &val)) {
+ tprintf("[%#x", val);
+ set_tcb_priv_ulong(tcp, 1);
+ }
+
+ return 0;
+ }
+
+ if (get_tcb_priv_ulong(tcp)) {
+ if (!umove(tcp, tcp->u_arg[1], &val))
+ tprintf("->%#x]", val);
+ else
+ tprints("->???]");
+ }
+
+ /* [out] uint32_t *event */
+ tprints(", ");
+ if (!umove_or_printaddr(tcp, tcp->u_arg[1], &val)) {
+ tprints("[");
+ printflags();
+ printflags_ex(val, "SPE_EVENT_???", XLAT_STYLE_VERBOSE,
+ spu_run_events, NULL);
+ tprints("]");
+ }
+
+ if (!syserror(tcp))
+ tcp->auxstr = sprint_spu_status(tcp->u_rval);
+
+ return RVAL_STR;
+}
+
+#endif /* POWERPC || POWERPC64 */
diff --git a/xlat/spu_create_flags.in b/xlat/spu_create_flags.in
new file mode 100644
index 000000000..3a1464861
--- /dev/null
+++ b/xlat/spu_create_flags.in
@@ -0,0 +1,6 @@
+SPU_CREATE_EVENTS_ENABLED 0x1
+SPU_CREATE_GANG 0x2
+SPU_CREATE_NOSCHED 0x4
+SPU_CREATE_ISOLATE 0x8
+SPU_CREATE_AFFINITY_SPU 0x10
+SPU_CREATE_AFFINITY_MEM 0x20
diff --git a/xlat/spu_run_events.in b/xlat/spu_run_events.in
new file mode 100644
index 000000000..decc49bbf
--- /dev/null
+++ b/xlat/spu_run_events.in
@@ -0,0 +1,6 @@
+SPE_EVENT_DMA_ALIGNMENT 0x8
+SPE_EVENT_SPE_ERROR 0x10
+SPE_EVENT_SPE_DATA_SEGMENT 0x20
+SPE_EVENT_SPE_DATA_STORAGE 0x40
+SPE_EVENT_INVALID_DMA 0x800
+
diff --git a/xlat/spu_run_status_flags.in b/xlat/spu_run_status_flags.in
new file mode 100644
index 000000000..fd4965f6a
--- /dev/null
+++ b/xlat/spu_run_status_flags.in
@@ -0,0 +1,9 @@
+SPU_STATUS_STOPPED_BY_STOP 0x2
+SPU_STATUS_STOPPED_BY_HALT 0x4
+SPU_STATUS_WAITING_FOR_CHANNEL 0x8
+SPU_STATUS_SINGLE_STEP 0x10
+SPU_STATUS_INVALID_INSTR 0x20
+SPU_STATUS_INVALID_CH 0x40
+SPU_STATUS_ISOLATED_STATE 0x80
+SPU_STATUS_ISOLATED_LOAD_STATUS 0x200
+SPU_STATUS_ISOLATED_EXIT_STATUS 0x400