qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alistair Francis <alistair23@gmail.com>
To: Irina Ryapolova <irina.ryapolova@syntacore.com>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org, palmer@dabbelt.com,
	 alistair.francis@wdc.com, bin.meng@windriver.com,
	liwei1518@gmail.com,  dbarboza@ventanamicro.com,
	zhiwei_liu@linux.alibaba.com
Subject: Re: [PATCH v2 1/2] target/riscv: FIX xATP_MODE validation
Date: Mon, 8 Jan 2024 10:45:02 +1000	[thread overview]
Message-ID: <CAKmqyKMKX8qK-D9TAyVViA9Dh0V_J4o251qDN7JptaBn=D1AnA@mail.gmail.com> (raw)
In-Reply-To: <20231212110305.45443-1-irina.ryapolova@syntacore.com>

On Tue, Dec 12, 2023 at 9:04 PM Irina Ryapolova
<irina.ryapolova@syntacore.com> wrote:
>
> [Changes since v1]
> used satp_mode.map instead of satp_mode.supported

The changelog needs to go

>
> [Original cover]
> The SATP register is an SXLEN-bit read/write WARL register. It means that CSR fields are only defined
> for a subset of bit encodings, but allow any value to be written while guaranteeing to return a legal
> value whenever read (See riscv-privileged-20211203, SATP CSR).
>
> For example on rv64 we are trying to write to SATP CSR val = 0x1000000000000000 (SATP_MODE = 1 - Reserved for standard use)
> and after that we are trying to read SATP_CSR. We read from the SATP CSR value = 0x1000000000000000, which is not a correct
> operation (return illegal value).
>
> Signed-off-by: Irina Ryapolova <irina.ryapolova@syntacore.com>
> ---

Below this line.

Otherwise it will be included in the git history, which we don't want

Alistair

>  target/riscv/csr.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/target/riscv/csr.c b/target/riscv/csr.c
> index fde7ce1a53..735fb27be7 100644
> --- a/target/riscv/csr.c
> +++ b/target/riscv/csr.c
> @@ -1278,8 +1278,8 @@ static RISCVException read_mstatus(CPURISCVState *env, int csrno,
>
>  static bool validate_vm(CPURISCVState *env, target_ulong vm)
>  {
> -    return (vm & 0xf) <=
> -           satp_mode_max_from_map(riscv_cpu_cfg(env)->satp_mode.map);
> +    uint64_t mode_supported = riscv_cpu_cfg(env)->satp_mode.map;
> +    return get_field(mode_supported, (1 << vm));
>  }
>
>  static target_ulong legalize_mpp(CPURISCVState *env, target_ulong old_mpp,
> --
> 2.25.1
>
>


      parent reply	other threads:[~2024-01-08  0:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-12 11:03 [PATCH v2 1/2] target/riscv: FIX xATP_MODE validation Irina Ryapolova
2023-12-12 11:03 ` [PATCH v2 2/2] target/riscv: UPDATE xATP write CSR Irina Ryapolova
2023-12-21 13:25   ` Daniel Henrique Barboza
2023-12-21 13:18 ` [PATCH v2 1/2] target/riscv: FIX xATP_MODE validation Daniel Henrique Barboza
2024-01-08  0:45 ` Alistair Francis [this message]

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='CAKmqyKMKX8qK-D9TAyVViA9Dh0V_J4o251qDN7JptaBn=D1AnA@mail.gmail.com' \
    --to=alistair23@gmail.com \
    --cc=alistair.francis@wdc.com \
    --cc=bin.meng@windriver.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=irina.ryapolova@syntacore.com \
    --cc=liwei1518@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=zhiwei_liu@linux.alibaba.com \
    /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).