Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is meant by trap-and-emulate virtualization?

I read the term trap-and-emulate virtualization in some articles on how to set up a virtual pc. Can anyone please tell me what this term means?

I understood that it definitely is some method for creating a virtual pc. But how is it done?

like image 238
Doubting Avatar asked Dec 04 '13 23:12

Doubting


People also ask

What is the use of trap and emulate?

Trap-and-emulate is a technique used by the virtual machine to emulate privileged instructions and registers and pretend to the OS that it's still in kernel mode.

What is emulation in virtualization?

Emulation, in a software context, is the use of an application program or device to imitate the behavior of another program or device. Common uses of emulation include: Running an operating system on a hardware platform for which it was not originally engineered.

What is the difference between simulation emulation and virtualization?

The main difference between them is that emulation is the computer program's ability in an electronic device to emulate the behavior of another program or device. On the other hand, virtualization is the process of creating a virtual instance of computer hardware platforms.

Can we use x86 architecture for trap and emulate virtualization?

"Until recently, the x86 architecture has not permitted classical trap-and-emulate virtualization. Virtual Machine Monitors for x86, such as VMware ® Workstation and Virtual PC, have instead used binary translation of the guest kernel code.


3 Answers

An operation system is designed to have full control of the system. But when an OS is running as a virtual machine in a hypervisor, some of its instructions may conflict with the host operation system. So what does the hypervisor do? It emulates the effect of that specific instruction or action without carrying it out. In this way, the host OS is not effected by the guest's actions. This is called trap and emulate.

like image 156
Khayam Gondal Avatar answered Sep 25 '22 02:09

Khayam Gondal


Attempting a privileged instruction when in user mode causes an error to occur thus leading to trap state.

And after this the VMM (Virtual Machine Manager) gets control and analyzed the error , executes the operation as attempted by the guest and then return the control back to guest in user mode.

Note : Kernel mode privileged command runs slower due to trap and emulate

like image 25
Umang Singh Avatar answered Sep 23 '22 02:09

Umang Singh


There are two types of operations performed by OS/Application running on Virtual Machine Manager (or Hypervisor):

  1. Non-privileged - Hypervisor directly allows OS/App to perform these operations.
  2. Privileged - Hypervisor uses the Trap-and-Emulate method to determine whether the operation is legal or illegal. It creates a trap for privileged operation first. Then, if the operation is illegal, the hypervisor terminates the operation, and if it is a legal operation, it emulates the behavior guest OS/App expects from the hardware.
like image 25
Pranav Bhendawade Avatar answered Sep 23 '22 02:09

Pranav Bhendawade