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

Re: [PATCH v2] xen/arm: gicv3: initialize eSPI unconditionally


  • To: Leonid Komarianskyi <Leonid_Komarianskyi@xxxxxxxx>
  • From: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • Date: Wed, 23 Sep 2026 11:04:07 +0300
  • Arc-authentication-results: i=1; mx.google.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/sGE1cWKRddn9BumVRWlGmuOGXI1Suk6ksjIkhQj8eU=; fh=WIBsbU94tzJ4cDiE2U1nGSEGZUKQH+ugjEkhmxI8Bgo=; b=N6TLUse4cVGrk4NfeFU//BiAeKJZBS8WV0/RYexNEMEX/sY2pxDO4q0LSlbcBFPtYj louWgIYOzL+ZoIQw/jrhrmo4pAg3nsY6MUroCHZcNK3vFBOZHgQuaZdcgMLLA5kxNcew YUQxypKSHZ4XDcU3GJhrxO1wGR6UHK6FqPUvwCKgPeqB4zGGr9iZGCm2y4jAV5/4Cgcj qMR7nI3nMGAWi11uZWCr84weN2E51kOHqKo3GcPdRmuiYBowa4VsjqPRJ43ShqN3nq66 Pqq3PYQNuoJEInKDXo1vDnN2DpkdLgsNljIWzIe6D2oUf2bErCPFG8MRvy55oRXXFyXr s9yA==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1790150659; cv=none; d=google.com; s=arc-20260327; b=VD5snWgQLThyOzsvFyIm0KJnX1dZogNkuziUIvv6Sj9cruMw4zKLxl9WBlmEYGQmyu jlhWbBc6EdwzqGWaD/uKbK5o0QWnZ9tKVtE+qVKv/tRuL5zaafRSKqd8lci4nXvPwT4+ 3M3qN78sw9ynyAa5BXi0DyGju0F3EezEIEZZFQNNzuMwvXR8FERsh4ihnfis7yWeuXmH mCVX5Yptlvh5VV2dbNpwoYAASPxFoeAjUswISEEfirceQ+v/1Dcmh0gAWHu4b+kGnm1d KiKkzgLxwQw2EqrxIqTBPqVwBZDk4l/Hif3H6xw2jqtuHII6MX9sYgwXEpoDKcH43bPk 947g==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>
  • Delivery-date: Wed, 23 Sep 2026 08:04:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Leonid,

Thank you for the patch.

On Tue, Sep 22, 2026 at 9:59 PM Leonid Komarianskyi
<Leonid_Komarianskyi@xxxxxxxx> wrote:
>
> Since the firmware may initialize eSPIs before Xen, and without
> CONFIG_GICV3_ESPI enabled, Xen would not reinitialize them properly
> during boot. In such cases, once the GIC is re-enabled in Xen,
> interrupts may be received that cannot be handled.
>
> To ensure proper operation on hardware with eSPI feature, even when the eSPI
> config is disabled, gicv3_dist_espi_common_init() should be invoked
> regardless of whether CONFIG_GICV3_ESPI is enabled or not. This will not
> affect hardware without eSPI support, as the function checks if the
> hardware supports eSPIs by reading the GICD_TYPER.ESPI field (using
> GICD_TYPER_ESPIS_NUM macro), which indicates whether the extended SPI
> range is supported. If the hardware does not support eSPI, the function
> will not perform any actions.
>
> There are no functional changes for setups where CONFIG_GICV3_ESPI=y.
>
> Suggested-by: Julien Grall <jgrall@xxxxxxxxxx>
> Signed-off-by: Leonid Komarianskyi <leonid_komarianskyi@xxxxxxxx>
> Acked-by: Julien Grall <jgrall@xxxxxxxxxx>
> ---
> Changes in v2:
> - rebased on the current staging
> - placed Suggested-by tag first to keep tags in chronological order
> - added Acked-by from Julien Grall
>
> This is a follow-up patch related to the discussion:
> https://lore.kernel.org/xen-devel/820704d0-4047-4f02-a058-01daba2765f1@xxxxxxx/
>
> Sending v2 with the requested changes, as I only now noticed
> that this patch has not been merged yet.
> ---
>  xen/arch/arm/gic-v3.c                  | 32 ++++++++++++++------------
>  xen/arch/arm/include/asm/gic_v3_defs.h |  2 --
>  2 files changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> index acdac22953..463769d77b 100644
> --- a/xen/arch/arm/gic-v3.c
> +++ b/xen/arch/arm/gic-v3.c
> @@ -703,17 +703,32 @@ unsigned int gic_number_espis(void)
>      return gic_hw_ops->info->nr_espi;
>  }
>
> +static void __init gicv3_dist_espi_init_aff(uint64_t affinity)
> +{
> +    unsigned int i;
> +
> +    for ( i = 0; i < gicv3_info.nr_espi; i++ )
> +        writeq_relaxed_non_atomic(affinity, GICD + GICD_IROUTERnE + i * 8);
> +}
> +#else
> +
> +static void __init gicv3_dist_espi_init_aff(uint64_t affinity) { }
> +#endif
> +
>  static void __init gicv3_dist_espi_common_init(uint32_t type)

I think the ordering in gicv3_dist_espi_common_init() needs to be
revisited now that this function is also called with
CONFIG_GICV3_ESPI=n.

The motivation for this patch is that firmware may have left an eSPI
enabled. However, we currently program GICD_ICFGRnE before clearing
the corresponding enable bit in GICD_ICENABLERnE.

The GIC architecture requires an interrupt to be individually disabled
before changing Int_config; otherwise the behavior is UNPREDICTABLE.
See Arm IHI 0069H.b, section 12.9.9 (GICD_ICFGR<n>).

We also rely on the same requirement in gic_set_irq_type().

So shouldn't we disable/deactivate all eSPIs before programming
GICD_ICFGRnE? Linux also initializes the extended SPI range in this
order: ICENABLERnE/ICACTIVERnE first, followed by IGROUPRnE,
ICFGRnE and IPRIORITYRnE.

This issue already seems to exist for the CONFIG_GICV3_ESPI=y path,
but this patch makes it relevant to the newly added CONFIG=n path,
where an eSPI left enabled by firmware is precisely the case we are
trying to handle.

Also, we could disable/deactivate eSPIs for all builds, while keeping
the rest of the eSPI configuration under CONFIG_GICV3_ESPI. This would
avoid accessing the other eSPI registers in builds without eSPI
support, unless there is a particular reason to initialize them there.

Best regards,
Mykola



 


Rackspace

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