On 30.05.2025 10:48, Teddy Astie wrote:
> 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-contexts
> invlidations.
> 
> Signed-off-by: Teddy Astie <[email protected]>
> ---
> Extracted from SEV series.
> This will be used for instance in fixed-ASID patches (in SEV series).

I think it should be in that series, which may still be some long way out.
Until then we'd carry dead/unreachable code (disliked by Misra), and we'd
risk that this bit-rots because of being unused.

> --- a/xen/arch/x86/include/asm/hvm/vmx/vmx.h
> +++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h
> @@ -451,6 +451,23 @@ static inline void ept_sync_all(void)
>  
>  void ept_sync_domain(struct p2m_domain *p2m);
>  
> +static inline void vpid_sync_vcpu_context(struct vcpu *v)

pointer-to-const?

> +{
> +    int type = INVVPID_SINGLE_CONTEXT;

Please don't use plain int when all values possibly held in a variable are
non-negative.

> +    /*
> +     * If single context invalidation is not supported, we escalate to
> +     * use all context invalidation.
> +     */
> +    if ( likely(cpu_has_vmx_vpid_invvpid_single_context) )
> +        goto execute_invvpid;
> +
> +    type = INVVPID_ALL_CONTEXT;
> +
> +execute_invvpid:

There no reason at all to use "goto" here (and with that replaced there's
then also no style issue with the label placement).

Jan

> +    __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;


Reply via email to