17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
5d51e907ab * Common Development and Distribution License (the "License").
6d51e907ab * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
217c478bdstevel@tonic-gate/*
22d9452f2Edward Pilatowicz * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bdstevel@tonic-gate * Use is subject to license terms.
247c478bdstevel@tonic-gate */
257c478bdstevel@tonic-gate
267c478bdstevel@tonic-gate#include <sys/stack.h>
277c478bdstevel@tonic-gate#include <sys/regset.h>
287c478bdstevel@tonic-gate#include <sys/frame.h>
297c478bdstevel@tonic-gate#include <sys/sysmacros.h>
30d9452f2Edward Pilatowicz#include <sys/machelf.h>
317c478bdstevel@tonic-gate
327c478bdstevel@tonic-gate#include <stdlib.h>
337c478bdstevel@tonic-gate#include <unistd.h>
347c478bdstevel@tonic-gate#include <sys/types.h>
357c478bdstevel@tonic-gate#include <errno.h>
367c478bdstevel@tonic-gate#include <string.h>
377c478bdstevel@tonic-gate
387c478bdstevel@tonic-gate#include "Pcontrol.h"
397c478bdstevel@tonic-gate#include "Pstack.h"
407c478bdstevel@tonic-gate#include "Pisadep.h"
417c478bdstevel@tonic-gate
427c478bdstevel@tonic-gate#define	SYSCALL32 0x91d02008	/* 32-bit syscall (ta 8) instruction */
437c478bdstevel@tonic-gate
447c478bdstevel@tonic-gate#ifndef	WINDOWSIZE32
457c478bdstevel@tonic-gate#define	WINDOWSIZE32	(16 * sizeof (int32_t))
467c478bdstevel@tonic-gate#endif
477c478bdstevel@tonic-gate
487c478bdstevel@tonic-gateconst char *
497c478bdstevel@tonic-gatePpltdest(struct ps_prochandle *P, uintptr_t pltaddr)
507c478bdstevel@tonic-gate{
517c478bdstevel@tonic-gate	map_info_t *mp = Paddr2mptr(P, pltaddr);
527c478bdstevel@tonic-gate
537c478bdstevel@tonic-gate	uintptr_t r_addr;
547c478bdstevel@tonic-gate	file_info_t *fp;
557c478bdstevel@tonic-gate	Elf32_Rela r;
567c478bdstevel@tonic-gate	size_t i;
577c478bdstevel@tonic-gate
587c478bdstevel@tonic-gate	if (mp == NULL || (fp = mp->map_file) == NULL ||
597c478bdstevel@tonic-gate	    fp->file_plt_base == 0 || pltaddr < fp->file_plt_base ||
607c478bdstevel@tonic-gate	    pltaddr >= fp->file_plt_base + fp->file_plt_size) {
617c478bdstevel@tonic-gate		errno = EINVAL;
627c478bdstevel@tonic-gate		return (NULL);
637c478bdstevel@tonic-gate	}
647c478bdstevel@tonic-gate
657c478bdstevel@tonic-gate	i = (pltaddr - fp->file_plt_base -
66d9452f2Edward Pilatowicz	    M_PLT_XNumber * M32_PLT_ENTSIZE) / M32_PLT_ENTSIZE;
677c478bdstevel@tonic-gate
687c478bdstevel@tonic-gate	r_addr = fp->file_jmp_rel + i * sizeof (Elf32_Rela);
697c478bdstevel@tonic-gate
707c478bdstevel@tonic-gate	if (Pread(P, &r, sizeof (r), r_addr) == sizeof (r) &&
717c478bdstevel@tonic-gate	    (i = ELF32_R_SYM(r.r_info)) < fp->file_dynsym.sym_symn) {
727c478bdstevel@tonic-gate
73d51e907ab		Elf_Data *data = fp->file_dynsym.sym_data_pri;
747c478bdstevel@tonic-gate		Elf32_Sym *symp = &(((Elf32_Sym *)data->d_buf)[i]);
757c478bdstevel@tonic-gate
767c478bdstevel@tonic-gate		return (fp->file_dynsym.sym_strs + symp->st_name);
777c478bdstevel@tonic-gate	}
787c478bdstevel@tonic-gate
797c478bdstevel@tonic-gate	return (NULL);
807c478bdstevel@tonic-gate}
817c478bdstevel@tonic-gate
827c478bdstevel@tonic-gateint
837c478bdstevel@tonic-gatePissyscall(struct ps_prochandle *P, uintptr_t addr)
847c478bdstevel@tonic-gate{
857c478bdstevel@tonic-gate	instr_t sysinstr;
867c478bdstevel@tonic-gate	instr_t instr;
877c478bdstevel@tonic-gate
887c478bdstevel@tonic-gate	sysinstr = SYSCALL32;
897c478bdstevel@tonic-gate
907c478bdstevel@tonic-gate	if (Pread(P, &instr, sizeof (instr), addr) != sizeof (instr) ||
917c478bdstevel@tonic-gate	    instr != sysinstr)
927c478bdstevel@tonic-gate		return (0);
937c478bdstevel@tonic-gate	else
947c478bdstevel@tonic-gate		return (1);
957c478bdstevel@tonic-gate}
967c478bdstevel@tonic-gate
977c478bdstevel@tonic-gateint
987c478bdstevel@tonic-gatePissyscall_prev(struct ps_prochandle *P, uintptr_t addr, uintptr_t *dst)
997c478bdstevel@tonic-gate{
1007c478bdstevel@tonic-gate	uintptr_t prevaddr = addr - sizeof (instr_t);
1017c478bdstevel@tonic-gate
1027c478bdstevel@tonic-gate	if (Pissyscall(P, prevaddr)) {
1037c478bdstevel@tonic-gate		if (dst)
1047c478bdstevel@tonic-gate			*dst = prevaddr;
1057c478bdstevel@tonic-gate		return (1);
1067c478bdstevel@tonic-gate	}
1077c478bdstevel@tonic-gate
1087c478bdstevel@tonic-gate	return (0);
1097c478bdstevel@tonic-gate}
1107c478bdstevel@tonic-gate
1117c478bdstevel@tonic-gate/* ARGSUSED */
1127c478bdstevel@tonic-gateint
1137c478bdstevel@tonic-gatePissyscall_text(struct ps_prochandle *P, const void *buf, size_t buflen)
1147c478bdstevel@tonic-gate{
1157c478bdstevel@tonic-gate	instr_t sysinstr;
1167c478bdstevel@tonic-gate
1177c478bdstevel@tonic-gate	sysinstr = SYSCALL32;
1187c478bdstevel@tonic-gate
1197c478bdstevel@tonic-gate	if (buflen >= sizeof (instr_t) &&
1207c478bdstevel@tonic-gate	    memcmp(buf, &sysinstr, sizeof (instr_t)) == 0)
1217c478bdstevel@tonic-gate		return (1);
1227c478bdstevel@tonic-gate	else
1237c478bdstevel@tonic-gate		return (0);
1247c478bdstevel@tonic-gate}
1257c478bdstevel@tonic-gate
1267c478bdstevel@tonic-gate/*
1277c478bdstevel@tonic-gate * For gwindows_t support, we define a structure to pass arguments to
1287c478bdstevel@tonic-gate * a Plwp_iter() callback routine.
1297c478bdstevel@tonic-gate */
1307c478bdstevel@tonic-gatetypedef struct {
1317c478bdstevel@tonic-gate	struct ps_prochandle *gq_proc;	/* libproc handle */
1327c478bdstevel@tonic-gate	struct rwindow *gq_rwin;	/* rwindow destination buffer */
1337c478bdstevel@tonic-gate	uintptr_t gq_addr;		/* stack address to match */
1347c478bdstevel@tonic-gate} gwin_query_t;
1357c478bdstevel@tonic-gate
1367c478bdstevel@tonic-gatestatic int
1377c478bdstevel@tonic-gatefind_gwin(gwin_query_t *gqp, const lwpstatus_t *psp)
1387c478bdstevel@tonic-gate{
1397c478bdstevel@tonic-gate	gwindows_t gwin;
1407c478bdstevel@tonic-gate	struct stat64 st;
1417c478bdstevel@tonic-gate	char path[64];
1427c478bdstevel@tonic-gate	ssize_t n;
1437c478bdstevel@tonic-gate	int fd, i;
1447c478bdstevel@tonic-gate	int rv = 0; /* Return value for skip to next lwp */
1457c478bdstevel@tonic-gate
1467c478bdstevel@tonic-gate	(void) snprintf(path, sizeof (path), "/proc/%d/lwp/%d/gwindows",
1477c478bdstevel@tonic-gate	    (int)gqp->gq_proc->pid, (int)psp->pr_lwpid);
1487c478bdstevel@tonic-gate
1497c478bdstevel@tonic-gate	if (stat64(path, &st) == -1 || st.st_size == 0)
1507c478bdstevel@tonic-gate		return (0); /* Nothing doing; skip to next lwp */
1517c478bdstevel@tonic-gate
1527c478bdstevel@tonic-gate	if ((fd = open64(path, O_RDONLY)) >= 0) {
1537c478bdstevel@tonic-gate		/*
1547c478bdstevel@tonic-gate		 * Zero out the gwindows_t because the gwindows file only has
1557c478bdstevel@tonic-gate		 * as much data as needed to represent the saved windows.
1567c478bdstevel@tonic-gate		 */
1577c478bdstevel@tonic-gate		(void) memset(&gwin, 0, sizeof (gwin));
1587c478bdstevel@tonic-gate		n = read(fd, &gwin, sizeof (gwin));
1597c478bdstevel@tonic-gate
1607c478bdstevel@tonic-gate		if (n > 0) {
1617c478bdstevel@tonic-gate			/*
1627c478bdstevel@tonic-gate			 * If we actually found a non-zero gwindows file and
1637c478bdstevel@tonic-gate			 * were able to read it, iterate through the buffers
1647c478bdstevel@tonic-gate			 * looking for a stack pointer match; if one is found,
1657c478bdstevel@tonic-gate			 * copy out the corresponding register window.
1667c478bdstevel@tonic-gate			 */
1677c478bdstevel@tonic-gate			for (i = 0; i < gwin.wbcnt; i++) {
1687c478bdstevel@tonic-gate				if (gwin.spbuf[i] == (greg_t *)gqp->gq_addr) {
1697c478bdstevel@tonic-gate					(void) memcpy(gqp->gq_rwin,
1707c478bdstevel@tonic-gate					    &gwin.wbuf[i],
1717c478bdstevel@tonic-gate					    sizeof (struct rwindow));
1727c478bdstevel@tonic-gate
1737c478bdstevel@tonic-gate					rv = 1; /* We're done */
1747c478bdstevel@tonic-gate					break;
1757c478bdstevel@tonic-gate				}
1767c478bdstevel@tonic-gate			}
1777c478bdstevel@tonic-gate		}
1787c478bdstevel@tonic-gate		(void) close(fd);
1797c478bdstevel@tonic-gate	}
1807c478bdstevel@tonic-gate
1817c478bdstevel@tonic-gate	return (rv);
1827c478bdstevel@tonic-gate}
1837c478bdstevel@tonic-gate
1847c478bdstevel@tonic-gatestatic int
1857c478bdstevel@tonic-gateread_gwin(struct ps_prochandle *P, struct rwindow *rwp, uintptr_t sp)
1867c478bdstevel@tonic-gate{
1877c478bdstevel@tonic-gate	gwin_query_t gq;
1887c478bdstevel@tonic-gate
1897c478bdstevel@tonic-gate	if (P->state == PS_DEAD) {
19069a119cChristopher Siden		core_info_t *core = P->data;
19169a119cChristopher Siden		lwp_info_t *lwp = list_next(&core->core_lwp_head);
1927c478bdstevel@tonic-gate		uint_t n;
1937c478bdstevel@tonic-gate		int i;
1947c478bdstevel@tonic-gate
19569a119cChristopher Siden		for (n = 0; n < core->core_nlwp; n++, lwp = list_next(lwp)) {
1967c478bdstevel@tonic-gate			gwindows_t *gwin = lwp->lwp_gwins;
1977c478bdstevel@tonic-gate
1987c478bdstevel@tonic-gate			if (gwin == NULL)
1997c478bdstevel@tonic-gate				continue; /* No gwindows for this lwp */
2007c478bdstevel@tonic-gate
2017c478bdstevel@tonic-gate			/*
2027c478bdstevel@tonic-gate			 * If this lwp has gwindows associated with it, iterate
2037c478bdstevel@tonic-gate			 * through the buffers looking for a stack pointer
2047c478bdstevel@tonic-gate			 * match; if one is found, copy out the register window.
2057c478bdstevel@tonic-gate			 */
2067c478bdstevel@tonic-gate			for (i = 0; i < gwin->wbcnt; i++) {
2077c478bdstevel@tonic-gate				if (gwin->spbuf[i] == (greg_t *)sp) {
2087c478bdstevel@tonic-gate					(void) memcpy(rwp, &gwin->wbuf[i],
2097c478bdstevel@tonic-gate					    sizeof (struct rwindow));
2107c478bdstevel@tonic-gate					return (0); /* We're done */
2117c478bdstevel@tonic-gate				}
2127c478bdstevel@tonic-gate			}
2137c478bdstevel@tonic-gate		}
2147c478bdstevel@tonic-gate
2157c478bdstevel@tonic-gate		return (-1); /* No gwindows match found */
2167c478bdstevel@tonic-gate
2177c478bdstevel@tonic-gate	}
2187c478bdstevel@tonic-gate
2197c478bdstevel@tonic-gate	gq.gq_proc = P;
2207c478bdstevel@tonic-gate	gq.gq_rwin = rwp;
2217c478bdstevel@tonic-gate	gq.gq_addr = sp;
2227c478bdstevel@tonic-gate
2237c478bdstevel@tonic-gate	return (Plwp_iter(P, (proc_lwp_f *)find_gwin, &gq) ? 0 : -1);
2247c478bdstevel@tonic-gate}
2257c478bdstevel@tonic-gate
2267c478bdstevel@tonic-gatestatic void
2277c478bdstevel@tonic-gateucontext_n_to_prgregs(const ucontext_t *src, prgregset_t dst)
2287c478bdstevel@tonic-gate{
2297c478bdstevel@tonic-gate	const greg_t *gregs = &src->uc_mcontext.gregs[0];
2307c478bdstevel@tonic-gate
2317c478bdstevel@tonic-gate	dst[R_PSR] = gregs[REG_PSR];
2327c478bdstevel@tonic-gate	dst[R_PC] = gregs[REG_PC];
2337c478bdstevel@tonic-gate	dst[R_nPC] = gregs[REG_nPC];
2347c478bdstevel@tonic-gate	dst[R_Y] = gregs[REG_Y];
2357c478bdstevel@tonic-gate
2367c478bdstevel@tonic-gate	dst[R_G1] = gregs[REG_G1];
2377c478bdstevel@tonic-gate	dst[R_G2] = gregs[REG_G2];
2387c478bdstevel@tonic-gate	dst[R_G3] = gregs[REG_G3];
2397c478bdstevel@tonic-gate	dst[R_G4] = gregs[REG_G4];
2407c478bdstevel@tonic-gate	dst[R_G5] = gregs[REG_G5];
2417c478bdstevel@tonic-gate	dst[R_G6] = gregs[REG_G6];
2427c478bdstevel@tonic-gate	dst[R_G7] = gregs[REG_G7];
2437c478bdstevel@tonic-gate
2447c478bdstevel@tonic-gate	dst[R_O0] = gregs[REG_O0];
2457c478bdstevel@tonic-gate	dst[R_O1] = gregs[REG_O1];
2467c478bdstevel@tonic-gate	dst[R_O2] = gregs[REG_O2];
2477c478bdstevel@tonic-gate	dst[R_O3] = gregs[REG_O3];
2487c478bdstevel@tonic-gate	dst[R_O4] = gregs[REG_O4];
2497c478bdstevel@tonic-gate	dst[R_O5] = gregs[REG_O5];
2507c478bdstevel@tonic-gate	dst[R_O6] = gregs[REG_O6];
2517c478bdstevel@tonic-gate	dst[R_O7] = gregs[REG_O7];
2527c478bdstevel@tonic-gate}
2537c478bdstevel@tonic-gate
2547c478bdstevel@tonic-gateint
2557c478bdstevel@tonic-gatePstack_iter(struct ps_prochandle *P, const prgregset_t regs,
2567c478bdstevel@tonic-gate	proc_stack_f *func, void *arg)
2577c478bdstevel@tonic-gate{
2587c478bdstevel@tonic-gate	prgreg_t *prevfp = NULL;
2597c478bdstevel@tonic-gate	uint_t pfpsize = 0;
2607c478bdstevel@tonic-gate	int nfp = 0;
2617c478bdstevel@tonic-gate	prgregset_t gregs;
2627c478bdstevel@tonic-gate	long args[6];
2637c478bdstevel@tonic-gate	prgreg_t fp;
2647c478bdstevel@tonic-gate	int i;
2657c478bdstevel@tonic-gate	int rv;
2667c478bdstevel@tonic-gate	uintptr_t sp;
2677c478bdstevel@tonic-gate	ssize_t n;
2687c478bdstevel@tonic-gate	uclist_t ucl;
2697c478bdstevel@tonic-gate	ucontext_t uc;
2707c478bdstevel@tonic-gate
2717c478bdstevel@tonic-gate	init_uclist(&ucl, P);
2727c478bdstevel@tonic-gate	(void) memcpy(gregs, regs, sizeof (gregs));
2737c478bdstevel@tonic-gate
2747c478bdstevel@tonic-gate	for (;;) {
2757c478bdstevel@tonic-gate		fp = gregs[R_FP];
2767c478bdstevel@tonic-gate		if (stack_loop(fp, &prevfp, &nfp, &pfpsize))
2777c478bdstevel@tonic-gate			break;
2787c478bdstevel@tonic-gate
2797c478bdstevel@tonic-gate		for (i = 0; i < 6; i++)
2807c478bdstevel@tonic-gate			args[i] = gregs[R_I0 + i];
2817c478bdstevel@tonic-gate		if ((rv = func(arg, gregs, 6, args)) != 0)
2827c478bdstevel@tonic-gate			break;
2837c478bdstevel@tonic-gate
2847c478bdstevel@tonic-gate		gregs[R_PC] = gregs[R_I7];
2857c478bdstevel@tonic-gate		gregs[R_nPC] = gregs[R_PC] + 4;
2867c478bdstevel@tonic-gate		(void) memcpy(&gregs[R_O0], &gregs[R_I0], 8*sizeof (prgreg_t));
2877c478bdstevel@tonic-gate		if ((sp = gregs[R_FP]) == 0)
2887c478bdstevel@tonic-gate			break;
2897c478bdstevel@tonic-gate
2907c478bdstevel@tonic-gate		sp += STACK_BIAS;
2917c478bdstevel@tonic-gate
2927c478bdstevel@tonic-gate		if (find_uclink(&ucl, sp + SA(sizeof (struct frame))) &&
2937c478bdstevel@tonic-gate		    Pread(P, &uc, sizeof (uc), sp +
2947c478bdstevel@tonic-gate		    SA(sizeof (struct frame))) == sizeof (uc)) {
2957c478bdstevel@tonic-gate			ucontext_n_to_prgregs(&uc, gregs);
2967c478bdstevel@tonic-gate			sp = gregs[R_SP] + STACK_BIAS;
2977c478bdstevel@tonic-gate		}
2987c478bdstevel@tonic-gate
2997c478bdstevel@tonic-gate		n = Pread(P, &gregs[R_L0], sizeof (struct rwindow), sp);
3007c478bdstevel@tonic-gate
3017c478bdstevel@tonic-gate		if (n == sizeof (struct rwindow))
3027c478bdstevel@tonic-gate			continue;
3037c478bdstevel@tonic-gate
3047c478bdstevel@tonic-gate		/*
3057c478bdstevel@tonic-gate		 * If we get here, then our Pread of the register window
3067c478bdstevel@tonic-gate		 * failed.  If this is because the address was not mapped,
3077c478bdstevel@tonic-gate		 * then we attempt to read this window via any gwindows
3087c478bdstevel@tonic-gate		 * information we have.  If that too fails, abort our loop.
3097c478bdstevel@tonic-gate		 */
3107c478bdstevel@tonic-gate		if (n > 0)
3117c478bdstevel@tonic-gate			break;	/* Failed for reason other than not mapped */
3127c478bdstevel@tonic-gate
3137c478bdstevel@tonic-gate		if (read_gwin(P, (struct rwindow *)&gregs[R_L0], sp) == -1)
3147c478bdstevel@tonic-gate			break;	/* No gwindows match either */
3157c478bdstevel@tonic-gate	}
3167c478bdstevel@tonic-gate
3177c478bdstevel@tonic-gate	if (prevfp)
3187c478bdstevel@tonic-gate		free(prevfp);
3197c478bdstevel@tonic-gate
3207c478bdstevel@tonic-gate	free_uclist(&ucl);
3217c478bdstevel@tonic-gate	return (rv);
3227c478bdstevel@tonic-gate}
3237c478bdstevel@tonic-gate
3247c478bdstevel@tonic-gateuintptr_t
3257c478bdstevel@tonic-gatePsyscall_setup(struct ps_prochandle *P, int nargs, int sysindex, uintptr_t sp)
3267c478bdstevel@tonic-gate{
3277c478bdstevel@tonic-gate	sp -= (nargs > 6)?
328d9452f2Edward Pilatowicz	    WINDOWSIZE32 + sizeof (int32_t) * (1 + nargs) :
329d9452f2Edward Pilatowicz	    WINDOWSIZE32 + sizeof (int32_t) * (1 + 6);
3307c478bdstevel@tonic-gate	sp = PSTACK_ALIGN32(sp);
3317c478bdstevel@tonic-gate
3327c478bdstevel@tonic-gate	P->status.pr_lwp.pr_reg[R_G1] = sysindex;
3337c478bdstevel@tonic-gate	P->status.pr_lwp.pr_reg[R_SP] = sp;
3347c478bdstevel@tonic-gate	P->status.pr_lwp.pr_reg[R_PC] = P->sysaddr;
3357c478bdstevel@tonic-gate	P->status.pr_lwp.pr_reg[R_nPC] = P->sysaddr + sizeof (instr_t);
3367c478bdstevel@tonic-gate
3377c478bdstevel@tonic-gate	return (sp + WINDOWSIZE32 + sizeof (int32_t));
3387c478bdstevel@tonic-gate}
3397c478bdstevel@tonic-gate
3407c478bdstevel@tonic-gateint
3417c478bdstevel@tonic-gatePsyscall_copyinargs(struct ps_prochandle *P, int nargs, argdes_t *argp,
3427c478bdstevel@tonic-gate    uintptr_t ap)
3437c478bdstevel@tonic-gate{
3447c478bdstevel@tonic-gate	uint32_t arglist[MAXARGS+2];
3457c478bdstevel@tonic-gate	int i;
3467c478bdstevel@tonic-gate	argdes_t *adp;
3477c478bdstevel@tonic-gate
3487c478bdstevel@tonic-gate	for (i = 0, adp = argp; i < nargs; i++, adp++) {
3497c478bdstevel@tonic-gate		arglist[i] = adp->arg_value;
3507c478bdstevel@tonic-gate
3517c478bdstevel@tonic-gate		if (i < 6)
3527c478bdstevel@tonic-gate			(void) Pputareg(P, R_O0+i, adp->arg_value);
3537c478bdstevel@tonic-gate	}
3547c478bdstevel@tonic-gate
3557c478bdstevel@tonic-gate	if (nargs > 6 &&
3567c478bdstevel@tonic-gate	    Pwrite(P, &arglist[0], sizeof (int32_t) * nargs,
3577c478bdstevel@tonic-gate	    (uintptr_t)ap) != sizeof (int32_t) * nargs)
3587c478bdstevel@tonic-gate		return (-1);
3597c478bdstevel@tonic-gate
3607c478bdstevel@tonic-gate	return (0);
3617c478bdstevel@tonic-gate}
3627c478bdstevel@tonic-gate
3637c478bdstevel@tonic-gate/* ARGSUSED */
3647c478bdstevel@tonic-gateint
3657c478bdstevel@tonic-gatePsyscall_copyoutargs(struct ps_prochandle *P, int nargs, argdes_t *argp,
3667c478bdstevel@tonic-gate    uintptr_t ap)
3677c478bdstevel@tonic-gate{
3687c478bdstevel@tonic-gate	/* Do nothing */
3697c478bdstevel@tonic-gate	return (0);
3707c478bdstevel@tonic-gate}
371