Re: svn commit: r367930 - in head/sys: kern sys

2020-11-21 Thread Kyle Evans
On Sat, Nov 21, 2020 at 11:47 PM Kyle Evans  wrote:
>
> Author: kevans
> Date: Sun Nov 22 05:47:45 2020
> New Revision: 367930
> URL: https://svnweb.freebsd.org/changeset/base/367930
>
> Log:
>   [2/2] _umtx_op: introduce 32-bit/i386 flags for operations
>
>   This patch takes advantage of the consolidation that happened to provide two
>   flags that can be used with the native _umtx_op(2): UMTX_OP___32BIT and
>   UMTX_OP__I386.
>
>   UMTX_OP__32BIT iindicates that we are being provided with 32-bit structures.
>   Note that this flag alone indicates a 64bit time_t, since this is the
>   majority case.
>
>   UMTX_OP__I386 has been provided so that we can emulate i386 as well,
>   regardless of whether the host is amd64 or not.
>
>   Both imply a different set of copyops in sysumtx_op. freebsd32__umtx_op
>   simply ignores the flags, since it's already doing a 32-bit operation and
>   it's unlikely we'll be running an emulator under compat32. Future work
>   could consider it, but the author sees little benefit.
>
>   This will be used by qemu-bsd-user to pass on all _umtx_op calls to the
>   native interface as long as the host/target endianness matches, effectively
>   eliminating most if not all of the remaining unresolved deadlocks for most.
>
>   This version changed a fair amount from what was under review, mostly in
>   response to refactoring of the prereq reorganization and battle-testing
>   it with qemu-bsd-user.  The main changes are as follows:
>
>   1.) The i386 flag got renamed to omit '32BIT' since this is redundant.
>   2.) The flags are now properly handled on 32-bit platforms to emulate other
>   32-bit platforms.
>   3.) Robust list handling was fixed, and the 32-bit functionality that was
>   previously gated by COMPAT_FREEBSD32 is now unconditional.
>   4.) Robust list handling was also improved, including the error reported
>   when a process has already registered 32-bit ABI lists and also
>   detecting if native robust lists have already been registered. Both
>   scenarios now return EBUSY rather than EINVAL, because the input is
>   technically valid but we're too busy with another ABI's lists.
>
>   libsysdecode/kdump/truss support will go into review soon-ish, along with
>   the associated manpage update.
>
>   Reviewed by:  kib (earlier version)
>   MFC after:3 weeks
>

Differential Revision: https://reviews.freebsd.org/D27223
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367930 - in head/sys: kern sys

2020-11-21 Thread Kyle Evans
Author: kevans
Date: Sun Nov 22 05:47:45 2020
New Revision: 367930
URL: https://svnweb.freebsd.org/changeset/base/367930

Log:
  [2/2] _umtx_op: introduce 32-bit/i386 flags for operations
  
  This patch takes advantage of the consolidation that happened to provide two
  flags that can be used with the native _umtx_op(2): UMTX_OP___32BIT and
  UMTX_OP__I386.
  
  UMTX_OP__32BIT iindicates that we are being provided with 32-bit structures.
  Note that this flag alone indicates a 64bit time_t, since this is the
  majority case.
  
  UMTX_OP__I386 has been provided so that we can emulate i386 as well,
  regardless of whether the host is amd64 or not.
  
  Both imply a different set of copyops in sysumtx_op. freebsd32__umtx_op
  simply ignores the flags, since it's already doing a 32-bit operation and
  it's unlikely we'll be running an emulator under compat32. Future work
  could consider it, but the author sees little benefit.
  
  This will be used by qemu-bsd-user to pass on all _umtx_op calls to the
  native interface as long as the host/target endianness matches, effectively
  eliminating most if not all of the remaining unresolved deadlocks for most.
  
  This version changed a fair amount from what was under review, mostly in
  response to refactoring of the prereq reorganization and battle-testing
  it with qemu-bsd-user.  The main changes are as follows:
  
  1.) The i386 flag got renamed to omit '32BIT' since this is redundant.
  2.) The flags are now properly handled on 32-bit platforms to emulate other
  32-bit platforms.
  3.) Robust list handling was fixed, and the 32-bit functionality that was
  previously gated by COMPAT_FREEBSD32 is now unconditional.
  4.) Robust list handling was also improved, including the error reported
  when a process has already registered 32-bit ABI lists and also
  detecting if native robust lists have already been registered. Both
  scenarios now return EBUSY rather than EINVAL, because the input is
  technically valid but we're too busy with another ABI's lists.
  
  libsysdecode/kdump/truss support will go into review soon-ish, along with
  the associated manpage update.
  
  Reviewed by:  kib (earlier version)
  MFC after:3 weeks

