A method for accessing a hardware resource, comprising: configuring permission for one or more privileged instructions that are used for accessing the hardware resource, so that when used by a user mode application program, the one or more privileged instructions can access the hardware resource without trapping into a kernel, wherein the application program calls, at a code level, a privileged application programming interface, API that is in user mode and has the one or more privileged instructions encapsulated therein; and executing the one or more privileged instructions that are encapsulated in the privileged API that is called at the code level by the application program; wherein the configuring permission for one or more privileged instructions that are used for accessing the hardware resource comprises: calling an interface that is related to instruction permission configuration and corresponds to a processor that supports hardware virtualization, to configure the permission for the one or more privileged instructions that are used for accessing the hardware resource; wherein before the one or more privileged instructions that are encapsulated in the privileged API that is called at the code level by the application program are executed, the method further comprises: determining, by using the kernel, that the application program has permission to call the privileged API to access the hardware resource, wherein the executing the one or more privileged instructions that are encapsulated in the privileged API that is called at the code level by the application program comprises: after receiving a request of the application program for accessing the hardware resource, determining by the kernel, according to a kernel policy, that the request of the application program for accessing the hardware resource does not need to trap into the kernel, and, if so, directly executing the one or more privileged instructions. configuring permission for one or more privileged instructions that are used for accessing the hardware resource, so that when used by a user mode application program, the one or more privileged instructions can access the hardware resource without trapping into a kernel, wherein the application program calls, at a code level, a privileged application programming interface, API that is in user mode and has the one or more privileged instructions encapsulated therein; and executing the one or more privileged instructions that are encapsulated in the privileged API that is called at the code level by the application program; wherein the configuring permission for one or more privileged instructions that are used for accessing the hardware resource comprises: calling an interface that is related to instruction permission configuration and corresponds to a processor that supports hardware virtualization, to configure the permission for the one or more privileged instructions that are used for accessing the hardware resource; wherein before the one or more privileged instructions that are encapsulated in the privileged API that is called at the code level by the application program are executed, the method further comprises: determining, by using the kernel, that the application program has permission to call the privileged API to access the hardware resource, wherein the executing the one or more privileged instructions that are encapsulated in the privileged API that is called at the code level by the application program comprises: after receiving a request of the application program for accessing the hardware resource, determining by the kernel, according to a kernel policy, that the request of the application program for accessing the hardware resource does not need to trap into the kernel, and, if so, directly executing the one or more privileged instructions. calling an interface that is related to instruction permission configuration and corresponds to a processor that supports hardware virtualization, to configure the permission for the one or more privileged instructions that are used for accessing the hardware resource; wherein before the one or more privileged instructions that are encapsulated in the privileged API that is called at the code level by the application program are executed, the method further comprises: determining, by using the kernel, that the application program has permission to call the privileged API to access the hardware resource, wherein the executing the one or more privileged instructions that are encapsulated in the privileged API that is called at the code level by the application program comprises: after receiving a request of the application program for accessing the hardware resource, determining by the kernel, according to a kernel policy, that the request of the application program for accessing the hardware resource does not need to trap into the kernel, and, if so, directly executing the one or more privileged instructions.