# CPU modes

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/CPU_modes
> Markdown URL: https://mediated.wiki/source/CPU_modes.md
> Source: https://en.wikipedia.org/wiki/CPU_modes
> Source revision: 1353034885
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Operating modes for central processing unit

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. Find sources: "CPU modes" – news · newspapers · books · scholar · JSTOR (November 2016) (Learn how and when to remove this message)

**CPU modes** (also called **processor modes**, **CPU states**, **CPU privilege levels** and other names) are operating modes for the [central processing unit](/source/Central_processing_unit) of most [computer architectures](/source/Computer_architecture) that place restrictions on the type and scope of operations that can be performed by instructions being executed by the CPU. For example, this design allows an [operating system](/source/Operating_system) to run with more privileges than [application software](/source/Application_software) by running the operating systems and applications in different modes.[1]

Ideally, only highly trusted [kernel](/source/Kernel_(operating_system)) code is allowed to execute in the unrestricted mode; everything else (including non-supervisory portions of the operating system) runs in a restricted mode and must use a [system call](/source/System_call) (via [interrupt](/source/Interrupt)) to request the kernel perform on its behalf any operation that could damage or compromise the system, making it impossible for untrusted programs to alter or damage other programs (or the computing system itself). [Device drivers](/source/Device_driver) are designed to be part of the kernel due to the need for frequent [I/O](/source/Input%2Foutput) access.

Multiple modes can be implemented, e.g. allowing a [hypervisor](/source/Hypervisor) to run multiple operating system supervisors beneath it, which is the basic design of many [virtual machine](/source/Virtual_machine) systems available today.

## Mode types

Further information on interoperation between CPU and OS levels of abstraction: [Protection ring](/source/Protection_ring)

The unrestricted mode is often called *kernel mode,* but many other designations exist (*master mode*, *supervisor mode*, *privileged mode*, etc.). Restricted modes are usually referred to as *user modes,* but are also known by many other names (*slave mode,* *problem state,* etc.).[2]

**Hypervisor**
- Hypervisor mode is used to support virtualization, allowing the simultaneous operation of multiple operating systems.

**Kernel and user**
- In kernel mode, the CPU may perform any operation allowed by its architecture; any instruction may be executed, any I/O operation initiated, any area of memory accessed, and so on. In the other CPU modes, certain restrictions on CPU operations are enforced by the hardware. Typically, certain instructions are not permitted (especially those—including I/O operations—that could alter the global state of the machine), some memory areas cannot be accessed, etc. User-mode capabilities of the CPU are typically a subset of those available in kernel mode, but in some cases, such as hardware emulation of non-native architectures, they may be significantly different from those available in standard kernel mode.

Some CPU architectures support more modes than those, often with a hierarchy of privileges. These architectures are often said to have *ring-based security,* wherein the hierarchy of privileges resembles a set of concentric rings, with the kernel mode in the center. [Multics](/source/Multics) hardware was the first significant implementation of ring security, but many other hardware platforms have been designed along similar lines, including the [Intel 80286](/source/Intel_80286) [protected mode](/source/Protected_mode), and the [IA-64](/source/IA-64) as well, though it is referred to by a different name in these cases.

Mode protection may extend to resources beyond the CPU hardware itself. Hardware registers track the current operating mode of the CPU, but additional [virtual-memory](/source/Virtual_memory) registers, [page-table](/source/Page_table) entries, and other data may track mode identifiers for other resources. For example, a CPU may be operating in Ring 0 as indicated by a status word in the CPU itself, but every access to memory may additionally be validated against a separate ring number for the virtual-memory segment targeted by the access, and/or against a ring number for the physical page (if any) being targeted. This has been demonstrated with the [PSP](/source/PlayStation_Portable) handheld system.

Hardware that meets the [Popek and Goldberg virtualization requirements](/source/Popek_and_Goldberg_virtualization_requirements) makes writing software to efficiently support a virtual machine much simpler. Such a system can run software that "believes" it is running in supervisor mode, but is actually running in user mode.

## Architectures

Several computer systems introduced in the 1960s, such as the [IBM System/360](/source/IBM_System%2F360), [DEC](/source/Digital_Equipment_Corporation) [PDP-6](/source/PDP-6)/[PDP-10](/source/PDP-10), the [GE-600](/source/GE-600_series)/[Honeywell 6000](/source/Honeywell_6000_series) series, and the [Burroughs](/source/Burroughs_Corporation) [B5000](/source/B5000) series and [B6500](/source/B6500) series, support two CPU modes; a mode that grants full privileges to code running in that mode, and a mode that prevents direct access to [input/output](/source/Input%2Foutput) devices and some other hardware facilities to code running in that mode. The first mode is referred to by names such as *supervisor state* (System/360), *executive mode* (PDP-6/PDP-10), *master mode* (GE-600 series), *control mode* (B5000 series), and *control state* (B6500 series). The second mode is referred to by names such as *problem state* (System/360), *user mode* (PDP-6/PDP-10), *slave mode* (GE-600 series), and *normal state* (B6500 series); there are multiple non-control modes in the B5000 series.

### RISC-V

[RISC-V](/source/RISC-V) has three main CPU modes: User Mode (U), Supervisor Mode (S), and Machine Mode (M).[3] Virtualization is supported via an orthogonal CSR setting instead of a fourth mode.

v t e Operating systems General Comparison Forensic engineering History List Timeline Usage share User features comparison Variants Disk operating system Distributed operating system Embedded operating system Hobbyist operating system Just enough operating system Mobile operating system Network operating system Object-oriented operating system Real-time operating system Supercomputer operating system Kernel Architectures Exokernel Hybrid Microkernel Monolithic Multikernel vkernel Rump kernel Unikernel Components Device driver Loadable kernel module User space and kernel space Process management Concepts Computer multitasking (Cooperative, Preemptive) Context switch Interrupt IPC Process Process control block Real-time Thread Time-sharing Scheduling algorithms Fixed-priority preemptive Multilevel feedback queue Round-robin Shortest job next Memory management, resource protection Bus error General protection fault Memory paging Memory protection Protection ring Segmentation fault Virtual memory Storage access, file systems Boot loader Defragmentation Device file File attribute Inode Journal Partition Virtual file system Virtual tape library Supporting concepts API Computer network HAL Live CD Live USB Shell CLI User interface PXE

## References

1. **[^](#cite_ref-1)** ["Processor Modes"](http://flint.cs.yale.edu/feng/cos/resources/BIOS/procModes.htm). *flint.cs.yale.edu*. [Archived](https://web.archive.org/web/20180512163926/http://flint.cs.yale.edu/feng/cos/resources/BIOS/procModes.htm) from the original on 2018-05-12. Retrieved 2023-08-23.

1. **[^](#cite_ref-2)** aviviano (2022-11-04). ["User mode and kernel mode - Windows drivers"](https://learn.microsoft.com/en-us/windows-hardware/drivers/gettingstarted/user-mode-and-kernel-mode). *learn.microsoft.com*. Retrieved 2023-08-23.

1. **[^](#cite_ref-3)** Harris, Sarah; Harris, David (2021-07-12). [*Digital Design and Computer Architecture, RISC-V Edition*](https://books.google.com/books?id=SksiEAAAQBAJ). Morgan Kaufmann. [ISBN](/source/ISBN_(identifier)) [978-0-12-820065-0](https://en.wikipedia.org/wiki/Special:BookSources/978-0-12-820065-0).

---
Adapted from the Wikipedia article [CPU modes](https://en.wikipedia.org/wiki/CPU_modes) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/CPU_modes?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
