On 9/25/15 12:12 AM, Bandan Das wrote:
Wanpeng Li <wanpeng...@hotmail.com> writes:

Introduce __vmx_flush_tlb() to handle specific vpid.

Signed-off-by: Wanpeng Li <wanpeng...@hotmail.com>
---
  arch/x86/kvm/vmx.c | 21 +++++++++++++--------
  1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 794c529..7188c5e 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1343,13 +1343,13 @@ static void loaded_vmcs_clear(struct loaded_vmcs 
*loaded_vmcs)
                         __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;
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)
@@ -1358,10 +1358,10 @@ static inline void vpid_sync_vcpu_global(void)
                __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())
-               vpid_sync_vcpu_single(vmx);
+               vpid_sync_vcpu_single(vpid);
        else
                vpid_sync_vcpu_global();
  }
Not sure myself what's the right thing to do but this may be undesirable
in a nested environment. Assuming the processor supports global invalidation
only, this seems like a easy way for the nested guest to invalidate *all*
mappings - even the L1 specific mappings.

Indeed, however, there's no easy way to handle the w/o single invalidation case, we can improve it if you have any idea, otherwise, it can be left to further optimization. :-)

Regards,
Wanpeng Li
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to