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

Re: [PATCH v8 10/13] xen/arm: Resume memory management on Xen resume


  • To: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • From: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • Date: Tue, 5 May 2026 18:55:55 +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=HuNZHulAwh+EOwt2M0h+Hs4hQD0c89BqN36BzTSZvHQ=; fh=uAzoxIkY79cy0zES8IqO07ArU7DBG3jlr2bg4XRVkR0=; b=YdzG0vcgs/90sPnmd32REblnlNbuYF9NbR3QzXBoQkFAyfPsdkBFONSTx3/XZHrY9Q KZLz9ONRQi7XwjsDvA0g12YvQpgb2TX3/itmWNT7PGn12fOVfg4t35jd4oLeOrePzWEq DKDeXNxuMxnuHrNBxOZ2nCXmlJuYWlTY9KcOm/soh5Eiu4sNAHtVO1+2Ixz70BRvd4pm LTDSI6BHW4DjeviMQ5+G29Qm/NvYYTNLZiJmbsI0x/Hut1RAUH6Fz0PpKZPMiBq5cmer PnXYyB07C8IqzIj94na5Juxx6A+1PLIxAJQdu9CTatoodP6FNpuKUmY1hdn5+yNV0kUg XMPg==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1777996567; cv=none; d=google.com; s=arc-20240605; b=OuHR0heqH2jo6s5ihAnrLa4bhD93e4aIv9gApk9AjOZM2oIoY5z+WaH4nkkJgoogbm 0YskHSUEEoWmkR/WTOg3vaipZ9CXQH0gDo3WWs4dgfwDJ0r9qPs6BHD1pkFMWEJj8y23 RrDelIKBUvumxazXOcztFSGY+v9uGoKIgGWR+qj6xnLYqFlF1VUV41UONTV6vPATaboD pceN8iD2muGZtHEqKqaWbJDEFrDIiOFlEc+HfJngZeiHvdiopFuejL3q/n81azP4Gm7u 7KRTjC4hKPJ2Gz+IagwgIouczDyEUxk3N9d4kRJ5aQd28gkJuWFJ2CZ8ktfV2WhLct69 B1lQ==
  • 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: Tue, 05 May 2026 15:56:11 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Luca,

Thank you for the review.

On Mon, Apr 27, 2026 at 5:51 PM Luca Fancellu <Luca.Fancellu@xxxxxxx> wrote:
>
> Hi Mykola,
>
> > On 2 Apr 2026, at 11:45, Mykola Kvach <xakep.amatop@xxxxxxxxx> wrote:
> >
> > From: Mirela Simonovic <mirela.simonovic@xxxxxxxxxx>
> >
> > The MMU must be enabled during the resume path before restoring context,
> > as virtual addresses are used to access the saved context data.
> >
> > This patch adds MMU setup during resume by reusing the existing
> > enable_secondary_cpu_mm function, which enables data cache and the MMU.
>
> I don’t understand where this last part happen in this commit:

This is a leftover from before the commits were reorganized. I will update the
commit message in v9 so that it only describes what this patch actually does.

>
> > Before the MMU is enabled, the content of TTBR0_EL2 is changed to point
> > to init_ttbr (page tables used at runtime).
> >
> > Signed-off-by: Mirela Simonovic <mirela.simonovic@xxxxxxxxxx>
> > Signed-off-by: Saeed Nowshadi <saeed.nowshadi@xxxxxxxxxx>
> > Signed-off-by: Mykyta Poturai <mykyta_poturai@xxxxxxxx>
> > Signed-off-by: Mykola Kvach <mykola_kvach@xxxxxxxx>
> > ---
> > Changes in v7:
> > - no functional changes, just moved commit
> > ---
> > xen/arch/arm/arm64/head.S | 24 ++++++++++++++++++++++++
> > 1 file changed, 24 insertions(+)
> >
> > diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
> > index 72c7b24498..596e960152 100644
> > --- a/xen/arch/arm/arm64/head.S
> > +++ b/xen/arch/arm/arm64/head.S
> > @@ -561,6 +561,30 @@ END(efi_xen_start)
> >
> > #endif /* CONFIG_ARM_EFI */
> >
> > +#ifdef CONFIG_SYSTEM_SUSPEND
> > +
> > +FUNC(hyp_resume)
>
> I think we should mask all exceptions here:
> msr DAIFSet, 0xf
>
> until we resume correctly the status (VBAR_EL2, etc).

This was discussed in an earlier version:

https://patchew.org/Xen/cover.1741164138.git.xakep.amatop@xxxxxxxxx/2ef15cb605f987eb087c5496d123c47c01cc0ae7.1741164138.git.xakep.amatop@xxxxxxxxx/#CAGeoDV97no7mXSKd7auFu5E85wSXAHKWvqGW2=-VEAbkrTyU8Q@xxxxxxxxxxxxxx

For SYSTEM_SUSPEND, PSCI ties the call semantics to CPU_SUSPEND. In
particular, section 5.20.2 says that the caller must observe all the rules
described for CPU_SUSPEND, and section 6.4 explicitly says that the initial
state rules also apply to SYSTEM_SUSPEND.

For the return Exception level on AArch64, section 6.4.3.3 requires
SPSR_ELx.{D,A,I,F} to be set to {1, 1, 1, 1}. Therefore Xen expects to enter
this resume path with DAIF already masked by PSCI-compliant firmware.

I agree this assumption is not obvious from the code, so I will add a comment
at the resume entry point to document that this path relies on the PSCI initial
core configuration requirements.

>
> > +        /* Initialize the UART if earlyprintk has been enabled. */
> > +#ifdef CONFIG_EARLY_PRINTK
> > +        bl    init_uart
> > +#endif
> > +        PRINT_ID("- Xen resuming -\r\n")
> > +
> > +        bl    check_cpu_mode
> > +        bl    cpu_init
> > +
> > +        ldr   x0, =start
> > +        adr   x20, start             /* x20 := paddr (start) */
> > +        sub   x20, x20, x0           /* x20 := phys-offset */
> > +        ldr   lr, =mmu_resumed
> > +        b     enable_secondary_cpu_mm
> > +
> > +mmu_resumed:
> > +        b .
> > +END(hyp_resume)
> > +
> > +#endif /* CONFIG_SYSTEM_SUSPEND */
> > +
> > /*
> >  * Local variables:
> >  * mode: ASM
> >
>
> This is more a trampoline for the core resuming, not sure if it could be 
> better to squash this
> into the following patch, the maintainer could provide their preference.

Yes, this patch is only the low-level resume trampoline before the context
restore code is added by the following patch. I do not have a strong preference
between keeping it separate and squashing it into the next patch. I can squash
them in v9 unless the maintainers prefer to keep the trampoline separate.

Best regards,
Mykola

>
> Cheers,
> Luca
>
>
>



 


Rackspace

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