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

Re: [PATCH v9 02/13] xen/arm: gic-v2: Implement GIC suspend/resume functions


  • To: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • From: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • Date: Fri, 15 May 2026 10:59:24 +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-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Aj5jvFEFmH+xjzvdxI8gC16245Xuwn0Bz0BnEbU1mKU=; fh=uAzoxIkY79cy0zES8IqO07ArU7DBG3jlr2bg4XRVkR0=; b=ZEDlPIuIsGb1e6mwnVM83ExHl8pQ37Go4NgAMQPEOtoHkX2OhbVeUCBlmQay+3a7pA 91lgZl30IRg0FRIbpB53cg0/M6jd7FUozoTqq03BhLdw0aePoOScypxdbmOuQq/OfHDP 4EYTozpTIZ540ASVg3nncdN+Gsj7YbsSLMBnJfHfvudZJWKdL+VQdFb/eT7tF4gFwDRU YVc6jRITni9k8BaV5ugOppUF+18+E3ftRsXWQnu/Ba9bnyUD8EdZMeJUaAulTzV9PNaQ gwiiTv9rQbm4SVvn483bmLNBCD3GWvBCvPOJafz8MBwE3pIGEoBJUs+NTkgkP1ROxotV 4Jeg==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1778831977; cv=none; d=google.com; s=arc-20240605; b=CYMPQ6cwoHOhJ8YhG/hLCqp9Ccqt1/IlcjjZGI2OhgB7REcnZLPWTlmqgZBT60f90/ eBO0Bo7foQ+HSxfqn/kRlkkJqtERH1WpuFZlDOt0KaAr0WGO6hiAtrx0h26KI8jpCkML 9k0dYObYUsSiXbAj6Vv2GEaf58P+LVbjKzVaVqYyv42dRXZUGl8cM8j7rbfJFtUDbah7 16JWn56eQrYWb8KP7dbO2/HKtTTqrNVrHNAh4CDPkDSwU0yCABkZ2iHz9+yWdDyfdzPn zLpINPYGYtkgbqXKFlJmPsA/rtZ1+bAqLfDh+1Vsakj73PVjRO91QMwZCoXyyMYEERhJ Lq/Q==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Mykola Kvach <mykola_kvach@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 15 May 2026 07:59:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Luca,

Thank you for the detailed review.

