简体   繁体   中英

When CPU protection ring play it's role?

I was reading cpu protection rings and system call working. But that leads me to a different question. What if I don't (ie a user program ) use kernel API calls (system calls), and if possible write everything in assembly and execute it. If the user program has some inconsistent code, the CPU must not execute them, or the system may crash. But at what point in time the CPU realizes that a particular instruction xyzw must not be executed? How the protection level plays the key role here? Does the underlying ISA have a predefined privilege level for each instruction?

Thank You.

If the user program has some inconsistent code, the CPU must not execute them, or the system may crash. But at what point in time the CPU realizes that a particular instruction xyzw must not be executed?

what does this mean?

if there is wrong stuff, say division by 0, the cpu will raise an exception while trying to execute it. this switches you to the kernel and the os decides what to do - typically kill the process. modulo cpu bugs this is what happens for all "inconsistent" instructions.

cpu raises exceptions and switches to the kernel all the time - page faults, first time fpu use and whatnot are the standard reasons.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM