gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/test/syscalls/linux/rseq/start_amd64.S (about) 1 // Copyright 2019 The gVisor Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 16 .text 17 .align 4 18 .type _start,@function 19 .globl _start 20 21 _start: 22 movq %rsp,%rdi 23 call __init 24 hlt 25 26 .size _start,.-_start 27 .section .note.GNU-stack,"",@progbits 28 29 .text 30 .globl raw_syscall 31 .type raw_syscall, @function 32 33 raw_syscall: 34 mov %rdi,%rax // syscall # 35 mov %rsi,%rdi // arg0 36 mov %rdx,%rsi // arg1 37 mov %rcx,%rdx // arg2 38 mov %r8,%r10 // arg3 (goes in r10 instead of rcx for system calls) 39 mov %r9,%r8 // arg4 40 mov 0x8(%rsp),%r9 // arg5 41 syscall 42 ret 43 44 .size raw_syscall,.-raw_syscall 45 .section .note.GNU-stack,"",@progbits 46 47 .text 48 .globl clone 49 .type clone, @function 50 51 clone: 52 // Initially: 53 // %rdi = fn 54 // %rsi = stack 55 // %edx = flags 56 // %rcx = arg 57 // %r8 = child_tid 58 push %rbx 59 push %r12 60 mov %rdi,%rbx 61 mov %rcx,%r12 62 mov %edx,%edi // flags 63 // stack already in %rsi 64 xor %edx,%edx // parent_tid 65 mov %r8,%r10 // child_tid 66 xor %r9d,%r9d // tls 67 mov $56,%rax // SYS_clone 68 syscall // clobbers %rcx, %r11 69 cmp $0,%rax 70 je child 71 pop %r12 72 pop %rbx 73 ret 74 child: 75 mov %rsi,%rsp 76 xor %rbp,%rbp 77 mov %r12,%rdi 78 call *%rbx 79 mov %rax,%rdi 80 mov $60,%rax // SYS_exit 81 syscall 82 hlt 83 84 .size clone,.-clone 85 .section .note.GNU-stack,"",@progbits