On Wed, May 13, 2026 at 5:09 PM Luca Fancellu <Luca.Fancellu@xxxxxxx> wrote:
>
> Hi Mykola,
>
> > +
> > +static void gicv2_resume(void)
> > +{
> > +    unsigned int i, blocks = DIV_ROUND_UP(gicv2_info.nr_lines, 32);
> > +
> > +    gicv2_cpu_disable();
> > +    /* Disable distributor */
> > +    writel_gicd(0, GICD_CTLR);
> > +
> > +    for ( i = 0; i < blocks; i++ )
> > +    {
> > +        struct irq_block *irqs = gic_ctx.dist.irqs + i;
> > +        size_t j, off = i * sizeof(irqs->isenabler);
> > +
> > +        writel_gicd(GENMASK(31, 0), GICD_ICENABLER + off);
> > +        writel_gicd(irqs->isenabler, GICD_ISENABLER + off);
> > +
> > +        writel_gicd(GENMASK(31, 0), GICD_ICACTIVER + off);
> > +        writel_gicd(irqs->isactiver, GICD_ISACTIVER + off);
> > +
> > +        off = i * sizeof(irqs->ipriorityr);
> > +        for ( j = 0; j < ARRAY_SIZE(irqs->ipriorityr); j++ )
> > +            writel_gicd(irqs->ipriorityr[j], GICD_IPRIORITYR + off + j * 
> > 4);
>
> apologies for spotting these only now, in case gicv2_info.nr_lines is 1020,
> here and below for GICD_ITARGETSR we are going to save also IDs 1020-1023
> which are reserved.
>
> Could we assume irqs->ipriorityr and irqs->itargetsr have the same size and 
> implement
> some cap logic which might cap the last loop (eventually):
>
>     for ( i = 0; i < blocks; i++ )
>     {
>         struct irq_block *irqs = gic_ctx.dist.irqs + i;
>         size_t j, off = i * sizeof(irqs->isenabler);
>         size_t nr_regs = ARRAY_SIZE(irqs->ipriorityr);
>
>         if ( i == blocks - 1 )
>             nr_regs = DIV_ROUND_UP(gicv2_info.nr_lines - i * 32, 4);
>
>         […]
>
>         off = i * sizeof(irqs->ipriorityr);
>         for ( j = 0; j < nr_regs; j++ )
>             writel_gicd(irqs->ipriorityr[j], GICD_IPRIORITYR + off + j * 4);
>
>         /*
>          * GICD_ITARGETSR0..7 cover SGIs/PPIs and hold no state to save:
>          * they are read-only on multiprocessor implementations and RAZ/WI
>          * on uniprocessor implementations.
>          */
>         if ( i )
>         {
>             off = i * sizeof(irqs->itargetsr);
>             for ( j = 0; j < nr_regs; j++ )
>                 writel_gicd(irqs->itargetsr[j], GICD_ITARGETSR + off + j * 4);
>         }
>
>         […]
>     }

This was intentional to keep the logic simpler.

For the 1020-interrupt case, the extra word would correspond to
interrupt IDs 1020-1023. My reading of ARM IHI 0048B.b is that this
is architecturally harmless: section 4.1.2 says that reserved
Distributor register addresses are RAZ/WI, and Table 4-1 marks
GICD_IPRIORITYR offset 0x7fc and GICD_ITARGETSR offset 0xbfc as
Reserved.

Would you be OK with keeping this as-is, or would you prefer me to add
the cap logic anyway?

>
> > +
> > +        /*
> > +         * GICD_ITARGETSR0..7 cover SGIs/PPIs and hold no state to save:
> > +         * they are read-only on multiprocessor implementations and RAZ/WI
> > +         * on uniprocessor implementations.
> > +         */
> > +        if ( i )
> > +        {
> > +            off = i * sizeof(irqs->itargetsr);
> > +            for ( j = 0; j < ARRAY_SIZE(irqs->itargetsr); j++ )
> > +                writel_gicd(irqs->itargetsr[j], GICD_ITARGETSR + off + j * 
> > 4);
> > +        }
> > +
> > +        off = i * sizeof(irqs->icfgr);
> > +        for ( j = 0; j < ARRAY_SIZE(irqs->icfgr); j++ )
> > +            writel_gicd(irqs->icfgr[j], GICD_ICFGR + off + j * 4);
>
> in the GICv2 specs the usage constraints
> of GICD_ICFGR says: “Before changing the value of a programmable Int_config 
> field,
> software must disable the corresponding interrupt, otherwise GIC behavior is
> UNPREDICTABLE"
>
> ARM IHI 0048B.b, 4.3.13.
>
> I think we should move this restore just after GICD_ICENABLER write, before 
> writing
> GICD_ISENABLER.

Good catch, I agree.

I will move the GICD_ICFGR restore after the GICD_ICENABLER writes
and before restoring GICD_ISENABLER, so that programmable Int_config
fields are restored while the corresponding interrupts are disabled.

I will also check whether it makes sense to move the other
configuration restores before GICD_ISENABLER as well. The spec does
not seem to impose the same strict requirement there, but keeping all
configuration restores before re-enabling the interrupts might make
the ordering clearer.

>
> And also the section says that the GICD_ICFGR0 is read-only.

For GICD_ICFGR0, my intention was to keep the restore loop uniform.
There should be no useful SGI state to restore here: section 4.3.13
says that SGI Int_config[1] is not programmable and RAO/WI, while
Int_config[0] is reserved. Also, the value written is the value
previously read from the same register.

So I do not expect this write to affect the architected SGI
configuration. However, if you prefer avoiding the write to
GICD_ICFGR0 explicitly, I will skip it in the next version of
this series.

Best regards,
Mykola



 


Rackspace

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