From owner-dev-commits-src-all@freebsd.org Sun Dec 27 03:06:26 2020 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D7D464CB4E9; Sun, 27 Dec 2020 03:06:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4D3QYt5jJvz3KcV; Sun, 27 Dec 2020 03:06:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B6BFB1FB6D; Sun, 27 Dec 2020 03:06:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 0BR36Qkr005915; Sun, 27 Dec 2020 03:06:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 0BR36QeR005914; Sun, 27 Dec 2020 03:06:26 GMT (envelope-from git) Date: Sun, 27 Dec 2020 03:06:26 GMT Message-Id: <202012270306.0BR36QeR005914@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 906cd9a167b1 - stable/12 - MFC _umtx_op: documentation and libsysdecode/kdump/truss decoding (32-bit) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 906cd9a167b154dabe7a916bb6749d22e2a5df1b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "Commit messages for all branches of the src repository." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Dec 2020 03:06:26 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=906cd9a167b154dabe7a916bb6749d22e2a5df1b commit 906cd9a167b154dabe7a916bb6749d22e2a5df1b Author: Kyle Evans AuthorDate: 2020-12-09 03:20:51 +0000 Commit: Kyle Evans CommitDate: 2020-12-27 03:06:11 +0000 MFC _umtx_op: documentation and libsysdecode/kdump/truss decoding (32-bit) e04a83a3: _umtx_op(2): document recent addition of 32bit compat flags This was part of D27325. 3b27074b: libsysdecode: decode _UMTX_OP flags Assume that UMTX_OP with a double underbar following is a flag, while any underbar+alphanumeric combination immeiately following is an op. This was a part of D27325. c2679dd7: kdump/truss: decode new _umtx_op flags In both cases, print the flag bits first followed by the command. Output now looks something like this: (ktrace) _umtx_op(0x8605f7008,0xf,0,0,0) _umtx_op(0x9fffdce8,0x80000003,0x1,0,0) (truss) _umtx_op(0x7fffffffda50,UMTX_OP_WAKE,0x1,0x0,0x0) = 0 (0x0) _umtx_op(0x9fffdd08,UMTX_OP__32BIT|UMTX_OP_WAKE,0x1,0x0,0x0) = 0 (0x0) (cherry picked from commit e04a83a3e1b40fc7c41b5938d2e432ba01facd74) (cherry picked from commit 3b27074b252cae3c7aee8f05f0c968dd26fa055b) (cherry picked from commit c2679dd779bb75f51682cde5eb55a291b72d7900) --- lib/libc/sys/_umtx_op.2 | 75 +++++++++++++++++++++++++++++++++++++++++++- lib/libsysdecode/flags.c | 14 +++++++++ lib/libsysdecode/mktables | 3 +- lib/libsysdecode/sysdecode.h | 1 + usr.bin/kdump/kdump.c | 22 ++++++++++--- usr.bin/truss/syscalls.c | 20 ++++++++++-- 6 files changed, 126 insertions(+), 9 deletions(-) diff --git a/lib/libc/sys/_umtx_op.2 b/lib/libc/sys/_umtx_op.2 index 547ed313e4a3..8b10e4ec7e15 100644 --- a/lib/libc/sys/_umtx_op.2 +++ b/lib/libc/sys/_umtx_op.2 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 16, 2020 +.Dd November 23, 2020 .Dt _UMTX_OP 2 .Os .Sh NAME @@ -1272,6 +1272,79 @@ See .Sx ROBUST UMUTEXES subsection for details. .El +.Pp +The +.Fa op +argument may be a bitwise OR of a single command from above with one or more of +the following flags: +.Bl -tag -width indent +.It Dv UMTX_OP__I386 +Request i386 ABI compatibility from the native +.Nm +system call. +Specifically, this implies that: +.Bl -hang -offset indent +.It +.Fa obj +arguments that point to a word, point to a 32-bit integer. +.It +The +.Dv UMTX_OP_NWAKE_PRIVATE +.Fa obj +argument is a pointer to an array of 32-bit pointers. +.It +The +.Dv m_rb_lnk +member of +.Vt struct umutex +is a 32-bit pointer. +.It +.Vt struct timespec +uses a 32-bit time_t. +.El +.Pp +.Dv UMTX_OP__32BIT +has no effect if this flag is set. +This flag is valid for all architectures, but it is ignored on i386. +.It Dv UMTX_OP__32BIT +Request non-i386, 32-bit ABI compatibility from the native +.Nm +system call. +Specifically, this implies that: +.Bl -hang -offset indent +.It +.Fa obj +arguments that point to a word, point to a 32-bit integer. +.It +The +.Dv UMTX_OP_NWAKE_PRIVATE +.Fa obj +argument is a pointer to an array of 32-bit pointers. +.It +The +.Dv m_rb_lnk +member of +.Vt struct umutex +is a 32-bit pointer. +.It +.Vt struct timespec +uses a 64-bit time_t. +.El +.Pp +This flag has no effect if +.Dv UMTX_OP__I386 +is set. +This flag is valid for all architectures. +.El +.Pp +Note that if any 32-bit ABI compatibility is being requested, then care must be +taken with robust lists. +A single thread may not mix 32-bit compatible robust lists with native +robust lists. +The first +.Dv UMTX_OP_ROBUST_LISTS +call in a given thread determines which ABI that thread will use for robust +lists going forward. .Sh RETURN VALUES If successful, all requests, except diff --git a/lib/libsysdecode/flags.c b/lib/libsysdecode/flags.c index ae2b5ff057e1..b9f66fb72f8c 100644 --- a/lib/libsysdecode/flags.c +++ b/lib/libsysdecode/flags.c @@ -931,6 +931,20 @@ sysdecode_umtx_op(int op) return (lookup_value(umtxop, op)); } +bool +sysdecode_umtx_op_flags(FILE *fp, int op, int *rem) +{ + uintmax_t val; + bool printed; + + printed = false; + val = (unsigned)op; + print_mask_part(fp, umtxopflags, &val, &printed); + if (rem != NULL) + *rem = val; + return (printed); +} + const char * sysdecode_vmresult(int result) { diff --git a/lib/libsysdecode/mktables b/lib/libsysdecode/mktables index 4765ca5d8beb..877a1024784a 100644 --- a/lib/libsysdecode/mktables +++ b/lib/libsysdecode/mktables @@ -145,7 +145,8 @@ gen_table "sockoptudp" "UDP_[[:alnum:]]+[[:space:]]+[0-9]+" "neti gen_table "sockoptudplite" "UDPLITE_[[:alnum:]_]+[[:space:]]+[0-9]+" "netinet/udplite.h" gen_table "socktype" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" "sys/socket.h" gen_table "thrcreateflags" "THR_[A-Z]+[[:space:]]+0x[0-9]+" "sys/thr.h" -gen_table "umtxop" "UMTX_OP_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/umtx.h" +gen_table "umtxop" "UMTX_OP_[[:alnum:]][[:alnum:]_]*[[:space:]]+[0-9]+" "sys/umtx.h" +gen_table "umtxopflags" "UMTX_OP__[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/umtx.h" gen_table "vmprot" "VM_PROT_[A-Z]+[[:space:]]+\(\(vm_prot_t\)[[:space:]]+0x[0-9]+\)" "vm/vm.h" gen_table "vmresult" "KERN_[A-Z_]+[[:space:]]+[0-9]+" "vm/vm_param.h" gen_table "wait6opt" "W[A-Z]+[[:space:]]+[0-9]+" "sys/wait.h" diff --git a/lib/libsysdecode/sysdecode.h b/lib/libsysdecode/sysdecode.h index 218943245b66..30e861780efd 100644 --- a/lib/libsysdecode/sysdecode.h +++ b/lib/libsysdecode/sysdecode.h @@ -121,6 +121,7 @@ const char *sysdecode_sysarch_number(int _number); bool sysdecode_thr_create_flags(FILE *_fp, int _flags, int *_rem); bool sysdecode_umtx_cvwait_flags(FILE *_fp, u_long _flags, u_long *_rem); const char *sysdecode_umtx_op(int _op); +bool sysdecode_umtx_op_flags(FILE *_fp, int op, int *_rem); bool sysdecode_umtx_rwlock_flags(FILE *_fp, u_long _flags, u_long *_rem); int sysdecode_utrace(FILE *_fp, void *_buf, size_t _len); bool sysdecode_vmprot(FILE *_fp, int _type, int *_rem); diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 704c7b5feef4..dbec2e820ccb 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -254,14 +254,21 @@ print_integer_arg_valid(const char *(*decoder)(int), int value) } } +static bool +print_mask_arg_part(bool (*decoder)(FILE *, int, int *), int value, int *rem) +{ + + printf("%#x<", value); + return (decoder(stdout, value, rem)); +} + static void print_mask_arg(bool (*decoder)(FILE *, int, int *), int value) { bool invalid; int rem; - printf("%#x<", value); - invalid = !decoder(stdout, value, &rem); + invalid = !print_mask_arg_part(decoder, value, &rem); printf(">"); if (invalid) printf("%u", rem); @@ -1437,10 +1444,16 @@ ktrsyscall(struct ktr_syscall *ktr, u_int sv_flags) ip++; narg--; break; - case SYS__umtx_op: + case SYS__umtx_op: { + int op; + print_number(ip, narg, c); putchar(','); - print_integer_arg(sysdecode_umtx_op, *ip); + if (print_mask_arg_part(sysdecode_umtx_op_flags, + *ip, &op)) + putchar('|'); + print_integer_arg(sysdecode_umtx_op, op); + putchar('>'); switch (*ip) { case UMTX_OP_CV_WAIT: ip++; @@ -1460,6 +1473,7 @@ ktrsyscall(struct ktr_syscall *ktr, u_int sv_flags) ip++; narg--; break; + } case SYS_ftruncate: case SYS_truncate: print_number(ip, narg, c); diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c index 47fcce5aeee8..155f8187ca66 100644 --- a/usr.bin/truss/syscalls.c +++ b/usr.bin/truss/syscalls.c @@ -877,12 +877,20 @@ print_integer_arg(const char *(*decoder)(int), FILE *fp, int value) fprintf(fp, "%d", value); } +static bool +print_mask_arg_part(bool (*decoder)(FILE *, int, int *), FILE *fp, int value, + int *rem) +{ + + return (decoder(fp, value, rem)); +} + static void print_mask_arg(bool (*decoder)(FILE *, int, int *), FILE *fp, int value) { int rem; - if (!decoder(fp, value, &rem)) + if (!print_mask_arg_part(decoder, fp, value, &rem)) fprintf(fp, "0x%x", rem); else if (rem != 0) fprintf(fp, "|0x%x", rem); @@ -2282,9 +2290,15 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval, case Procctl: print_integer_arg(sysdecode_procctl_cmd, fp, args[sc->offset]); break; - case Umtxop: - print_integer_arg(sysdecode_umtx_op, fp, args[sc->offset]); + case Umtxop: { + int rem; + + if (print_mask_arg_part(sysdecode_umtx_op_flags, fp, + args[sc->offset], &rem)) + fprintf(fp, "|"); + print_integer_arg(sysdecode_umtx_op, fp, rem); break; + } case Atfd: print_integer_arg(sysdecode_atfd, fp, args[sc->offset]); break;