hw/intc/arm_gicv3_its: Refactor process_its_cmd() to reduce nesting
Refactor process_its_cmd() so that it consistently uses the structure do thing; if (error condition) { return early; } do next thing; rather than doing some of the work nested inside if (not error) code blocks. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20220111171048.3545974-8-peter.maydell@linaro.org
This commit is contained in:
parent
593a7cc2d3
commit
be0ed8fb7f
|
@ -273,56 +273,54 @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
|
|||
}
|
||||
dte_valid = FIELD_EX64(dte, DTE, VALID);
|
||||
|
||||
if (dte_valid) {
|
||||
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
|
||||
|
||||
ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
|
||||
|
||||
if (res != MEMTX_OK) {
|
||||
return CMD_STALL;
|
||||
}
|
||||
|
||||
if (ite_valid) {
|
||||
cte_valid = get_cte(s, icid, &cte, &res);
|
||||
}
|
||||
|
||||
if (res != MEMTX_OK) {
|
||||
return CMD_STALL;
|
||||
}
|
||||
} else {
|
||||
if (!dte_valid) {
|
||||
qemu_log_mask(LOG_GUEST_ERROR,
|
||||
"%s: invalid command attributes: "
|
||||
"invalid dte: %"PRIx64" for %d (MEM_TX: %d)\n",
|
||||
__func__, dte, devid, res);
|
||||
"invalid dte: %"PRIx64" for %d\n",
|
||||
__func__, dte, devid);
|
||||
return CMD_CONTINUE;
|
||||
}
|
||||
|
||||
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
|
||||
|
||||
ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
|
||||
if (res != MEMTX_OK) {
|
||||
return CMD_STALL;
|
||||
}
|
||||
|
||||
if (!ite_valid) {
|
||||
qemu_log_mask(LOG_GUEST_ERROR,
|
||||
"%s: invalid command attributes: invalid ITE\n",
|
||||
__func__);
|
||||
return CMD_CONTINUE;
|
||||
}
|
||||
|
||||
cte_valid = get_cte(s, icid, &cte, &res);
|
||||
if (res != MEMTX_OK) {
|
||||
return CMD_STALL;
|
||||
}
|
||||
if (!cte_valid) {
|
||||
qemu_log_mask(LOG_GUEST_ERROR,
|
||||
"%s: invalid command attributes: "
|
||||
"invalid cte: %"PRIx64"\n",
|
||||
__func__, cte);
|
||||
return CMD_CONTINUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* In this implementation, in case of guest errors we ignore the
|
||||
* command and move onto the next command in the queue.
|
||||
*/
|
||||
if (devid >= s->dt.num_ids) {
|
||||
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: "
|
||||
"dte: %s, ite: %s, cte: %s\n",
|
||||
__func__,
|
||||
dte_valid ? "valid" : "invalid",
|
||||
ite_valid ? "valid" : "invalid",
|
||||
cte_valid ? "valid" : "invalid");
|
||||
return CMD_CONTINUE;
|
||||
} else if (eventid >= num_eventids) {
|
||||
}
|
||||
if (eventid >= num_eventids) {
|
||||
qemu_log_mask(LOG_GUEST_ERROR,
|
||||
"%s: invalid command attributes: eventid %d >= %"
|
||||
PRId64 "\n",
|
||||
__func__, eventid, num_eventids);
|
||||
return CMD_CONTINUE;
|
||||
} else {
|
||||
}
|
||||
|
||||
/*
|
||||
* Current implementation only supports rdbase == procnum
|
||||
* Hence rdbase physical address is ignored
|
||||
|
@ -346,7 +344,6 @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
|
|||
}
|
||||
return CMD_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
|
||||
uint32_t offset, bool ignore_pInt)
|
||||
|
|
Loading…
Reference in a new issue