From: Richard Henderson <richard.henderson@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>,
qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH] target/arm: Take an exception if PSTATE.IL is set
Date: Tue, 17 Aug 2021 10:31:40 -1000 [thread overview]
Message-ID: <a59ce840-3694-0936-b67e-2187d367a90d@linaro.org> (raw)
In-Reply-To: <20210817162118.24319-1-peter.maydell@linaro.org>
On 8/17/21 6:21 AM, Peter Maydell wrote:
> In v8A, the PSTATE.IL bit is set for various kinds of illegal
> exception return or mode-change attempts. We already set PSTATE.IL
> (or its AArch32 equivalent CPSR.IL) in all those cases, but we
> weren't implementing the part of the behaviour where attempting to
> execute an instruction with PSTATE.IL takes an immediate exception
> with an appropriate syndrome value.
>
> Add a new TB flags bit tracking PSTATE.IL/CPSR.IL, and generate code
> to take an exception instead of whatever the instruction would have
> been.
>
> PSTATE.IL and CPSR.IL change only on exception entry, attempted
> exception exit, and various AArch32 mode changes via cpsr_write().
> These places generally already rebuild the hflags, so the only place
> we need an extra rebuild_hflags call is in the illegal-return
> codepath of the AArch64 exception_return helper.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> Obviously correct guest code is never going to set PSTATE.IL, but
> it's pretty confusing to debug bugs in guest OSes if we just plough
> on executing code rather than taking the illegal-state exception. We
> had a user point this bug out to us earlier this year I think
> (probably on IRC since I can't find anything about it in my email).
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> + if (s->pstate_il) {
> + /*
> + * Illegal execution state. This has priority over BTI
> + * exceptions, but comes after instruction abort exceptions.
> + */
> + gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
> + syn_illegalstate(), default_exception_el(s));
> + }
Missing return after exception.
> @@ -9045,6 +9045,15 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
> return;
> }
>
> + if (s->pstate_il) {
> + /*
> + * Illegal execution state. This has priority over BTI
> + * exceptions, but comes after instruction abort exceptions.
> + */
> + gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
> + syn_illegalstate(), default_exception_el(s));
> + }
...
> @@ -9576,6 +9586,15 @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
> }
> dc->insn = insn;
>
> + if (dc->pstate_il) {
> + /*
> + * Illegal execution state. This has priority over BTI
> + * exceptions, but comes after instruction abort exceptions.
> + */
> + gen_exception_insn(dc, dc->pc_curr, EXCP_UDEF,
> + syn_illegalstate(), default_exception_el(dc));
> + }
Likewise.
Otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
next prev parent reply other threads:[~2021-08-17 20:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-17 16:21 [PATCH] target/arm: Take an exception if PSTATE.IL is set Peter Maydell
2021-08-17 20:31 ` Richard Henderson [this message]
2021-08-21 18:59 ` Richard Henderson
2021-08-21 19:06 ` Peter Maydell
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=a59ce840-3694-0936-b67e-2187d367a90d@linaro.org \
--to=richard.henderson@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@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).