1
votes

What actually happens when hardware virtualization is enabled ? if not, a hypervisor uses binary translation. but, when hardware virtualization is enabled, i have read that it uses trap and emulate. so the guest code executes directly on the host cpu, if its a privileged instruction the cpu hands over the control to the hypervisor, the hypervisor emulates that instruciton and then executes it.

so, what does the emulation means here ? is the same binary translation carried out when hardware virtualization is enable ?

1

1 Answers

2
votes

Enabling HW virtualization sets the vmx flag in Intel and svm flag in AMD.

In Intel architecture, this allows the user-space calls to run as-is on the lower protection ring as they cannot potentially interfear with the host OS. On the other hand the kernel-space calls of the virualized OS are trapped and binary-translated by the hypervisor.

This is done so as to partly take away the CPU intensive translation for trivial calls. How-much of this happens depends on the virtualization type- full, partial or paravirtual.

Binary-translation is a subset of the more elaborate process of emulation. It alligns the guest code to be able to run on the host-architecture.