diff options
author | Abel Gordon <abelg@il.ibm.com> | 2013-04-18 07:37:25 -0400 |
---|---|---|
committer | Gleb Natapov <gleb@redhat.com> | 2013-04-22 03:52:10 -0400 |
commit | 8de48833708a7834f1ba65a80944b1045082553a (patch) | |
tree | 0e2afad141c35ca6d1f1a5d65034ce7761c82ddb | |
parent | 145c28dd19a2a05aa798e77bd7e679847fe8bee3 (diff) |
KVM: nVMX: Allocate shadow vmcs
Allocate a shadow vmcs used by the processor to shadow part of the fields
stored in the software defined VMCS12 (let L1 access fields without causing
exits). Note we keep a shadow vmcs only for the current vmcs12. Once a vmcs12
becomes non-current, its shadow vmcs is released.
Signed-off-by: Abel Gordon <abelg@il.ibm.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
-rw-r--r-- | arch/x86/kvm/vmx.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 1cdfb5d7580a..7b27af9a14d8 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -355,6 +355,7 @@ struct nested_vmx { | |||
355 | /* The host-usable pointer to the above */ | 355 | /* The host-usable pointer to the above */ |
356 | struct page *current_vmcs12_page; | 356 | struct page *current_vmcs12_page; |
357 | struct vmcs12 *current_vmcs12; | 357 | struct vmcs12 *current_vmcs12; |
358 | struct vmcs *current_shadow_vmcs; | ||
358 | 359 | ||
359 | /* vmcs02_list cache of VMCSs recently used to run L2 guests */ | 360 | /* vmcs02_list cache of VMCSs recently used to run L2 guests */ |
360 | struct list_head vmcs02_pool; | 361 | struct list_head vmcs02_pool; |
@@ -5527,6 +5528,7 @@ static int handle_vmon(struct kvm_vcpu *vcpu) | |||
5527 | { | 5528 | { |
5528 | struct kvm_segment cs; | 5529 | struct kvm_segment cs; |
5529 | struct vcpu_vmx *vmx = to_vmx(vcpu); | 5530 | struct vcpu_vmx *vmx = to_vmx(vcpu); |
5531 | struct vmcs *shadow_vmcs; | ||
5530 | 5532 | ||
5531 | /* The Intel VMX Instruction Reference lists a bunch of bits that | 5533 | /* The Intel VMX Instruction Reference lists a bunch of bits that |
5532 | * are prerequisite to running VMXON, most notably cr4.VMXE must be | 5534 | * are prerequisite to running VMXON, most notably cr4.VMXE must be |
@@ -5555,6 +5557,16 @@ static int handle_vmon(struct kvm_vcpu *vcpu) | |||
5555 | skip_emulated_instruction(vcpu); | 5557 | skip_emulated_instruction(vcpu); |
5556 | return 1; | 5558 | return 1; |
5557 | } | 5559 | } |
5560 | if (enable_shadow_vmcs) { | ||
5561 | shadow_vmcs = alloc_vmcs(); | ||
5562 | if (!shadow_vmcs) | ||
5563 | return -ENOMEM; | ||
5564 | /* mark vmcs as shadow */ | ||
5565 | shadow_vmcs->revision_id |= (1u << 31); | ||
5566 | /* init shadow vmcs */ | ||
5567 | vmcs_clear(shadow_vmcs); | ||
5568 | vmx->nested.current_shadow_vmcs = shadow_vmcs; | ||
5569 | } | ||
5558 | 5570 | ||
5559 | INIT_LIST_HEAD(&(vmx->nested.vmcs02_pool)); | 5571 | INIT_LIST_HEAD(&(vmx->nested.vmcs02_pool)); |
5560 | vmx->nested.vmcs02_num = 0; | 5572 | vmx->nested.vmcs02_num = 0; |