Re: Intel VT-x VMCS doubt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Oct 15, 2011, Shashank Rachamalla wrote about "Intel VT-x VMCS doubt":
> Hi 
> 
> After catching up with some reading on Intel VT-x, I could understand
> the use of VMCS ( virtual machine control structure ) which allows a VMM
> to specify instructions and events that cause VM entries and exits. My
> current understanding is that a VMCS structure is maintained by VMM for
> each guest and this structure is used by CPU during a VM entry and VM
> exit.

This is correct.

> However, I am not sure if each CPU core has a separate VMCS
> structure for each guest ? Also, does the number of guest VCPUs
> determine the number of VMCS structures required for a guest ? Can
> someone please help me figure out answers to these questions..

I'm not sure the KVM development mailing list is the best place to ask these
questions, but I'll try to answer anyway.

The VMCS is, at its essense, an ordinary data structure in ordinary memory,
and as you said there is just one per guest, and their number is NOT multiplied
by the number of physical CPUs.

When the hypervisor decides to actually run a particular guest with a
particular VMCS on a particular physical CPU, there are certain things it
needs to do to make this VMCS "ready" for this CPU. One things that needs to
be done is to modify a few host fields in the VMCS, because in Linux a few
registers take different default values in different cores, and the "host
fields" in the VMCS remember the values we need to go back to after the exit.
The second thing that needs to be done is, according to the spec, to VMPTRLD
the VMCS onto the physical CPU (doing VMCLEAR first on a previous CPU, if this
VMCS was previously used on a different CPU). This is necessary because,
according to the spec, each physical CPU (core) might want work with a cached
version of the VMCS - and this cache might be per core.

So to make a long story short: while KVM is running a particular VMCS on a
particular CPU, it slightly modifies this VMCS to fit the needs of this
particular CPU; It *doesn't* save additional copies of the same VMCS for
running on different CPUs. The event of switching a guest from running on
one physical CPU to a different physical CPU is known as "VCPU migration"
(the VCPU "migrates" between two physical CPUs) and KVM handles this case
by setting a few VMCS fields and doing VMCLEAR/VMPTRLD as explained above.

I hope this helps make things clearer...

-- 
Nadav Har'El                        |                    Sunday, Oct 16 2011, 
nyh@xxxxxxxxxxxxxxxxxxx             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |Computers are like air conditioners. Both
http://nadav.harel.org.il           |stop working if you open windows.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux