]> granicus.if.org Git - strace/commitdiff
prctl: add decoding of PR_SVE_SET_VL and PR_SVE_GET_VL commands
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 21 Feb 2018 19:57:16 +0000 (20:57 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 6 Mar 2018 23:52:08 +0000 (23:52 +0000)
These commands were introduced in Linux commit v4.15-rc1~110^2~9.

* xlat/pr_sve_vl_flags.in: New file.
* xlat/prctl_options.in: Likewise.
* prctl.c: Include "xstring.h" and "xlat/pr_sve_vl_flags.h".
[!PR_SVE_VL_LEN_MASK] (PR_SVE_VL_LEN_MASK): New macro constant.
(sprint_sve_val): New function.
(SYS_FUNC(prctl)): Add decoding for PR_SVE_GET_VL and PR_SVE_SET_VL
commands.
* NEWS: Mention it.

NEWS
prctl.c
xlat/pr_sve_vl_flags.in [new file with mode: 0644]
xlat/prctl_options.in

diff --git a/NEWS b/NEWS
index a3c5283b38f8860b6593631b580123e7794a1e20..ced14e09606063dbaf1cbd1278a75c639f943633 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,7 +11,7 @@ Noteworthy changes in release ?.?? (????-??-??)
 * Improvements
   * IPv6 addresses shown in socket information in -yy mode are now printed
     in brackets.
-  * Enhanced decoding of ptrace syscall.
+  * Enhanced decoding of prctl and ptrace syscalls.
   * Enhanced NETLINK_ROUTE protocol decoding.
   * Updated lists of signal codes.
   * Updated lists of BPF_*, BTN_*, ETH_P_*, INET_DIAG_BC_*, KEY_*, POLL*, RWF_*,
diff --git a/prctl.c b/prctl.c
index befa14b3151de20a1db6f25146a8932857fe74d2..07bb768b1ad53360904c21b07f30596f629c0624 100644 (file)
--- a/prctl.c
+++ b/prctl.c
@@ -33,6 +33,8 @@
 
 #include <linux/prctl.h>
 
+#include "xstring.h"
+
 #include "xlat/prctl_options.h"
 #include "xlat/pr_cap_ambient.h"
 #include "xlat/pr_dumpable.h"
@@ -40,6 +42,7 @@
 #include "xlat/pr_mce_kill.h"
 #include "xlat/pr_mce_kill_policy.h"
 #include "xlat/pr_set_mm.h"
+#include "xlat/pr_sve_vl_flags.h"
 #include "xlat/pr_tsc.h"
 #include "xlat/pr_unalign_flags.h"
 
@@ -65,6 +68,11 @@ enum {
 
 #include "xlat/cap.h"
 
+#ifndef PR_SVE_VL_LEN_MASK
+# define PR_SVE_VL_LEN_MASK 0xffff
+#endif
+
+
 static void
 print_prctl_args(struct tcb *tcp, const unsigned int first)
 {
@@ -74,6 +82,22 @@ print_prctl_args(struct tcb *tcp, const unsigned int first)
                tprintf(", %#" PRI_klx, tcp->u_arg[i]);
 }
 
+static char *
+sprint_sve_val(kernel_ulong_t arg)
+{
+       static char out[sizeof("PR_SVE_SET_VL_ONEXEC|PR_SVE_VL_INHERIT|0x") +
+                       sizeof(kernel_ulong_t) * 2];
+
+       kernel_ulong_t vl = arg & PR_SVE_VL_LEN_MASK;
+       kernel_ulong_t flags = arg & ~PR_SVE_VL_LEN_MASK;
+       const char *flags_str = sprintflags("", pr_sve_vl_flags, flags);
+
+       xsprintf(out, "%s%s%#" PRI_klx,
+                flags_str ?: "", flags_str ? "|" : "", vl);
+
+       return out;
+}
+
 SYS_FUNC(prctl)
 {
        const unsigned int option = tcp->u_arg[0];
@@ -184,6 +208,23 @@ SYS_FUNC(prctl)
                                          (kernel_ulong_t) tcp->u_rval);
                return RVAL_STR;
 
+       case PR_SVE_SET_VL:
+               if (entering(tcp)) {
+                       tprintf(", %s", sprint_sve_val(arg2));
+                       return 0;
+               }
+               ATTRIBUTE_FALLTHROUGH;
+
+       case PR_SVE_GET_VL:
+               if (entering(tcp))
+                       break;
+               if (syserror(tcp) || tcp->u_rval == 0)
+                       return 0;
+
+               tcp->auxstr = sprint_sve_val(tcp->u_rval);
+
+               return RVAL_STR;
+
        /* PR_TASK_PERF_EVENTS_* take no arguments. */
        case PR_TASK_PERF_EVENTS_DISABLE:
        case PR_TASK_PERF_EVENTS_ENABLE:
diff --git a/xlat/pr_sve_vl_flags.in b/xlat/pr_sve_vl_flags.in
new file mode 100644 (file)
index 0000000..dcd6998
--- /dev/null
@@ -0,0 +1,2 @@
+PR_SVE_SET_VL_ONEXEC          (1 << 18)
+PR_SVE_VL_INHERIT             (1 << 17)
index 8c09ee31ee7544f770ff0d8f720107225382d98a..86fcd2cd42b1deaa84fc2d013c2cf0ec4985ad19 100644 (file)
@@ -44,4 +44,6 @@ PR_MPX_DISABLE_MANAGEMENT 44
 PR_SET_FP_MODE 45
 PR_GET_FP_MODE 46
 PR_CAP_AMBIENT 47
+PR_SVE_SET_VL 50
+PR_SVE_GET_VL 51
 PR_SET_VMA 0x53564d41