Jeff Dike | d67b569 | 2005-07-07 17:56:49 -0700 | [diff] [blame] | 1 | #include "uml-config.h" |
Jeff Dike | 54ae36f | 2007-10-16 01:27:33 -0700 | [diff] [blame] | 2 | #include "as-layout.h" |
Jeff Dike | d67b569 | 2005-07-07 17:56:49 -0700 | [diff] [blame] | 3 | |
| 4 | .globl syscall_stub |
| 5 | .section .__syscall_stub, "x" |
| 6 | syscall_stub: |
| 7 | syscall |
| 8 | /* We don't have 64-bit constants, so this constructs the address |
| 9 | * we need. |
| 10 | */ |
Jeff Dike | 4bdf8bc | 2008-02-04 22:30:44 -0800 | [diff] [blame] | 11 | movq $(STUB_DATA >> 32), %rbx |
Jeff Dike | d67b569 | 2005-07-07 17:56:49 -0700 | [diff] [blame] | 12 | salq $32, %rbx |
Jeff Dike | 4bdf8bc | 2008-02-04 22:30:44 -0800 | [diff] [blame] | 13 | movq $(STUB_DATA & 0xffffffff), %rcx |
Jeff Dike | d67b569 | 2005-07-07 17:56:49 -0700 | [diff] [blame] | 14 | or %rcx, %rbx |
| 15 | movq %rax, (%rbx) |
| 16 | int3 |
Jeff Dike | c560049 | 2005-09-03 15:57:36 -0700 | [diff] [blame] | 17 | |
| 18 | .globl batch_syscall_stub |
| 19 | batch_syscall_stub: |
Jeff Dike | 4bdf8bc | 2008-02-04 22:30:44 -0800 | [diff] [blame] | 20 | mov $(STUB_DATA >> 32), %rbx |
Bodo Stroesser | 07bf731 | 2005-09-03 15:57:50 -0700 | [diff] [blame] | 21 | sal $32, %rbx |
Jeff Dike | 4bdf8bc | 2008-02-04 22:30:44 -0800 | [diff] [blame] | 22 | mov $(STUB_DATA & 0xffffffff), %rax |
Bodo Stroesser | 07bf731 | 2005-09-03 15:57:50 -0700 | [diff] [blame] | 23 | or %rax, %rbx |
| 24 | /* load pointer to first operation */ |
| 25 | mov %rbx, %rsp |
| 26 | add $0x10, %rsp |
| 27 | again: |
| 28 | /* load length of additional data */ |
| 29 | mov 0x0(%rsp), %rax |
| 30 | |
| 31 | /* if(length == 0) : end of list */ |
| 32 | /* write possible 0 to header */ |
| 33 | mov %rax, 8(%rbx) |
| 34 | cmp $0, %rax |
| 35 | jz done |
| 36 | |
| 37 | /* save current pointer */ |
| 38 | mov %rsp, 8(%rbx) |
| 39 | |
| 40 | /* skip additional data */ |
| 41 | add %rax, %rsp |
| 42 | |
| 43 | /* load syscall-# */ |
| 44 | pop %rax |
| 45 | |
| 46 | /* load syscall params */ |
Jeff Dike | c560049 | 2005-09-03 15:57:36 -0700 | [diff] [blame] | 47 | pop %rdi |
| 48 | pop %rsi |
| 49 | pop %rdx |
| 50 | pop %r10 |
| 51 | pop %r8 |
| 52 | pop %r9 |
Bodo Stroesser | 07bf731 | 2005-09-03 15:57:50 -0700 | [diff] [blame] | 53 | |
| 54 | /* execute syscall */ |
Jeff Dike | c560049 | 2005-09-03 15:57:36 -0700 | [diff] [blame] | 55 | syscall |
Bodo Stroesser | 07bf731 | 2005-09-03 15:57:50 -0700 | [diff] [blame] | 56 | |
| 57 | /* check return value */ |
| 58 | pop %rcx |
| 59 | cmp %rcx, %rax |
| 60 | je again |
| 61 | |
| 62 | done: |
| 63 | /* save return value */ |
Jeff Dike | c560049 | 2005-09-03 15:57:36 -0700 | [diff] [blame] | 64 | mov %rax, (%rbx) |
Bodo Stroesser | 07bf731 | 2005-09-03 15:57:50 -0700 | [diff] [blame] | 65 | |
| 66 | /* stop */ |
| 67 | int3 |