Print this page
11787 Kernel needs to be built with retpolines
11788 Kernel needs to generally use RSB stuffing
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: John Levon <john.levon@joyent.com>


 112  * However, 32-bit applications only expect (%eax, %edx, %ecx) to be volatile
 113  * across a function call -- in particular, %esi and %edi MUST be saved!
 114  *
 115  * We could do this differently by making a FAST_INTR_PUSH32 for 32-bit
 116  * programs, and FAST_INTR_PUSH for 64-bit programs, but it doesn't seem
 117  * particularly worth it.
 118  */
 119 #define FAST_INTR_PUSH                  \
 120         INTGATE_INIT_KERNEL_FLAGS;      \
 121         subq    $REGOFF_RIP, %rsp;      \
 122         movq    %rsi, REGOFF_RSI(%rsp); \
 123         movq    %rdi, REGOFF_RDI(%rsp); \
 124         swapgs
 125 
 126 #define FAST_INTR_POP                   \
 127         swapgs;                         \
 128         movq    REGOFF_RSI(%rsp), %rsi; \
 129         movq    REGOFF_RDI(%rsp), %rdi; \
 130         addq    $REGOFF_RIP, %rsp
 131 
 132 #define FAST_INTR_RETURN        call *x86_md_clear; jmp tr_iret_user
 133 
 134 #elif defined(__i386)
 135 
 136 #define FAST_INTR_PUSH          \
 137         cld;                    \
 138         __SEGREGS_PUSH          \
 139         __SEGREGS_LOAD_KERNEL
 140 
 141 #define FAST_INTR_POP           \
 142         __SEGREGS_POP
 143 
 144 #define FAST_INTR_RETURN        iret
 145 
 146 #endif  /* __i386 */
 147 
 148 /*
 149  * Handling the CR0.TS bit for floating point handling.
 150  *
 151  * When the TS bit is *set*, attempts to touch the floating
 152  * point hardware will result in a #nm trap.




 112  * However, 32-bit applications only expect (%eax, %edx, %ecx) to be volatile
 113  * across a function call -- in particular, %esi and %edi MUST be saved!
 114  *
 115  * We could do this differently by making a FAST_INTR_PUSH32 for 32-bit
 116  * programs, and FAST_INTR_PUSH for 64-bit programs, but it doesn't seem
 117  * particularly worth it.
 118  */
 119 #define FAST_INTR_PUSH                  \
 120         INTGATE_INIT_KERNEL_FLAGS;      \
 121         subq    $REGOFF_RIP, %rsp;      \
 122         movq    %rsi, REGOFF_RSI(%rsp); \
 123         movq    %rdi, REGOFF_RDI(%rsp); \
 124         swapgs
 125 
 126 #define FAST_INTR_POP                   \
 127         swapgs;                         \
 128         movq    REGOFF_RSI(%rsp), %rsi; \
 129         movq    REGOFF_RDI(%rsp), %rdi; \
 130         addq    $REGOFF_RIP, %rsp
 131 
 132 #define FAST_INTR_RETURN        call x86_md_clear; jmp tr_iret_user
 133 
 134 #elif defined(__i386)
 135 
 136 #define FAST_INTR_PUSH          \
 137         cld;                    \
 138         __SEGREGS_PUSH          \
 139         __SEGREGS_LOAD_KERNEL
 140 
 141 #define FAST_INTR_POP           \
 142         __SEGREGS_POP
 143 
 144 #define FAST_INTR_RETURN        iret
 145 
 146 #endif  /* __i386 */
 147 
 148 /*
 149  * Handling the CR0.TS bit for floating point handling.
 150  *
 151  * When the TS bit is *set*, attempts to touch the floating
 152  * point hardware will result in a #nm trap.