All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: Julien Grall <julien.grall@arm.com>
Cc: sstabellini@kernel.org, volodymyr_babchuk@epam.com,
	xen-devel@lists.xen.org
Subject: Re: [[PATCH v3] 2/4] xen/arm: cpufeature: Add helper to check constant caps
Date: Mon, 1 Oct 2018 12:59:56 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.10.1810011259130.25821@sstabellini-ThinkPad-X260> (raw)
In-Reply-To: <20181001124639.22885-3-julien.grall@arm.com>

On Mon, 1 Oct 2018, Julien Grall wrote:
> Some capababilities are set right during boot and will never change
> afterwards. At the moment, the function cpu_have_caps will check whether
> the cap is enabled from the memory.
> 
> It is possible to avoid the load from the memory by using an
> ALTERNATIVE. With that the check is just reduced to 1 instruction.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

> ---
> 
> This is the static key for the poor. At some point we might want to
> introduce something similar to static key in Xen.
> 
>     Changes in v2:
>         - Use unlikely
> ---
>  xen/include/asm-arm/cpufeature.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/xen/include/asm-arm/cpufeature.h b/xen/include/asm-arm/cpufeature.h
> index 3de6b54301..c6cbc2ec84 100644
> --- a/xen/include/asm-arm/cpufeature.h
> +++ b/xen/include/asm-arm/cpufeature.h
> @@ -63,6 +63,18 @@ static inline bool cpus_have_cap(unsigned int num)
>      return test_bit(num, cpu_hwcaps);
>  }
>  
> +/* System capability check for constant cap */
> +#define cpus_have_const_cap(num) ({                 \
> +        bool __ret;                                 \
> +                                                    \
> +        asm volatile (ALTERNATIVE("mov %0, #0",     \
> +                                  "mov %0, #1",     \
> +                                  num)              \
> +                      : "=r" (__ret));              \
> +                                                    \
> +        unlikely(__ret);                            \
> +        })
> +
>  static inline void cpus_set_cap(unsigned int num)
>  {
>      if (num >= ARM_NCAPS)
> -- 
> 2.11.0
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-10-01 19:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-01 12:46 [[PATCH v3] 0/4] xen/arm: SMCCC fixup and improvement Julien Grall
2018-10-01 12:46 ` [[PATCH v3] 1/4] xen/arm: add SMC wrapper that is compatible with SMCCC v1.0 Julien Grall
2018-10-01 12:46 ` [[PATCH v3] 2/4] xen/arm: cpufeature: Add helper to check constant caps Julien Grall
2018-10-01 19:59   ` Stefano Stabellini [this message]
2018-10-01 12:46 ` [[PATCH v3] 3/4] xen/arm: smccc: Add wrapper to automatically select the calling convention Julien Grall
2018-10-01 12:46 ` [[PATCH v3] 4/4] xen/arm: Replace call_smc with arm_smccc_smc Julien Grall
2018-10-01 13:11   ` Andrew Cooper
2018-10-01 13:33     ` Julien Grall
2018-10-01 13:13   ` Julien Grall
2018-10-01 20:01   ` Stefano Stabellini
2018-10-01 20:52     ` Stefano Stabellini
2018-10-01 20:57       ` Julien Grall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.10.1810011259130.25821@sstabellini-ThinkPad-X260 \
    --to=sstabellini@kernel.org \
    --cc=julien.grall@arm.com \
    --cc=volodymyr_babchuk@epam.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.