Introduce vpid_sync_vcpu_context to do a single-context invalidation on the vpid attached to the vcpu as a alternative to per-gva and all-context invlidations.
Signed-off-by: Teddy Astie <[email protected]> --- v2: Drop use of goto. xen/arch/x86/include/asm/hvm/vmx/vmx.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/xen/arch/x86/include/asm/hvm/vmx/vmx.h b/xen/arch/x86/include/asm/hvm/vmx/vmx.h index fe2cb4be0e..08854c36ca 100644 --- a/xen/arch/x86/include/asm/hvm/vmx/vmx.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h @@ -452,6 +452,20 @@ static inline void ept_sync_all(void) void ept_sync_domain(struct p2m_domain *p2m); +static inline void vpid_sync_vcpu_context(const struct vcpu *v) +{ + int type = INVVPID_SINGLE_CONTEXT; + + /* + * If single context invalidation is not supported, we escalate to + * use all context invalidation. + */ + if ( unlikely(!cpu_has_vmx_vpid_invvpid_single_context) ) + type = INVVPID_ALL_CONTEXT; + + __invvpid(type, v->arch.hvm.n1asid.asid, 0); +} + static inline void vpid_sync_vcpu_gva(struct vcpu *v, unsigned long gva) { int type = INVVPID_INDIVIDUAL_ADDR; -- 2.54.0 -- Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech
