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

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


  • To: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • From: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • Date: Mon, 11 May 2026 23:41:13 +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=WRemxzkQYjKIVnvZ1Hx2EfW0Nt+e2MfR2vsQ8gRiO2I=; fh=uAzoxIkY79cy0zES8IqO07ArU7DBG3jlr2bg4XRVkR0=; b=LWWK++JPPpUHSNwfJHZZzeWeJOIA2g2g5NJA+PHpfkzGowFIwC5A33LYPCKow0+QAg W8J+gQcHgTsFCN1IqcOBK2WgrDte6JyG6fbBKLUr6o/WI6Vgynqt9T7nlrm8yBCdqN/V n/fPkLxDK0+zSOjCkD3zH6oYImfLpedWHjt7eG/fIxUpGdbn7UxVzON74SGRdrv1vxBp 2laTUlmWpQ/Y1ux+ePDuyTxV1OS9lCMtgSqGZgmJ4iYeRi1LVv4Yim6aHUajxtcTQTyE SMQx/uQ5om9mZ52HfOBEPQKQzvmh0Aqq3XVK8v84DGmRZde9GoHioHrLFeKYN+IciRu8 8mww==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1778532085; cv=none; d=google.com; s=arc-20240605; b=jaHjkqhkKShhEzqmBTR3TG22tcULvkPN5qyhgY8w3UbmJ8FY3v9iXdwrfcdHHSs9ZO w+7bcyrgMMDbgDsaEeZYWV4GAKtUeYxfgUbhHqxrGKw6eQzSOeRvxSUWdl/SHqLDQskf 2c93zeSlxQWJYnOD0m2GMMiVArpnZD2VZeVfCmr1aorlQAGLUIwHadnZfbH1oFhLA07a h97RYfLd3ce7Ucy4efWJNdrh4U6sBHmPzR7hWokiC71AReBnfoKTiAJSl8vEdKzfh39Y uB5nSSiiO4dooNWUap+cie9K8FhjAkOB0kxCumXx4tvdirZEofDxtxfNHeIEYdASFUNy oDgw==
  • 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: Mon, 11 May 2026 20:41:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, May 11, 2026 at 9:41 AM Luca Fancellu <Luca.Fancellu@xxxxxxx> wrote:
>
> Hi Mykola,
>
> >
> >>
> >>>
> >>> For GICC_APRn/GICC_NSAPRn, those registers describe active priority state 
> >>> for
> >>> interrupts already acknowledged by the CPU interface. The final suspend 
> >>> path is
> >>> not expected to run with an active physical interrupt context. If those
> >>> registers were non-zero there, restoring only APR/NSAPR would not make the
> >>> corresponding interrupt handling context valid after resume, and could 
> >>> instead
> >>> leave the CPU interface with stale active priority state.
> >>
> >> Ok I understand now, but if we are expecting here GICD_ISACTIVERn zeroed, 
> >> why are
> >> we saving/restoring it? Shouldn’t we instead have a runtime check that 
> >> it’s zero and in case
> >> it’s not bail out? And in the resume path we would only zero it.
> >>
> >> Am I missing something?
> >
> > Good questions.
> >
> > Yes, the distinction I should have made clearer is between CPU-interface
> > active-priority state and distributor active state.
> >
> > For GICC_APRn/GICC_NSAPRn, I expect the state to be quiesced at this point.
> > Those registers track active priorities in the CPU interface. Xen reaches
> > gic_suspend() with local interrupts disabled, and for the guest-routed
> > interrupt case that can leave a distributor active bit behind, Xen has
> > already performed the physical EOI, so the CPU-interface priority has been
> > dropped.
> > There is no CPU-interface active-priority context that we can meaningfully
> > replay after resume.
> >
> > That is different from GICD_ISACTIVERn. In EOImode==1, EOIR only drops the
> > priority. The interrupt remains active in the distributor until the separate
> > deactivation step. For a guest-routed interrupt Xen's GICv2 guest end path 
> > does
> > only the physical EOI; deactivation is completed later by the virtual 
> > GIC/GICV
> > path when the guest completes the interrupt.
> >
> > This is why APR/NSAPR and ISACTIVERn are treated differently. For example:
> >
> >  1. A physical IRQ routed to a guest is acknowledged by Xen.
> >  2. The GIC marks the interrupt active in the distributor.
> >  3. Xen EOIs it, which drops the physical priority.
> >  4. Xen queues/injects the interrupt to the vGIC.
> >  5. The guest has not yet run, or the virtual interrupt is not yet 
> > deliverable
> >     because of guest PMR/priority/local IRQ masking/vGIC state.
> >  6. Therefore the guest-side deactivate has not happened yet, and the 
> > physical
> >     distributor active bit remains set.
> >
> > There is also a late suspend window in the current Xen path: domains are
> > suspended and the scheduler is disabled before local IRQs are disabled.
> > A guest-routed IRQ can therefore be taken by Xen after the guest is already
> > suspended, but before gic_suspend(). Xen can EOI/priority-drop it and queue
> > it for the guest, while the guest cannot run and deactivate it before the
> > GIC state is saved.
> >
> > This is the same class of issue handled by Linux for GIC EOImode==1. Linux
> > saves/restores the active state because forwarded interrupts can remain 
> > active
> > while passed to a VM [1].
> >
> > So I don't think GICD_ISACTIVERn should be treated as "must be zero" unless 
> > we
> > also add an explicit suspend-abort/quiesce policy for in-flight guest
> > interrupts. That would be a different design: detect non-zero 
> > active/in-flight
> > state, unwind suspend, thaw domains, let the guest drain/deactivate the
> > interrupts, and retry later. This series does not implement that policy. 
> > Given
> > the current flow, preserving GICD_ISACTIVERn avoids losing architectural
> > interrupt-controller state across suspend/resume.
> >
> > I am not opposed to such a policy as a follow-up if we want stricter suspend
> > quiescence rules, but I think it should be designed explicitly rather than
> > inferred from the GIC save/restore code.
> >
> > Best regards,
> > Mykola
> >
> > [1] 
> > https://patchwork.kernel.org/project/linux-arm-kernel/patch/1447701208-18150-5-git-send-email-marc.zyngier@xxxxxxx/
>
> Right, yes I agree! I have another question though, since GICC_APRn state 
> should be
> quiesced in the suspend path (allimplemented active-priority bits should read 
> as zero),
> should we have a runtime check just after disabling the CPU interface?

Yes, I think a runtime check is appropriate here.

Best regards,
Mykola

>
> Cheers,
> Luca
>



 


Rackspace

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