]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
irqchip/gic-v3-its: Honor hypervisor enforced LPI range
authorMarc Zyngier <marc.zyngier@arm.com>
Thu, 31 May 2018 08:01:59 +0000 (09:01 +0100)
committerMarc Zyngier <marc.zyngier@arm.com>
Mon, 16 Jul 2018 13:22:19 +0000 (14:22 +0100)
A recent extension to the GIC architecture allows a hypervisor to
arbitrarily reduce the number of LPIs available to a guest, no
matter what the GIC says about the valid range of IntIDs.

Let's factor in this information when computing the number of
available LPIs

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
drivers/irqchip/irq-gic-v3-its.c
include/linux/irqchip/arm-gic-v3.h

index efe6d1a6c32e942d1a9fbd20deab37b6785f7722..f56c849772414d0b8b40cc8b565ee3af2382f406 100644 (file)
@@ -1541,8 +1541,17 @@ static int free_lpi_range(u32 base, u32 nr_lpis)
 static int __init its_lpi_init(u32 id_bits)
 {
        u32 lpis = (1UL << id_bits) - 8192;
+       u32 numlpis;
        int err;
 
+       numlpis = 1UL << GICD_TYPER_NUM_LPIS(gic_rdists->gicd_typer);
+
+       if (numlpis > 2 && !WARN_ON(numlpis > lpis)) {
+               lpis = numlpis;
+               pr_info("ITS: Using hypervisor restricted LPI range [%u]\n",
+                       lpis);
+       }
+
        /*
         * Initializing the allocator is just the same as freeing the
         * full range of LPIs.
index 396cd99af02f5b224bf3acf2cc8fd1c84f3c0558..9d2ea3e907d0fc018d8f7e13d2912537c83c5e70 100644 (file)
@@ -73,6 +73,7 @@
 #define GICD_TYPER_MBIS                        (1U << 16)
 
 #define GICD_TYPER_ID_BITS(typer)      ((((typer) >> 19) & 0x1f) + 1)
+#define GICD_TYPER_NUM_LPIS(typer)     ((((typer) >> 11) & 0x1f) + 1)
 #define GICD_TYPER_IRQS(typer)         ((((typer) & 0x1f) + 1) * 32)
 
 #define GICD_IROUTER_SPI_MODE_ONE      (0U << 31)