@@ -369,6 +369,36 @@ static int its_handle_movi(struct virt_its *its, uint64_t *cmdptr)
return 0;
}
+static int its_handle_discard(struct virt_its *its, uint64_t *cmdptr)
+{
+ uint32_t devid = its_cmd_get_deviceid(cmdptr);
+ uint32_t eventid = its_cmd_get_id(cmdptr);
+ struct pending_irq *pirq;
+ struct vcpu *vcpu;
+ uint32_t vlpi;
+
+ if ( !read_itte(its, devid, eventid, &vcpu, &vlpi) )
+ return -1;
+
+ pirq = lpi_to_pending(vcpu, vlpi, false);
+ if ( pirq )
+ {
+ clear_bit(GIC_IRQ_GUEST_QUEUED, &pirq->status);
+ gic_remove_from_queues(vcpu, vlpi);
+
+ /* Mark this pending IRQ struct as availabe again. */
+ if ( !test_bit(GIC_IRQ_GUEST_VISIBLE, &pirq->status) )
+ pirq->irq = 0;
+ }
+
+ if ( !write_itte(its, devid, eventid, ~0, INVALID_LPI, NULL) )
+ return -1;
+
+ gicv3_assign_guest_event(its->d, its->doorbell_address, devid, eventid, NULL, 0);
+
+ return 0;
+}
+
#define ITS_CMD_BUFFER_SIZE(baser) ((((baser) & 0xff) + 1) << 12)
static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its,
@@ -392,6 +422,9 @@ static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its,
case GITS_CMD_CLEAR:
its_handle_clear(its, cmdptr);
break;
+ case GITS_CMD_DISCARD:
+ its_handle_discard(its, cmdptr);
+ break;
case GITS_CMD_INT:
its_handle_int(its, cmdptr);
break;
The DISCARD command drops the connection between a DeviceID/EventID and an LPI/collection pair. We mark the respective structure entries as not allocated and make sure that any queued IRQs are removed. Signed-off-by: Andre Przywara <andre.przywara@arm.com> --- xen/arch/arm/vgic-v3-its.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)