CPU保护环什么时候发挥作用?
When CPU protection ring play it's role?
我正在阅读 cpu protection rings and system call 工作。但这让我想到了一个不同的问题。如果我不(即用户程序)使用内核 API 调用(系统调用)怎么办,如果可能的话,将所有内容都写在汇编中并执行它。如果用户程序有一些不一致的代码,CPU一定不要执行它们,否则系统可能会崩溃。但是 CPU 在什么时间点意识到不能执行特定的 instruction xyzw
?保护级别如何在这里发挥关键作用?底层 ISA 是否为每条指令预定义了特权级别?
谢谢。
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?
这是什么意思?
如果有错误的东西,比如被 0 除,cpu 将在尝试执行它时引发异常。这会将您切换到内核并且 os 决定要做什么 - 通常会终止进程。模 cpu 错误这是所有 "inconsistent" 指令的情况。
cpu 引发异常并一直切换到内核 - 页面错误、第一次使用 fpu 等等是标准原因。
我正在阅读 cpu protection rings and system call 工作。但这让我想到了一个不同的问题。如果我不(即用户程序)使用内核 API 调用(系统调用)怎么办,如果可能的话,将所有内容都写在汇编中并执行它。如果用户程序有一些不一致的代码,CPU一定不要执行它们,否则系统可能会崩溃。但是 CPU 在什么时间点意识到不能执行特定的 instruction xyzw
?保护级别如何在这里发挥关键作用?底层 ISA 是否为每条指令预定义了特权级别?
谢谢。
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?
这是什么意思?
如果有错误的东西,比如被 0 除,cpu 将在尝试执行它时引发异常。这会将您切换到内核并且 os 决定要做什么 - 通常会终止进程。模 cpu 错误这是所有 "inconsistent" 指令的情况。
cpu 引发异常并一直切换到内核 - 页面错误、第一次使用 fpu 等等是标准原因。