Commit dd5f5341 authored by Wanpeng Li's avatar Wanpeng Li Committed by Paolo Bonzini

KVM: VMX: introduce __vmx_flush_tlb to handle specific vpid

Introduce __vmx_flush_tlb() to handle specific vpid.
Signed-off-by: default avatarWanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 991e7a0e
...@@ -1392,13 +1392,13 @@ static void loaded_vmcs_clear(struct loaded_vmcs *loaded_vmcs) ...@@ -1392,13 +1392,13 @@ static void loaded_vmcs_clear(struct loaded_vmcs *loaded_vmcs)
__loaded_vmcs_clear, loaded_vmcs, 1); __loaded_vmcs_clear, loaded_vmcs, 1);
} }
static inline void vpid_sync_vcpu_single(struct vcpu_vmx *vmx) static inline void vpid_sync_vcpu_single(int vpid)
{ {
if (vmx->vpid == 0) if (vpid == 0)
return; return;
if (cpu_has_vmx_invvpid_single()) if (cpu_has_vmx_invvpid_single())
__invvpid(VMX_VPID_EXTENT_SINGLE_CONTEXT, vmx->vpid, 0); __invvpid(VMX_VPID_EXTENT_SINGLE_CONTEXT, vpid, 0);
} }
static inline void vpid_sync_vcpu_global(void) static inline void vpid_sync_vcpu_global(void)
...@@ -1407,10 +1407,10 @@ static inline void vpid_sync_vcpu_global(void) ...@@ -1407,10 +1407,10 @@ static inline void vpid_sync_vcpu_global(void)
__invvpid(VMX_VPID_EXTENT_ALL_CONTEXT, 0, 0); __invvpid(VMX_VPID_EXTENT_ALL_CONTEXT, 0, 0);
} }
static inline void vpid_sync_context(struct vcpu_vmx *vmx) static inline void vpid_sync_context(int vpid)
{ {
if (cpu_has_vmx_invvpid_single()) if (cpu_has_vmx_invvpid_single())
vpid_sync_vcpu_single(vmx); vpid_sync_vcpu_single(vpid);
else else
vpid_sync_vcpu_global(); vpid_sync_vcpu_global();
} }
...@@ -3563,9 +3563,9 @@ static void exit_lmode(struct kvm_vcpu *vcpu) ...@@ -3563,9 +3563,9 @@ static void exit_lmode(struct kvm_vcpu *vcpu)
#endif #endif
static void vmx_flush_tlb(struct kvm_vcpu *vcpu) static inline void __vmx_flush_tlb(struct kvm_vcpu *vcpu, int vpid)
{ {
vpid_sync_context(to_vmx(vcpu)); vpid_sync_context(vpid);
if (enable_ept) { if (enable_ept) {
if (!VALID_PAGE(vcpu->arch.mmu.root_hpa)) if (!VALID_PAGE(vcpu->arch.mmu.root_hpa))
return; return;
...@@ -3573,6 +3573,11 @@ static void vmx_flush_tlb(struct kvm_vcpu *vcpu) ...@@ -3573,6 +3573,11 @@ static void vmx_flush_tlb(struct kvm_vcpu *vcpu)
} }
} }
static void vmx_flush_tlb(struct kvm_vcpu *vcpu)
{
__vmx_flush_tlb(vcpu, to_vmx(vcpu)->vpid);
}
static void vmx_decache_cr0_guest_bits(struct kvm_vcpu *vcpu) static void vmx_decache_cr0_guest_bits(struct kvm_vcpu *vcpu)
{ {
ulong cr0_guest_owned_bits = vcpu->arch.cr0_guest_owned_bits; ulong cr0_guest_owned_bits = vcpu->arch.cr0_guest_owned_bits;
...@@ -4915,7 +4920,7 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) ...@@ -4915,7 +4920,7 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
vmx_fpu_activate(vcpu); vmx_fpu_activate(vcpu);
update_exception_bitmap(vcpu); update_exception_bitmap(vcpu);
vpid_sync_context(vmx); vpid_sync_context(vmx->vpid);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment