diff options
author | Gui Jianfeng <guijianfeng@cn.fujitsu.com> | 2010-06-06 22:32:29 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-08-01 03:46:04 -0400 |
commit | b9d762fa79f541ab480cdb733b46fdb0b4471c2d (patch) | |
tree | 58b1a1934b6759b6c279b2c8b8cee3f09cff8abd /arch/x86/kvm/vmx.c | |
parent | 0671a8e75d8aeb33e15c5152147abb0d2fa0c1e6 (diff) |
KVM: VMX: Add all-context INVVPID type support
Add all-context INVVPID type support.
Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/vmx.c')
-rw-r--r-- | arch/x86/kvm/vmx.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 945265361885..622d83b0caf3 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -365,6 +365,11 @@ static inline bool cpu_has_vmx_invvpid_single(void) | |||
365 | return vmx_capability.vpid & VMX_VPID_EXTENT_SINGLE_CONTEXT_BIT; | 365 | return vmx_capability.vpid & VMX_VPID_EXTENT_SINGLE_CONTEXT_BIT; |
366 | } | 366 | } |
367 | 367 | ||
368 | static inline bool cpu_has_vmx_invvpid_global(void) | ||
369 | { | ||
370 | return vmx_capability.vpid & VMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT; | ||
371 | } | ||
372 | |||
368 | static inline bool cpu_has_vmx_ept(void) | 373 | static inline bool cpu_has_vmx_ept(void) |
369 | { | 374 | { |
370 | return vmcs_config.cpu_based_2nd_exec_ctrl & | 375 | return vmcs_config.cpu_based_2nd_exec_ctrl & |
@@ -513,6 +518,20 @@ static inline void vpid_sync_vcpu_all(struct vcpu_vmx *vmx) | |||
513 | __invvpid(VMX_VPID_EXTENT_SINGLE_CONTEXT, vmx->vpid, 0); | 518 | __invvpid(VMX_VPID_EXTENT_SINGLE_CONTEXT, vmx->vpid, 0); |
514 | } | 519 | } |
515 | 520 | ||
521 | static inline void vpid_sync_vcpu_global(void) | ||
522 | { | ||
523 | if (cpu_has_vmx_invvpid_global()) | ||
524 | __invvpid(VMX_VPID_EXTENT_ALL_CONTEXT, 0, 0); | ||
525 | } | ||
526 | |||
527 | static inline void vpid_sync_context(struct vcpu_vmx *vmx) | ||
528 | { | ||
529 | if (cpu_has_vmx_invvpid_single()) | ||
530 | vpid_sync_vcpu_all(vmx); | ||
531 | else | ||
532 | vpid_sync_vcpu_global(); | ||
533 | } | ||
534 | |||
516 | static inline void ept_sync_global(void) | 535 | static inline void ept_sync_global(void) |
517 | { | 536 | { |
518 | if (cpu_has_vmx_invept_global()) | 537 | if (cpu_has_vmx_invept_global()) |
@@ -1800,7 +1819,7 @@ static void exit_lmode(struct kvm_vcpu *vcpu) | |||
1800 | 1819 | ||
1801 | static void vmx_flush_tlb(struct kvm_vcpu *vcpu) | 1820 | static void vmx_flush_tlb(struct kvm_vcpu *vcpu) |
1802 | { | 1821 | { |
1803 | vpid_sync_vcpu_all(to_vmx(vcpu)); | 1822 | vpid_sync_context(to_vmx(vcpu)); |
1804 | if (enable_ept) | 1823 | if (enable_ept) |
1805 | ept_sync_context(construct_eptp(vcpu->arch.mmu.root_hpa)); | 1824 | ept_sync_context(construct_eptp(vcpu->arch.mmu.root_hpa)); |
1806 | } | 1825 | } |
@@ -2756,7 +2775,7 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu) | |||
2756 | vmx_fpu_activate(&vmx->vcpu); | 2775 | vmx_fpu_activate(&vmx->vcpu); |
2757 | update_exception_bitmap(&vmx->vcpu); | 2776 | update_exception_bitmap(&vmx->vcpu); |
2758 | 2777 | ||
2759 | vpid_sync_vcpu_all(vmx); | 2778 | vpid_sync_context(vmx); |
2760 | 2779 | ||
2761 | ret = 0; | 2780 | ret = 0; |
2762 | 2781 | ||