Virtual 8086 mode

from Wikipedia, the free encyclopedia

The operating mode Virtual 8086 Mode - VM86 for short - was introduced with the 80386 processor from Intel in 1985 . Since at that time protected mode operating systems had not yet prevailed on the market against the real mode operating system DOS , the Virtual 8086 Mode created the possibility of real-mode programs (i.e. before all DOS programs) without leaving the protected mode environment.

The best-known example of this is the so-called DOS box , which existed from Microsoft Windows 3.0 .

In Protected Mode (PM), several programs - so-called tasks - can run more or less in parallel. For each of these tasks, a specific bit in the status register can be used to determine whether it should be a VM86 task.

In the Virtual 8086 mode the processor behaves from the program point of view like a processor in real mode. For a program, however, it is easy to determine whether it is running in real mode or in VM86 mode. A maximum of one mebibyte of main memory is available for each VM86 task . In contrast to real mode, this does not have to be the first mebibyte in the physical memory, since the protected mode environment automatically converts the virtual addresses into physical addresses in the background .

Since a VM86 task usually runs without privileges, it only has limited access rights to the hardware or certain CPU registers . This is necessary because otherwise a program in a "DOS box" could bypass the protected mode operating system and thus the memory protection. Every hardware access made by a VM86 task is therefore intercepted by the processor and reported as an exception to the PM operating system, which then either has to emulate (simulate) the behavior of the hardware or, in the event of unauthorized access, the VM86 task and that in it running program ended. Since such direct hardware access occurs quite frequently under DOS, this places great demands on the PM operating system, as a large number of hardware behaviors must be simulated. Since intercepting and simulating hardware access is usually slower than direct hardware access, many DOS programs run noticeably slower in VM86 mode than in "real" real mode.

The VM86 mode was not only used for DOS boxes, e.g. B. under Windows, OS / 2 , Linux (via the DosEmu program), but also used by DOS itself. The memory driver EMM386.EXE from MS-DOS switched - usually unnoticed by the user - to protected mode in order to access the memory beyond the 1 mebibyte limit. Then he started a VM86 task into which the already running DOS was then relocated. EMM386.EXE used the paging technology, which was also available from the 80386, to make more memory available to DOS programs by fading in memory from beyond the 1 mebibyte limit into the DOS address space ( Expanded Memory , EMS ). Such memory managers also existed for the other MS-DOS-compatible operating systems. Their names were different there, but the way they worked was identical.

With the 80486 and Pentium , additional features were added for the VM86 mode, which allow certain interrupt service routines to be processed completely in the VM86 mode without having to switch tasks to the protected mode operating system (virtual mode extensions, VME). This enables an execution speed that comes very close to real real mode, especially since software interrupts are very common under DOS, as they are used as calls to the operating system and BIOS routines.

With the dwindling importance of the DOS operating system, the VM86 mode is now more likely to be viewed as historical and is therefore rarely used, even if it is still available in every current x86-compatible CPU. In the "Compatibility Mode" of the AMD64 architecture - which is used to run a 16- or 32-bit program on a 64-bit operating system - the Virtual86 mode is no longer supported. However, there are software emulators such as DOSBox , which can completely emulate an 8086-compatible CPU including a PC-typical hardware environment in software. It is also available in "Legacy Mode" (32-bit mode) and in every 16 or 32-bit virtual machine .

The implementation of the Virtual Mode Extensions (VME) in the AMD Ryzen processor (mid-2017) is incorrect, so that software that uses this extension does not run stably. Due to the low importance of the Virtual 8086 mode nowadays, AMD decided not to fix the bug , but only to deactivate the support for VME, so that the bug no longer comes into play.

Individual evidence

  1. Christof Windeck: AMD Ryzen: Coming BIOS updates also patch "VME bug". In: Heise online . June 1, 2017 . Retrieved July 7, 2017.