Search code examples
assemblyoperating-systemprivileges

How hardware privilege levels are manipulated in x86 processor


I'm not able to understand how the hardware knows that currently a kernel code is running. Do we need to set up some memory address range in some registers indicating the CPU that between these memory address, it is the kernel running.


Solution

  • On x86 architectures, this is achieved with descriptor tables. The startup code, installs tables which tells the CPU which memory regions have which privileges. When memory is accessed, the hardware will check if the instruction and/or access methods are valid for the given descriptor of the adress.

    Well, that is a very basic description, as this is a rather broad question.

    Some posting and link to get you started:

    What are Ring 0 and Ring 3 in OS

    http://duartes.org/gustavo/blog/post/cpu-rings-privilege-and-protection/

    I would also recommend to download (for free) the Intel manuals as this is described in detail there as well.

    http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html