[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XEN PATCH v2 18/25] arm: new VGIC: its: Allow updates of LPI configuration table


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>
  • Date: Fri, 10 Nov 2023 12:56:22 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=R+qyDsQa2NT4e9gFoYJ+T5c68j98f1YS+6LB32nWM3A=; b=kDv9jsn9vUJn9MNYRasdKk92SYfCpTH8GA0K4YRlewijVYWN8MFvNjurnEEs5W81IijW3zgwVKKQArtJBy/JUpnWSiZaYN/CG6/iEB6knk5/cQP8zh73c7bbF3jx+8RrVliZdFy6XEcJOmA+xjua5Q2j7oVsJg9bZGfm00NPte63r7WtRZSyJltsioQcYzxVPKESdV+Ytg8JEzp3PhuXes57yR59bM45RAzcXZNLEfvLzuEZB+Rr64pEbXczyaN2jKiXDPFSWnZuiC76ta41maVIUEJS5fOlhKxR9aTf9HH/EjeT0iVgd/YUckVKbN5idmwl/5soXmO5N11/1/uwXg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C8KW2a6xEXibdMIUZwRRhmigq3gy+R9e7mbMdzPfYwN+4x7CWpA6LzkDw74rxck+RaVKglLMQEwtfRPI2jhiEI7qTLXnwHffrkrtYNQrKNqK2tg+twiN8QKFyw5JTpw8Gmc1iiAoR/wfdv0OlKIxjZK9vjgiSS7F+aSwq9GHBOPSrrfiMhdrhwccpOjrU+ZyquxyXtyKFZp+G256vL6uW19vuUII3fcauOV0uik5twnXQ0eAMfVsPmrc4U7fhxDwQddx7RM8MeD4sVn/ZUrUJE0Yz31PpxIgnlOo84RcRSekacxjWAG4UfbkjbOIkiBD1F7Xm+PxhUaG9b1hV/khhQ==
  • Cc: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
  • Delivery-date: Fri, 10 Nov 2023 12:56:52 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHaE9VORAkqYbrpzkWH9gdi+lifIQ==
  • Thread-topic: [XEN PATCH v2 18/25] arm: new VGIC: its: Allow updates of LPI configuration table

The (system-wide) LPI configuration table is held in a table in
(guest) memory. To achieve reasonable performance, we cache this data
in our struct vgic_irq. If the guest updates the configuration data
(which consists of the enable bit and the priority value), it issues
an INV or INVALL command to allow us to update our information.
Provide functions that update that information for one LPI or all LPIs
mapped to a specific collection.

Based on Linux commit f9f77af9e2a551 by Andre Przywara

Signed-off-by: Mykyta Poturai <mykyta_poturai@xxxxxxxx>
---
 xen/arch/arm/vgic/vgic-its.c | 48 ++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/xen/arch/arm/vgic/vgic-its.c b/xen/arch/arm/vgic/vgic-its.c
index af19cf4414..6c726dde3a 100644
--- a/xen/arch/arm/vgic/vgic-its.c
+++ b/xen/arch/arm/vgic/vgic-its.c
@@ -63,6 +63,54 @@ static struct vgic_its_device *find_its_device(struct 
vgic_its *its, u32 device_
 #define VGIC_ITS_TYPER_DEVBITS          16
 #define VGIC_ITS_TYPER_ITE_SIZE         8
 
+#define GIC_LPI_OFFSET              8192
+
+#define LPI_PROP_ENABLE_BIT(p) ((p)&LPI_PROP_ENABLED)
+#define LPI_PROP_PRIORITY(p)   ((p)&0xfc)
+
+/*
+ * Reads the configuration data for a given LPI from guest memory and
+ * updates the fields in struct vgic_irq.
+ * If filter_vcpu is not NULL, applies only if the IRQ is targeting this
+ * VCPU. Unconditionally applies if filter_vcpu is NULL.
+ */
+static int update_lpi_config(struct domain *d, struct vgic_irq *irq,
+                             struct vcpu *filter_vcpu, bool needs_inv)
+{
+    u64 propbase = GICR_PROPBASER_ADDRESS(d->arch.vgic.propbaser);
+    u8 prop;
+    int ret;
+    unsigned long flags;
+
+    ret = access_guest_memory_by_gpa(d, propbase + irq->intid - GIC_LPI_OFFSET,
+                                     &prop, 1, false);
+
+    if ( ret )
+        return ret;
+
+    spin_lock_irqsave(&irq->irq_lock, flags);
+
+    if ( !filter_vcpu || filter_vcpu == irq->target_vcpu )
+    {
+        irq->priority = LPI_PROP_PRIORITY(prop);
+        irq->enabled  = LPI_PROP_ENABLE_BIT(prop);
+
+        if ( !irq->hw )
+        {
+            vgic_queue_irq_unlock(d, irq, flags);
+            return 0;
+        }
+    }
+
+    spin_unlock_irqrestore(&irq->irq_lock, flags);
+
+    /* GICv4 style VLPIS are not yet supported */
+    WARN_ON(irq->hw);
+
+    return 0;
+}
+
+
 /*
  * Create a snapshot of the current LPIs targeting @vcpu, so that we can
  * enumerate those LPIs without holding any lock.
-- 
2.34.1



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.