The GIC CD* insns that update interrupt state also work for SPIs.
Instead of ignoring the GICV5_SPI type in gicv5_set_priority() and
friends, update the state in our SPI state array.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/intc/arm_gicv5.c | 64 ++++++++++++++++++++++++++++++
include/hw/intc/arm_gicv5_common.h | 40 +++++++++++++++++++
2 files changed, 104 insertions(+)
diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c
index d1eb96fce0..9ca1826253 100644
--- a/hw/intc/arm_gicv5.c
+++ b/hw/intc/arm_gicv5.c
@@ -490,6 +490,19 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, uint8_t priority,
put_l2_iste(cs, cfg, &h);
break;
}
+ case GICV5_SPI:
+ {
+ GICv5SPIState *spi = gicv5_spi_state(cs, id, domain);
+
+ if (!spi) {
+ qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_priority: tried to set "
+ "priority of unreachable SPI %d\n", id);
+ return;
+ }
+
+ spi->priority = priority;
+ break;
+ }
default:
qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_priority: tried to set "
"priority of bad interrupt type %d\n", type);
@@ -524,6 +537,19 @@ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, bool enabled,
put_l2_iste(cs, cfg, &h);
break;
}
+ case GICV5_SPI:
+ {
+ GICv5SPIState *spi = gicv5_spi_state(cs, id, domain);
+
+ if (!spi) {
+ qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_enabled: tried to set "
+ "enable state of unreachable SPI %d\n", id);
+ return;
+ }
+
+ spi->enabled = true;
+ break;
+ }
default:
qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_enabled: tried to set "
"enable state of bad interrupt type %d\n", type);
@@ -558,6 +584,19 @@ void gicv5_set_pending(GICv5Common *cs, uint32_t id, bool pending,
put_l2_iste(cs, cfg, &h);
break;
}
+ case GICV5_SPI:
+ {
+ GICv5SPIState *spi = gicv5_spi_state(cs, id, domain);
+
+ if (!spi) {
+ qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_pending: tried to set "
+ "pending state of unreachable SPI %d\n", id);
+ return;
+ }
+
+ spi->pending = true;
+ break;
+ }
default:
qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_pending: tried to set "
"pending state of bad interrupt type %d\n", type);
@@ -593,6 +632,18 @@ void gicv5_set_handling(GICv5Common *cs, uint32_t id,
put_l2_iste(cs, cfg, &h);
break;
}
+ case GICV5_SPI:
+ {
+ GICv5SPIState *spi = gicv5_spi_state(cs, id, domain);
+
+ if (!spi) {
+ qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_handling: tried to set "
+ "priority of unreachable SPI %d\n", id);
+ }
+
+ spi->hm = handling;
+ break;
+ }
default:
qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_handling: tried to set "
"handling mode of bad interrupt type %d\n", type);
@@ -642,6 +693,19 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, uint32_t iaffid,
put_l2_iste(cs, cfg, &h);
break;
}
+ case GICV5_SPI:
+ {
+ GICv5SPIState *spi = gicv5_spi_state(cs, id, domain);
+
+ if (!spi) {
+ qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_target: tried to set "
+ "target of unreachable SPI %d\n", id);
+ return;
+ }
+
+ spi->iaffid = iaffid;
+ break;
+ }
default:
qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_target: tried to set "
"target of bad interrupt type %d\n", type);
diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5_common.h
index d3f4999321..a81c941765 100644
--- a/include/hw/intc/arm_gicv5_common.h
+++ b/include/hw/intc/arm_gicv5_common.h
@@ -189,4 +189,44 @@ static inline bool gicv5_domain_implemented(GICv5Common *cs, GICv5Domain domain)
*/
const char *gicv5_class_name(void);
+/**
+ * gicv5_raw_spi_state
+ * @cs: GIC object
+ * @id: INTID of SPI to look up
+ *
+ * Return pointer to the GICv5SPIState for this SPI, or NULL if the
+ * interrupt ID is out of range. This does not do a check that the SPI
+ * is assigned to the right domain: generally you should call it via
+ * some other wrapper that performs an appropriate further check.
+ */
+static inline GICv5SPIState *gicv5_raw_spi_state(GICv5Common *cs, uint32_t id)
+{
+ if (id < cs->spi_base || id >= cs->spi_base + cs->spi_irs_range) {
+ return NULL;
+ }
+
+ return cs->spi + (id - cs->spi_base);
+}
+
+/**
+ * gicv5_spi_state:
+ * @cs: GIC object
+ * @id: INTID of SPI to look up
+ * @domain: domain to check
+ *
+ * Return pointer to the GICv5SPIState for this SPI, or NULL if the
+ * interrupt is unreachable (which can be because the INTID is out of
+ * range, or because the SPI is configured for a different domain).
+ */
+static inline GICv5SPIState *gicv5_spi_state(GICv5Common *cs, uint32_t id,
+ GICv5Domain domain)
+{
+ GICv5SPIState *spi = gicv5_raw_spi_state(cs, id);
+
+ if (!spi || spi->domain != domain) {
+ return NULL;
+ }
+ return spi;
+}
+
#endif
--
2.43.0