Skip to content

Commit

Permalink
hw/intc/arm_gicv3_its: Factor out "is intid a valid LPI ID?"
Browse files Browse the repository at this point in the history
In process_mapti() we check interrupt IDs to see whether they are
in the valid LPI range. Factor this out into its own utility
function, as we're going to want it elsewhere too for GICv4.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20220408141550.1271295-7-peter.maydell@linaro.org
  • Loading branch information
pm215 committed Apr 22, 2022
1 parent 9acd2d3 commit c3c9a09
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions hw/intc/arm_gicv3_its.c
Expand Up @@ -79,6 +79,12 @@ typedef enum ItsCmdResult {
CMD_CONTINUE = 1,
} ItsCmdResult;

static inline bool intid_in_lpi_range(uint32_t id)
{
return id >= GICV3_LPI_INTID_START &&
id < (1 << (GICD_TYPER_IDBITS + 1));
}

static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz)
{
uint64_t result = 0;
Expand Down Expand Up @@ -410,7 +416,6 @@ static ItsCmdResult process_mapti(GICv3ITSState *s, const uint64_t *cmdpkt,
uint32_t devid, eventid;
uint32_t pIntid = 0;
uint64_t num_eventids;
uint32_t num_intids;
uint16_t icid = 0;
DTEntry dte;
ITEntry ite;
Expand Down Expand Up @@ -438,7 +443,6 @@ static ItsCmdResult process_mapti(GICv3ITSState *s, const uint64_t *cmdpkt,
return CMD_STALL;
}
num_eventids = 1ULL << (dte.size + 1);
num_intids = 1ULL << (GICD_TYPER_IDBITS + 1);

if (icid >= s->ct.num_entries) {
qemu_log_mask(LOG_GUEST_ERROR,
Expand All @@ -460,7 +464,7 @@ static ItsCmdResult process_mapti(GICv3ITSState *s, const uint64_t *cmdpkt,
return CMD_CONTINUE;
}

if (pIntid < GICV3_LPI_INTID_START || pIntid >= num_intids) {
if (!intid_in_lpi_range(pIntid)) {
qemu_log_mask(LOG_GUEST_ERROR,
"%s: invalid interrupt ID 0x%x\n", __func__, pIntid);
return CMD_CONTINUE;
Expand Down

0 comments on commit c3c9a09

Please sign in to comment.