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