From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
To: Irina Ryapolova <irina.ryapolova@syntacore.com>, qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, palmer@dabbelt.com,
alistair.francis@wdc.com, bin.meng@windriver.com,
liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com
Subject: Re: [PATCH v2 1/2] target/riscv: FIX xATP_MODE validation
Date: Thu, 21 Dec 2023 10:18:55 -0300 [thread overview]
Message-ID: <bc309588-6f70-4843-bfcd-7f1ca0784d55@ventanamicro.com> (raw)
In-Reply-To: <20231212110305.45443-1-irina.ryapolova@syntacore.com>
Hi,
On 12/12/23 08:03, Irina Ryapolova wrote:
> [Changes since v1]
> used satp_mode.map instead of satp_mode.supported
>
> [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>
> ---
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
> 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,
next prev parent reply other threads:[~2023-12-21 13:19 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 ` Daniel Henrique Barboza [this message]
2024-01-08 0:45 ` [PATCH v2 1/2] target/riscv: FIX xATP_MODE validation Alistair Francis
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=bc309588-6f70-4843-bfcd-7f1ca0784d55@ventanamicro.com \
--to=dbarboza@ventanamicro.com \
--cc=alistair.francis@wdc.com \
--cc=bin.meng@windriver.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 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.