From: Eugene Syromyatnikov Date: Wed, 21 Feb 2018 19:57:16 +0000 (+0100) Subject: prctl: add decoding of PR_SVE_SET_VL and PR_SVE_GET_VL commands X-Git-Tag: v4.22~120 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=beafdd36e1db6e360976683cea50cd69c00d029b;p=strace prctl: add decoding of PR_SVE_SET_VL and PR_SVE_GET_VL commands 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. --- diff --git a/NEWS b/NEWS index a3c5283b..ced14e09 100644 --- 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 befa14b3..07bb768b 100644 --- a/prctl.c +++ b/prctl.c @@ -33,6 +33,8 @@ #include +#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 index 00000000..dcd69980 --- /dev/null +++ b/xlat/pr_sve_vl_flags.in @@ -0,0 +1,2 @@ +PR_SVE_SET_VL_ONEXEC (1 << 18) +PR_SVE_VL_INHERIT (1 << 17) diff --git a/xlat/prctl_options.in b/xlat/prctl_options.in index 8c09ee31..86fcd2cd 100644 --- a/xlat/prctl_options.in +++ b/xlat/prctl_options.in @@ -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