[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] xen: Disable emulate.c REP optimization if introspection is active



>>> On 03.11.14 at 10:39, <rcojocaru@xxxxxxxxxxxxxxx> wrote:
> --- a/xen/arch/x86/hvm/emulate.c
> +++ b/xen/arch/x86/hvm/emulate.c
> @@ -395,6 +395,7 @@ static int hvmemul_virtual_to_linear(
>  {
>      struct segment_register *reg;
>      int okay;
> +    struct domain *currd = current->domain;

This is being used just once and hence not really worthwhile.

> @@ -402,12 +403,15 @@ static int hvmemul_virtual_to_linear(
>          return X86EMUL_OKAY;
>      }
>  
> -    /*
> -     * Clip repetitions to avoid overflow when multiplying by @bytes_per_rep.
> -     * The chosen maximum is very conservative but it's what we use in
> -     * hvmemul_linear_to_phys() so there is no point in using a larger value.
> -     */
> -    *reps = min_t(unsigned long, *reps, 4096);
> +    if ( currd->arch.hvm_domain.introspection_enabled )
> +        *reps = 1;
> +    else
> +        /*
> +         * Clip repetitions to avoid overflow when multiplying by 
> @bytes_per_rep.
> +         * The chosen maximum is very conservative but it's what we use in
> +         * hvmemul_linear_to_phys() so there is no point in using a larger 
> value.
> +         */
> +        *reps = min_t(unsigned long, *reps, 4096);

With introspection_enabled supposedly being the unusual case (at
least for the majority of current users), a likely()/unlikely() annotation
should be used here. Further, with it being unclear (at least from
patch description and context alone) whether *reps could legally be
zero when getting here, I'd prefer

    *reps = min_t(unsigned long, *reps,
                  
unlikely(current->domain->arch.hvm_domain.introspection_enabled)
                           ? 1 : 4096);

Perhaps with an adjustment to the comment explaining why.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.