linux/arch/i386/kernel/vsyscall-sysenter.S
<<
>>
Prefs
   1/*
   2 * Code for the vsyscall page.  This version uses the sysenter instruction.
   3 *
   4 * NOTE:
   5 * 1) __kernel_vsyscall _must_ be first in this page.
   6 * 2) there are alignment constraints on this stub, see vsyscall-sigreturn.S
   7 *    for details.
   8 */
   9
  10/*
  11 * The caller puts arg2 in %ecx, which gets pushed. The kernel will use
  12 * %ecx itself for arg2. The pushing is because the sysexit instruction
  13 * (found in entry.S) requires that we clobber %ecx with the desired %esp.
  14 * User code might expect that %ecx is unclobbered though, as it would be
  15 * for returning via the iret instruction, so we must push and pop.
  16 *
  17 * The caller puts arg3 in %edx, which the sysexit instruction requires
  18 * for %eip. Thus, exactly as for arg2, we must push and pop.
  19 *
  20 * Arg6 is different. The caller puts arg6 in %ebp. Since the sysenter
  21 * instruction clobbers %esp, the user's %esp won't even survive entry
  22 * into the kernel. We store %esp in %ebp. Code in entry.S must fetch
  23 * arg6 from the stack.
  24 *
  25 * You can not use this vsyscall for the clone() syscall because the
  26 * three dwords on the parent stack do not get copied to the child.
  27 */
  28        .text
  29        .globl __kernel_vsyscall
  30        .type __kernel_vsyscall,@function
  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
  45        /* 14: System call restart point is here! (SYSENTER_RETURN-2) */
  46        jmp .Lenter_kernel
  47        /* 16: System call normal return point is here! */
  48        .globl SYSENTER_RETURN  /* Symbol used by sysenter.c  */
  49SYSENTER_RETURN:
  50        pop %ebp
  51.Lpop_ebp:
  52        pop %edx
  53.Lpop_edx:
  54        pop %ecx
  55.Lpop_ecx:
  56        ret
  57.LEND_vsyscall:
  58        .size __kernel_vsyscall,.-.LSTART_vsyscall
  59        .previous
  60
  61        .section .eh_frame,"a",@progbits
  62.LSTARTFRAMEDLSI:
  63        .long .LENDCIEDLSI-.LSTARTCIEDLSI
  64.LSTARTCIEDLSI:
  65        .long 0                 /* CIE ID */
  66        .byte 1                 /* Version number */
  67        .string "zR"            /* NUL-terminated augmentation string */
  68        .uleb128 1              /* Code alignment factor */
  69        .sleb128 -4             /* Data alignment factor */
  70        .byte 8                 /* Return address register column */
  71        .uleb128 1              /* Augmentation value length */
  72        .byte 0x1b              /* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
  73        .byte 0x0c              /* DW_CFA_def_cfa */
  74        .uleb128 4
  75        .uleb128 4
  76        .byte 0x88              /* DW_CFA_offset, column 0x8 */
  77        .uleb128 1
  78        .align 4
  79.LENDCIEDLSI:
  80        .long .LENDFDEDLSI-.LSTARTFDEDLSI /* Length FDE */
  81.LSTARTFDEDLSI:
  82        .long .LSTARTFDEDLSI-.LSTARTFRAMEDLSI /* CIE pointer */
  83        .long .LSTART_vsyscall-.        /* PC-relative start address */
  84        .long .LEND_vsyscall-.LSTART_vsyscall
  85        .uleb128 0
  86        /* What follows are the instructions for the table generation.
  87           We have to record all changes of the stack pointer.  */
  88        .byte 0x04              /* DW_CFA_advance_loc4 */
  89        .long .Lpush_ecx-.LSTART_vsyscall
  90        .byte 0x0e              /* DW_CFA_def_cfa_offset */
  91        .byte 0x08              /* RA at offset 8 now */
  92        .byte 0x04              /* DW_CFA_advance_loc4 */
  93        .long .Lpush_edx-.Lpush_ecx
  94        .byte 0x0e              /* DW_CFA_def_cfa_offset */
  95        .byte 0x0c              /* RA at offset 12 now */
  96        .byte 0x04              /* DW_CFA_advance_loc4 */
  97        .long .Lenter_kernel-.Lpush_edx
  98        .byte 0x0e              /* DW_CFA_def_cfa_offset */
  99        .byte 0x10              /* RA at offset 16 now */
 100        .byte 0x85, 0x04        /* DW_CFA_offset %ebp -16 */
 101        /* Finally the epilogue.  */
 102        .byte 0x04              /* DW_CFA_advance_loc4 */
 103        .long .Lpop_ebp-.Lenter_kernel
 104        .byte 0x0e              /* DW_CFA_def_cfa_offset */
 105        .byte 0x0c              /* RA at offset 12 now */
 106        .byte 0xc5              /* DW_CFA_restore %ebp */
 107        .byte 0x04              /* DW_CFA_advance_loc4 */
 108        .long .Lpop_edx-.Lpop_ebp
 109        .byte 0x0e              /* DW_CFA_def_cfa_offset */
 110        .byte 0x08              /* RA at offset 8 now */
 111        .byte 0x04              /* DW_CFA_advance_loc4 */
 112        .long .Lpop_ecx-.Lpop_edx
 113        .byte 0x0e              /* DW_CFA_def_cfa_offset */
 114        .byte 0x04              /* RA at offset 4 now */
 115        .align 4
 116.LENDFDEDLSI:
 117        .previous
 118
 119/*
 120 * Get the common code for the sigreturn entry points.
 121 */
 122#include "vsyscall-sigreturn.S"
 123
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.