Message ID | 1491434362-30310-26-git-send-email-andre.przywara@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, 6 Apr 2017, Andre Przywara wrote: > 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 | 32 ++++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) > > diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c > index 6afb915..47f2884 100644 > --- a/xen/arch/arm/vgic-v3-its.c > +++ b/xen/arch/arm/vgic-v3-its.c > @@ -549,6 +549,35 @@ out_unlock: > return ret; > } > > +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 = its->d->arch.vgic.handler->lpi_to_pending(its->d, vlpi); > + if ( pirq ) > + { > + clear_bit(GIC_IRQ_GUEST_QUEUED, &pirq->status); > + gic_remove_from_queues(vcpu, vlpi); we need to remove it from inflight > + } > + > + if ( !write_itte(its, devid, eventid, UNMAPPED_COLLECTION, INVALID_LPI, > + NULL) ) > + return -1; > + > + if ( !gicv3_assign_guest_event(its->d, its->doorbell_address, > + devid, eventid, NULL, 0) ) > + return -1; > + > + return 0; > +} > + > #define ITS_CMD_BUFFER_SIZE(baser) ((((baser) & 0xff) + 1) << 12) > > /* > @@ -580,6 +609,9 @@ static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its) > case GITS_CMD_CLEAR: > ret = its_handle_clear(its, command); > break; > + case GITS_CMD_DISCARD: > + ret = its_handle_discard(its, command); > + break; > case GITS_CMD_INT: > ret = its_handle_int(its, command); > break; > -- > 2.8.2 >
Hi Andre, On 06/04/17 00:19, Andre Przywara wrote: > 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 | 32 ++++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) > > diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c > index 6afb915..47f2884 100644 > --- a/xen/arch/arm/vgic-v3-its.c > +++ b/xen/arch/arm/vgic-v3-its.c > @@ -549,6 +549,35 @@ out_unlock: > return ret; > } > > +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 = its->d->arch.vgic.handler->lpi_to_pending(its->d, vlpi); > + if ( pirq ) > + { > + clear_bit(GIC_IRQ_GUEST_QUEUED, &pirq->status); > + gic_remove_from_queues(vcpu, vlpi); > + } Do we expect to have pirq returning NULL? If so, in which case? Also, why not directly using pirq = gicv3_assign_guest(....); This would prevent the issue below where it would not be possible to write back in the guest memory, and leave the mapping with the host LPI. > + > + if ( !write_itte(its, devid, eventid, UNMAPPED_COLLECTION, INVALID_LPI, > + NULL) ) > + return -1; > + > + if ( !gicv3_assign_guest_event(its->d, its->doorbell_address, > + devid, eventid, NULL, 0) ) In which case gicv3_assign_guest_event can fail? And what would happen if it fails. By that I mean, would we need to carry some clean-up for host lpi during domain destruction? > + return -1; > + > + return 0; > +} > + > #define ITS_CMD_BUFFER_SIZE(baser) ((((baser) & 0xff) + 1) << 12) > > /* > @@ -580,6 +609,9 @@ static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its) > case GITS_CMD_CLEAR: > ret = its_handle_clear(its, command); > break; > + case GITS_CMD_DISCARD: > + ret = its_handle_discard(its, command); > + break; > case GITS_CMD_INT: > ret = its_handle_int(its, command); > break; > Cheers,
diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c index 6afb915..47f2884 100644 --- a/xen/arch/arm/vgic-v3-its.c +++ b/xen/arch/arm/vgic-v3-its.c @@ -549,6 +549,35 @@ out_unlock: return ret; } +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 = its->d->arch.vgic.handler->lpi_to_pending(its->d, vlpi); + if ( pirq ) + { + clear_bit(GIC_IRQ_GUEST_QUEUED, &pirq->status); + gic_remove_from_queues(vcpu, vlpi); + } + + if ( !write_itte(its, devid, eventid, UNMAPPED_COLLECTION, INVALID_LPI, + NULL) ) + return -1; + + if ( !gicv3_assign_guest_event(its->d, its->doorbell_address, + devid, eventid, NULL, 0) ) + return -1; + + return 0; +} + #define ITS_CMD_BUFFER_SIZE(baser) ((((baser) & 0xff) + 1) << 12) /* @@ -580,6 +609,9 @@ static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its) case GITS_CMD_CLEAR: ret = its_handle_clear(its, command); break; + case GITS_CMD_DISCARD: + ret = its_handle_discard(its, command); + break; case GITS_CMD_INT: ret = its_handle_int(its, command); 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 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)