@@ -248,7 +248,7 @@ static uint64_t encode_phys_addr(paddr_t addr, int page_bits)
{
uint64_t ret;
- if ( page_bits < 16)
+ if ( page_bits < 16 )
return (uint64_t)addr & GENMASK(47, page_bits);
ret = addr & GENMASK(47, 16);
@@ -228,6 +228,75 @@ out_unlock:
return ret;
}
+/* For a given virtual LPI read the enabled bit from the virtual property
+ * table and update the virtual IRQ's state.
+ * This takes care of removing or pushing of virtual LPIs to their VCPUs.
+ */
+static void update_lpi_enabled_status(struct virt_its* its,
+ struct vcpu *vcpu, uint32_t vlpi)
+{
+ struct pending_irq *pirq = lpi_to_pending(vcpu, vlpi, false);
+ uint8_t property = its->d->arch.vgic.proptable[vlpi - 8192];
+
+ if ( property & LPI_PROP_ENABLED )
+ {
+ if ( pirq )
+ {
+ unsigned long flags;
+
+ set_bit(GIC_IRQ_GUEST_ENABLED, &pirq->status);
+ spin_lock_irqsave(&vcpu->arch.vgic.lock, flags);
+ if ( !list_empty(&pirq->inflight) &&
+ !test_bit(GIC_IRQ_GUEST_VISIBLE, &pirq->status) )
+ gic_raise_guest_irq(vcpu, vlpi, property & 0xfc);
+ spin_unlock_irqrestore(&vcpu->arch.vgic.lock, flags);
+ }
+
+ /* Check whether the LPI has fired while the guest had it disabled. */
+ if (test_and_clear_bit(vlpi - 8192, vcpu->arch.vgic.pendtable))
+ vgic_vcpu_inject_irq(vcpu, vlpi);
+ }
+ else
+ {
+ if ( pirq )
+ {
+ clear_bit(GIC_IRQ_GUEST_ENABLED, &pirq->status);
+ gic_remove_from_queues(vcpu, vlpi);
+ }
+ }
+}
+
+static int its_handle_inv(struct virt_its *its, uint64_t *cmdptr)
+{
+ uint32_t devid = its_cmd_get_deviceid(cmdptr);
+ uint32_t eventid = its_cmd_get_id(cmdptr);
+ struct vits_itte *itte;
+ struct vcpu *vcpu;
+ uint32_t vlpi;
+ int ret = -1;
+
+ spin_lock(&its->its_lock);
+
+ itte = get_devid_evid(its, devid, eventid);
+ if ( !itte )
+ goto out_unlock;
+
+ vcpu = its->d->vcpu[itte->collection];
+ vlpi = itte->vlpi;
+
+ ret = 0;
+
+ put_devid_evid(its, itte);
+
+out_unlock:
+ spin_unlock(&its->its_lock);
+
+ if ( !ret )
+ update_lpi_enabled_status(its, vcpu, vlpi);
+
+ return ret;
+}
+
static int its_handle_mapc(struct virt_its *its, uint64_t *cmdptr)
{
uint32_t collid = its_cmd_get_collection(cmdptr);
@@ -418,6 +487,9 @@ static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its,
case GITS_CMD_INT:
its_handle_int(its, cmdptr);
break;
+ case GITS_CMD_INV:
+ its_handle_inv(its, cmdptr);
+ break;
case GITS_CMD_MAPC:
its_handle_mapc(its, cmdptr);
break;
The INV command instructs the ITS to update the configuration data for a given LPI by re-reading its entry from the property table. We don't need to care so much about the priority value, but enabling or disabling an LPI has some effect: We remove or push virtual LPIs to their VCPUs, also check the virtual pending bit if an LPI gets enabled. Signed-off-by: Andre Przywara <andre.przywara@arm.com> --- xen/arch/arm/gic-its.c | 2 +- xen/arch/arm/vgic-its.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-)