From: David Gibson <david@gibson.dropbear.id.au>
To: Fabiano Rosas <farosas@linux.ibm.com>
Cc: richard.henderson@linaro.org, danielhb413@gmail.com,
qemu-ppc@nongnu.org, qemu-devel@nongnu.org, clg@kaod.org
Subject: Re: [PATCH v2 2/5] target/ppc: powerpc_excp: Add excp_vectors bounds check
Date: Sat, 1 Jan 2022 19:29:08 +1100 [thread overview]
Message-ID: <YdAQ1DuxfAV8mcY2@yekko> (raw)
In-Reply-To: <20211229165751.3774248-3-farosas@linux.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 1868 bytes --]
On Wed, Dec 29, 2021 at 01:57:48PM -0300, Fabiano Rosas wrote:
> The next patch will start accessing the excp_vectors array earlier in
> the function, so add a bounds check as first thing here.
>
> This converts the empty return on POWERPC_EXCP_NONE to an error. This
> exception number never reaches this function and if it does it
> probably means something else went wrong up the line.
>
> Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> target/ppc/excp_helper.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
> index 8b9c6bc5a8..9a03e4b896 100644
> --- a/target/ppc/excp_helper.c
> +++ b/target/ppc/excp_helper.c
> @@ -300,6 +300,10 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
> target_ulong msr, new_msr, vector;
> int srr0, srr1, lev = -1;
>
> + if (excp <= POWERPC_EXCP_NONE || excp >= POWERPC_EXCP_NB) {
> + cpu_abort(cs, "Invalid PowerPC exception %d. Aborting\n", excp);
> + }
> +
> qemu_log_mask(CPU_LOG_INT, "Raise exception at " TARGET_FMT_lx
> " => %08x (%02x)\n", env->nip, excp, env->error_code);
>
> @@ -353,9 +357,6 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
> #endif
>
> switch (excp) {
> - case POWERPC_EXCP_NONE:
> - /* Should never happen */
> - return;
> case POWERPC_EXCP_CRITICAL: /* Critical input */
> switch (excp_model) {
> case POWERPC_EXCP_40x:
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2022-01-01 8:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-29 16:57 [PATCH v2 0/5] target/ppc: powerpc_excp improvements (1/n) Fabiano Rosas
2021-12-29 16:57 ` [PATCH v2 1/5] target/ppc: powerpc_excp: Set alternate SRRs directly Fabiano Rosas
2021-12-29 16:57 ` [PATCH v2 2/5] target/ppc: powerpc_excp: Add excp_vectors bounds check Fabiano Rosas
2021-12-30 22:04 ` Richard Henderson
2021-12-31 7:40 ` Cédric Le Goater
2022-01-01 8:29 ` David Gibson [this message]
2021-12-29 16:57 ` [PATCH v2 3/5] target/ppc: powerpc_excp: Set vector earlier Fabiano Rosas
2021-12-30 22:05 ` Richard Henderson
2022-01-01 8:31 ` David Gibson
2021-12-29 16:57 ` [PATCH v2 4/5] target/ppc: powerpc_excp: Move system call vectored code together Fabiano Rosas
2021-12-29 16:57 ` [PATCH v2 5/5] target/ppc: powerpc_excp: Stop passing excp_model around Fabiano Rosas
2022-01-04 7:40 ` [PATCH v2 0/5] target/ppc: powerpc_excp improvements (1/n) Cédric Le Goater
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=YdAQ1DuxfAV8mcY2@yekko \
--to=david@gibson.dropbear.id.au \
--cc=clg@kaod.org \
--cc=danielhb413@gmail.com \
--cc=farosas@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=richard.henderson@linaro.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).