| ... | @@ -196,17 +196,28 @@ pub fn clone() callconv(.naked) u64 { | ... | @@ -196,17 +196,28 @@ pub fn clone() callconv(.naked) u64 { |
| 196 | // g1 o0, o1, o2, o3, o4 | 196 | // g1 o0, o1, o2, o3, o4 |
| 197 | asm volatile ( | 197 | asm volatile ( |
| 198 | \\ save %%sp, -192, %%sp | 198 | \\ save %%sp, -192, %%sp |
| | 199 | \\ |
| | 200 | \\ // clone() on SPARC can fail with EFAULT if %%sp points to uncommitted memory, so flush |
| | 201 | \\ // all register windows up to this point to ensure that the kernel has enough committed |
| | 202 | \\ // memory for its stack frame. |
| | 203 | \\ save %%sp, -192, %%sp |
| | 204 | \\ flushw |
| | 205 | \\ restore |
| | 206 | \\ |
| 199 | \\ # Save the func pointer and the arg pointer | 207 | \\ # Save the func pointer and the arg pointer |
| 200 | \\ mov %%i0, %%g2 | 208 | \\ mov %%i0, %%g2 |
| 201 | \\ mov %%i3, %%g3 | 209 | \\ mov %%i3, %%g3 |
| | 210 | \\ |
| 202 | \\ # Shuffle the arguments | 211 | \\ # Shuffle the arguments |
| 203 | \\ mov 217, %%g1 // SYS_clone | 212 | \\ mov 217, %%g1 // SYS_clone |
| 204 | \\ mov %%i2, %%o0 | 213 | \\ mov %%i2, %%o0 |
| | 214 | \\ |
| 205 | \\ # Add some extra space for the initial frame | 215 | \\ # Add some extra space for the initial frame |
| 206 | \\ sub %%i1, 176 + 2047, %%o1 | 216 | \\ sub %%i1, 192 + 2047, %%o1 |
| | 217 | \\ |
| 207 | \\ mov %%i4, %%o2 | 218 | \\ mov %%i4, %%o2 |
| 208 | \\ mov %%i5, %%o3 | 219 | \\ mov %%i5, %%o3 |
| 209 | \\ ldx [%%fp + 0x8af], %%o4 | 220 | \\ ldx [%%fp + 176 + 2047], %%o4 |
| 210 | \\ t 0x6d | 221 | \\ t 0x6d |
| 211 | \\ bcs,pn %%xcc, 1f | 222 | \\ bcs,pn %%xcc, 1f |
| 212 | \\ nop | 223 | \\ nop |
| ... | @@ -214,15 +225,18 @@ pub fn clone() callconv(.naked) u64 { | ... | @@ -214,15 +225,18 @@ pub fn clone() callconv(.naked) u64 { |
| 214 | \\ # process is the child (=1) or the parent (=0). | 225 | \\ # process is the child (=1) or the parent (=0). |
| 215 | \\ brnz %%o1, 2f | 226 | \\ brnz %%o1, 2f |
| 216 | \\ nop | 227 | \\ nop |
| | 228 | \\ |
| 217 | \\ # Parent process, return the child pid | 229 | \\ # Parent process, return the child pid |
| 218 | \\ mov %%o0, %%i0 | 230 | \\ mov %%o0, %%i0 |
| 219 | \\ ret | 231 | \\ ret |
| 220 | \\ restore | 232 | \\ restore |
| | 233 | \\ |
| 221 | \\1: | 234 | \\1: |
| 222 | \\ # The syscall failed | 235 | \\ # The syscall failed |
| 223 | \\ sub %%g0, %%o0, %%i0 | 236 | \\ sub %%g0, %%o0, %%i0 |
| 224 | \\ ret | 237 | \\ ret |
| 225 | \\ restore | 238 | \\ restore |
| | 239 | \\ |
| 226 | \\2: | 240 | \\2: |
| 227 | \\ # Child process | 241 | \\ # Child process |
| 228 | ); | 242 | ); |