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

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


  • To: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Mon, 28 Sep 2026 07:36:15 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=gmail.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=B8jd32gK1oaXXEftE0Vgdt5iTX2loRb2XP/JQkN1jjU=; b=EsQ7Wnkrp6CVwFc5r/N8ZpvWX1ZEg592yGOM3nC1kgJ0PBPmIXOv/wZiO2ocMw2ELsGmeduxxcQdEdqHidzRc7baNsu9+/BnirU+UbVRFXzNRbkQzetTClfw7Wv4A4K9GKSPqhlSZpX2PGI//YWfmvm2KQcxwkMpBg89Vk+5YsqcMQWhTtgny+zBTxXjJgay7kHFQqTCiYyS5okFZXRHuq6NMB+S27RMBoHHzArQTlQvFEDebBNNekjjVbujKqYIzfxl+W8sJNfHyut/2ZK3fXzTsxpqgjXZ/sUdyRa9DobmqIvGJoBSqZ+69WHI9nss7PcvO/DezBwHj5ewKAfMdw==
  • 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=B8jd32gK1oaXXEftE0Vgdt5iTX2loRb2XP/JQkN1jjU=; b=mCkqljYm0JfEOl7MOASJn4bDrUkTyAd/wBL24XP5D8pzO7AiSMjESQbcLRokVGF9YatGPTY9NYYfLH9/TpDSjg003HwSRti8UdyUnB54Vzw97DMuAHThm/lReW75nlbcbFvi7dX6F1KU3gc+9rl6qtrKwg2OVVsk1f5ymTNJB4LB4zj+wZP3fKKHtMkf1Lg5UCMYz20uNXypX7rxyqAntCtdM67lD6FMwyZHVkBhhr8lZ3DZVlaZ3upJk2DvUOQb2Crbu3usnw1W0bmpiH2CBCyopLWNjNCC55hR7iKayR9e3Zi/5kEA1Ts995GKGY4Xt7jKIe9ceL8NJXK9j+lhuA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=E1ioMwyDcypta5394uWC/gRudNSWGKdwRNQszgx2I9JP/ymXPKQ5TiIv0qp8MqlmLH+DKeGdh9Pgcdd1apxmj+u0zfzu9jCL7V9x0C/JlOXpg8XqByCWId4EGa4gEsCp/72Hgmm8wi64o4fv/o/4F2eHflnm7edITQViuO+AVGgg8v6EDzQ5S0Xh5WULPLxf/tgnetxtQ+AbF65CJqWSclqZWyEP/in5XqYrf4USJY3raQpUJVHfLkkRTP9alzzBsHKIVtdmrNj5DWF6xDV37zV9apwbfmPbfrSqhdY6B7da/9VPPY+1ihthLpzORGDzJsvfqfBnFrCK1ZA16o32pQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=emCWuoIDT1mJpnLDrARKW7uBTGSwWySLXsmrUNJveWua0LAIzh8yFCBe5fSNttW7r7E2JcJOdEuGxOEJGRyADAkH2aOxOOi8/1Faj/hoRm9UzAVMoLQmJXkxIJNcsoX2qq74bMAqJL+gH1X2LgWpxhfNrqQ+VktU4SnXwttEtBXTc0/0lSnS1d3f5HQheeT8+QGHJNNrOu2kuXw511fd36jrYBgG/DEBMUFtM/43baRmFCdnWCxPFYBkT/ph+RLpkcETod/9fOuDpU8kYLZ0byZDYf3e8tCSUantNfftAm8gmAFKDDpk07zY9EVFkvCyg5tTbDDc89tnoZQAfUTLiA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results-original: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Mykola Kvach <mykola_kvach@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Delivery-date: Mon, 28 Sep 2026 07:37:11 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHdNjDkV92bkh6okkqfhA392pMLzbbcc6SAgAIGhwCABVF7AA==
  • Thread-topic: [PATCH v12 02/13] xen/arm: gic-v2: Implement GIC suspend/resume functions

Hi Mykola,

