处理器运行模式

  The IA-32 architecture supports three basic operating modes: protected mode, real addressmode, and system management mode. The operating mode determines which instructions and architectural features are accessible:

  1. Real-address mode (Real mode) —  is an operating mode of 80286 and later x86-compatible CPUs. Real mode is characterized by a 20 bit segmented memory address space (giving exactly 1 MiB of addressable memory) and unlimited direct software access to all memory, I/O addresses and peripheral hardware. Real mode provides no support for memory protection, multitasking, or code privilege levels. 80186 CPUs and earlier, back to the original 8086, have only one operational mode, which is equivalent to real mode in later chips. All x86 CPUs in the 80286 series and later start in real mode when reset(后向兼容的需要).This mode implements the programming environment of the Intel 8086 processor with extensions (such as the ability to switch to protected or system management mode). 

  2. Protected mode (also called protected virtual address mode) — This mode is the native state of the processor. It allows system software to utilize features such as virtual memory, paging, safe multi-tasking, and other features designed to increase an operating system's control over application software.Protected mode may only be entered after the system software sets up several descriptor tables and enables the Protection Enable (PE) bit in the Control Register 0 (CR0).

  Protected mode has a number of features designed to enhance an operating system's control over application software, in order to increase security and system stability.These additions allow the operating system to function in a way that would be significantly more difficult or even impossible without proper hardware support.

   Privilege levels:In protected mode, there are four privilege levels or rings, numbered from 0 to 3, with ring 0 being the most privileged and 3 being the least. The use of rings allows for system software to restrict tasks from accessing data, call gates or executing privileged instructions.In most environments, the operating system and some device drivers run in ring 0 and applications run in ring 3.

  

  Virtual 8086 mode: With the release of the 386, protected mode offers what the Intel manuals call virtual 8086 mode. Virtual 8086 mode is designed to allow code previously written for the 8086 to run unmodified and concurrently with other tasks, without compromising security or system stability. Virtual 8086 mode, however, is not completely backwards compatible with all programs. Programs that require segment manipulation, privileged instructions, direct hardware access, or use self-modifying code will generate an exception that must be served by the operating system.In addition, applications running in virtual 8086 mode generate a trap with the use of instructions that involve input/output (I/O), which can negatively impact performance. Due to these limitations, some programs originally designed to run on the 8086 cannot be run in virtual 8086 mode. As a result, system software is forced to either compromise system security or backwards compatibility when dealing with legacy software. An example of such a compromise can be seen with the release of Windows NT, which dropped backwards compatibility for "ill-behaved" DOS applications.

  3. System management mode (SMM) — is an operating mode in which all normal execution (including the operating system) is suspended, and special separate software (usually firmware or a hardware-assisted debugger) is executed in high-privilege mode. It was first released with the Intel 386SL. While initially special SL versions were required for SMM, Intel incorporated SMM in its mainline 486 and Pentium processors in 1993.

  Some uses of SMM are:

  • Handle system events like memory or chipset errors.
  • Manage system safety functions, such as shutdown on high CPU temperature and turning the fans on and off.
  • Security functions, such as flash device lock down require SMM support on some chipsets.
  • Deeper sleep power management support on Intel systems.
  • Control power management operations, such as managing the voltage regulator modules.
  • Emulate motherboard hardware that is unimplemented or buggy.
  • Emulate a PS/2 mouse or keyboard by converting the messages from USB versions of those peripherals to the messages that would have been generated had PS/2 versions of such hardware been connected.
  • Centralize system configuration, such as on Toshiba and IBM notebook computers.
  • Breaking into SMM to run high-privileged rootkits as shown at Black Hat 2008.
  • Emulate or forward calls to a Trusted Platform Module (TPM).

  

 

 

本篇文章主要来源:

1.Wikipedia

 http://en.wikipedia.org/wiki/Real_mode

 http://en.wikipedia.org/wiki/Protected_mode

   http://en.wikipedia.org/wiki/System_Management_Mode

2.Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 1:Basic Architecture

posted on 2012-04-24 11:14  Luft  阅读(257)  评论(0)    收藏  举报

导航