1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate #include <sys/stack.h>
30*0Sstevel@tonic-gate #include <sys/regset.h>
31*0Sstevel@tonic-gate #include <sys/frame.h>
32*0Sstevel@tonic-gate #include <sys/sysmacros.h>
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate #include <stdlib.h>
35*0Sstevel@tonic-gate #include <unistd.h>
36*0Sstevel@tonic-gate #include <sys/types.h>
37*0Sstevel@tonic-gate #include <errno.h>
38*0Sstevel@tonic-gate #include <string.h>
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate #include "Pcontrol.h"
41*0Sstevel@tonic-gate #include "Pstack.h"
42*0Sstevel@tonic-gate #include "Pisadep.h"
43*0Sstevel@tonic-gate 
44*0Sstevel@tonic-gate #define	M_PLT_NRSV	4			/* reserved PLT entries */
45*0Sstevel@tonic-gate #define	M_PLT_ENTSIZE	12			/* size of each PLT entry */
46*0Sstevel@tonic-gate 
47*0Sstevel@tonic-gate #define	SYSCALL32 0x91d02008	/* 32-bit syscall (ta 8) instruction */
48*0Sstevel@tonic-gate 
49*0Sstevel@tonic-gate #ifndef	WINDOWSIZE32
50*0Sstevel@tonic-gate #define	WINDOWSIZE32	(16 * sizeof (int32_t))
51*0Sstevel@tonic-gate #endif
52*0Sstevel@tonic-gate 
53*0Sstevel@tonic-gate const char *
54*0Sstevel@tonic-gate Ppltdest(struct ps_prochandle *P, uintptr_t pltaddr)
55*0Sstevel@tonic-gate {
56*0Sstevel@tonic-gate 	map_info_t *mp = Paddr2mptr(P, pltaddr);
57*0Sstevel@tonic-gate 
58*0Sstevel@tonic-gate 	uintptr_t r_addr;
59*0Sstevel@tonic-gate 	file_info_t *fp;
60*0Sstevel@tonic-gate 	Elf32_Rela r;
61*0Sstevel@tonic-gate 	size_t i;
62*0Sstevel@tonic-gate 
63*0Sstevel@tonic-gate 	if (mp == NULL || (fp = mp->map_file) == NULL ||
64*0Sstevel@tonic-gate 	    fp->file_plt_base == 0 || pltaddr < fp->file_plt_base ||
65*0Sstevel@tonic-gate 	    pltaddr >= fp->file_plt_base + fp->file_plt_size) {
66*0Sstevel@tonic-gate 		errno = EINVAL;
67*0Sstevel@tonic-gate 		return (NULL);
68*0Sstevel@tonic-gate 	}
69*0Sstevel@tonic-gate 
70*0Sstevel@tonic-gate 	i = (pltaddr - fp->file_plt_base -
71*0Sstevel@tonic-gate 	    M_PLT_NRSV * M_PLT_ENTSIZE) / M_PLT_ENTSIZE;
72*0Sstevel@tonic-gate 
73*0Sstevel@tonic-gate 	r_addr = fp->file_jmp_rel + i * sizeof (Elf32_Rela);
74*0Sstevel@tonic-gate 
75*0Sstevel@tonic-gate 	if (Pread(P, &r, sizeof (r), r_addr) == sizeof (r) &&
76*0Sstevel@tonic-gate 	    (i = ELF32_R_SYM(r.r_info)) < fp->file_dynsym.sym_symn) {
77*0Sstevel@tonic-gate 
78*0Sstevel@tonic-gate 		Elf_Data *data = fp->file_dynsym.sym_data;
79*0Sstevel@tonic-gate 		Elf32_Sym *symp = &(((Elf32_Sym *)data->d_buf)[i]);
80*0Sstevel@tonic-gate 
81*0Sstevel@tonic-gate 		return (fp->file_dynsym.sym_strs + symp->st_name);
82*0Sstevel@tonic-gate 	}
83*0Sstevel@tonic-gate 
84*0Sstevel@tonic-gate 	return (NULL);
85*0Sstevel@tonic-gate }
86*0Sstevel@tonic-gate 
87*0Sstevel@tonic-gate int
88*0Sstevel@tonic-gate Pissyscall(struct ps_prochandle *P, uintptr_t addr)
89*0Sstevel@tonic-gate {
90*0Sstevel@tonic-gate 	instr_t sysinstr;
91*0Sstevel@tonic-gate 	instr_t instr;
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate 	sysinstr = SYSCALL32;
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate 	if (Pread(P, &instr, sizeof (instr), addr) != sizeof (instr) ||
96*0Sstevel@tonic-gate 	    instr != sysinstr)
97*0Sstevel@tonic-gate 		return (0);
98*0Sstevel@tonic-gate 	else
99*0Sstevel@tonic-gate 		return (1);
100*0Sstevel@tonic-gate }
101*0Sstevel@tonic-gate 
102*0Sstevel@tonic-gate int
103*0Sstevel@tonic-gate Pissyscall_prev(struct ps_prochandle *P, uintptr_t addr, uintptr_t *dst)
104*0Sstevel@tonic-gate {
105*0Sstevel@tonic-gate 	uintptr_t prevaddr = addr - sizeof (instr_t);
106*0Sstevel@tonic-gate 
107*0Sstevel@tonic-gate 	if (Pissyscall(P, prevaddr)) {
108*0Sstevel@tonic-gate 		if (dst)
109*0Sstevel@tonic-gate 			*dst = prevaddr;
110*0Sstevel@tonic-gate 		return (1);
111*0Sstevel@tonic-gate 	}
112*0Sstevel@tonic-gate 
113*0Sstevel@tonic-gate 	return (0);
114*0Sstevel@tonic-gate }
115*0Sstevel@tonic-gate 
116*0Sstevel@tonic-gate /* ARGSUSED */
117*0Sstevel@tonic-gate int
118*0Sstevel@tonic-gate Pissyscall_text(struct ps_prochandle *P, const void *buf, size_t buflen)
119*0Sstevel@tonic-gate {
120*0Sstevel@tonic-gate 	instr_t sysinstr;
121*0Sstevel@tonic-gate 
122*0Sstevel@tonic-gate 	sysinstr = SYSCALL32;
123*0Sstevel@tonic-gate 
124*0Sstevel@tonic-gate 	if (buflen >= sizeof (instr_t) &&
125*0Sstevel@tonic-gate 	    memcmp(buf, &sysinstr, sizeof (instr_t)) == 0)
126*0Sstevel@tonic-gate 		return (1);
127*0Sstevel@tonic-gate 	else
128*0Sstevel@tonic-gate 		return (0);
129*0Sstevel@tonic-gate }
130*0Sstevel@tonic-gate 
131*0Sstevel@tonic-gate /*
132*0Sstevel@tonic-gate  * For gwindows_t support, we define a structure to pass arguments to
133*0Sstevel@tonic-gate  * a Plwp_iter() callback routine.
134*0Sstevel@tonic-gate  */
135*0Sstevel@tonic-gate typedef struct {
136*0Sstevel@tonic-gate 	struct ps_prochandle *gq_proc;	/* libproc handle */
137*0Sstevel@tonic-gate 	struct rwindow *gq_rwin;	/* rwindow destination buffer */
138*0Sstevel@tonic-gate 	uintptr_t gq_addr;		/* stack address to match */
139*0Sstevel@tonic-gate } gwin_query_t;
140*0Sstevel@tonic-gate 
141*0Sstevel@tonic-gate static int
142*0Sstevel@tonic-gate find_gwin(gwin_query_t *gqp, const lwpstatus_t *psp)
143*0Sstevel@tonic-gate {
144*0Sstevel@tonic-gate 	gwindows_t gwin;
145*0Sstevel@tonic-gate 	struct stat64 st;
146*0Sstevel@tonic-gate 	char path[64];
147*0Sstevel@tonic-gate 	ssize_t n;
148*0Sstevel@tonic-gate 	int fd, i;
149*0Sstevel@tonic-gate 	int rv = 0; /* Return value for skip to next lwp */
150*0Sstevel@tonic-gate 
151*0Sstevel@tonic-gate 	(void) snprintf(path, sizeof (path), "/proc/%d/lwp/%d/gwindows",
152*0Sstevel@tonic-gate 	    (int)gqp->gq_proc->pid, (int)psp->pr_lwpid);
153*0Sstevel@tonic-gate 
154*0Sstevel@tonic-gate 	if (stat64(path, &st) == -1 || st.st_size == 0)
155*0Sstevel@tonic-gate 		return (0); /* Nothing doing; skip to next lwp */
156*0Sstevel@tonic-gate 
157*0Sstevel@tonic-gate 	if ((fd = open64(path, O_RDONLY)) >= 0) {
158*0Sstevel@tonic-gate 		/*
159*0Sstevel@tonic-gate 		 * Zero out the gwindows_t because the gwindows file only has
160*0Sstevel@tonic-gate 		 * as much data as needed to represent the saved windows.
161*0Sstevel@tonic-gate 		 */
162*0Sstevel@tonic-gate 		(void) memset(&gwin, 0, sizeof (gwin));
163*0Sstevel@tonic-gate 		n = read(fd, &gwin, sizeof (gwin));
164*0Sstevel@tonic-gate 
165*0Sstevel@tonic-gate 		if (n > 0) {
166*0Sstevel@tonic-gate 			/*
167*0Sstevel@tonic-gate 			 * If we actually found a non-zero gwindows file and
168*0Sstevel@tonic-gate 			 * were able to read it, iterate through the buffers
169*0Sstevel@tonic-gate 			 * looking for a stack pointer match; if one is found,
170*0Sstevel@tonic-gate 			 * copy out the corresponding register window.
171*0Sstevel@tonic-gate 			 */
172*0Sstevel@tonic-gate 			for (i = 0; i < gwin.wbcnt; i++) {
173*0Sstevel@tonic-gate 				if (gwin.spbuf[i] == (greg_t *)gqp->gq_addr) {
174*0Sstevel@tonic-gate 					(void) memcpy(gqp->gq_rwin,
175*0Sstevel@tonic-gate 					    &gwin.wbuf[i],
176*0Sstevel@tonic-gate 					    sizeof (struct rwindow));
177*0Sstevel@tonic-gate 
178*0Sstevel@tonic-gate 					rv = 1; /* We're done */
179*0Sstevel@tonic-gate 					break;
180*0Sstevel@tonic-gate 				}
181*0Sstevel@tonic-gate 			}
182*0Sstevel@tonic-gate 		}
183*0Sstevel@tonic-gate 		(void) close(fd);
184*0Sstevel@tonic-gate 	}
185*0Sstevel@tonic-gate 
186*0Sstevel@tonic-gate 	return (rv);
187*0Sstevel@tonic-gate }
188*0Sstevel@tonic-gate 
189*0Sstevel@tonic-gate static int
190*0Sstevel@tonic-gate read_gwin(struct ps_prochandle *P, struct rwindow *rwp, uintptr_t sp)
191*0Sstevel@tonic-gate {
192*0Sstevel@tonic-gate 	gwin_query_t gq;
193*0Sstevel@tonic-gate 
194*0Sstevel@tonic-gate 	if (P->state == PS_DEAD) {
195*0Sstevel@tonic-gate 		lwp_info_t *lwp = list_next(&P->core->core_lwp_head);
196*0Sstevel@tonic-gate 		uint_t n;
197*0Sstevel@tonic-gate 		int i;
198*0Sstevel@tonic-gate 
199*0Sstevel@tonic-gate 		for (n = 0; n < P->core->core_nlwp; n++, lwp = list_next(lwp)) {
200*0Sstevel@tonic-gate 			gwindows_t *gwin = lwp->lwp_gwins;
201*0Sstevel@tonic-gate 
202*0Sstevel@tonic-gate 			if (gwin == NULL)
203*0Sstevel@tonic-gate 				continue; /* No gwindows for this lwp */
204*0Sstevel@tonic-gate 
205*0Sstevel@tonic-gate 			/*
206*0Sstevel@tonic-gate 			 * If this lwp has gwindows associated with it, iterate
207*0Sstevel@tonic-gate 			 * through the buffers looking for a stack pointer
208*0Sstevel@tonic-gate 			 * match; if one is found, copy out the register window.
209*0Sstevel@tonic-gate 			 */
210*0Sstevel@tonic-gate 			for (i = 0; i < gwin->wbcnt; i++) {
211*0Sstevel@tonic-gate 				if (gwin->spbuf[i] == (greg_t *)sp) {
212*0Sstevel@tonic-gate 					(void) memcpy(rwp, &gwin->wbuf[i],
213*0Sstevel@tonic-gate 					    sizeof (struct rwindow));
214*0Sstevel@tonic-gate 					return (0); /* We're done */
215*0Sstevel@tonic-gate 				}
216*0Sstevel@tonic-gate 			}
217*0Sstevel@tonic-gate 		}
218*0Sstevel@tonic-gate 
219*0Sstevel@tonic-gate 		return (-1); /* No gwindows match found */
220*0Sstevel@tonic-gate 
221*0Sstevel@tonic-gate 	}
222*0Sstevel@tonic-gate 
223*0Sstevel@tonic-gate 	gq.gq_proc = P;
224*0Sstevel@tonic-gate 	gq.gq_rwin = rwp;
225*0Sstevel@tonic-gate 	gq.gq_addr = sp;
226*0Sstevel@tonic-gate 
227*0Sstevel@tonic-gate 	return (Plwp_iter(P, (proc_lwp_f *)find_gwin, &gq) ? 0 : -1);
228*0Sstevel@tonic-gate }
229*0Sstevel@tonic-gate 
230*0Sstevel@tonic-gate static void
231*0Sstevel@tonic-gate ucontext_n_to_prgregs(const ucontext_t *src, prgregset_t dst)
232*0Sstevel@tonic-gate {
233*0Sstevel@tonic-gate 	const greg_t *gregs = &src->uc_mcontext.gregs[0];
234*0Sstevel@tonic-gate 
235*0Sstevel@tonic-gate 	dst[R_PSR] = gregs[REG_PSR];
236*0Sstevel@tonic-gate 	dst[R_PC] = gregs[REG_PC];
237*0Sstevel@tonic-gate 	dst[R_nPC] = gregs[REG_nPC];
238*0Sstevel@tonic-gate 	dst[R_Y] = gregs[REG_Y];
239*0Sstevel@tonic-gate 
240*0Sstevel@tonic-gate 	dst[R_G1] = gregs[REG_G1];
241*0Sstevel@tonic-gate 	dst[R_G2] = gregs[REG_G2];
242*0Sstevel@tonic-gate 	dst[R_G3] = gregs[REG_G3];
243*0Sstevel@tonic-gate 	dst[R_G4] = gregs[REG_G4];
244*0Sstevel@tonic-gate 	dst[R_G5] = gregs[REG_G5];
245*0Sstevel@tonic-gate 	dst[R_G6] = gregs[REG_G6];
246*0Sstevel@tonic-gate 	dst[R_G7] = gregs[REG_G7];
247*0Sstevel@tonic-gate 
248*0Sstevel@tonic-gate 	dst[R_O0] = gregs[REG_O0];
249*0Sstevel@tonic-gate 	dst[R_O1] = gregs[REG_O1];
250*0Sstevel@tonic-gate 	dst[R_O2] = gregs[REG_O2];
251*0Sstevel@tonic-gate 	dst[R_O3] = gregs[REG_O3];
252*0Sstevel@tonic-gate 	dst[R_O4] = gregs[REG_O4];
253*0Sstevel@tonic-gate 	dst[R_O5] = gregs[REG_O5];
254*0Sstevel@tonic-gate 	dst[R_O6] = gregs[REG_O6];
255*0Sstevel@tonic-gate 	dst[R_O7] = gregs[REG_O7];
256*0Sstevel@tonic-gate }
257*0Sstevel@tonic-gate 
258*0Sstevel@tonic-gate int
259*0Sstevel@tonic-gate Pstack_iter(struct ps_prochandle *P, const prgregset_t regs,
260*0Sstevel@tonic-gate 	proc_stack_f *func, void *arg)
261*0Sstevel@tonic-gate {
262*0Sstevel@tonic-gate 	prgreg_t *prevfp = NULL;
263*0Sstevel@tonic-gate 	uint_t pfpsize = 0;
264*0Sstevel@tonic-gate 	int nfp = 0;
265*0Sstevel@tonic-gate 	prgregset_t gregs;
266*0Sstevel@tonic-gate 	long args[6];
267*0Sstevel@tonic-gate 	prgreg_t fp;
268*0Sstevel@tonic-gate 	int i;
269*0Sstevel@tonic-gate 	int rv;
270*0Sstevel@tonic-gate 	uintptr_t sp;
271*0Sstevel@tonic-gate 	ssize_t n;
272*0Sstevel@tonic-gate 	uclist_t ucl;
273*0Sstevel@tonic-gate 	ucontext_t uc;
274*0Sstevel@tonic-gate 
275*0Sstevel@tonic-gate 	init_uclist(&ucl, P);
276*0Sstevel@tonic-gate 	(void) memcpy(gregs, regs, sizeof (gregs));
277*0Sstevel@tonic-gate 
278*0Sstevel@tonic-gate 	for (;;) {
279*0Sstevel@tonic-gate 		fp = gregs[R_FP];
280*0Sstevel@tonic-gate 		if (stack_loop(fp, &prevfp, &nfp, &pfpsize))
281*0Sstevel@tonic-gate 			break;
282*0Sstevel@tonic-gate 
283*0Sstevel@tonic-gate 		for (i = 0; i < 6; i++)
284*0Sstevel@tonic-gate 			args[i] = gregs[R_I0 + i];
285*0Sstevel@tonic-gate 		if ((rv = func(arg, gregs, 6, args)) != 0)
286*0Sstevel@tonic-gate 			break;
287*0Sstevel@tonic-gate 
288*0Sstevel@tonic-gate 		gregs[R_PC] = gregs[R_I7];
289*0Sstevel@tonic-gate 		gregs[R_nPC] = gregs[R_PC] + 4;
290*0Sstevel@tonic-gate 		(void) memcpy(&gregs[R_O0], &gregs[R_I0], 8*sizeof (prgreg_t));
291*0Sstevel@tonic-gate 		if ((sp = gregs[R_FP]) == 0)
292*0Sstevel@tonic-gate 			break;
293*0Sstevel@tonic-gate 
294*0Sstevel@tonic-gate 		sp += STACK_BIAS;
295*0Sstevel@tonic-gate 
296*0Sstevel@tonic-gate 		if (find_uclink(&ucl, sp + SA(sizeof (struct frame))) &&
297*0Sstevel@tonic-gate 		    Pread(P, &uc, sizeof (uc), sp +
298*0Sstevel@tonic-gate 		    SA(sizeof (struct frame))) == sizeof (uc)) {
299*0Sstevel@tonic-gate 			ucontext_n_to_prgregs(&uc, gregs);
300*0Sstevel@tonic-gate 			sp = gregs[R_SP] + STACK_BIAS;
301*0Sstevel@tonic-gate 		}
302*0Sstevel@tonic-gate 
303*0Sstevel@tonic-gate 		n = Pread(P, &gregs[R_L0], sizeof (struct rwindow), sp);
304*0Sstevel@tonic-gate 
305*0Sstevel@tonic-gate 		if (n == sizeof (struct rwindow))
306*0Sstevel@tonic-gate 			continue;
307*0Sstevel@tonic-gate 
308*0Sstevel@tonic-gate 		/*
309*0Sstevel@tonic-gate 		 * If we get here, then our Pread of the register window
310*0Sstevel@tonic-gate 		 * failed.  If this is because the address was not mapped,
311*0Sstevel@tonic-gate 		 * then we attempt to read this window via any gwindows
312*0Sstevel@tonic-gate 		 * information we have.  If that too fails, abort our loop.
313*0Sstevel@tonic-gate 		 */
314*0Sstevel@tonic-gate 		if (n > 0)
315*0Sstevel@tonic-gate 			break;	/* Failed for reason other than not mapped */
316*0Sstevel@tonic-gate 
317*0Sstevel@tonic-gate 		if (read_gwin(P, (struct rwindow *)&gregs[R_L0], sp) == -1)
318*0Sstevel@tonic-gate 			break;	/* No gwindows match either */
319*0Sstevel@tonic-gate 	}
320*0Sstevel@tonic-gate 
321*0Sstevel@tonic-gate 	if (prevfp)
322*0Sstevel@tonic-gate 		free(prevfp);
323*0Sstevel@tonic-gate 
324*0Sstevel@tonic-gate 	free_uclist(&ucl);
325*0Sstevel@tonic-gate 	return (rv);
326*0Sstevel@tonic-gate }
327*0Sstevel@tonic-gate 
328*0Sstevel@tonic-gate uintptr_t
329*0Sstevel@tonic-gate Psyscall_setup(struct ps_prochandle *P, int nargs, int sysindex, uintptr_t sp)
330*0Sstevel@tonic-gate {
331*0Sstevel@tonic-gate 	sp -= (nargs > 6)?
332*0Sstevel@tonic-gate 		WINDOWSIZE32 + sizeof (int32_t) * (1 + nargs) :
333*0Sstevel@tonic-gate 		WINDOWSIZE32 + sizeof (int32_t) * (1 + 6);
334*0Sstevel@tonic-gate 	sp = PSTACK_ALIGN32(sp);
335*0Sstevel@tonic-gate 
336*0Sstevel@tonic-gate 	P->status.pr_lwp.pr_reg[R_G1] = sysindex;
337*0Sstevel@tonic-gate 	P->status.pr_lwp.pr_reg[R_SP] = sp;
338*0Sstevel@tonic-gate 	P->status.pr_lwp.pr_reg[R_PC] = P->sysaddr;
339*0Sstevel@tonic-gate 	P->status.pr_lwp.pr_reg[R_nPC] = P->sysaddr + sizeof (instr_t);
340*0Sstevel@tonic-gate 
341*0Sstevel@tonic-gate 	return (sp + WINDOWSIZE32 + sizeof (int32_t));
342*0Sstevel@tonic-gate }
343*0Sstevel@tonic-gate 
344*0Sstevel@tonic-gate int
345*0Sstevel@tonic-gate Psyscall_copyinargs(struct ps_prochandle *P, int nargs, argdes_t *argp,
346*0Sstevel@tonic-gate     uintptr_t ap)
347*0Sstevel@tonic-gate {
348*0Sstevel@tonic-gate 	uint32_t arglist[MAXARGS+2];
349*0Sstevel@tonic-gate 	int i;
350*0Sstevel@tonic-gate 	argdes_t *adp;
351*0Sstevel@tonic-gate 
352*0Sstevel@tonic-gate 	for (i = 0, adp = argp; i < nargs; i++, adp++) {
353*0Sstevel@tonic-gate 		arglist[i] = adp->arg_value;
354*0Sstevel@tonic-gate 
355*0Sstevel@tonic-gate 		if (i < 6)
356*0Sstevel@tonic-gate 			(void) Pputareg(P, R_O0+i, adp->arg_value);
357*0Sstevel@tonic-gate 	}
358*0Sstevel@tonic-gate 
359*0Sstevel@tonic-gate 	if (nargs > 6 &&
360*0Sstevel@tonic-gate 	    Pwrite(P, &arglist[0], sizeof (int32_t) * nargs,
361*0Sstevel@tonic-gate 	    (uintptr_t)ap) != sizeof (int32_t) * nargs)
362*0Sstevel@tonic-gate 		return (-1);
363*0Sstevel@tonic-gate 
364*0Sstevel@tonic-gate 	return (0);
365*0Sstevel@tonic-gate }
366*0Sstevel@tonic-gate 
367*0Sstevel@tonic-gate /* ARGSUSED */
368*0Sstevel@tonic-gate int
369*0Sstevel@tonic-gate Psyscall_copyoutargs(struct ps_prochandle *P, int nargs, argdes_t *argp,
370*0Sstevel@tonic-gate     uintptr_t ap)
371*0Sstevel@tonic-gate {
372*0Sstevel@tonic-gate 	/* Do nothing */
373*0Sstevel@tonic-gate 	return (0);
374*0Sstevel@tonic-gate }
375