1. A method performed in a computer system, the method comprising: enabling a secure environment in the computer system for executing a thread comprising a plurality of instructions, wherein: an application executing on the computer system generates the thread and initiates execution of the thread in the secure environment; and the computer system is configured to redirect the execution of the plurality of instructions from an operating system kernel to the secure environment; receiving an instruction from the thread; determining whether the instruction includes a call into the operating system kernel, the instruction being one of an interrupt instruction, a system call instruction, or a system enter instruction; in response to determining that the instruction is one of the interrupt instruction, the system call instruction, or the system enter instruction, determining that the instruction need not be executed in the secure environment; and in response to determining that the instruction need not be executed in the secure environment: eliminating the redirection of the execution of the instruction to the secure environment, modifying a stack to specify return of control for the thread when the execution of the instruction is completed, and passing the control for the thread to the operating system kernel for execution of the instruction.