Print this page
15254 %ymm registers not restored after signal handler
15367 x86 getfpregs() summons corrupting %xmm ghosts
15333 want x86 /proc xregs support (libc_db, libproc, mdb, etc.)
15336 want libc functions for extended ucontext_t
15334 want ps_lwphandle-specific reg routines
15328 FPU_CW_INIT mistreats reserved bit
15335 i86pc fpu_subr.c isn't really platform-specific
15332 setcontext(2) isn't actually noreturn
15331 need <sys/stdalign.h>
Change-Id: I7060aa86042dfb989f77fc3323c065ea2eafa9ad
Conflicts:
    usr/src/uts/common/fs/proc/prcontrol.c
    usr/src/uts/intel/os/archdep.c
    usr/src/uts/intel/sys/ucontext.h
    usr/src/uts/intel/syscall/getcontext.c

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/proc/prvnops.c
          +++ new/usr/src/uts/common/fs/proc/prvnops.c
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright 2019 Joyent, Inc.
  25   25   * Copyright (c) 2017 by Delphix. All rights reserved.
  26   26   * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
  27   27   * Copyright 2022 MNX Cloud, Inc.
  28      - * Copyright 2022 Oxide Computer Company
       28 + * Copyright 2023 Oxide Computer Company
  29   29   */
  30   30  
  31   31  /*      Copyright (c) 1984,      1986, 1987, 1988, 1989 AT&T    */
  32   32  /*        All Rights Reserved   */
  33   33  
  34   34  #include <sys/types.h>
  35   35  #include <sys/param.h>
  36   36  #include <sys/time.h>
  37   37  #include <sys/cred.h>
  38   38  #include <sys/policy.h>
↓ open down ↓ 1691 lines elided ↑ open up ↑
1730 1730  
1731 1731          prunlock(pnp);
1732 1732  
1733 1733          return (pr_uioread(lwpname, sizeof (lwpname), uiop));
1734 1734  }
1735 1735  
1736 1736  /* ARGSUSED */
1737 1737  static int
1738 1738  pr_read_xregs(prnode_t *pnp, uio_t *uiop, cred_t *cr)
1739 1739  {
1740      -#if defined(__sparc)
1741 1740          proc_t *p;
1742 1741          kthread_t *t;
1743 1742          int error;
1744      -        char *xreg;
     1743 +        void *xreg;
1745 1744          size_t size;
1746 1745  
1747 1746          ASSERT(pnp->pr_type == PR_XREGS);
1748 1747  
1749      -        xreg = kmem_zalloc(sizeof (prxregset_t), KM_SLEEP);
1750      -
1751 1748          if ((error = prlock(pnp, ZNO)) != 0)
1752      -                goto out;
     1749 +                return (error);
1753 1750  
1754 1751          p = pnp->pr_common->prc_proc;
1755 1752          t = pnp->pr_common->prc_thread;
1756 1753  
1757      -        size = prhasx(p)? prgetprxregsize(p) : 0;
     1754 +        /*
     1755 +         * While we would prefer to do the allocation with holding the process
     1756 +         * this way, we can only determine this size while holding the process
     1757 +         * as the hold guarantees us:
     1758 +         *
     1759 +         *  o That the process in question actualy exists.
     1760 +         *  o That the process in question cannot change the set of FPU features
     1761 +         *    it has enabled.
     1762 +         *
     1763 +         * We will drop p_lock across the allocation call itself. This should be
     1764 +         * safe as the enabled feature set should not change while the process
     1765 +         * is locked (e.g. enabling extending FPU state like AMX on x86 should
     1766 +         * require the process to be locked).
     1767 +         */
     1768 +        size = prhasx(p) ? prgetprxregsize(p) : 0;
     1769 +        if (size == 0) {
     1770 +                prunlock(pnp);
     1771 +                return (0);
     1772 +        }
     1773 +        mutex_exit(&p->p_lock);
     1774 +        xreg = kmem_zalloc(size, KM_SLEEP);
     1775 +        mutex_enter(&p->p_lock);
     1776 +        ASSERT3U(size, ==, prgetprxregsize(p));
     1777 +
1758 1778          if (uiop->uio_offset >= size) {
1759 1779                  prunlock(pnp);
1760 1780                  goto out;
1761 1781          }
1762 1782  
1763 1783          /* drop p->p_lock while (possibly) touching the stack */
1764 1784          mutex_exit(&p->p_lock);
1765 1785          prgetprxregs(ttolwp(t), xreg);
1766 1786          mutex_enter(&p->p_lock);
1767 1787          prunlock(pnp);
1768 1788  
1769 1789          error = pr_uioread(xreg, size, uiop);
1770 1790  out:
1771      -        kmem_free(xreg, sizeof (prxregset_t));
     1791 +        kmem_free(xreg, size);
1772 1792          return (error);
1773      -#else
1774      -        return (0);
1775      -#endif
1776 1793  }
1777 1794  
1778 1795  static int
1779 1796  pr_read_spymaster(prnode_t *pnp, uio_t *uiop, cred_t *cr)
1780 1797  {
1781 1798          psinfo_t psinfo;
1782 1799          int error;
1783 1800          klwp_t *lwp;
1784 1801  
1785 1802          ASSERT(pnp->pr_type == PR_SPYMASTER);
↓ open down ↓ 4843 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX