[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 21/26] hw/intc/arm_gicv3_its: Fix return codes in process_its_cmd
From: |
Peter Maydell |
Subject: |
[PATCH 21/26] hw/intc/arm_gicv3_its: Fix return codes in process_its_cmd() |
Date: |
Sat, 11 Dec 2021 19:11:30 +0000 |
Fix process_its_cmd() to consistently return CMD_STALL for
memory errors and CMD_CONTINUE for parameter errors, as
we claim in the comments that we do.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/intc/arm_gicv3_its.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
index 59dd564d91c..3a2254ea7c7 100644
--- a/hw/intc/arm_gicv3_its.c
+++ b/hw/intc/arm_gicv3_its.c
@@ -248,7 +248,6 @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s,
uint64_t value,
bool ite_valid = false;
uint64_t cte = 0;
bool cte_valid = false;
- ItsCmdResult result = CMD_STALL;
uint64_t rdbase;
if (cmd == NONE) {
@@ -262,7 +261,7 @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s,
uint64_t value,
}
if (res != MEMTX_OK) {
- return result;
+ return CMD_STALL;
}
eventid = (value & EVENTID_MASK);
@@ -270,7 +269,7 @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s,
uint64_t value,
dte = get_dte(s, devid, &res);
if (res != MEMTX_OK) {
- return result;
+ return CMD_STALL;
}
dte_valid = FIELD_EX64(dte, DTE, VALID);
@@ -280,7 +279,7 @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s,
uint64_t value,
ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
if (res != MEMTX_OK) {
- return result;
+ return CMD_STALL;
}
if (ite_valid) {
@@ -288,14 +287,14 @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s,
uint64_t value,
}
if (res != MEMTX_OK) {
- return result;
+ return CMD_STALL;
}
} else {
qemu_log_mask(LOG_GUEST_ERROR,
"%s: invalid command attributes: "
"invalid dte: %"PRIx64" for %d (MEM_TX: %d)\n",
__func__, dte, devid, res);
- return result;
+ return CMD_CONTINUE;
}
@@ -307,7 +306,7 @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s,
uint64_t value,
qemu_log_mask(LOG_GUEST_ERROR,
"%s: invalid command attributes: devid %d>=%d",
__func__, devid, s->dt.num_ids);
-
+ return CMD_CONTINUE;
} else if (!dte_valid || !ite_valid || !cte_valid) {
qemu_log_mask(LOG_GUEST_ERROR,
"%s: invalid command attributes: "
@@ -316,10 +315,12 @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s,
uint64_t value,
dte_valid ? "valid" : "invalid",
ite_valid ? "valid" : "invalid",
cte_valid ? "valid" : "invalid");
+ return CMD_CONTINUE;
} else if (eventid >= num_eventids) {
qemu_log_mask(LOG_GUEST_ERROR,
"%s: invalid command attributes: eventid %d > %d\n",
__func__, eventid, num_eventids);
+ return CMD_CONTINUE;
} else {
/*
* Current implementation only supports rdbase == procnum
@@ -328,7 +329,7 @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s,
uint64_t value,
rdbase = FIELD_EX64(cte, CTE, RDBASE);
if (rdbase >= s->gicv3->num_cpu) {
- return result;
+ return CMD_CONTINUE;
}
if ((cmd == CLEAR) || (cmd == DISCARD)) {
@@ -340,11 +341,10 @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s,
uint64_t value,
if (cmd == DISCARD) {
IteEntry ite = {};
/* remove mapping from interrupt translation table */
- result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE :
CMD_STALL;
+ return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
}
+ return CMD_CONTINUE;
}
-
- return result;
}
static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
--
2.25.1
- Re: [PATCH 11/26] hw/intc/arm_gicv3_its: Use 1ULL when shifting by (DTE.SIZE + 1), (continued)
[PATCH 13/26] hw/intc/arm_gicv3_its: Use FIELD macros for CTEs, Peter Maydell, 2021/12/11
[PATCH 09/26] hw/intc/arm_gicv3_its: Correct handling of MAPI, Peter Maydell, 2021/12/11
[PATCH 17/26] hw/intc/arm_gicv3_its: Convert int ID check to num_intids convention, Peter Maydell, 2021/12/11
[PATCH 21/26] hw/intc/arm_gicv3_its: Fix return codes in process_its_cmd(),
Peter Maydell <=
[PATCH 08/26] hw/intc/arm_gicv3_its: Don't misuse GITS_TYPE_PHYSICAL define, Peter Maydell, 2021/12/11
[PATCH 20/26] hw/intc/arm_gicv3_its: Use enum for return value of process_* functions, Peter Maydell, 2021/12/11
[PATCH 26/26] hw/intc/arm_gicv3_its: Factor out "find address of table entry" code, Peter Maydell, 2021/12/11