Skip to content

Commit

Permalink
irqchip/gic-v3-its: Honor hypervisor enforced LPI range
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Marc Zyngier committed Jul 16, 2018
1 parent a4f9edb commit 12b2905
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/irqchip/irq-gic-v3-its.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions include/linux/irqchip/arm-gic-v3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 12b2905

Please sign in to comment.