[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/26] target/ppc: powerpc_excp: Add excp_vectors bounds check
From: |
Cédric Le Goater |
Subject: |
[PULL 19/26] target/ppc: powerpc_excp: Add excp_vectors bounds check |
Date: |
Tue, 4 Jan 2022 08:31:14 +0100 |
From: Fabiano Rosas <farosas@linux.ibm.com>
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: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <20211229165751.3774248-3-farosas@linux.ibm.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
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 c7efbdc3051b..9e7c428821e1 100644
--- a/target/ppc/excp_helper.c
+++ b/target/ppc/excp_helper.c
@@ -372,6 +372,10 @@ static 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
" => %s (%d) error=%02x\n", env->nip,
powerpc_excp_name(excp),
excp, env->error_code);
@@ -426,9 +430,6 @@ static 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:
--
2.31.1
- [PULL 00/26] ppc queue, Cédric Le Goater, 2022/01/04
- [PULL 04/26] pnv_phb3.c: do not set 'root-bus' as bus name, Cédric Le Goater, 2022/01/04
- [PULL 19/26] target/ppc: powerpc_excp: Add excp_vectors bounds check,
Cédric Le Goater <=
- [PULL 24/26] target/ppc: Rewrite pmu_increment_insns, Cédric Le Goater, 2022/01/04
- [PULL 16/26] ppc/ppc405: Dump specific registers, Cédric Le Goater, 2022/01/04
- [PULL 07/26] target/ppc: Check effective address validity, Cédric Le Goater, 2022/01/04
- [PULL 21/26] target/ppc: powerpc_excp: Move system call vectored code together, Cédric Le Goater, 2022/01/04
- [PULL 17/26] target/ppc: do not silence snan in xscvspdpn, Cédric Le Goater, 2022/01/04
- [PULL 14/26] ppc/ppc405: Fix timer initialization, Cédric Le Goater, 2022/01/04
- [PULL 20/26] target/ppc: powerpc_excp: Set vector earlier, Cédric Le Goater, 2022/01/04
- [PULL 11/26] ppc/ppc405: Activate MMU logs, Cédric Le Goater, 2022/01/04
- [PULL 05/26] pnv_phb4.c: do not set 'root-bus' as bus name, Cédric Le Goater, 2022/01/04
- [PULL 06/26] target/ppc: Improve logging in Radix MMU, Cédric Le Goater, 2022/01/04