Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is basic idea behind emulation of the instruction set?

I am new to virtualization and trying to understand basic idea behind the instuction set emulation.

I am following the e500 core instruction set emulation .

http://www.linux-kvm.org/page/E500_virtual_CPU_specification

This particular "kvmppc_core_emulate_mtspr()" in kernel code is emulating the mtspr instruction of powerpc core.

Would want to know what exactly we are doing inside this function to emulate mtspr and why only two instructions(mtspr and mfspr) are emulated as per e500_emulate.c

like image 491
Amit Singh Tomar Avatar asked Aug 23 '14 13:08

Amit Singh Tomar


1 Answers

Hardware-assisted virtualization is the art of executing as many of the instructions of the target program directly, without emulation. A processor that supports hardware-assisted virtualization is designed so that only a few privileged instructions cannot be executed directly. Since the processor is executing the target code directly, when one of these instructions appears, it has to have a mechanism to transfer control back to the hypervisor, which may want to emulate in software the effects the privileged instruction is supposed to have, so as to make it look to the target program that it is being executed directly. This is how running an unmodified OS that was not designed for this inside an hypervisor can be achieved.

Only two instructions are emulated because only these two need to be. The others are executed directly and at full speed by the processor, without emulation.

like image 192
Pascal Cuoq Avatar answered Nov 08 '22 08:11

Pascal Cuoq