Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Roland McGrath | 69d0627 | 2008-01-30 13:30:44 +0100 | [diff] [blame] | 2 | * Code for the vDSO. This version uses the sysenter instruction. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
Roland McGrath | 69d0627 | 2008-01-30 13:30:44 +0100 | [diff] [blame] | 4 | * First get the common code for the sigreturn entry points. |
| 5 | * This must come first. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
Roland McGrath | 69d0627 | 2008-01-30 13:30:44 +0100 | [diff] [blame] | 7 | #include "sigreturn.S" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | |
Albert D. Cahalan | 581141c | 2006-02-14 13:53:20 -0800 | [diff] [blame] | 9 | /* |
| 10 | * The caller puts arg2 in %ecx, which gets pushed. The kernel will use |
| 11 | * %ecx itself for arg2. The pushing is because the sysexit instruction |
| 12 | * (found in entry.S) requires that we clobber %ecx with the desired %esp. |
| 13 | * User code might expect that %ecx is unclobbered though, as it would be |
| 14 | * for returning via the iret instruction, so we must push and pop. |
| 15 | * |
| 16 | * The caller puts arg3 in %edx, which the sysexit instruction requires |
| 17 | * for %eip. Thus, exactly as for arg2, we must push and pop. |
| 18 | * |
| 19 | * Arg6 is different. The caller puts arg6 in %ebp. Since the sysenter |
| 20 | * instruction clobbers %esp, the user's %esp won't even survive entry |
| 21 | * into the kernel. We store %esp in %ebp. Code in entry.S must fetch |
| 22 | * arg6 from the stack. |
Chuck Ebbert | be0a391 | 2006-03-23 02:59:48 -0800 | [diff] [blame] | 23 | * |
| 24 | * You can not use this vsyscall for the clone() syscall because the |
Roland McGrath | 69d0627 | 2008-01-30 13:30:44 +0100 | [diff] [blame] | 25 | * three words on the parent stack do not get copied to the child. |
Albert D. Cahalan | 581141c | 2006-02-14 13:53:20 -0800 | [diff] [blame] | 26 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | .text |
| 28 | .globl __kernel_vsyscall |
| 29 | .type __kernel_vsyscall,@function |
Roland McGrath | 69d0627 | 2008-01-30 13:30:44 +0100 | [diff] [blame] | 30 | ALIGN |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | __kernel_vsyscall: |
| 32 | .LSTART_vsyscall: |
| 33 | push %ecx |
| 34 | .Lpush_ecx: |
| 35 | push %edx |
| 36 | .Lpush_edx: |
| 37 | push %ebp |
| 38 | .Lenter_kernel: |
| 39 | movl %esp,%ebp |
| 40 | sysenter |
| 41 | |
| 42 | /* 7: align return point with nop's to make disassembly easier */ |
| 43 | .space 7,0x90 |
| 44 | |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 45 | /* 14: System call restart point is here! (SYSENTER_RETURN-2) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | jmp .Lenter_kernel |
| 47 | /* 16: System call normal return point is here! */ |
Roland McGrath | 6c3652e | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 48 | VDSO32_SYSENTER_RETURN: /* Symbol used by sysenter.c via vdso32-syms.h */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | pop %ebp |
| 50 | .Lpop_ebp: |
| 51 | pop %edx |
| 52 | .Lpop_edx: |
| 53 | pop %ecx |
| 54 | .Lpop_ecx: |
| 55 | ret |
| 56 | .LEND_vsyscall: |
| 57 | .size __kernel_vsyscall,.-.LSTART_vsyscall |
| 58 | .previous |
| 59 | |
| 60 | .section .eh_frame,"a",@progbits |
| 61 | .LSTARTFRAMEDLSI: |
| 62 | .long .LENDCIEDLSI-.LSTARTCIEDLSI |
| 63 | .LSTARTCIEDLSI: |
| 64 | .long 0 /* CIE ID */ |
| 65 | .byte 1 /* Version number */ |
| 66 | .string "zR" /* NUL-terminated augmentation string */ |
| 67 | .uleb128 1 /* Code alignment factor */ |
| 68 | .sleb128 -4 /* Data alignment factor */ |
| 69 | .byte 8 /* Return address register column */ |
| 70 | .uleb128 1 /* Augmentation value length */ |
| 71 | .byte 0x1b /* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */ |
| 72 | .byte 0x0c /* DW_CFA_def_cfa */ |
| 73 | .uleb128 4 |
| 74 | .uleb128 4 |
| 75 | .byte 0x88 /* DW_CFA_offset, column 0x8 */ |
| 76 | .uleb128 1 |
| 77 | .align 4 |
| 78 | .LENDCIEDLSI: |
| 79 | .long .LENDFDEDLSI-.LSTARTFDEDLSI /* Length FDE */ |
| 80 | .LSTARTFDEDLSI: |
| 81 | .long .LSTARTFDEDLSI-.LSTARTFRAMEDLSI /* CIE pointer */ |
| 82 | .long .LSTART_vsyscall-. /* PC-relative start address */ |
| 83 | .long .LEND_vsyscall-.LSTART_vsyscall |
| 84 | .uleb128 0 |
| 85 | /* What follows are the instructions for the table generation. |
| 86 | We have to record all changes of the stack pointer. */ |
Roland McGrath | cadd516 | 2008-01-30 13:30:44 +0100 | [diff] [blame] | 87 | .byte 0x40 + (.Lpush_ecx-.LSTART_vsyscall) /* DW_CFA_advance_loc */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | .byte 0x0e /* DW_CFA_def_cfa_offset */ |
| 89 | .byte 0x08 /* RA at offset 8 now */ |
Roland McGrath | cadd516 | 2008-01-30 13:30:44 +0100 | [diff] [blame] | 90 | .byte 0x40 + (.Lpush_edx-.Lpush_ecx) /* DW_CFA_advance_loc */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | .byte 0x0e /* DW_CFA_def_cfa_offset */ |
| 92 | .byte 0x0c /* RA at offset 12 now */ |
Roland McGrath | cadd516 | 2008-01-30 13:30:44 +0100 | [diff] [blame] | 93 | .byte 0x40 + (.Lenter_kernel-.Lpush_edx) /* DW_CFA_advance_loc */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | .byte 0x0e /* DW_CFA_def_cfa_offset */ |
| 95 | .byte 0x10 /* RA at offset 16 now */ |
| 96 | .byte 0x85, 0x04 /* DW_CFA_offset %ebp -16 */ |
| 97 | /* Finally the epilogue. */ |
Roland McGrath | cadd516 | 2008-01-30 13:30:44 +0100 | [diff] [blame] | 98 | .byte 0x40 + (.Lpop_ebp-.Lenter_kernel) /* DW_CFA_advance_loc */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | .byte 0x0e /* DW_CFA_def_cfa_offset */ |
| 100 | .byte 0x0c /* RA at offset 12 now */ |
| 101 | .byte 0xc5 /* DW_CFA_restore %ebp */ |
Roland McGrath | cadd516 | 2008-01-30 13:30:44 +0100 | [diff] [blame] | 102 | .byte 0x40 + (.Lpop_edx-.Lpop_ebp) /* DW_CFA_advance_loc */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | .byte 0x0e /* DW_CFA_def_cfa_offset */ |
| 104 | .byte 0x08 /* RA at offset 8 now */ |
Roland McGrath | cadd516 | 2008-01-30 13:30:44 +0100 | [diff] [blame] | 105 | .byte 0x40 + (.Lpop_ecx-.Lpop_edx) /* DW_CFA_advance_loc */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | .byte 0x0e /* DW_CFA_def_cfa_offset */ |
| 107 | .byte 0x04 /* RA at offset 4 now */ |
| 108 | .align 4 |
| 109 | .LENDFDEDLSI: |
| 110 | .previous |
| 111 | |
Roland McGrath | 69d0627 | 2008-01-30 13:30:44 +0100 | [diff] [blame] | 112 | /* |
| 113 | * Emit a symbol with the size of this .eh_frame data, |
| 114 | * to verify it matches the other versions. |
| 115 | */ |
| 116 | VDSO32_vsyscall_eh_frame_size = (.LENDFDEDLSI-.LSTARTFRAMEDLSI) |