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/lib/libc/amd64/sys/getcontext.S
+++ new/usr/src/lib/libc/amd64/sys/getcontext.S
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 (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
|
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 +/*
28 + * Copyright 2023 Oxide Computer Company
29 + */
30 +
27 31 .file "getcontext.s"
28 32
29 33 #include <sys/asm_linkage.h>
30 34
31 35 ANSI_PRAGMA_WEAK(getcontext,function)
32 36 ANSI_PRAGMA_WEAK(swapcontext,function)
33 37
34 38 #include "SYS.h"
35 39 #include <../assym.h>
36 40
37 41 /*
38 42 * getcontext() is written in assembler since it has to capture the correct
39 43 * machine state of the calle.
40 44 *
41 45 * As swapcontext() is actually equivalent to getcontext() + setcontext(),
42 46 * swapcontext() shares the most code with getcontext().
43 47 */
44 48
45 -#define GETCONTEXT_IMPL(offset) \
49 +#define GETCONTEXT_IMPL(offset, func) \
46 50 pushq %rdi; /* preserve the ucontext_t pointer */ \
47 - call __getcontext; \
51 + call func; \
48 52 /* call getcontext: syscall */ \
49 53 popq %rdx; \
50 54 andl %eax, %eax; /* if (error_return_from_syscall) */ \
51 55 je 1f; \
52 56 addq $offset, %rsp; \
53 57 ret; /* then just return */ \
54 58 1: \
55 59 /* \
56 60 * fix up %rsp and %rip \
57 61 */ \
58 62 addq $UC_MCONTEXT_GREGS, %rdx; \
59 63 /* &ucp->uc_mcontext.gregs */ \
60 64 movq offset+0(%rsp), %rax; \
61 65 /* read return PC from stack */ \
|
↓ open down ↓ |
4 lines elided |
↑ open up ↑ |
62 66 movq %rax, RIP_OFF (%rdx); \
63 67 /* store ret PC in EIP of env var */ \
64 68 leaq offset+8(%rsp), %rax; \
65 69 /* get caller's sp at time of call */ \
66 70 movq %rax, RSP_OFF (%rdx); \
67 71 /* store the sp into UESP of env var */ \
68 72 xorq %rax, %rax; /* return 0 */ \
69 73 movq %rax, RAX_OFF (%rdx); \
70 74 /* getcontext returns 0 after setcontext */
71 75
72 -/*
73 - * getcontext(ucontext_t *ucp)
76 +/*
77 + * int getcontext(ucontext_t *ucp)
74 78 */
75 79
76 80 ENTRY(getcontext)
77 - GETCONTEXT_IMPL(0)
81 + GETCONTEXT_IMPL(0, __getcontext)
78 82 ret
79 83 SET_SIZE(getcontext)
80 84
81 85 /*
82 - * swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
86 + * int swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
83 87 */
84 88
85 89 ENTRY(swapcontext)
86 90 pushq %rsi /* preserve the 2nd argument */
87 -
88 - GETCONTEXT_IMPL(8)
89 91
92 + GETCONTEXT_IMPL(8, __getcontext)
93 +
90 94 /* call setcontext */
91 95 popq %rdi
92 96 call setcontext
93 97 ret
94 98 SET_SIZE(swapcontext)
99 +
100 +/*
101 + * int getcontext_extd(ucontext_t * ctx, uint32_t flags)
102 + */
103 + ENTRY(getcontext_extd)
104 + cmpl $0, %esi
105 + jne 2f
106 + GETCONTEXT_IMPL(0, __getcontext_extd)
107 + ret
108 +2:
109 + movl $EINVAL, %eax /* errno = EINVAL */
110 + jmp __cerror /* return (-1) */
111 + SET_SIZE(getcontext_extd)
112 +
113 +/*
114 + * int swapcontext_extd(ucontext_t *oucp, uint32_t flags, const ucontext_t *ucp)
115 + */
116 +
117 + ENTRY(swapcontext_extd)
118 + cmpl $0, %esi
119 + jne 2f
120 + pushq %rdx /* preserve the 3rd argument */
121 +
122 + GETCONTEXT_IMPL(8, __getcontext_extd)
123 +
124 + /* call setcontext */
125 + popq %rdi
126 + call setcontext
127 + ret
128 +2:
129 + movl $EINVAL, %eax /* errno = EINVAL */
130 + jmp __cerror /* return (-1) */
131 + SET_SIZE(swapcontext_extd)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX