5
votes

I understand what trap and emulate is, however I'm struggling to understand what binary translation is and how it differs from trap and emulate. I'm very new to this topic and am trying to understand this introduction from a paper from 2006:

"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. However, both Intel and AMD have now introduced architectural extensions to support classical virtualization."

I also don't understand what "classical virtualization" is in the context trap and emulate vs binary translation. Any help understanding these terms would be appreciated.

1
Trap-and-emulate is classic virtualization, and was in use back in the 1960s and 1970s. - Charles Duffy
For anyone who may wonder which the paper is, it's: "A Comparison of Software and Hardware Techniques for x86 Virtualization". - Ta Thanh Dinh

1 Answers

13
votes

I think this link will help you. I have tried to summarized it, for more information refer the link.

Whenever the guest operating system tries to perform one of these privileged operations, the processor will "trap" the instruction and hand over control to the host operating system or hypervisor, so that it can do the required operation and then return control back to the guest. But most real-world instruction sets, including x86, were not designed with virtualization in mind. As a result, there are privileged instructions that do not have any corresponding trap facility.

Binary translation addresses this problem directly. Instead of depending on the processor itself to detect the privileged instructions it uses virtualization software that inspects the instruction stream in software and whenever the virtualization software detects a problem instruction, it rewrites it on-the-fly,typically replacing it with a kind of manual trap, that will hand over control to the hypervisor at the appropriate moment. Hope this helps you.