From: Richard Henderson <richard.henderson@linaro.org>
To: Furquan Shaikh <furquan@rivosinc.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Alistair Francis <alistair.francis@wdc.com>,
Bin Meng <bin.meng@windriver.com>,
qemu-riscv@nongnu.org
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] riscv: Make semihosting configurable for all privilege modes
Date: Fri, 12 Aug 2022 16:27:25 -0700 [thread overview]
Message-ID: <37244ef8-d2f1-038a-8a51-01d9f62fbe2c@linaro.org> (raw)
In-Reply-To: <CA+tJHD7FcrBTetGRO0vZn-XGPmZmQraMrw1dw9ia6jzHQniB0w@mail.gmail.com>
On 8/11/22 13:41, Furquan Shaikh wrote:
> Unlike ARM, RISC-V does not define a separate breakpoint type for
> semihosting. Instead, it is entirely ABI. Thus, we need an option
> to allow users to configure what the ebreak behavior should be for
> different privilege levels - M, S, U, VS, VU. As per the RISC-V
> privilege specification[1], ebreak traps into the execution
> environment. However, RISC-V debug specification[2] provides
> ebreak{m,s,u,vs,vu} configuration bits to allow ebreak behavior to
> be configured to trap into debug mode instead. This change adds
> settable properties for RISC-V CPUs - `ebreakm`, `ebreaks`, `ebreaku`,
> `ebreakvs` and `ebreakvu` to allow user to configure whether qemu
> should treat ebreak as semihosting traps or trap according to the
> privilege specification.
>
> [1] https://github.com/riscv/riscv-isa-manual/releases/download/draft-20220723-10eea63/riscv-privileged.pdf
> [2] https://github.com/riscv/riscv-debug-spec/blob/release/riscv-debug-release.pdf
I don't see why you need to change anything at all.
Semihosting doesn't only use 'ebreak', but a sequence of 3 insns:
slli x0, x0, 0x1f # 0x01f01013 Entry NOP
ebreak # 0x00100073 Break to debugger
srai x0, x0, 7 # 0x40705013 NOP encoding the semihosting call number 7
If the -semihosting command-line argument is absent, then the new DSCR fields apply as
normal. If the -semihosting command-line argument is present, and the ebreak is not
surrounded by the required nops, then the new DSCR fields apply as normal. But if the
command-line argument is present and the nops are present, then semihosting overrides the
architecture and DSCR does not apply at all.
r~
next prev parent reply other threads:[~2022-08-12 23:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-11 20:41 [PATCH] riscv: Make semihosting configurable for all privilege modes Furquan Shaikh
2022-08-11 20:56 ` Furquan Shaikh
2022-08-11 23:27 ` Philippe Mathieu-Daudé via
2022-08-12 11:04 ` Andrew Jones
2022-08-12 22:05 ` Furquan Shaikh
2022-08-12 23:00 ` Palmer Dabbelt
2022-08-12 23:28 ` Furquan Shaikh
2022-08-12 11:28 ` Peter Maydell
2022-08-12 23:11 ` Furquan Shaikh
2022-08-12 23:27 ` Richard Henderson [this message]
2022-08-12 23:42 ` Richard Henderson
2022-08-12 23:57 ` Furquan Shaikh
2022-08-13 0:30 ` Richard Henderson
2022-08-13 0:50 ` Furquan Shaikh
2022-08-13 2:31 ` Richard Henderson
2022-08-13 5:22 ` Furquan Shaikh
2022-08-13 10:19 ` Peter Maydell
2022-08-14 22:03 ` Alistair Francis
2022-08-15 6:24 ` Furquan Shaikh
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=37244ef8-d2f1-038a-8a51-01d9f62fbe2c@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=bin.meng@windriver.com \
--cc=furquan@rivosinc.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 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).