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


   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2019 Joyent, Inc.
  25  * Copyright (c) 2017 by Delphix. All rights reserved.
  26  * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
  27  * Copyright 2022 MNX Cloud, Inc.
  28  * Copyright 2022 Oxide Computer Company
  29  */
  30 
  31 /*      Copyright (c) 1984,      1986, 1987, 1988, 1989 AT&T        */
  32 /*        All Rights Reserved   */
  33 
  34 #include <sys/types.h>
  35 #include <sys/param.h>
  36 #include <sys/time.h>
  37 #include <sys/cred.h>
  38 #include <sys/policy.h>
  39 #include <sys/debug.h>
  40 #include <sys/dirent.h>
  41 #include <sys/errno.h>
  42 #include <sys/file.h>
  43 #include <sys/inline.h>
  44 #include <sys/kmem.h>
  45 #include <sys/pathname.h>
  46 #include <sys/proc.h>
  47 #include <sys/brand.h>
  48 #include <sys/signal.h>


1720 
1721         if ((error = prlock(pnp, ZNO)) != 0)
1722                 return (error);
1723 
1724         bzero(lwpname, sizeof (lwpname));
1725 
1726         t = pnp->pr_common->prc_thread;
1727 
1728         if (t->t_name != NULL)
1729                 (void) strlcpy(lwpname, t->t_name, sizeof (lwpname));
1730 
1731         prunlock(pnp);
1732 
1733         return (pr_uioread(lwpname, sizeof (lwpname), uiop));
1734 }
1735 
1736 /* ARGSUSED */
1737 static int
1738 pr_read_xregs(prnode_t *pnp, uio_t *uiop, cred_t *cr)
1739 {
1740 #if defined(__sparc)
1741         proc_t *p;
1742         kthread_t *t;
1743         int error;
1744         char *xreg;
1745         size_t size;
1746 
1747         ASSERT(pnp->pr_type == PR_XREGS);
1748 
1749         xreg = kmem_zalloc(sizeof (prxregset_t), KM_SLEEP);
1750 
1751         if ((error = prlock(pnp, ZNO)) != 0)
1752                 goto out;
1753 
1754         p = pnp->pr_common->prc_proc;
1755         t = pnp->pr_common->prc_thread;
1756 
1757         size = prhasx(p)? prgetprxregsize(p) : 0;























1758         if (uiop->uio_offset >= size) {
1759                 prunlock(pnp);
1760                 goto out;
1761         }
1762 
1763         /* drop p->p_lock while (possibly) touching the stack */
1764         mutex_exit(&p->p_lock);
1765         prgetprxregs(ttolwp(t), xreg);
1766         mutex_enter(&p->p_lock);
1767         prunlock(pnp);
1768 
1769         error = pr_uioread(xreg, size, uiop);
1770 out:
1771         kmem_free(xreg, sizeof (prxregset_t));
1772         return (error);
1773 #else
1774         return (0);
1775 #endif
1776 }
1777 
1778 static int
1779 pr_read_spymaster(prnode_t *pnp, uio_t *uiop, cred_t *cr)
1780 {
1781         psinfo_t psinfo;
1782         int error;
1783         klwp_t *lwp;
1784 
1785         ASSERT(pnp->pr_type == PR_SPYMASTER);
1786 
1787         if ((error = prlock(pnp, ZNO)) != 0)
1788                 return (error);
1789 
1790         if (pnp->pr_common->prc_thread == NULL) {
1791                 prunlock(pnp);
1792                 return (0);
1793         }
1794 
1795         lwp = pnp->pr_common->prc_thread->t_lwp;




   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2019 Joyent, Inc.
  25  * Copyright (c) 2017 by Delphix. All rights reserved.
  26  * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
  27  * Copyright 2022 MNX Cloud, Inc.
  28  * Copyright 2023 Oxide Computer Company
  29  */
  30 
  31 /*      Copyright (c) 1984,      1986, 1987, 1988, 1989 AT&T        */
  32 /*        All Rights Reserved   */
  33 
  34 #include <sys/types.h>
  35 #include <sys/param.h>
  36 #include <sys/time.h>
  37 #include <sys/cred.h>
  38 #include <sys/policy.h>
  39 #include <sys/debug.h>
  40 #include <sys/dirent.h>
  41 #include <sys/errno.h>
  42 #include <sys/file.h>
  43 #include <sys/inline.h>
  44 #include <sys/kmem.h>
  45 #include <sys/pathname.h>
  46 #include <sys/proc.h>
  47 #include <sys/brand.h>
  48 #include <sys/signal.h>


1720 
1721         if ((error = prlock(pnp, ZNO)) != 0)
1722                 return (error);
1723 
1724         bzero(lwpname, sizeof (lwpname));
1725 
1726         t = pnp->pr_common->prc_thread;
1727 
1728         if (t->t_name != NULL)
1729                 (void) strlcpy(lwpname, t->t_name, sizeof (lwpname));
1730 
1731         prunlock(pnp);
1732 
1733         return (pr_uioread(lwpname, sizeof (lwpname), uiop));
1734 }
1735 
1736 /* ARGSUSED */
1737 static int
1738 pr_read_xregs(prnode_t *pnp, uio_t *uiop, cred_t *cr)
1739 {

1740         proc_t *p;
1741         kthread_t *t;
1742         int error;
1743         void *xreg;
1744         size_t size;
1745 
1746         ASSERT(pnp->pr_type == PR_XREGS);
1747 


1748         if ((error = prlock(pnp, ZNO)) != 0)
1749                 return (error);
1750 
1751         p = pnp->pr_common->prc_proc;
1752         t = pnp->pr_common->prc_thread;
1753 
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 
1778         if (uiop->uio_offset >= size) {
1779                 prunlock(pnp);
1780                 goto out;
1781         }
1782 
1783         /* drop p->p_lock while (possibly) touching the stack */
1784         mutex_exit(&p->p_lock);
1785         prgetprxregs(ttolwp(t), xreg);
1786         mutex_enter(&p->p_lock);
1787         prunlock(pnp);
1788 
1789         error = pr_uioread(xreg, size, uiop);
1790 out:
1791         kmem_free(xreg, size);
1792         return (error);



1793 }
1794 
1795 static int
1796 pr_read_spymaster(prnode_t *pnp, uio_t *uiop, cred_t *cr)
1797 {
1798         psinfo_t psinfo;
1799         int error;
1800         klwp_t *lwp;
1801 
1802         ASSERT(pnp->pr_type == PR_SPYMASTER);
1803 
1804         if ((error = prlock(pnp, ZNO)) != 0)
1805                 return (error);
1806 
1807         if (pnp->pr_common->prc_thread == NULL) {
1808                 prunlock(pnp);
1809                 return (0);
1810         }
1811 
1812         lwp = pnp->pr_common->prc_thread->t_lwp;