qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
To: Daniel Henrique Barboza <dbarboza@ventanamicro.com>,
	qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com,
	bmeng@tinylab.org, liweiwei@iscas.ac.cn,
	richard.henderson@linaro.org,
	Andrew Jones <ajones@ventanamicro.com>
Subject: Re: [PATCH v6 5/9] target/riscv: remove RISCV_FEATURE_EPMP
Date: Fri, 17 Feb 2023 09:58:07 +0800	[thread overview]
Message-ID: <df379d26-73aa-556c-c028-8c85af693796@linux.alibaba.com> (raw)
In-Reply-To: <20230216215550.1011637-6-dbarboza@ventanamicro.com>


On 2023/2/17 5:55, Daniel Henrique Barboza wrote:
> RISCV_FEATURE_EPMP is always set to the same value as the cpu->cfg.epmp
> flag. Use the flag directly.
>
> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
> Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
> Reviewed-by: Bin Meng <bmeng@tinylab.org>
> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
> ---
>   target/riscv/cpu.c | 10 +++-------
>   target/riscv/cpu.h |  1 -
>   target/riscv/csr.c |  2 +-
>   target/riscv/pmp.c |  4 ++--
>   4 files changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
> index 4585ca74dc..71b2042d73 100644
> --- a/target/riscv/cpu.c
> +++ b/target/riscv/cpu.c
> @@ -927,17 +927,13 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
>           riscv_set_feature(env, RISCV_FEATURE_PMP);
>       }
>   
> -    if (cpu->cfg.epmp) {
> -        riscv_set_feature(env, RISCV_FEATURE_EPMP);
> -
> +    if (cpu->cfg.epmp && !cpu->cfg.pmp) {
>           /*
>            * Enhanced PMP should only be available
>            * on harts with PMP support
>            */
> -        if (!cpu->cfg.pmp) {
> -            error_setg(errp, "Invalid configuration: EPMP requires PMP support");
> -            return;
> -        }
> +        error_setg(errp, "Invalid configuration: EPMP requires PMP support");
> +        return;
>       }
>   
>   
> diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
> index 2afb705930..6d659d74fa 100644
> --- a/target/riscv/cpu.h
> +++ b/target/riscv/cpu.h
> @@ -88,7 +88,6 @@
>   enum {
>       RISCV_FEATURE_MMU,
>       RISCV_FEATURE_PMP,
> -    RISCV_FEATURE_EPMP,
>   };
>   
>   /* Privileged specification version */
> diff --git a/target/riscv/csr.c b/target/riscv/csr.c
> index 58af2c0e66..cdc68d3676 100644
> --- a/target/riscv/csr.c
> +++ b/target/riscv/csr.c
> @@ -428,7 +428,7 @@ static RISCVException pmp(CPURISCVState *env, int csrno)
>   
>   static RISCVException epmp(CPURISCVState *env, int csrno)
>   {
> -    if (env->priv == PRV_M && riscv_feature(env, RISCV_FEATURE_EPMP)) {
> +    if (env->priv == PRV_M && riscv_cpu_cfg(env)->epmp) {
>           return RISCV_EXCP_NONE;
>       }
>   
> diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
> index 4bc4113531..aa4d1996e9 100644
> --- a/target/riscv/pmp.c
> +++ b/target/riscv/pmp.c
> @@ -88,7 +88,7 @@ static void pmp_write_cfg(CPURISCVState *env, uint32_t pmp_index, uint8_t val)
>       if (pmp_index < MAX_RISCV_PMPS) {
>           bool locked = true;
>   
> -        if (riscv_feature(env, RISCV_FEATURE_EPMP)) {
> +        if (riscv_cpu_cfg(env)->epmp) {
>               /* mseccfg.RLB is set */
>               if (MSECCFG_RLB_ISSET(env)) {
>                   locked = false;
> @@ -239,7 +239,7 @@ static bool pmp_hart_has_privs_default(CPURISCVState *env, target_ulong addr,
>   {
>       bool ret;
>   
> -    if (riscv_feature(env, RISCV_FEATURE_EPMP)) {
> +    if (riscv_cpu_cfg(env)->epmp) {

Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>

Zhiwei

>           if (MSECCFG_MMWP_ISSET(env)) {
>               /*
>                * The Machine Mode Whitelist Policy (mseccfg.MMWP) is set


  reply	other threads:[~2023-02-17  1:58 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-16 21:55 [PATCH v6 0/9] make write_misa a no-op and FEATURE_* cleanups Daniel Henrique Barboza
2023-02-16 21:55 ` [PATCH v6 1/9] target/riscv: turn write_misa() into an official no-op Daniel Henrique Barboza
2023-02-17  1:42   ` LIU Zhiwei
2023-02-21 15:49     ` Daniel Henrique Barboza
2023-02-21 17:06       ` Andrew Jones
2023-02-21 18:22         ` Daniel Henrique Barboza
2023-02-21 18:28           ` Andrew Jones
2023-02-22  8:41             ` Daniel Henrique Barboza
2023-02-22  9:21           ` LIU Zhiwei
2023-02-22 16:42             ` Daniel Henrique Barboza
2023-02-17  2:31   ` weiwei
2023-02-16 21:55 ` [PATCH v6 2/9] target/riscv: introduce riscv_cpu_cfg() Daniel Henrique Barboza
2023-02-17  0:45   ` Bin Meng
2023-02-17  0:47     ` Bin Meng
2023-02-17  1:45   ` LIU Zhiwei
2023-02-17  1:50   ` LIU Zhiwei
2023-02-17  2:19     ` LIU Zhiwei
2023-02-17  2:31   ` weiwei
2023-02-17  2:55   ` LIU Zhiwei
2023-02-17  8:39     ` Daniel Henrique Barboza
2023-02-17  5:40   ` Richard Henderson
2023-02-16 21:55 ` [PATCH v6 3/9] target/riscv: remove RISCV_FEATURE_DEBUG Daniel Henrique Barboza
2023-02-17  1:53   ` LIU Zhiwei
2023-02-16 21:55 ` [PATCH v6 4/9] target/riscv/cpu.c: error out if EPMP is enabled without PMP Daniel Henrique Barboza
2023-02-17  1:55   ` LIU Zhiwei
2023-02-16 21:55 ` [PATCH v6 5/9] target/riscv: remove RISCV_FEATURE_EPMP Daniel Henrique Barboza
2023-02-17  1:58   ` LIU Zhiwei [this message]
2023-02-16 21:55 ` [PATCH v6 6/9] target/riscv: remove RISCV_FEATURE_PMP Daniel Henrique Barboza
2023-02-17  1:59   ` LIU Zhiwei
2023-02-16 21:55 ` [PATCH v6 7/9] hw/riscv/virt.c: do not use RISCV_FEATURE_MMU in create_fdt_socket_cpus() Daniel Henrique Barboza
2023-02-17  1:59   ` LIU Zhiwei
2023-02-16 21:55 ` [PATCH v6 8/9] target/riscv: remove RISCV_FEATURE_MMU Daniel Henrique Barboza
2023-02-17  2:04   ` LIU Zhiwei
2023-02-16 21:55 ` [PATCH v6 9/9] target/riscv/cpu: remove CPUArchState::features and friends Daniel Henrique Barboza
2023-02-17  2:05   ` LIU Zhiwei

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=df379d26-73aa-556c-c028-8c85af693796@linux.alibaba.com \
    --to=zhiwei_liu@linux.alibaba.com \
    --cc=ajones@ventanamicro.com \
    --cc=alistair.francis@wdc.com \
    --cc=bmeng@tinylab.org \
    --cc=dbarboza@ventanamicro.com \
    --cc=liweiwei@iscas.ac.cn \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@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).