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

Re: [PATCH v9 10/13] xen/arm64: Save/restore CPU context across SYSTEM_SUSPEND


  • To: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • From: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • Date: Mon, 18 May 2026 17:05:36 +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=BpgLHi9Qz5Is4RecBAOuzC6FxHCCy6X6Nea8EIJTNUo=; fh=uAzoxIkY79cy0zES8IqO07ArU7DBG3jlr2bg4XRVkR0=; b=WVCqiltkz4VYq6t/IeiA6OiLmKvB9iJQQk/NFAWM1Gm/UA55V2h5aKQJ3JKBBaeQz3 1jbGyS4sbKVcI6jxrgmqLq2jGeDx4LlbruKxOU76/xLveaxW0mxYVwfCJrKLsF60FAWs eDtLDQd+QMG7TQiuabC8r74mK2SmZUyGr4OElbA2y+NVXlsKyaH2DFrxYEFKK2QDnP48 qxzcHT5KCxKVzgy1Hb1j3dAVFhQAedyqM3G3JXdPGU51Bdi1SZGbUbgaq544XV5j1Ucg fuPoPpir8YbbjbhG5dRZMvkNaBEpgiCrdzkY1/y+wCRN07Y2xWseeLIjx4TSn3Ghgp/B 5BeA==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1779113148; cv=none; d=google.com; s=arc-20240605; b=I/pbgb4Y43mOA2xBIz6ycoH0M+ReD7SpNNWjciBdUWnjIgZt62/5NUyrE38DFYcvPp lmCdv2CFcbAcwAfq0gj6AUCIsDpGmBnoO5PEGWe+Rz5J25RgbWlIITmFMygnzjbWa8mQ A0nnvvxG9P8VXFr0RHiFG1BmCsuEO3FzjQEQpqc2xXsFWODpEIsulXq2P23Ig2p5JIdS KtRgIkg0g4w/YH9+wfGfMmO0L6YoVuQ+Wsnrd5cWMiYOY5rvnyePxXn1p9814hRIogpc e8IadKqr3jiYOOAkadaS4HjUmMR7hwyO/uXuh64FwB6C/qwHMXv+4IBDISV2RTtYa7wN MBww==
  • 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, 18 May 2026 14:06:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Luca,

Thank you for the detailed review.

On Thu, May 14, 2026 at 8:22 PM Luca Fancellu <Luca.Fancellu@xxxxxxx> wrote:
>
> Hi Mykola,
>
> >
> > +#ifdef CONFIG_SYSTEM_SUSPEND
> > +/*
> > + * int prepare_resume_ctx(void)
> > + *
> > + * CPU context saved here will be restored on resume in hyp_resume 
> > function.
> > + * prepare_resume_ctx shall return a non-zero value. Upon restoring context
> > + * hyp_resume shall return value zero instead. From C code that invokes
> > + * prepare_resume_ctx, the return value is interpreted to determine whether
> > + * the context is saved (prepare_resume_ctx) or restored (hyp_resume).
> > + */
> > +FUNC(prepare_resume_ctx)
> > +        ldr   x0, =resume_cpu_context
> > +
> > +        /* Store callee-saved registers */
> > +        stp   x19, x20, [x0, #RESUME_CTX_X19]
> > +        stp   x21, x22, [x0, #RESUME_CTX_X21]
> > +        stp   x23, x24, [x0, #RESUME_CTX_X23]
> > +        stp   x25, x26, [x0, #RESUME_CTX_X25]
> > +        stp   x27, x28, [x0, #RESUME_CTX_X27]
> > +        stp   x29, lr, [x0, #RESUME_CTX_X29]
> > +
> > +        /* Store stack-pointer */
> > +        mov   x2, sp
> > +        str   x2, [x0, #RESUME_CTX_SP]
> > +
> > +        /* Store system control registers */
> > +        mrs   x2, VBAR_EL2
> > +        str   x2, [x0, #RESUME_CTX_VBAR_EL2]
> > +        mrs   x2, VTCR_EL2
> > +        str   x2, [x0, #RESUME_CTX_VTCR_EL2]
> > +        mrs   x2, VTTBR_EL2
> > +        str   x2, [x0, #RESUME_CTX_VTTBR_EL2]
> > +        mrs   x2, TPIDR_EL2
> > +        str   x2, [x0, #RESUME_CTX_TPIDR_EL2]
> > +        mrs   x2, MDCR_EL2
> > +        str   x2, [x0, #RESUME_CTX_MDCR_EL2]
> > +        mrs   x2, HSTR_EL2
> > +        str   x2, [x0, #RESUME_CTX_HSTR_EL2]
> > +        mrs   x2, CPTR_EL2
> > +        str   x2, [x0, #RESUME_CTX_CPTR_EL2]
> > +        mrs   x2, HCR_EL2
> > +        str   x2, [x0, #RESUME_CTX_HCR_EL2]
>
> Do you think we should save also CNTHCTL_EL2? Apologies it escaped my first 
> review,
> but I see we program it in the boot cpu path + secondary cpu path: 
> init_timer_interrupt().
>
> The rest looks ok.

Ack. Good catch, thanks.

CNTHCTL_EL2 is programmed from init_timer_interrupt() for both the boot
CPU and secondary CPUs, so it should be part of the EL2 context saved and
restored across SYSTEM_SUSPEND. I will add save/restore for it.

I will also re-audit the context save/restore list against the current
boot path to check whether any other EL2 system registers are missing.

Best regards,
Mykola



 


Rackspace

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