> On 25 Sep 2026, at 00:23, Mykola Kvach <xakep.amatop@xxxxxxxxx> wrote:
> 
> Hi Bertrand,
> 
> Thank you for the review.
> 
> On Wed, Sep 23, 2026 at 6:28 PM Bertrand Marquis
> <Bertrand.Marquis@xxxxxxx> wrote:
>> 
>> Hi Mykola,
>> 
>> Sorry for the delay to review this serie.
>> 
>>> On 27 Aug 2026, at 16:31, Mykola Kvach <mykola_kvach@xxxxxxxx> wrote:
>>> 
>>> From: Mirela Simonovic <mirela.simonovic@xxxxxxxxxx>
>>> 
>>> System suspend may lead to a state where GIC would be powered down.
>>> Therefore, Xen should save/restore the context of GIC on suspend/resume.
>>> 
>>> Note that the context consists of states of registers which are
>>> controlled by the hypervisor. Other GIC registers which are accessible
>>> by guests are saved/restored on context switch.
>>> 
>>> Transient physical SGI pending state (GICD_CPENDSGIRn/GICD_SPENDSGIRn)
>>> is intentionally excluded. CPU-interface active-priority state is also
>>> not restored across suspend/resume. Xen reaches the final suspend path
>>> at a quiescent point, so there is no active-priority execution context
>>> to replay after resume. Enforce this with a runtime check after
>>> disabling the CPU interface: if any implemented GICC_APRn word is still
>>> non-zero, restore GICC_CTLR and abort suspend with -EBUSY.
>> 
>> You mention SGI pending state but you do not say what would happen for 
>> PPI/SPI
>> pending state, and the patch does not look at or save/restore GICD_ISPENDR.
>> 
>> Can you clarify what is expected for those?
> 
> This patch was originally based on the Linux GICv2 suspend/resume
> code, which also does not save PPI/SPI pending state. The comment
> above gic_dist_restore() explains that level interrupts still
> asserted after resume will be handled, while edge events during
> suspend need to be handled by the platform-specific wakeup
> mechanism.
> 
> Saving GICD_ISPENDR would preserve the pending state at the time of
> each read. However, an interrupt could become pending after that
> read and before the GIC loses power. Saving pending state alone
> therefore does not cover the whole suspend transition.
> 
> The assumption here is that device drivers have stopped normal I/O
> and quiesced non-wakeup interrupt sources before Xen suspends the
> GIC. Earlier events must already have been handled, or their state
> must be preserved outside the GIC. Only configured wakeup sources
> are expected to generate new events at this point.
> 
> We rely on the platform wakeup mechanism throughout suspend entry
> and sleep. If the GIC loses power, this mechanism must capture
> wakeup events outside the GIC and keep them observable after
> resume.
> 
> Not saving pending state depends on these assumptions. The race
> after a register read does not, by itself, justify losing an event
> that is already pending.

I think this would deserve a bit more explanation in the commit message
and maybe a comment in the code so the next one does not wonder if
something is needed here or not and why.

> ---
> 
> While checking the pending-state question, I also noticed a related
> issue with disabling the Distributor during suspend entry.
> 
> My earlier reasoning relied on the Distributor being powered down
> during system suspend. Not every platform is required to follow
> BSA.
> 
> PSCI requires us to save the state that could be lost. Section 6.8
> explicitly discusses Distributor power-down as a feature of some
> systems. This does not require Xen to disable its interrupt group
> before calling SYSTEM_SUSPEND.
> 
> The GICv2 pseudocode in section 3.7.2 shows that irq_wake and
> fiq_wake depend on the Distributor group enables, but not on the
> CPU interface group enables. Clearing the group enable in
> GICD_CTLR can therefore block that group's wakeup path on a
> platform that uses these signals.
> 
> I therefore propose leaving the Distributor group enabled during
> suspend entry, while still saving its configuration in case it
> loses power. The platform would handle any further shutdown and
> the required wakeup configuration. The Distributor would still
> be disabled while restoring its registers on resume.
> 
> Linux also leaves the GICv2 CPU interface enabled before the PSCI
> call. Our early gicv2_cpu_disable() is another difference: it can
> hide that group's interrupts from TF-A's early ISR_EL1 check.
> I propose leaving that shutdown to firmware as well.

Yes that would make sense.
I will let you do that on next version once i will be done with this
version of the serie.

Cheers
Bertrand

> 
> Best regards,
> Mykola



 


Rackspace

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