Modified:
  head/sys/kern/kern_umtx.c
  head/sys/sys/umtx.h

Modified: head/sys/kern/kern_umtx.c
==
--- head/sys/kern/kern_umtx.c   Sun Nov 22 05:42:52 2020(r367929)
+++ head/sys/kern/kern_umtx.c   Sun Nov 22 05:47:45 2020(r367930)
@@ -75,8 +75,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#ifdef COMPAT_FREEBSD32
 #include 
+#ifdef COMPAT_FREEBSD32
 #include 
 #endif
 
@@ -232,7 +232,6 @@ struct umtx_copyops {
const bool  compat32;
 };
 
-#ifdef COMPAT_FREEBSD32
 struct umtx_time32 {
struct  timespec32  _timeout;
uint32_t_flags;
@@ -257,7 +256,6 @@ struct umutex32 {
 _Static_assert(sizeof(struct umutex) == sizeof(struct umutex32), "umutex32");
 _Static_assert(__offsetof(struct umutex, m_spare[0]) ==
 __offsetof(struct umutex32, m_spare[0]), "m_spare32");
-#endif
 
 int umtx_shm_vnobj_persistent = 0;
 SYSCTL_INT(_kern_ipc, OID_AUTO, umtx_vnode_persistent, CTLFLAG_RWTUN,
@@ -4167,6 +4165,15 @@ __umtx_op_robust_lists(struct thread *td, struct _umtx
struct umtx_robust_lists_params rb;
int error;
 
+   if (ops->compat32) {
+   if ((td->td_pflags2 & TDP2_COMPAT32RB) == 0 &&
+   (td->td_rb_list != 0 || td->td_rbp_list != 0 ||
+   td->td_rb_inact != 0))
+   return (EBUSY);
+   } else if ((td->td_pflags2 & TDP2_COMPAT32RB) != 0) {
+   return (EBUSY);
+   }
+
bzero(, sizeof(rb));
error = ops->copyin_robust_lists(uap->uaddr1, uap->val, );
if (error != 0)
@@ -4174,8 +4181,6 @@ __umtx_op_robust_lists(struct thread *td, struct _umtx
 
if (ops->compat32)
td->td_pflags2 |= TDP2_COMPAT32RB;
-   else if ((td->td_pflags2 & TDP2_COMPAT32RB) != 0)
-   return (EINVAL);
 
td->td_rb_list = rb.robust_list_offset;
td->td_rbp_list = rb.robust_priv_list_offset;
@@ -4183,11 +4188,70 @@ __umtx_op_robust_lists(struct thread *td, struct _umtx
return (0);
 }
 
-#ifdef COMPAT_FREEBSD32
+#if defined(__i386__) || defined(__amd64__)
+/*
+ * Provide the standard 32-bit definitions for x86, since native/compat32 use a
+ * 32-bit time_t there.  Other architectures just need the i386 definitions
+ * along with their standard compat32.
+ */
+struct timespecx32 {
+   int64_t tv_sec;
+   int32_t tv_nsec;
+};
+
+struct umtx_timex32 {
+   struct  timespecx32 _timeout;
+   uint32_t_flags;
+   uint32_t_clockid;
+};
+
+#ifndef __i386__
+#definetimespeci386timespec32
+#defineumtx_timei386   umtx_time32
+#endif