Linux Kernel state and user State-Linux general technology-Linux programming and kernel information. The following is a detailed description. 386 or more CPUs implement four privileged-level modes (only two of them are used in WINDOWS)
The privileged level 0 (Ring0) is reserved for the operating system code and the device driver code. They work in the core state of the system;
Privileged 3 (Ring3) is used by common user programs and they work in the user State.
The code running on the core state of the processor is unrestricted and can freely access any valid address for direct port access. Code running in the user State is subject to a lot of checks by the processor. They can only access the virtual address of the page that can be accessed in the user State specified in the page table entry of the ing address space, and only the I/O permit Bitmap (I/O Permission Bitmap) in the task status segment (TSS) can be) (In this case, the IOPL In the processor status and Control Mark register EFLAGS is usually 0, specifies that the lowest level of privilege for direct I/O is Ring0 ). The above discussion is only limited to operating systems in protection mode. Real-mode operating systems such as DOS do not have these concepts, and all the code can be seen as running in the core state. Since running in the core State has so many advantages, the virus certainly has no reason not to get Ring0. The switch from Ring3 to Ring0 In the processor mode occurs when the control is transferred. There are two situations: the long transfer command CALL of the access question CALL door, And the INT command of the access interrupt door or trap door. The transfer details involve complex protection checks and stack switching. For more information, see relevant materials. Modern Operating systems usually use the interrupt gate to provide system services, and execute a command to switch the mode. on INTEL X86, this command is INT, for example, in WIN9X, It is INT30 (protection mode callback), INT80 in LINUX, and INT2E in WINNT/2000. User-modeled service programs (such as system DLL) request system services by executing an INTXX, and then the processor mode switches to the core state, the corresponding system code working on the core State serves this request and sends the result to the user program. ---- From China e-forum
Summary:
The main difference between the user State and the core state is that the core State Code of the processor is not restricted and can freely access any valid address for direct port access. Code running in the user State is subject to a lot of checks by the processor. They can only access the virtual address of the page that can be accessed in the user State specified in the page table entry of the ing address space, you can only directly access the accessible ports specified in the I/O permit Bitmap (I/O Permission Bitmap) in the task status segment (TSS ).
From the user State to the core State, there are two situations: the long transfer command CALL of the Access CALL door, the INT command of the access interrupt door or trap door
In linux, the user-state process and the kernel-state process are synchronized between the user State and the kernel state through soket (inaccurate)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service