]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit - arch/x86/kvm/vmx.c
KVM: nVMX: Introduce vmcs02: VMCS used to run L2
authorNadav Har'El <nyh@il.ibm.com>
Wed, 25 May 2011 20:05:27 +0000 (23:05 +0300)
committerAvi Kivity <avi@redhat.com>
Tue, 12 Jul 2011 08:45:11 +0000 (11:45 +0300)
commitff2f6fe9618806d365f76a6f11a4f37881919412
treef9434971981ca95302f973d2403b00ffa7d7e810
parent064aea774768749c6fd308b37818ea3a9600583d
KVM: nVMX: Introduce vmcs02: VMCS used to run L2

We saw in a previous patch that L1 controls its L2 guest with a vcms12.
L0 needs to create a real VMCS for running L2. We call that "vmcs02".
A later patch will contain the code, prepare_vmcs02(), for filling the vmcs02
fields. This patch only contains code for allocating vmcs02.

In this version, prepare_vmcs02() sets *all* of vmcs02's fields each time we
enter from L1 to L2, so keeping just one vmcs02 for the vcpu is enough: It can
be reused even when L1 runs multiple L2 guests. However, in future versions
we'll probably want to add an optimization where vmcs02 fields that rarely
change will not be set each time. For that, we may want to keep around several
vmcs02s of L2 guests that have recently run, so that potentially we could run
these L2s again more quickly because less vmwrites to vmcs02 will be needed.

This patch adds to each vcpu a vmcs02 pool, vmx->nested.vmcs02_pool,
which remembers the vmcs02s last used to run up to VMCS02_POOL_SIZE L2s.
As explained above, in the current version we choose VMCS02_POOL_SIZE=1,
I.e., one vmcs02 is allocated (and loaded onto the processor), and it is
reused to enter any L2 guest. In the future, when prepare_vmcs02() is
optimized not to set all fields every time, VMCS02_POOL_SIZE should be
increased.

Signed-off-by: Nadav Har'El <nyh@il.ibm.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/vmx.c