Messages in this thread | | | Subject | Re: [PATCH 1/2] KVM: introduce __vmx_flush_tlb to handle specific vpid | From | Wanpeng Li <> | Date | Fri, 25 Sep 2015 11:01:18 +0800 |
| |
On 9/25/15 12:12 AM, Bandan Das wrote: > Wanpeng Li <wanpeng.li@hotmail.com> writes: > >> Introduce __vmx_flush_tlb() to handle specific vpid. >> >> Signed-off-by: Wanpeng Li <wanpeng.li@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
| |