qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: maobibo <maobibo@loongson.cn>
To: Song Gao <gaosong@loongson.cn>, qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org, philmd@redhat.com,
	peter.maydell@linaro.org, eblake@redhat.com, armbru@redhat.com
Subject: Re: [PATCH v2 2/4] target/loongarch: Add cpu feature flags
Date: Fri, 20 Oct 2023 16:05:18 +0800	[thread overview]
Message-ID: <a3448f95-bcb5-f4ba-2cb0-65a80501ef5a@loongson.cn> (raw)
In-Reply-To: <20231019125853.3436531-3-gaosong@loongson.cn>



在 2023/10/19 下午8:58, Song Gao 写道:
> CPULoongArchState adds cpu feature flags features.
> Intrduce loongarch_feature() to check feature and
> set_feature() to set feature.
> 
> Signed-off-by: Song Gao <gaosong@loongson.cn>
> ---
>   target/loongarch/cpu.c |  4 ++++
>   target/loongarch/cpu.h | 32 ++++++++++++++++++++++++++++++++
>   2 files changed, 36 insertions(+)
> 
> diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
> index ef6922e812..87fcd08110 100644
> --- a/target/loongarch/cpu.c
> +++ b/target/loongarch/cpu.c
> @@ -366,6 +366,10 @@ static void loongarch_la464_initfn(Object *obj)
>       CPULoongArchState *env = &cpu->env;
>       int i;
>   
> +    env->features = 0;
> +    set_feature(env, CPU_FEATURE_LSX);
> +    set_feature(env, CPU_FEATURE_LASX);
> +
>       for (i = 0; i < 21; i++) {
>           env->cpucfg[i] = 0x0;
>       }
> diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
> index 8b54cf109c..b98064945a 100644
> --- a/target/loongarch/cpu.h
> +++ b/target/loongarch/cpu.h
> @@ -295,6 +295,8 @@ typedef struct CPUArchState {
>       uint64_t lladdr; /* LL virtual address compared against SC */
>       uint64_t llval;
>   
> +    uint64_t features;
Like what Richard says, it is not necessary to use features here,
cpucfg2 can be used directly.

> +
>       /* LoongArch CSRs */
>       uint64_t CSR_CRMD;
>       uint64_t CSR_PRMD;
> @@ -364,6 +366,36 @@ typedef struct CPUArchState {
>   #endif
>   } CPULoongArchState;
>   
> +/*
> + * See arch/loongarch/include/asm/cpu.h
> + * and arch/loongarch/include/uapi/asm/hwcap.h
> + */
> +enum loongarch_features {
> +    CPU_FEATURE_CPUCFG,
> +    CPU_FEATURE_LAM,
> +    CPU_FEATURE_UAL,
> +    CPU_FEATURE_FPU,
> +    CPU_FEATURE_LSX,
> +    CPU_FEATURE_LASX,
> +    CPU_FEATURE_CRC32,
> +    CPU_FEATURE_COMPLEX,
> +    CPU_FEATURE_CRYPTO,
> +    CPU_FEATURE_LVZ,
> +    CPU_FEATURE_LBT_X86,
> +    CPU_FEATURE_LBT_ARM,
> +    CPU_FEATURE_LBT_MIPS,
> +};
Suggest to only list features which can be set on/off from QEMU command 
line.

Regards
Bibo, Mao
> +
> +static inline int loongarch_feature(CPULoongArchState *env, int feature)
> +{
> +    return (env->features & (1ULL << feature)) != 0;
> +}
> +
> +static inline void set_feature(CPULoongArchState *env, int feature)
> +{
> +    env->features |= 1ULL << feature;
> +}
> +
>   /**
>    * LoongArchCPU:
>    * @env: #CPULoongArchState
> 



  reply	other threads:[~2023-10-20  8:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-19 12:58 [PATCH v2 0/4] Allow user enable/disable LSX/LASX Song Gao
2023-10-19 12:58 ` [PATCH v2 1/4] target/loongarch: Add cpu model 'max' Song Gao
2023-10-19 12:58 ` [PATCH v2 2/4] target/loongarch: Add cpu feature flags Song Gao
2023-10-20  8:05   ` maobibo [this message]
2023-10-20  8:56     ` gaosong
2023-10-19 12:58 ` [PATCH v2 3/4] target/loongarch: Allow user enable/disable LSX/LASX features Song Gao
2023-10-19 12:58 ` [PATCH v2 4/4] target/loongarch: Implement query-cpu-model-expansion Song Gao

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=a3448f95-bcb5-f4ba-2cb0-65a80501ef5a@loongson.cn \
    --to=maobibo@loongson.cn \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=gaosong@loongson.cn \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).