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

Re: [PATCH v3 1/4] xen/arm: make is_espi() a pure range predicate


  • To: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • From: Mykola Kvach <mykola_kvach@xxxxxxxx>
  • Date: Mon, 21 Sep 2026 14:25:42 +0300
  • 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=arcselector10001; 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=gInDqvUmat87BsFtiV4wX/Ma1zOReKqD0U48CEuYybA=; b=sv4Rc03R5jRvwCO8Oyg9awrJDtybqVDMeaXL4dTVTRlXUd87d/VJ+f+YtceADbpoRzRa5m+ziLV6kEpECO7DB1JnA8KNzXcpyepNtP/A++jQMPY5CochoNTyQsEjBo5gvgYTmxGfE79euNwucT1FVAj/wxemSocsJ8ASgBvlxXU0dGuuchuGflr6RXCkUU0h8JEGZmKdS1bWUG6Php4mBlcYrdD7MrZ6ClQ9AAjYL4OWdw/p7EO3Jp9wGudJ06K+i3Qfq8M9MZmyl6QUsnuFV2Zg+VrAmmnscSisQBr3KEmcj7lEXfucyw9n/xKFigTC6uzZi74e3n2ChMcOXwgoZA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IDmn9iy6RL9NmuXy2lUNoTGZxVvGOBTYr4Z/Y/nRr/G1gxbxh9ZJ6otfCsjixq9AY34i2fw+bc06AV5NQ8iiheGdP/IeD23st/2hPCm5Z9uQ05sB2ygKyVxXfU6JwuXrWUWIfek+qsYGzQ4zKqcIw8gl4kwMuBsZJOTTRgmd2E92VB2bQzWmaHmDfXnNCtR4rR1bGTjQ+I+tOEgzpeT0nZcjnVlth4/7aM9Hd1zBJXLORRcWfTIzA/yStL7EUHuRBSixJbQvKDBVsiyL25/rUQUaGlMYS7cXgFkE991ssNyxl0LdV1gf8yAlWkGoTAx3Ca2uDx7DYIurDHmQgSjWnQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 21 Sep 2026 11:25:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Mail-followup-to: "Orzel, Michal" <michal.orzel@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>

Hi Michal,

Thank you for the review.

On Fri, Sep 11, 2026 at 01:03:28PM +0200, Orzel, Michal wrote:
> 
> 
> On 18-Aug-26 13:32, Mykola Kvach wrote:
> > is_espi() currently changes its result according to CONFIG_GICV3_ESPI
> > and asserts when an eSPI INTID is passed to a build without eSPI
> > support. This makes a range predicate carry configuration policy and
> > causes callers to depend on its hidden side effects.
> > 
> > Make is_espi() report only whether an INTID is in the architectural
> > eSPI range. Gate eSPI handling explicitly at call sites and preserve
> > the debug checks on paths where an eSPI is invalid without compiled-in
> > support.
> > 
> > Signed-off-by: Mykola Kvach <mykola_kvach@xxxxxxxx>
> > ---
> > Changes in v3:
> > - New preparatory cleanup requested during review.
> > ---
> >  xen/arch/arm/gic.c             |  5 ++++-
> >  xen/arch/arm/include/asm/irq.h | 11 -----------
> >  xen/arch/arm/vgic.c            |  4 ++--
> >  3 files changed, 6 insertions(+), 14 deletions(-)
> > 
> > diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
> > index 078049e741..075e1d2c50 100644
> > --- a/xen/arch/arm/gic.c
> > +++ b/xen/arch/arm/gic.c
> > @@ -348,7 +348,10 @@ void gic_interrupt(struct cpu_user_regs *regs, int 
> > is_fiq)
> >          /* Reading IRQ will ACK it */
> >          irq = gic_hw_ops->read_irq();
> >  
> > -        if ( likely(irq >= GIC_SGI_STATIC_MAX && irq < 1020) || 
> > is_espi(irq) )
> > +        ASSERT(IS_ENABLED(CONFIG_GICV3_ESPI) || !is_espi(irq));
> > +
> > +        if ( likely(irq >= GIC_SGI_STATIC_MAX && irq < 1020) ||
> > +             (IS_ENABLED(CONFIG_GICV3_ESPI) && is_espi(irq)) )
> Take a look at LPIs that are also protected by CONFIG option. We don't ASSERT
> because they are gone in a release build. We want to BUG() for eSPIs same as 
> for
> LPIs if we cannot continue with this condition (we haven't configured/enabled
> them, so it's impossible condition where something went wrong). Here you 
> should
> just BUG().

I will replace ASSERT with BUG_ON() and remove the extra config
check in IRQ dispatch.

> 
> >          {
> >              isb();
> >              do_IRQ(regs, irq, is_fiq);
> > diff --git a/xen/arch/arm/include/asm/irq.h b/xen/arch/arm/include/asm/irq.h
> > index 09788dbfeb..c29f3d04a3 100644
> > --- a/xen/arch/arm/include/asm/irq.h
> > +++ b/xen/arch/arm/include/asm/irq.h
> > @@ -66,18 +66,7 @@ static inline bool is_lpi(unsigned int irq)
> >  
> >  static inline bool is_espi(unsigned int irq)
> >  {
> > -#ifdef CONFIG_GICV3_ESPI
> >      return irq >= ESPI_BASE_INTID && irq <= ESPI_MAX_INTID;
> > -#else
> > -    /*
> > -     * The function should not be called for eSPIs when CONFIG_GICV3_ESPI 
> > is
> > -     * disabled. Returning false allows the compiler to optimize the code
> > -     * when the config is disabled, while the assert ensures that 
> > out-of-range
> > -     * array resources are not accessed.
> > -     */
> > -    ASSERT(!(irq >= ESPI_BASE_INTID && irq <= ESPI_MAX_INTID));
> > -    return false;
> > -#endif
> >  }
> >  
> >  static inline unsigned int espi_intid_to_idx(unsigned int intid)
> > diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> > index e5aca17dcb..e14123a30a 100644
> > --- a/xen/arch/arm/vgic.c
> > +++ b/xen/arch/arm/vgic.c
> > @@ -718,8 +718,9 @@ struct pending_irq *spi_to_pending(struct domain *d, 
> > unsigned int irq)
> >      unsigned int idx;
> >  
> >      ASSERT(irq >= NR_LOCAL_IRQS);
> > +    ASSERT(IS_ENABLED(CONFIG_GICV3_ESPI) || !is_espi(irq));
> >  
> > -    if ( is_espi(irq) )
> > +    if ( IS_ENABLED(CONFIG_GICV3_ESPI) && is_espi(irq) )
> Following the LPIs, irq_to_pending() returns NULL if they are not supported 
> and
> we somehow ended up here. We should do the same here without using IS_ENABLED
> and ASSERT. Note though that for that, some call sites need to be enabled not 
> to
> dereference NULL.

I will add an espi_to_pending() stub that returns NULL when eSPI
support is disabled.

I checked the callers. They already handle NULL, check the IRQ range
or register rank, or use allocated IRQs. I did not find a need for
extra NULL checks.

I tested the proposed change on QEMU and FVP with eSPI, ITS and
debug support on and off.

Best regards,
Mykola



 


Rackspace

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