From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
To: Alistair Francis <alistair.francis@opensource.wdc.com>,
qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: palmer@dabbelt.com, alistair.francis@wdc.com,
Bin Meng <bin.meng@windriver.com>,
alistair23@gmail.com, bmeng.cn@gmail.com
Subject: Re: [PATCH] hw/riscv: boot: Don't use CSRs if they are disabled
Date: Mon, 23 Jan 2023 09:02:59 -0300 [thread overview]
Message-ID: <9ab1e3af-db52-4d55-03e7-263a2f7ae965@ventanamicro.com> (raw)
In-Reply-To: <20230123035754.75553-1-alistair.francis@opensource.wdc.com>
On 1/23/23 00:57, Alistair Francis wrote:
> From: Alistair Francis <alistair.francis@wdc.com>
>
> If the CSRs and CSR instructions are disabled because the Zicsr
> extension isn't enabled then we want to make sure we don't run any CSR
> instructions in the boot ROM.
>
> This patches removes the CSR instructions from the reset-vec if the
> extension isn't enabled. We replace the instruction with a NOP instead.
>
> Note that we don't do this for the SiFive U machine, as we are modelling
> the hardware in that case.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1447
> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> ---
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
> hw/riscv/boot.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
> index 2594276223..cb27798a25 100644
> --- a/hw/riscv/boot.c
> +++ b/hw/riscv/boot.c
> @@ -356,6 +356,15 @@ void riscv_setup_rom_reset_vec(MachineState *machine, RISCVHartArrayState *harts
> reset_vec[4] = 0x0182b283; /* ld t0, 24(t0) */
> }
>
> + if (!harts->harts[0].cfg.ext_icsr) {
> + /*
> + * The Zicsr extension has been disabled, so let's ensure we don't
> + * run the CSR instruction. Let's fill the address with a non
> + * compressed nop.
> + */
> + reset_vec[2] = 0x00000013; /* addi x0, x0, 0 */
> + }
> +
> /* copy in the reset vector in little_endian byte order */
> for (i = 0; i < ARRAY_SIZE(reset_vec); i++) {
> reset_vec[i] = cpu_to_le32(reset_vec[i]);
next prev parent reply other threads:[~2023-01-23 12:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-23 3:57 [PATCH] hw/riscv: boot: Don't use CSRs if they are disabled Alistair Francis
2023-01-23 10:24 ` Daniel Henrique Barboza
2023-01-23 11:51 ` Alistair Francis
2023-01-23 12:02 ` Daniel Henrique Barboza [this message]
2023-01-23 23:59 ` Alistair Francis
2023-01-24 1:24 ` Bin Meng
2023-01-24 1:42 ` Alistair Francis
2023-01-26 12:03 ` Bin Meng
2023-01-29 23:18 ` Alistair Francis
2023-01-31 12:31 ` Bin Meng
2023-02-02 0:26 ` Alistair Francis
-- strict thread matches above, loose matches on Subject: below --
2023-01-23 22:14 Jesse Taube
2023-01-23 23:56 ` 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=9ab1e3af-db52-4d55-03e7-263a2f7ae965@ventanamicro.com \
--to=dbarboza@ventanamicro.com \
--cc=alistair.francis@opensource.wdc.com \
--cc=alistair.francis@wdc.com \
--cc=alistair23@gmail.com \
--cc=bin.meng@windriver.com \
--cc=bmeng.cn@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.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.