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/exec/elf/old_notes.c
+++ new/usr/src/uts/common/exec/elf/old_notes.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 #include <sys/types.h>
28 28 #include <sys/param.h>
29 29 #include <sys/thread.h>
30 30 #include <sys/sysmacros.h>
31 31 #include <sys/signal.h>
32 32 #include <sys/cred.h>
33 33 #include <sys/user.h>
34 34 #include <sys/errno.h>
35 35 #include <sys/vnode.h>
36 36 #include <sys/mman.h>
37 37 #include <sys/kmem.h>
38 38 #include <sys/proc.h>
39 39 #include <sys/pathname.h>
40 40 #include <sys/cmn_err.h>
41 41 #include <sys/systm.h>
42 42 #include <sys/elf.h>
43 43 #include <sys/vmsystm.h>
44 44 #include <sys/debug.h>
45 45 #include <sys/old_procfs.h>
46 46 #include <sys/auxv.h>
47 47 #include <sys/exec.h>
48 48 #include <sys/prsystm.h>
49 49 #include <vm/as.h>
|
↓ open down ↓ |
49 lines elided |
↑ open up ↑ |
50 50 #include <vm/rm.h>
51 51 #include <sys/modctl.h>
52 52 #include <sys/systeminfo.h>
53 53 #include <sys/machelf.h>
54 54 #include <sys/zone.h>
55 55 #include "elf_impl.h"
56 56
57 57 extern void oprgetstatus(kthread_t *, prstatus_t *, zone_t *);
58 58 extern void oprgetpsinfo(proc_t *, prpsinfo_t *, kthread_t *);
59 59
60 +/*
61 + * Historically the system dumped the xreg note when on SPARC. Because we no
62 + * longer support SPARC we do not dump the old note form of the xregs for any
63 + * additional platforms. Please do not add this back unless it's for SPARC's
64 + * future resurrection.
65 + */
60 66 void
61 67 setup_old_note_header(Phdr *v, proc_t *p)
62 68 {
63 69 int nlwp = p->p_lwpcnt;
64 - size_t size;
65 70
66 71 v[0].p_type = PT_NOTE;
67 72 v[0].p_flags = PF_R;
68 73 v[0].p_filesz = (sizeof (Note) * (3 + nlwp))
69 74 + roundup(sizeof (prpsinfo_t), sizeof (Word))
70 75 + roundup(strlen(platform) + 1, sizeof (Word))
71 76 + roundup(__KERN_NAUXV_IMPL * sizeof (aux_entry_t),
72 77 sizeof (Word))
73 78 + nlwp * roundup(sizeof (prstatus_t), sizeof (Word));
74 - if (prhasfp())
75 - v[0].p_filesz += nlwp * sizeof (Note)
76 - + nlwp*roundup(sizeof (prfpregset_t), sizeof (Word));
77 - if ((size = prhasx(p)? prgetprxregsize(p) : 0) != 0)
78 - v[0].p_filesz += nlwp * sizeof (Note)
79 - + nlwp * roundup(size, sizeof (Word));
80 -
81 -#if defined(__sparc)
82 - /*
83 - * Figure out the number and sizes of register windows.
84 - */
85 - {
86 - kthread_t *t = p->p_tlist;
87 - do {
88 - if ((size = prnwindows(ttolwp(t))) != 0) {
89 - size = sizeof (gwindows_t) -
90 - (SPARC_MAXREGWINDOW - size) *
91 - sizeof (struct rwindow);
92 - v[0].p_filesz += sizeof (Note) +
93 - roundup(size, sizeof (Word));
94 - }
95 - } while ((t = t->t_forw) != p->p_tlist);
79 + if (prhasfp()) {
80 + v[0].p_filesz += nlwp * sizeof (Note) +
81 + nlwp * roundup(sizeof (prfpregset_t), sizeof (Word));
96 82 }
97 -#endif /* __sparc */
98 83 }
99 84
100 85 int
101 86 write_old_elfnotes(proc_t *p, int sig, vnode_t *vp, offset_t offset,
102 87 rlim64_t rlimit, cred_t *credp)
103 88 {
104 89 union {
105 90 prpsinfo_t psinfo;
106 91 prstatus_t prstat;
107 92 prfpregset_t fpregs;
108 -#if defined(__sparc)
109 - gwindows_t gwindows;
110 -#endif /* __sparc */
111 - char xregs[1];
112 93 aux_entry_t auxv[__KERN_NAUXV_IMPL];
113 94 } *bigwad;
114 - int xregsize = prhasx(p)? prgetprxregsize(p) : 0;
115 - size_t bigsize = MAX(sizeof (*bigwad), (size_t)xregsize);
95 + size_t bigsize = sizeof (*bigwad);
116 96 kthread_t *t;
117 97 klwp_t *lwp;
118 98 user_t *up;
119 99 int i;
120 100 int nlwp;
121 101 int error;
122 102
123 103 bigwad = kmem_alloc(bigsize, KM_SLEEP);
124 104
125 105 /*
126 106 * The order of the elfnote entries should be same here and in
127 107 * the gcore(1) command. Synchronization is needed between the
128 108 * kernel and libproc's Pfgcore() function where the meat of
129 109 * the gcore(1) command lives.
130 110 */
131 111
132 112 mutex_enter(&p->p_lock);
133 113 oprgetpsinfo(p, &bigwad->psinfo, NULL);
134 114 mutex_exit(&p->p_lock);
135 115 error = elfnote(vp, &offset, NT_PRPSINFO, sizeof (bigwad->psinfo),
136 116 (caddr_t)&bigwad->psinfo, rlimit, credp);
137 117 if (error)
138 118 goto done;
139 119
140 120 error = elfnote(vp, &offset, NT_PLATFORM, strlen(platform) + 1,
141 121 platform, rlimit, credp);
142 122 if (error)
143 123 goto done;
144 124
145 125 up = PTOU(p);
146 126 for (i = 0; i < __KERN_NAUXV_IMPL; i++) {
147 127 bigwad->auxv[i].a_type = up->u_auxv[i].a_type;
148 128 bigwad->auxv[i].a_un.a_val = up->u_auxv[i].a_un.a_val;
149 129 }
150 130 error = elfnote(vp, &offset, NT_AUXV, sizeof (bigwad->auxv),
151 131 (caddr_t)bigwad->auxv, rlimit, credp);
152 132 if (error)
153 133 goto done;
154 134
155 135 t = curthread;
156 136 nlwp = p->p_lwpcnt;
157 137 do {
158 138 ASSERT(nlwp != 0);
159 139 nlwp--;
160 140 lwp = ttolwp(t);
161 141
162 142 mutex_enter(&p->p_lock);
163 143 if (t == curthread) {
164 144 uchar_t oldsig;
165 145
166 146 /*
167 147 * Modify t_whystop and lwp_cursig so it appears that
168 148 * the current LWP is stopped after faulting on the
169 149 * signal that caused the core dump. As a result,
170 150 * oprgetstatus() will record that signal, the saved
171 151 * lwp_siginfo, and its signal handler in the core file
172 152 * status. We restore lwp_cursig in case a subsequent
173 153 * signal was received while dumping core.
174 154 */
175 155 oldsig = lwp->lwp_cursig;
176 156 lwp->lwp_cursig = (uchar_t)sig;
177 157 t->t_whystop = PR_FAULTED;
178 158
179 159 oprgetstatus(t, &bigwad->prstat, p->p_zone);
180 160 bigwad->prstat.pr_why = 0;
181 161
182 162 t->t_whystop = 0;
183 163 lwp->lwp_cursig = oldsig;
184 164
185 165 } else {
186 166 oprgetstatus(t, &bigwad->prstat, p->p_zone);
187 167 }
188 168 mutex_exit(&p->p_lock);
189 169 error = elfnote(vp, &offset, NT_PRSTATUS,
190 170 sizeof (bigwad->prstat), (caddr_t)&bigwad->prstat,
191 171 rlimit, credp);
|
↓ open down ↓ |
66 lines elided |
↑ open up ↑ |
192 172 if (error)
193 173 goto done;
194 174
195 175 if (prhasfp()) {
196 176 prgetprfpregs(lwp, &bigwad->fpregs);
197 177 error = elfnote(vp, &offset, NT_PRFPREG,
198 178 sizeof (bigwad->fpregs), (caddr_t)&bigwad->fpregs,
199 179 rlimit, credp);
200 180 if (error)
201 181 goto done;
202 - }
203 -
204 -#if defined(__sparc)
205 - /*
206 - * Unspilled SPARC register windows.
207 - */
208 - {
209 - size_t size = prnwindows(lwp);
210 -
211 - if (size != 0) {
212 - size = sizeof (gwindows_t) -
213 - (SPARC_MAXREGWINDOW - size) *
214 - sizeof (struct rwindow);
215 - prgetwindows(lwp, &bigwad->gwindows);
216 - error = elfnote(vp, &offset, NT_GWINDOWS,
217 - size, (caddr_t)&bigwad->gwindows,
218 - rlimit, credp);
219 - if (error)
220 - goto done;
221 - }
222 - }
223 -#endif /* __sparc */
224 -
225 - if (xregsize) {
226 - prgetprxregs(lwp, bigwad->xregs);
227 - error = elfnote(vp, &offset, NT_PRXREG,
228 - xregsize, bigwad->xregs, rlimit, credp);
229 - if (error)
230 - goto done;
231 182 }
232 183 } while ((t = t->t_forw) != curthread);
233 184 ASSERT(nlwp == 0);
234 185
235 186 done:
236 187 kmem_free(bigwad, bigsize);
237 188 return (error);
238 189 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX