git: 906cd9a167b1 - stable/12 - MFC _umtx_op: documentation and libsysdecode/kdump/truss decoding (32-bit)
Kyle Evans
kevans at FreeBSD.org
Sun Dec 27 03:06:26 UTC 2020
The branch stable/12 has been updated by kevans:
URL: https://cgit.FreeBSD.org/src/commit/?id=906cd9a167b154dabe7a916bb6749d22e2a5df1b
commit 906cd9a167b154dabe7a916bb6749d22e2a5df1b
Author: Kyle Evans <kevans at FreeBSD.org>
AuthorDate: 2020-12-09 03:20:51 +0000
Commit: Kyle Evans <kevans at FreeBSD.org>
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<UMTX_OP_WAIT_UINT_PRIVATE>,0,0,0)
_umtx_op(0x9fffdce8,0x80000003<UMTX_OP__32BIT|UMTX_OP_WAKE>,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("<invalid>%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;
More information about the dev-commits-src-all
mailing list