A computer device, wherein the computer device comprises a hardware layer, a host runs at the hardware layer, the host being a virtualization platform and the hardware layer comprises a first processor, a virtual machine (101,102) VM runs on the first processor, and the first processor comprises a redirection apparatus; the first processor is configured to obtain an exception instruction triggered by the VM; the redirection apparatus is configured to: switch from a virtualization privilege level of the VM to a user mode of the host; and the first processor is further configured to execute, in the user mode of the host, an exception processing function corresponding to the exception instruction, wherein the exception processing function is comprised in a thread of a virtual processor that runs in the user mode of the host; an execution environment allocated to the thread of the virtual processor comprises a main thread execution environment, an execution environment of the VM, and a shadow execution environment, wherein the shadow execution environment has user-mode memory space independent of the main thread execution environment and the execution environment of the VM; and the shadow execution environment is used to execute the exception processing function, and the exception processing function is used to process an exception that triggers the exception instruction; and the first processor is specifically configured to: switch from a context of the VM to a context of a user-mode shadow execution environment, and the user-mode memory space of the shadow execution environment is used to store the context of the VM that is migrated out during context switching. the first processor is configured to obtain an exception instruction triggered by the VM; the redirection apparatus is configured to: switch from a virtualization privilege level of the VM to a user mode of the host; and the first processor is further configured to execute, in the user mode of the host, an exception processing function corresponding to the exception instruction, wherein the exception processing function is comprised in a thread of a virtual processor that runs in the user mode of the host; an execution environment allocated to the thread of the virtual processor comprises a main thread execution environment, an execution environment of the VM, and a shadow execution environment, wherein the shadow execution environment has user-mode memory space independent of the main thread execution environment and the execution environment of the VM; and the shadow execution environment is used to execute the exception processing function, and the exception processing function is used to process an exception that triggers the exception instruction; and the first processor is specifically configured to: switch from a context of the VM to a context of a user-mode shadow execution environment, and the user-mode memory space of the shadow execution environment is used to store the context of the VM that is migrated out during context switching. switch from a virtualization privilege level of the VM to a user mode of the host; and the first processor is further configured to execute, in the user mode of the host, an exception processing function corresponding to the exception instruction, wherein the exception processing function is comprised in a thread of a virtual processor that runs in the user mode of the host; an execution environment allocated to the thread of the virtual processor comprises a main thread execution environment, an execution environment of the VM, and a shadow execution environment, wherein the shadow execution environment has user-mode memory space independent of the main thread execution environment and the execution environment of the VM; and the shadow execution environment is used to execute the exception processing function, and the exception processing function is used to process an exception that triggers the exception instruction; and the first processor is specifically configured to: switch from a context of the VM to a context of a user-mode shadow execution environment, and the user-mode memory space of the shadow execution environment is used to store the context of the VM that is migrated out during context switching.