This series fixes sparse eSPI INTID handling and checks errors returned by
irq_set_type().
Patch 1 makes is_espi() check the architectural INTID range regardless of
CONFIG_GICV3_ESPI. If the GIC reports an eSPI without compiled-in support,
Xen stops with BUG_ON(). Virtual eSPI pending lookups return NULL when
eSPI support is disabled.
Xen has IRQ descriptors for INTIDs below NR_IRQS and, with eSPI support,
for eSPIs starting at 4096. It has no descriptors for INTIDs 1024 through
4095. Patch 2 checks INTIDs in setup_irq() and irq_set_spi_type() before
these functions look up a descriptor. irq_set_spi_type() checks descriptor
ranges because it can run before the GIC line counts are known.
setup_irq() uses the line counts once they are available.
Patch 3 fixes the vGIC allocation bitmap. Reserving an eSPI used a compact
bitmap index, but freeing it used the raw virtual INTID. This could write
past the bitmap and leave the eSPI reserved.
Patch 4, introduced in v2, checks errors from irq_set_type() in the GTDT,
MADT, SPCR, and FF-A paths. GTDT and MADT could keep a rejected timer or
maintenance INTID and later use it in a direct descriptor lookup. This
patch also fixes MISRA C Rule 17.7 violations.
Additional testing during v4 review, before the final edits:
- Patch 1: QEMU and FVP tests with CONFIG_GICV3_ESPI, CONFIG_HAS_ITS, and
CONFIG_DEBUG enabled and disabled.
- Patch 1: pending lookup checks for all eSPI INTIDs, including NULL
results without eSPI support.
- Patch 1: physical and virtual eSPI delivery on FVP, including delivery
to both vCPUs and retriggering an active eSPI.
- Patch 1: injected an unsupported physical eSPI and confirmed BUG_ON()
in both debug and release builds.
- Patch 2: Arm64 builds with CONFIG_GICV3_ESPI and CONFIG_DEBUG enabled
and disabled.
Testing on v3:
- Arm64 debug builds with CONFIG_ACPI=y and CONFIG_FFA=y, both with and
without CONFIG_GICV3_ESPI.
- FVP Device Tree boot with 64 eSPIs; Linux dom0 started.
- QEMU virt UEFI/ACPI boot to a dom0 initramfs shell; this covered the GTDT,
GICv3 MADT, and PL011 SPCR paths.
Changes in v4:
- Use BUG_ON() when the GIC reports an eSPI without compiled-in support.
- Return NULL for virtual eSPI pending lookups when support is disabled.
- Remove the redundant CONFIG_GICV3_ESPI check in IRQ dispatch.
- Share irq_has_desc() with the assertion in __irq_to_desc().
- Log invalid IRQs rejected by setup_irq().
- Document the compressed vIRQ allocation bitmap above the conversion
helpers, with an ASCII diagram and a reference to struct vgic_dist.
- Clarify the is_espi() commit message and drop unrelated blank-line
removals.
- Add Reviewed-by tags.
Changes in v3:
- Add a preparatory patch making is_espi() a pure range predicate and move
configuration policy and debug checks to callers.
- Add the requested assertion before regular descriptor lookup.
- Avoid partial MADT and UART state updates after irq_set_type() failures.
- Apply cosmetic cleanups from review.
Changes in v2:
- Check descriptor ranges in irq_set_spi_type() and implemented GIC lines
in setup_irq().
- Keep the is_espi() debug check when CONFIG_GICV3_ESPI is disabled.
- Remove a redundant CONFIG_GICV3_ESPI guard from the vGIC code.
- Add patch 3 to check irq_set_type() errors in the GTDT, MADT, SPCR, and
FF-A paths.
- Target master instead of the 4.22 release.
Mykola Kvach (4):
xen/arm: make is_espi() a pure range predicate
xen/arm: validate IRQs before descriptor lookup
xen/arm: vgic: free eSPIs using the bitmap index
xen/arm: handle irq_set_type() failures
xen/arch/arm/gic-v2.c | 15 ++++---
xen/arch/arm/gic-v3.c | 15 ++++---
xen/arch/arm/gic.c | 2 +
xen/arch/arm/include/asm/irq.h | 11 ------
xen/arch/arm/irq.c | 28 +++++++++++--
xen/arch/arm/tee/ffa_notif.c | 11 +++++-
xen/arch/arm/time.c | 18 +++++++--
xen/arch/arm/vgic.c | 72 ++++++++++++++++++++++------------
xen/drivers/char/ns16550.c | 8 +++-
xen/drivers/char/pl011.c | 4 +-
10 files changed, 125 insertions(+), 59 deletions(-)
--
2.53.0