Add initial Xen Suspend-to-RAM support on ARM64
v4 cover Add initial Xen Suspend-to-RAM support on ARM64
From: Mykola Kvach <[email protected]>
This is part 2 of version 4 of the ARM Xen system suspend/resume patch series, based on earlier work by Mirela Simonovic and Mykyta Poturai. This version is ported to Xen master (4.21-unstable) and includes extensive improvements based on reviewer feedback. The patch series restructures code to improve robustness, maintainability, and implements system Suspend-to-RAM support on ARM64 hardware domains.
Part 1 of the v4 patch series is available here:
https://patchew.org/Xen/[email protected]/
This part also depends on the patch that introduces CONFIG_SYSTEM_SUSPEND:
https://patchew.org/Xen/[email protected]/eb586049ef5180bb33e9414c4754ee2621a772bc.1748381788.git.mykola._5Fkvach@epam.com/
Previous versions:
V1: https://marc.info/?l=xen-devel&m=154202231501850&w=2
V2: https://marc.info/?l=xen-devel&m=166514782207736&w=2
V3: https://lists.xen.org/archives/html/xen-devel/2025-03/msg00168.html
At a high-level, this patch series provides:
- Support for Host system suspend/resume via PSCI SYSTEM_SUSPEND (ARM64)
- Suspend/resume infrastructure for CPU context, timers, and GICv2
- Proper error propagation and recovery throughout the suspend/resume flow
Key updates in this series:
- Introduced architecture-specific suspend/resume infrastructure (new suspend.c, suspend.h, low-level context save/restore in head.S)
- Integrated GICv2 suspend and resume, including memory-backed context save/restore with error handling
- Added time and IRQ suspend/resume hooks, ensuring correct timer/interrupt state across suspend cycles
- Refactored domain shutdown flow to consistently propagate errors from arch-specific suspend handlers
- Implemented proper PSCI SYSTEM_SUSPEND invocation and version checks
- Improved state management and recovery in error cases during suspend/resume
---
TODOs:
- Test system suspend with LLC_COLORING enabled and verify functionality
- Implement IOMMU suspend/resume handlers and integrate them into the suspend/resume path
- Add GICv3 suspend/resume support if required
- Enable "xl suspend" support on ARM
- Properly disable Xen timer watchdog from relevant services
- Add suspend/resume CI test for ARM (QEMU if feasible)
- Investigate feasibility and need for implementing system suspend on ARM32
---
Changes introduced in V4:
- Remove the prior tasklet-based workaround in favor of a more straightforward and safer solution.
- Rework the approach by adding explicit system state checks around request_irq and release_irq calls; skip these calls during suspend and resume states to avoid unsafe memory operations when IRQs are disabled.
- Prevent reinitialization of local IRQ descriptors on system resume.
- Restore the state of local IRQs during system resume for secondary CPUs.
- Drop code for saving and restoring VCPU context (see part 1 of the patch series for details).
- Remove IOMMU suspend and resume calls until these features are implemented.
- Move system suspend logic to arch_domain_shutdown, invoked from domain_shutdown.
- Add console_end_sync to the resume path after system suspend.
- Drop unnecessary DAIF masking; interrupts are already masked on resume.
- Remove leftover TLB flush instructions; flushing is handled in enable_mmu.
- Avoid setting x19 in hyp_resume as it is not required.
- Replace prepare_secondary_mm with set_init_ttbr, and call it from system_suspend.
- Produce a build-time error for ARM32 when CONFIG_SYSTEM_SUSPEND is enabled.
- Use register_t instead of uint64_t in the cpu_context structure.
- Apply minor fixes such as renaming functions, updating comments, and modifying commit messages to accurately reflect the changes introduced by this patch series.
For earlier changelogs, please refer to the previous cover letters.
Mirela Simonovic (7):
xen/x86: Move freeze/thaw_domains to common code
xen/arm: Add suspend and resume timer helpers
xen/arm: Implement GIC suspend/resume functions (gicv2 only) xen/arm: Add support for system suspend triggered by hardware domain xen/arm: Implement PSCI SYSTEM_SUSPEND call (host interface) xen/arm: Resume memory management on Xen resume
xen/arm: Save/restore context on suspend/resume
Mykola Kvach (3):
xen/arm: Prevent crash during disable_nonboot_cpus on suspend xen/arm: irq: avoid local IRQ descriptors reinit on system resume xen/arm: irq: Restore state of local IRQs during system resume
xen/arch/arm/Kconfig | 1 + xen/arch/arm/Makefile | 1 + xen/arch/arm/arm64/head.S | 110 +++++++++++++++++++ xen/arch/arm/domain.c | 21 +++- xen/arch/arm/gic-v2.c | 154 ++++++++++++++++++++++++++ xen/arch/arm/gic.c | 35 ++++++ xen/arch/arm/include/asm/gic.h | 12 +++ xen/arch/arm/include/asm/mm.h | 2 + xen/arch/arm/include/asm/psci.h | 1 + xen/arch/arm/include/asm/suspend.h | 44 ++++++++ xen/arch/arm/include/asm/time.h | 5 + xen/arch/arm/irq.c | 48 +++++++++ xen/arch/arm/mmu/smpboot.c | 2 +- xen/arch/arm/psci.c | 23 +++- xen/arch/arm/suspend.c | 167 +++++++++++++++++++++++++++++ xen/arch/arm/tee/ffa_notif.c | 2 +- xen/arch/arm/time.c | 56 +++++++--- xen/arch/arm/vpsci.c | 4 - xen/arch/ppc/stubs.c | 2 +- xen/arch/riscv/stubs.c | 2 +- xen/arch/x86/acpi/power.c | 25 ----- xen/arch/x86/domain.c | 4 +- xen/common/domain.c | 34 +++++- xen/include/xen/domain.h | 2 +- xen/include/xen/sched.h | 3 + 25 files changed, 709 insertions(+), 51 deletions(-) create mode 100644 xen/arch/arm/include/asm/suspend.h create mode 100644 xen/arch/arm/suspend.c
Signature · 1 line
2.48.1
PATCH v4 1/10 xen/x86: Move freeze/thaw_domains to common code
From: Mirela Simonovic <[email protected]>
The freeze_domains and thaw_domains functions are currently defined in x86-specific suspend code. These functions are also useful on other architectures, such as ARM, for implementing system-wide suspend and resume functionality.
This patch moves these functions to common code so they can be reused across architectures.
---
Changes in v4:
- Enhanced commit message with a clearer explanation of the rationale for moving freeze/thaw_domains to common code.
--- xen/arch/x86/acpi/power.c | 25 ------------------------- xen/common/domain.c | 25 +++++++++++++++++++++++++ xen/include/xen/sched.h | 3 +++ 3 files changed, 28 insertions(+), 25 deletions(-)
xen/arch/x86/acpi/power.c +0 -25
@@ -138,31 +138,6 @@ static void device_power_up(enum dev_power_saved saved) } } -static void freeze_domains (void ) -{ -struct domain *d; - -rcu_read_lock (&domlist_read_lock); -/* -* Note that we iterate in order of domain-id. Hence we will pause dom0 -* first which is required for correctness (as only dom0 can add domains to -* the domain list). Otherwise we could miss concurrently-created domains. -*/ -for_each_domain ( d ) -domain_pause (d); -rcu_read_unlock (&domlist_read_lock); -} - -static void thaw_domains (void ) -{ -struct domain *d; - -rcu_read_lock (&domlist_read_lock); -for_each_domain ( d ) -domain_unpause (d); -rcu_read_unlock (&domlist_read_lock); -} -static void acpi_sleep_prepare (u32 state) {void *wakeup_vector_va;
xen/common/domain.c +25 -0
@@ -2405,6 +2405,31 @@ domid_t get_initial_domain_id(void)return hardware_domid; } +void freeze_domains (void ) +{ +struct domain *d; + +rcu_read_lock (&domlist_read_lock); +/* +* Note that we iterate in order of domain-id. Hence we will pause dom0 +* first which is required for correctness (as only dom0 can add domains to +* the domain list). Otherwise we could miss concurrently-created domains. +*/ +for_each_domain ( d ) +domain_pause (d); +rcu_read_unlock (&domlist_read_lock); +} + +void thaw_domains (void ) +{ +struct domain *d; + +rcu_read_lock (&domlist_read_lock); +for_each_domain ( d ) +domain_unpause (d); +rcu_read_unlock (&domlist_read_lock); +} +/* * Local variables: * mode: C
xen/include/xen/sched.h +3 -0
@@ -1070,6 +1070,9 @@ static inline struct vcpu *domain_vcpu(const struct domain *d,return vcpu_id >= d->max_vcpus ?NULL : d->vcpu[idx]; } +void freeze_domains (void ); +void thaw_domains (void ); +void cpu_init (void );/*
Signature · 1 line
2.48.1
Re: [PATCH v4][PART 2 01/10] xen/x86: Move freeze/thaw_domains to common code
Quoted 7 lines · Mykola Kvach
From: Mirela Simonovic <[email protected]>
The
freeze_domainsandthaw_domainsfunctions are currently defined in x86-specific suspend code. These functions are also useful on other architectures, such as ARM, for implementing system-wide suspend and resume functionality.
Quoted 7 lines
This patch moves these functions to common code so they can be reused across architectures.
Signed-off-by Mirela Simonovic <[email protected]>Signed-off-by Saeed Nowshadi <[email protected]>Signed-off-by Mykyta Poturai <[email protected]>Signed-off-by Mykola Kvach <[email protected]>
On the assumption that the transient Misra violation is okay:
Jan
Re: [PATCH v4][PART 2 01/10] xen/x86: Move freeze/thaw_domains to common code
Quoted 12 lines · Jan Beulich
Quoted 10 lines · Mykola Kvach
From: Mirela Simonovic <[email protected]>
The
freeze_domainsandthaw_domainsfunctions are currently defined in x86-specific suspend code. These functions are also useful on other architectures, such as ARM, for implementing system-wide suspend and resume functionality.This patch moves these functions to common code so they can be reused across architectures.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Mirela Simonovic <[email protected]>Signed-off-by Saeed Nowshadi <[email protected]>Signed-off-by Mykyta Poturai <[email protected]>Signed-off-by Mykola Kvach <[email protected]>On the assumption that the transient Misra violation is okay:
Perhaps wrapping it with CONFIG_SYSTEM_SUSPEND would be sufficient.
Quoted 3 lines
Acked-by Jan Beulich <[email protected]>Jan
Mykola
Re: [PATCH v4][PART 2 01/10] xen/x86: Move freeze/thaw_domains to common code
Quoted 13 lines · Mykola Kvach
Quoted 12 lines · Jan Beulich
Quoted 10 lines · Mykola Kvach
From: Mirela Simonovic <[email protected]>
The
freeze_domainsandthaw_domainsfunctions are currently defined in x86-specific suspend code. These functions are also useful on other architectures, such as ARM, for implementing system-wide suspend and resume functionality.This patch moves these functions to common code so they can be reused across architectures.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Signed-off-by Mirela Simonovic <[email protected]>Signed-off-by Saeed Nowshadi <[email protected]>Signed-off-by Mykyta Poturai <[email protected]>Signed-off-by Mykola Kvach <[email protected]>On the assumption that the transient Misra violation is okay:
Perhaps wrapping it with
CONFIG_SYSTEM_SUSPENDwould be sufficient.
Quite likely, unless another use case for the functions would appear.
Jan
PATCH v4 2/10 xen/arm: Add suspend and resume timer helpers
In reply to Mykola KvachFrom: Mirela Simonovic <[email protected]>
Timer interrupts must be disabled while the system is suspended to prevent spurious wake-ups. Suspending the timers involves disabling both the EL1 physical timer and the EL2 hypervisor timer. Resuming consists of raising the TIMER_SOFTIRQ, which prompts the generic timer code to reprogram the EL2 timer as needed. Re-enabling of the EL1 timer is left to the entity that uses it.
Introduce a new helper, disable_physical_timers, to encapsulate disabling of the physical timers.
---
Changes in V4:
- Rephrased comment and commit message for better clarity
- Created separate function for disabling physical timers
Changes in V3:
- time_suspend and time_resume are now conditionally compiled under CONFIG_SYSTEM_SUSPEND
--- xen/arch/arm/include/asm/time.h | 5 +++++ xen/arch/arm/time.c | 38 +++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 6 deletions(-)
xen/arch/arm/include/asm/time.h +5 -0
@@ -108,6 +108,11 @@ void preinit_xen_time(void);void force_update_vcpu_system_time (struct vcpu *v); +#ifdef CONFIG_SYSTEM_SUSPEND +void time_suspend (void ); +void time_resume (void ); +#endif /* CONFIG_SYSTEM_SUSPEND */ +#endif /* __ARM_TIME_H__ */ /* * Local variables:
xen/arch/arm/time.c +32 -6
@@ -303,6 +303,14 @@ static void check_timer_irq_cfg(unsigned int irq, const char *which) "WARNING: %s-timer IRQ%u is not level triggered.\n", which, irq); } +/* Disable physical timers for EL1 and EL2 on the current CPU */ +static inline void disable_physical_timers (void ) +{ +WRITE_SYSREG (0 ,CNTP_CTL_EL0 );/* Physical timer disabled */ +WRITE_SYSREG (0 ,CNTHP_CTL_EL2 );/* Hypervisor's timer disabled */ +isb (); +} +/* Set up the timer interrupt on this CPU */ void init_timer_interrupt (void ) {
@@ -310,9 +318,7 @@ void init_timer_interrupt(void)WRITE_SYSREG64 (0 ,CNTVOFF_EL2 );/* No VM-specific offset */ /* Do not let the VMs program the physical timer, only read the physical counter */ WRITE_SYSREG (CNTHCTL_EL2_EL1PCTEN ,CNTHCTL_EL2 ); -WRITE_SYSREG (0 ,CNTP_CTL_EL0 );/* Physical timer disabled */ -WRITE_SYSREG (0 ,CNTHP_CTL_EL2 );/* Hypervisor's timer disabled */ -isb (); +disable_physical_timers ();request_irq (timer_irq[TIMER_HYP_PPI ],0 , htimer_interrupt,"hyptimer" ,NULL );
@@ -330,9 +336,7 @@ void init_timer_interrupt(void)*/ static void deinit_timer_interrupt (void ) { -WRITE_SYSREG (0 ,CNTP_CTL_EL0 );/* Disable physical timer */ -WRITE_SYSREG (0 ,CNTHP_CTL_EL2 );/* Disable hypervisor's timer */ -isb (); +disable_physical_timers ();release_irq (timer_irq[TIMER_HYP_PPI ],NULL );release_irq (timer_irq[TIMER_VIRT_PPI ],NULL );
@@ -372,6 +376,28 @@ void domain_set_time_offset(struct domain *d, int64_t time_offset_seconds)/* XXX update guest visible wallclock time */ } +#ifdef CONFIG_SYSTEM_SUSPEND + +void time_suspend (void ) +{ +disable_physical_timers (); +} + +void time_resume (void ) +{ +/* +* Raising the timer softirq triggers generic code to call reprogram_timer +* with the correct timeout (not known here). +* +* No further action is needed to restore timekeeping after power down, +* since the system counter is unaffected. See ARM DDI 0487 L.a, D12.1.2 +* "The system counter must be implemented in an always-on power domain." +*/ +raise_softirq (TIMER_SOFTIRQ ); +} + +#endif /* CONFIG_SYSTEM_SUSPEND */ +static int cpu_time_callback (struct notifier_block *nfb,unsigned long action,void *hcpu)
Signature · 1 line
2.48.1
Re: [PATCH v4][PART 2 02/10] xen/arm: Add suspend and resume timer helpers
Hi Mykola,
Quoted 107 lines · Mykola Kvach
CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.
From: Mirela Simonovic <[email protected]>
Timer interrupts must be disabled while the system is suspended to prevent spurious wake-ups. Suspending the timers involves disabling both the EL1 physical timer and the EL2 hypervisor timer. Resuming consists of raising the
TIMER_SOFTIRQ, which prompts the generic timer code to reprogram the EL2 timer as needed. Re-enabling of the EL1 timer is left to the entity that uses it.Introduce a new helper,
disable_physical_timers, to encapsulate disabling of the physical timers.Signed-off-by Mirela Simonovic <[email protected]>Signed-off-by Saeed Nowshadi <[email protected]>Signed-off-by Mykola Kvach <[email protected]>---
Changes in V4:
- Rephrased comment and commit message for better clarity
- Created separate function for disabling physical timersChanges in V3:
-time_suspendandtime_resumeare now conditionally compiled underCONFIG_SYSTEM_SUSPEND--- xen/arch/arm/include/asm/time.h | 5 +++++ xen/arch/arm/time.c | 38 +++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 6 deletions(-)xen/arch/arm/include/asm/time.h +5
-0@@ -108,6 +108,11 @@ void preinit_xen_time(void);void force_update_vcpu_system_time (struct vcpu *v); +#ifdef CONFIG_SYSTEM_SUSPEND +void time_suspend (void ); +void time_resume (void ); +#endif /* CONFIG_SYSTEM_SUSPEND */ +#endif /* __ARM_TIME_H__ */ /* * Local variables: xen/arch/arm/time.c +25
-6@@ -303,6 +303,14 @@ static void check_timer_irq_cfg(unsigned int irq, const char *which) "WARNING: %s-timer IRQ%u is not level triggered.\n", which, irq); } +/* Disable physical timers for EL1 and EL2 on the current CPU */ +static inline void disable_physical_timers (void ) +{ +WRITE_SYSREG (0 ,CNTP_CTL_EL0 );/* Physical timer disabled */ +WRITE_SYSREG (0 ,CNTHP_CTL_EL2 );/* Hypervisor's timer disabled */ +isb (); +} +/* Set up the timer interrupt on this CPU */ void init_timer_interrupt (void ) {@@ -310,9 +318,7 @@ void init_timer_interrupt(void)WRITE_SYSREG64 (0 ,CNTVOFF_EL2 );/* No VM-specific offset */ /* Do not let the VMs program the physical timer, only read the physical counter */ WRITE_SYSREG (CNTHCTL_EL2_EL1PCTEN ,CNTHCTL_EL2 ); -WRITE_SYSREG (0 ,CNTP_CTL_EL0 );/* Physical timer disabled */ -WRITE_SYSREG (0 ,CNTHP_CTL_EL2 );/* Hypervisor's timer disabled */ -isb (); +disable_physical_timers ();request_irq (timer_irq[TIMER_HYP_PPI ],0 , htimer_interrupt,"hyptimer" ,NULL );@@ -330,9 +336,7 @@ void init_timer_interrupt(void)*/ static void deinit_timer_interrupt (void ) { -WRITE_SYSREG (0 ,CNTP_CTL_EL0 );/* Disable physical timer */ -WRITE_SYSREG (0 ,CNTHP_CTL_EL2 );/* Disable hypervisor's timer */ -isb (); +disable_physical_timers ();release_irq (timer_irq[TIMER_HYP_PPI ],NULL );release_irq (timer_irq[TIMER_VIRT_PPI ],NULL );@@ -372,6 +376,28 @@ void domain_set_time_offset(struct domain *d, int64_t time_offset_seconds)/* XXX update guest visible wallclock time */ } +#ifdef CONFIG_SYSTEM_SUSPEND + +void time_suspend (void ) +{ +disable_physical_timers (); +} + +void time_resume (void ) +{ +/* +* Raising the timer softirq triggers generic code to call reprogram_timer +* with the correct timeout (not known here). +* +* No further action is needed to restore timekeeping after power down, +* since the system counter is unaffected. See ARM DDI 0487 L.a, D12.1.2
xen/arch/arm/time.c void domain_set_time_offset(struct domain *d, int64_t time_offset_seconds) · line 403
Quoted 10 lines
xen/arch/arm/time.c +7
-0+* "The system counter must be implemented in an always-on power domain." +*/ + raise_softirq(TIMER_SOFTIRQ); +} + +#endif /* CONFIG_SYSTEM_SUSPEND */ +static int cpu_time_callback (struct notifier_block *nfb,unsigned long action,void *hcpu)
A question. Do you see CPU_DYING gets invoked during platform suspend ? I wonder how this code path is invoked with
time_suspend()
- Ayan
Quoted 4 lines
--
2.48.1
Re: [PATCH v4][PART 2 02/10] xen/arm: Add suspend and resume timer helpers
Hi Ayan
Quoted 114 lines · Ayan Kumar Halder
Hi Mykola,
Quoted 110 lines · Mykola Kvach
CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.
From: Mirela Simonovic <[email protected]>
Timer interrupts must be disabled while the system is suspended to prevent spurious wake-ups. Suspending the timers involves disabling both the EL1 physical timer and the EL2 hypervisor timer. Resuming consists of raising the
TIMER_SOFTIRQ, which prompts the generic timer code to reprogram the EL2 timer as needed. Re-enabling of the EL1 timer is left to the entity that uses it.Introduce a new helper,
disable_physical_timers, to encapsulate disabling of the physical timers.Signed-off-by Mirela Simonovic <[email protected]>Signed-off-by Saeed Nowshadi <[email protected]>Signed-off-by Mykola Kvach <[email protected]>---
Changes in V4:
- Rephrased comment and commit message for better clarity
- Created separate function for disabling physical timersChanges in V3:
-time_suspendandtime_resumeare now conditionally compiled underCONFIG_SYSTEM_SUSPEND--- xen/arch/arm/include/asm/time.h | 5 +++++ xen/arch/arm/time.c | 38 +++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 6 deletions(-)xen/arch/arm/include/asm/time.h +5
-0@@ -108,6 +108,11 @@ void preinit_xen_time(void);void force_update_vcpu_system_time (struct vcpu *v); +#ifdef CONFIG_SYSTEM_SUSPEND +void time_suspend (void ); +void time_resume (void ); +#endif /* CONFIG_SYSTEM_SUSPEND */ +#endif /* __ARM_TIME_H__ */ /* * Local variables: xen/arch/arm/time.c +28
-6@@ -303,6 +303,14 @@ static void check_timer_irq_cfg(unsigned int irq, const char *which) "WARNING: %s-timer IRQ%u is not level triggered.\n", which, irq); } +/* Disable physical timers for EL1 and EL2 on the current CPU */ +static inline void disable_physical_timers (void ) +{ +WRITE_SYSREG (0 ,CNTP_CTL_EL0 );/* Physical timer disabled */ +WRITE_SYSREG (0 ,CNTHP_CTL_EL2 );/* Hypervisor's timer disabled */ +isb (); +} +/* Set up the timer interrupt on this CPU */ void init_timer_interrupt (void ) {@@ -310,9 +318,7 @@ void init_timer_interrupt(void)WRITE_SYSREG64 (0 ,CNTVOFF_EL2 );/* No VM-specific offset */ /* Do not let the VMs program the physical timer, only read the physical counter */ WRITE_SYSREG (CNTHCTL_EL2_EL1PCTEN ,CNTHCTL_EL2 ); -WRITE_SYSREG (0 ,CNTP_CTL_EL0 );/* Physical timer disabled */ -WRITE_SYSREG (0 ,CNTHP_CTL_EL2 );/* Hypervisor's timer disabled */ -isb (); +disable_physical_timers ();request_irq (timer_irq[TIMER_HYP_PPI ],0 , htimer_interrupt,"hyptimer" ,NULL );@@ -330,9 +336,7 @@ void init_timer_interrupt(void)*/ static void deinit_timer_interrupt (void ) { -WRITE_SYSREG (0 ,CNTP_CTL_EL0 );/* Disable physical timer */ -WRITE_SYSREG (0 ,CNTHP_CTL_EL2 );/* Disable hypervisor's timer */ -isb (); +disable_physical_timers ();release_irq (timer_irq[TIMER_HYP_PPI ],NULL );release_irq (timer_irq[TIMER_VIRT_PPI ],NULL );@@ -372,6 +376,28 @@ void domain_set_time_offset(struct domain *d, int64_t time_offset_seconds)/* XXX update guest visible wallclock time */ } +#ifdef CONFIG_SYSTEM_SUSPEND + +void time_suspend (void ) +{ +disable_physical_timers (); +} + +void time_resume (void ) +{ +/* +* Raising the timer softirq triggers generic code to call reprogram_timer +* with the correct timeout (not known here). +* +* No further action is needed to restore timekeeping after power down, +* since the system counter is unaffected. See ARM DDI 0487 L.a, D12.1.2 +* "The system counter must be implemented in an always-on power domain." +*/ +raise_softirq (TIMER_SOFTIRQ );
Quoted 8 lines
xen/arch/arm/time.c void domain_set_time_offset(struct domain *d, int64_t time_offset_seconds) · line 403
Quoted 7 lines
xen/arch/arm/time.c +4
-0+} + +#endif /* CONFIG_SYSTEM_SUSPEND */ +static int cpu_time_callback (struct notifier_block *nfb,unsigned long action,void *hcpu)A question. Do you see
CPU_DYINGgets invoked during platform suspend ?
Yes, it is invoked through the following code flow:system_suspend (introduced in this patch series)
-> disable_nonboot_cpus
-> cpu_down
-> take_cpu_down
-> _take_cpu_downQuoted 3 lines
I wonder how this code path is invoked with
time_suspend()
time_suspend is called directly from system_suspend,
which was introduced in one of the latest commits in this patch series.
In one of the previous patch series, there was a request to separate implementations and usage of functions.
This was done to reduce the amount of code in each commit and to simplify the review process.
Quoted 7 lines
- Ayan
Quoted 4 lines
--
2.48.1
Best regards,
Mykola
PATCH v4 3/10 xen/arm: Implement GIC suspend/resume functions (gicv2 only)
In reply to Mykola KvachFrom: Mirela Simonovic <[email protected]>
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.
Tested on Xilinx Ultrascale+ MPSoC with (and without) powering down the GIC.
---
Changes in v4:
- Add error logging for allocation failures
Changes in v3:
- Drop asserts and return error codes instead.
- Wrap code with CONFIG_SYSTEM_SUSPEND.
Changes in v2:
- Minor fixes after review.
--- xen/arch/arm/gic-v2.c | 154 +++++++++++++++++++++++++++++++++ xen/arch/arm/gic.c | 29 +++++++ xen/arch/arm/include/asm/gic.h | 12 +++ 3 files changed, 195 insertions(+)
xen/arch/arm/gic-v2.c +154 -0
@@ -1098,6 +1098,151 @@ static int gicv2_iomem_deny_access(struct domain *d)return iomem_deny_access (d, mfn, mfn + nr); } +#ifdef CONFIG_SYSTEM_SUSPEND + +/* GICv2 registers to be saved/restored on system suspend/resume */ +struct gicv2_context { +/* GICC context */ +uint32_t gicc_ctlr; +uint32_t gicc_pmr; +uint32_t gicc_bpr; +/* GICD context */ +uint32_t gicd_ctlr; +uint32_t *gicd_isenabler; +uint32_t *gicd_isactiver; +uint32_t *gicd_ipriorityr; +uint32_t *gicd_itargetsr; +uint32_t *gicd_icfgr; +}; + +static struct gicv2_context gicv2_context; + +static int gicv2_suspend (void ) +{ +unsigned int i; + +if ( !gicv2_context.gicd_isenabler ) + { +dprintk (XENLOG_WARNING ,"%s:%d: GICv2 suspend context not allocated!\n" , + __func__, __LINE__); +return -ENOMEM ; + } + +/* Save GICC configuration */ + gicv2_context.gicc_ctlr =readl_gicc (GICC_CTLR ); + gicv2_context.gicc_pmr =readl_gicc (GICC_PMR ); + gicv2_context.gicc_bpr =readl_gicc (GICC_BPR ); + +/* Save GICD configuration */ + gicv2_context.gicd_ctlr =readl_gicd (GICD_CTLR ); + +for ( i =0 ; i <DIV_ROUND_UP (gicv2_info.nr_lines,32 ); i++ ) + gicv2_context.gicd_isenabler[i] =readl_gicd (GICD_ISENABLER + i *4 ); + +for ( i =0 ; i <DIV_ROUND_UP (gicv2_info.nr_lines,32 ); i++ ) + gicv2_context.gicd_isactiver[i] =readl_gicd (GICD_ISACTIVER + i *4 ); + +for ( i =0 ; i <DIV_ROUND_UP (gicv2_info.nr_lines,4 ); i++ ) + gicv2_context.gicd_ipriorityr[i] =readl_gicd (GICD_IPRIORITYR + i *4 ); + +for ( i =0 ; i <DIV_ROUND_UP (gicv2_info.nr_lines,4 ); i++ ) + gicv2_context.gicd_itargetsr[i] =readl_gicd (GICD_ITARGETSR + i *4 ); + +for ( i =0 ; i <DIV_ROUND_UP (gicv2_info.nr_lines,16 ); i++ ) + gicv2_context.gicd_icfgr[i] =readl_gicd (GICD_ICFGR + i *4 ); + +return 0 ; +} + +static void gicv2_resume (void ) +{ +unsigned int i; + +if ( !gicv2_context.gicd_isenabler ) + { +dprintk (XENLOG_WARNING ,"%s:%d: GICv2 suspend context not allocated!\n" , + __func__, __LINE__); +return ; + } + +gicv2_cpu_disable (); +/* Disable distributor */ +writel_gicd (0 ,GICD_CTLR ); + +/* Restore GICD configuration */ +for ( i =0 ; i <DIV_ROUND_UP (gicv2_info.nr_lines,32 ); i++ ) { +writel_gicd (0xffffffff ,GICD_ICENABLER + i *4 ); +writel_gicd (gicv2_context.gicd_isenabler[i],GICD_ISENABLER + i *4 ); + } + +for ( i =0 ; i <DIV_ROUND_UP (gicv2_info.nr_lines,32 ); i++ ) { +writel_gicd (0xffffffff ,GICD_ICACTIVER + i *4 ); +writel_gicd (gicv2_context.gicd_isactiver[i],GICD_ISACTIVER + i *4 ); + } + +for ( i =0 ; i <DIV_ROUND_UP (gicv2_info.nr_lines,4 ); i++ ) +writel_gicd (gicv2_context.gicd_ipriorityr[i],GICD_IPRIORITYR + i *4 ); + +for ( i =0 ; i <DIV_ROUND_UP (gicv2_info.nr_lines,4 ); i++ ) +writel_gicd (gicv2_context.gicd_itargetsr[i],GICD_ITARGETSR + i *4 ); + +for ( i =0 ; i <DIV_ROUND_UP (gicv2_info.nr_lines,16 ); i++ ) +writel_gicd (gicv2_context.gicd_icfgr[i],GICD_ICFGR + i *4 ); + +/* Make sure all registers are restored and enable distributor */ +writel_gicd (gicv2_context.gicd_ctlr |GICD_CTL_ENABLE ,GICD_CTLR ); + +/* Restore GIC CPU interface configuration */ +writel_gicc (gicv2_context.gicc_pmr,GICC_PMR ); +writel_gicc (gicv2_context.gicc_bpr,GICC_BPR ); + +/* Enable GIC CPU interface */ +writel_gicc (gicv2_context.gicc_ctlr |GICC_CTL_ENABLE |GICC_CTL_EOI , +GICC_CTLR ); +} + +static void gicv2_alloc_context (struct gicv2_context *gc) +{ +uint32_t n = gicv2_info.nr_lines; + + gc->gicd_isenabler =xzalloc_array (uint32_t,DIV_ROUND_UP (n,32 )); +if ( !gc->gicd_isenabler ) + goto err_free; + + gc->gicd_isactiver =xzalloc_array (uint32_t,DIV_ROUND_UP (n,32 )); +if ( !gc->gicd_isactiver ) + goto err_free; + + gc->gicd_itargetsr =xzalloc_array (uint32_t,DIV_ROUND_UP (n,4 )); +if ( !gc->gicd_itargetsr ) + goto err_free; + + gc->gicd_ipriorityr =xzalloc_array (uint32_t,DIV_ROUND_UP (n,4 )); +if ( !gc->gicd_ipriorityr ) + goto err_free; + + gc->gicd_icfgr =xzalloc_array (uint32_t,DIV_ROUND_UP (n,16 )); +if ( !gc->gicd_icfgr ) + goto err_free; + +return ; + + err_free: +dprintk (XENLOG_ERR , +"%s:%d: failed to allocate memory for GICv2 suspend context\n" , + __func__, __LINE__); + +xfree (gc->gicd_icfgr); +xfree (gc->gicd_ipriorityr); +xfree (gc->gicd_itargetsr); +xfree (gc->gicd_isactiver); +xfree (gc->gicd_isenabler); + +memset (gc,0 ,sizeof (*gc)); +} + +#endif /* CONFIG_SYSTEM_SUSPEND */ +#ifdef CONFIG_ACPI static unsigned long gicv2_get_hwdom_extra_madt_size (const struct domain *d) {
@@ -1302,6 +1447,11 @@ static int __init gicv2_init(void)spin_unlock (&gicv2.lock); +#ifdef CONFIG_SYSTEM_SUSPEND +/* Allocate memory to be used for saving GIC context during the suspend */ +gicv2_alloc_context (&gicv2_context); +#endif /* CONFIG_SYSTEM_SUSPEND */ +return 0 ; }
@@ -1345,6 +1495,10 @@ static const struct gic_hw_operations gicv2_ops = { .map_hwdom_extra_mappings = gicv2_map_hwdom_extra_mappings, .iomem_deny_access = gicv2_iomem_deny_access, .do_LPI = gicv2_do_LPI, +#ifdef CONFIG_SYSTEM_SUSPEND + .suspend = gicv2_suspend, + .resume = gicv2_resume, +#endif /* CONFIG_SYSTEM_SUSPEND */ };/* Set up the GIC */
xen/arch/arm/gic.c +29 -0
@@ -425,6 +425,35 @@ int gic_iomem_deny_access(struct domain *d)return gic_hw_ops->iomem_deny_access (d); } +#ifdef CONFIG_SYSTEM_SUSPEND + +int gic_suspend (void ) +{ +/* Must be called by boot CPU#0 with interrupts disabled */ +ASSERT (!local_irq_is_enabled ()); +ASSERT (!smp_processor_id ()); + +if ( !gic_hw_ops->suspend || !gic_hw_ops->resume ) +return -ENOSYS ; + +return gic_hw_ops->suspend (); +} + +void gic_resume (void ) +{ +/* +* Must be called by boot CPU#0 with interrupts disabled after gic_suspend +* has returned successfully. +*/ +ASSERT (!local_irq_is_enabled ()); +ASSERT (!smp_processor_id ()); +ASSERT (gic_hw_ops->resume); + + gic_hw_ops->resume (); +} + +#endif /* CONFIG_SYSTEM_SUSPEND */ +static int cpu_gic_callback (struct notifier_block *nfb,unsigned long action,void *hcpu)
xen/arch/arm/include/asm/gic.h +12 -0
@@ -280,6 +280,12 @@ extern int gicv_setup(struct domain *d);extern void gic_save_state (struct vcpu *v);extern void gic_restore_state (struct vcpu *v); +#ifdef CONFIG_SYSTEM_SUSPEND +/* Suspend/resume */ +extern int gic_suspend (void ); +extern void gic_resume (void ); +#endif /* CONFIG_SYSTEM_SUSPEND */ +/* SGI (AKA IPIs) */ enum gic_sgi {GIC_SGI_EVENT_CHECK ,
@@ -395,6 +401,12 @@ struct gic_hw_operations {int (*iomem_deny_access)(struct domain *d);/* Handle LPIs, which require special handling */ void (*do_LPI)(unsigned int lpi); +#ifdef CONFIG_SYSTEM_SUSPEND +/* Save GIC configuration due to the system suspend */ +int (*suspend)(void ); +/* Restore GIC configuration due to the system resume */ +void (*resume)(void ); +#endif /* CONFIG_SYSTEM_SUSPEND */ };extern const struct gic_hw_operations *gic_hw_ops;
Signature · 1 line
2.48.1
PATCH v4 4/10 xen/arm: Prevent crash during disable_nonboot_cpus on suspend
In reply to Mykola KvachFrom: Mykola Kvach <[email protected]>
If we call disable_nonboot_cpus on ARM64 with system_state set to SYS_STATE_suspend, the following assertion will be triggered:
``` (XEN) [ 25.582712] Disabling non-boot CPUs ... (XEN) [ 25.587032] Assertion '!in_irq() && (local_irq_is_enabled() || num_online_cpus() <= 1)' failed at common/xmalloc_tlsf.c:714 [...] (XEN) [ 25.975069] Xen call trace: (XEN) [ 25.978353] [<00000a000022e098>] xfree+0x130/0x1a4 (PC) (XEN) [ 25.984314] [<00000a000022e08c>] xfree+0x124/0x1a4 (LR) (XEN) [ 25.990276] [<00000a00002747d4>] release_irq+0xe4/0xe8 (XEN) [ 25.996152] [<00000a0000278588>] time.c#cpu_time_callback+0x44/0x60 (XEN) [ 26.003150] [<00000a000021d678>] notifier_call_chain+0x7c/0xa0 (XEN) [ 26.009717] [<00000a00002018e0>] cpu.c#cpu_notifier_call_chain+0x24/0x48 (XEN) [ 26.017148] [<00000a000020192c>] cpu.c#_take_cpu_down+0x28/0x34 (XEN) [ 26.023801] [<00000a0000201944>] cpu.c#take_cpu_down+0xc/0x18 (XEN) [ 26.030281] [<00000a0000225c5c>] stop_machine.c#stopmachine_action+0xbc/0xe4 (XEN) [ 26.038057] [<00000a00002264bc>] tasklet.c#do_tasklet_work+0xb8/0x100 (XEN) [ 26.045229] [<00000a00002268a4>] do_tasklet+0x68/0xb0 (XEN) [ 26.051018] [<00000a000026e120>] domain.c#idle_loop+0x7c/0x194 (XEN) [ 26.057585] [<00000a0000277e30>] start_secondary+0x21c/0x220 (XEN) [ 26.063978] [<00000a0000361258>] 00000a0000361258 ```
This happens because before invoking take_cpu_down via the stop_machine_run function on the target CPU, stop_machine_run requests
the STOPMACHINE_DISABLE_IRQ state on that CPU. Releasing memory in the release_irq function then triggers the assertion:
/*
* Heap allocations may need TLB flushes which may require IRQs to be
* enabled (except when only 1 PCPU is online).
*/
This patch adds system state checks to guard calls to request_irq and release_irq. These calls are now skipped when system_state is SYS_STATE_{resume,suspend}, preventing unsafe operations during suspend/resume handling.
---
Changes in V4:
- removed the prior tasklet-based workaround in favor of a more straightforward and safer solution
- reworked the approach by adding explicit system state checks around request_irq and release_irq calls, skips these calls during suspend and resume states to avoid unsafe memory operations when IRQs are disabled
--- xen/arch/arm/gic.c | 6 ++++++ xen/arch/arm/tee/ffa_notif.c | 2 +- xen/arch/arm/time.c | 18 ++++++++++++------ 3 files changed, 19 insertions(+), 7 deletions(-)
xen/arch/arm/gic.c +6 -0
@@ -388,6 +388,9 @@ void gic_dump_info(struct vcpu *v)void init_maintenance_interrupt (void ) { +if ( system_state == SYS_STATE_resume ) +return ; +request_irq (gic_hw_ops->info->maintenance_irq,0 , maintenance_interrupt,"irq-maintenance" ,NULL ); }
@@ -461,6 +464,9 @@ static int cpu_gic_callback(struct notifier_block *nfb,switch ( action ) {case CPU_DYING : +if ( system_state == SYS_STATE_suspend ) +break ; +/* This is reverting the work done in init_maintenance_interrupt */ release_irq (gic_hw_ops->info->maintenance_irq,NULL );break ;
xen/arch/arm/tee/ffa_notif.c +1 -1
@@ -347,7 +347,7 @@ void ffa_notif_init_interrupt(void) {int ret; -if ( notif_enabled && notif_sri_irq <NR_GIC_SGI ) +if ( notif_enabled && notif_sri_irq <NR_GIC_SGI && system_state != SYS_STATE_resume ) {/* * An error here is unlikely since the primary CPU has already
xen/arch/arm/time.c +12 -6
@@ -320,10 +320,13 @@ void init_timer_interrupt(void)WRITE_SYSREG (CNTHCTL_EL2_EL1PCTEN ,CNTHCTL_EL2 );disable_physical_timers (); -request_irq (timer_irq[TIMER_HYP_PPI ],0 , htimer_interrupt, -"hyptimer" ,NULL ); -request_irq (timer_irq[TIMER_VIRT_PPI ],0 , vtimer_interrupt, -"virtimer" ,NULL ); +if ( system_state != SYS_STATE_resume ) + { +request_irq (timer_irq[TIMER_HYP_PPI ],0 , htimer_interrupt, +"hyptimer" ,NULL ); +request_irq (timer_irq[TIMER_VIRT_PPI ],0 , vtimer_interrupt, +"virtimer" ,NULL ); + }check_timer_irq_cfg (timer_irq[TIMER_HYP_PPI ],"hypervisor" );check_timer_irq_cfg (timer_irq[TIMER_VIRT_PPI ],"virtual" );
@@ -338,8 +341,11 @@ static void deinit_timer_interrupt(void) {disable_physical_timers (); -release_irq (timer_irq[TIMER_HYP_PPI ],NULL ); -release_irq (timer_irq[TIMER_VIRT_PPI ],NULL ); +if ( system_state != SYS_STATE_suspend ) + { +release_irq (timer_irq[TIMER_HYP_PPI ],NULL ); +release_irq (timer_irq[TIMER_VIRT_PPI ],NULL ); + } }/* Wait a set number of microseconds */
Signature · 1 line
2.48.1
PATCH v4 5/10 xen/arm: irq: avoid local IRQ descriptors reinit on system resume
In reply to Mykola KvachFrom: Mykola Kvach <[email protected]>
On ARM, during system resume, CPUs are brought online again. This normally triggers init_local_irq_data, which reinitializes IRQ descriptors for banked interrupts (SGIs and PPIs).
These descriptors are statically allocated per CPU and retain valid state across suspend/resume cycles. Re-initializing them on resume is unnecessary and may result in loss of interrupt configuration or restored state.
This patch skips init_local_irq_data when system_state is set to SYS_STATE_resume to preserve banked IRQ descs state during resume.
--- xen/arch/arm/irq.c | 4 ++++ 1 file changed, 4 insertions(+)
xen/arch/arm/irq.c +4 -0
@@ -122,6 +122,10 @@ static int cpu_callback(struct notifier_block *nfb, unsigned long action,switch ( action ) {case CPU_UP_PREPARE : +/* Skip local IRQ cleanup on resume */ +if ( system_state == SYS_STATE_resume ) +break ; + rc =init_local_irq_data (cpu);if ( rc ) printk(XENLOG_ERR "Unable to allocate local IRQ for CPU%u\n",
Signature · 1 line
2.48.1
PATCH v4 6/10 xen/arm: irq: Restore state of local IRQs during system resume
In reply to Mykola KvachFrom: Mykola Kvach <[email protected]>
On ARM, the first 32 interrupts (SGIs and PPIs) are banked per-CPU and not restored by gic_resume (for secondary cpus).
This patch introduces restore_local_irqs_on_resume, a function that restores the state of local interrupts on the target CPU during system resume.
It iterates over all local IRQs and re-enables those that were not disabled, reprogramming their routing and affinity accordingly.
The function is invoked from start_secondary, ensuring that local IRQ state is restored early during CPU bring-up after suspend.
--- xen/arch/arm/irq.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
xen/arch/arm/irq.c +44 -0
@@ -113,6 +113,47 @@ static int init_local_irq_data(unsigned int cpu)return 0 ; } +/* +* The first 32 interrupts (PPIs and SGIs) are per-CPU, +* so call this function on the target CPU to restore them. +* +* SPIs are restored via gic_resume. +*/ +static void restore_local_irqs_on_resume (void ) +{ +int irq; + +if ( system_state != SYS_STATE_resume ) +return ; + +spin_lock (&local_irqs_type_lock); + +for ( irq =0 ; irq <NR_LOCAL_IRQS ; irq++ ) + { +struct irq_desc *desc =irq_to_desc (irq); + +spin_lock (&desc->lock); + +if (test_bit (_IRQ_DISABLED, &desc->status) ) + { +spin_unlock (&desc->lock); +continue ; + } + +/* it is needed to avoid asserts in below calls */ +set_bit (_IRQ_DISABLED, &desc->status); + +gic_route_irq_to_xen (desc,GIC_PRI_IRQ ); + +/* _IRQ_DISABLED is cleared by below call */ + desc->handler->startup (desc); + +spin_unlock (&desc->lock); + } + +spin_unlock (&local_irqs_type_lock); +} +static int cpu_callback (struct notifier_block *nfb,unsigned long action,void *hcpu) {
@@ -131,6 +172,9 @@ static int cpu_callback(struct notifier_block *nfb, unsigned long action,printk (XENLOG_ERR "Unable to allocate local IRQ for CPU%u\n" , cpu);break ; +case CPU_STARTING : +restore_local_irqs_on_resume (); +break ; }return notifier_from_errno (rc);
Signature · 1 line
2.48.1
PATCH v4 7/10 xen/arm: Add support for system suspend triggered by hardware domain
In reply to Mykola KvachFrom: Mirela Simonovic <[email protected]>
Trigger Xen suspend when the hardware domain initiates suspend via SHUTDOWN_suspend. Redirect system suspend to CPU#0 to ensure the suspend logic runs on the boot CPU, as required.
Introduce full suspend/resume infrastructure gated by CONFIG_SYSTEM_SUSPEND, including logic to:
- disable and enable non-boot physical CPUs
- freeze and thaw domains
- suspend and resume the GIC, timer and console
- maintain system state before and after suspend
Extend arch_domain_shutdown to return a status code and integrate system_suspend into the ARM-specific path. Update stub implementations and function signatures across other architectures (x86, riscv, ppc) for consistency.
Remove the restriction in the PSCI interface preventing suspend from the hardware domain.
Update Kconfig and Makefile to support conditional inclusion of the new suspend.c implementation.Limit SYSTEM_SUSPEND support to ARM64 with UNSUPPORTED enabled and LLC_COLORING disabled.
---
Changes introduced in V4:
- drop code for saving and restoring VCPU context (for more information refer part 1 of patch series)
- remove IOMMU suspend and resume calls until they will be implemented
- move system suspend logic to arch_domain_shutdown, invoked from domain_shutdown
- apply minor fixes such as renaming functions, updating comments, and modifying the commit message to reflect these changes
- add console_end_sync to resume path after system suspend
Changes introduced in V3:
- merge changes from other commits into this patch (previously stashed):
1) disable/enable non-boot physical CPUs and freeze/thaw domains during suspend/resume
2) suspend/resume the timer, GIC, console, IOMMU, and hardware domain
--- xen/arch/arm/Kconfig | 1 + xen/arch/arm/Makefile | 1 + xen/arch/arm/domain.c | 21 ++++- xen/arch/arm/include/asm/suspend.h | 22 +++++ xen/arch/arm/suspend.c | 143 +++++++++++++++++++++++++++++ xen/arch/arm/vpsci.c | 4 - xen/arch/ppc/stubs.c | 2 +- xen/arch/riscv/stubs.c | 2 +- xen/arch/x86/domain.c | 4 +- xen/common/domain.c | 9 +- xen/include/xen/domain.h | 2 +- 11 files changed, 200 insertions(+), 11 deletions(-) create mode 100644 xen/arch/arm/include/asm/suspend.h create mode 100644 xen/arch/arm/suspend.c
xen/arch/arm/Kconfig +1 -0
@@ -19,6 +19,7 @@ config ARM select HAS_DOM0LESS select HAS_GRANT_CACHE_FLUSH if GRANT_TABLE select HAS_STACK_PROTECTOR + select HAS_SYSTEM_SUSPEND if ARM_64 && !LLC_COLORING && UNSUPPORTED select HAS_UBSAN config ARCH_DEFCONFIG
xen/arch/arm/Makefile +1 -0
@@ -53,6 +53,7 @@ obj-y += smp.o obj-y += smpboot.o obj-$(CONFIG_STATIC_MEMORY) += static-memory.init.o obj-$(CONFIG_STATIC_SHM) += static-shmem.init.o +obj-$(CONFIG_SYSTEM_SUSPEND) += suspend.o obj-y += sysctl.o obj-y += time.o obj-y += traps.o
xen/arch/arm/domain.c +20 -1
@@ -24,11 +24,14 @@#include <asm/platform.h> #include <asm/procinfo.h> #include <asm/regs.h> +#include <asm/suspend.h> #include <asm/tee/tee.h> #include <asm/vfp.h> #include <asm/vgic.h> #include <asm/vtimer.h> +#include <public/sched.h> +#include "vpci.h" #include "vuart.h"
@@ -857,8 +860,24 @@ void arch_domain_destroy(struct domain *d)domain_io_free (d); } -void arch_domain_shutdown (struct domain *d) +int arch_domain_shutdown (struct domain *d) { +switch ( d->shutdown_code ) + { +case SHUTDOWN_suspend: +#ifdef CONFIG_SYSTEM_SUSPEND +if ( !is_hardware_domain (d) ) +break ; + +return host_system_suspend (); +#else +break ; +#endif +default : +break ; + } + +return 0 ; }void arch_domain_pause (struct domain *d)
xen/arch/arm/include/asm/suspend.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __ASM_ARM_SUSPEND_H__ +#define __ASM_ARM_SUSPEND_H__ + +#ifdef CONFIG_SYSTEM_SUSPEND + +int host_system_suspend (void ); + +#endif /* CONFIG_SYSTEM_SUSPEND */ + +#endif /* __ASM_ARM_SUSPEND_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/arm/suspend.c new file +143 -0
143 lines not on this page · raw message
xen/arch/arm/vpsci.c +0 -4
@@ -202,10 +202,6 @@ static int32_t do_psci_1_0_system_suspend(register_t epoint, register_t cid)struct vcpu *v;struct domain *d = current->domain; -/* Drop this check once SYSTEM_SUSPEND is supported in hardware domain */ -if (is_hardware_domain (d) ) -return PSCI_NOT_SUPPORTED ; -/* Ensure that all CPUs other than the calling one are offline */ for_each_vcpu ( d, v ) {
xen/arch/ppc/stubs.c +1 -1
@@ -219,7 +219,7 @@ void arch_domain_destroy(struct domain *d)BUG_ON ("unimplemented" ); } -void arch_domain_shutdown (struct domain *d) +int arch_domain_shutdown (struct domain *d) {BUG_ON ("unimplemented" ); }
xen/arch/riscv/stubs.c +1 -1
@@ -204,7 +204,7 @@ void arch_domain_destroy(struct domain *d)BUG_ON ("unimplemented" ); } -void arch_domain_shutdown (struct domain *d) +int arch_domain_shutdown (struct domain *d) {BUG_ON ("unimplemented" ); }
xen/arch/x86/domain.c +3 -1
@@ -951,10 +951,12 @@ void arch_domain_destroy(struct domain *d)psr_domain_free (d); } -void arch_domain_shutdown (struct domain *d) +int arch_domain_shutdown (struct domain *d) {if (is_viridian_domain (d) )viridian_time_domain_freeze (d); + +return 0 ; }void arch_domain_pause (struct domain *d)
xen/common/domain.c +7 -2
@@ -1276,6 +1276,7 @@ void __domain_crash(struct domain *d)int domain_shutdown (struct domain *d,u8 reason) {struct vcpu *v; +int ret;#ifdef CONFIG_X86 if ( pv_shim )
@@ -1288,7 +1289,11 @@ int domain_shutdown(struct domain *d, u8 reason) d->shutdown_code = reason; reason = d->shutdown_code; +#if defined(CONFIG_SYSTEM_SUSPEND ) && defined(CONFIG_ARM ) +if ( reason != SHUTDOWN_suspend &&is_hardware_domain (d) ) +#else if ( is_hardware_domain(d) ) +#endif hwdom_shutdown (reason);if ( d->is_shutting_down )
@@ -1311,13 +1316,13 @@ int domain_shutdown(struct domain *d, u8 reason) v->paused_for_shutdown =1 ; } -arch_domain_shutdown (d); + ret =arch_domain_shutdown (d);__domain_finalise_shutdown (d);spin_unlock (&d->shutdown_lock); -return 0 ; +return ret; }void domain_resume (struct domain *d)
xen/include/xen/domain.h +1 -1
@@ -101,7 +101,7 @@ int arch_domain_create(struct domain *d,int arch_domain_teardown (struct domain *d);void arch_domain_destroy (struct domain *d); -void arch_domain_shutdown (struct domain *d); +int arch_domain_shutdown (struct domain *d);void arch_domain_pause (struct domain *d);void arch_domain_unpause (struct domain *d);
Signature · 1 line
2.48.1
Re: [PATCH v4][PART 2 07/10] xen/arm: Add support for system suspend triggered by hardware domain
Quoted 14 lines · Mykola Kvach
xen/arch/arm/domain.c +8
-1@@ -857,8 +860,24 @@ void arch_domain_destroy(struct domain *d)domain_io_free (d); } -void arch_domain_shutdown (struct domain *d) +int arch_domain_shutdown (struct domain *d) { +switch ( d->shutdown_code ) + { +case SHUTDOWN_suspend: +#ifdef CONFIG_SYSTEM_SUSPEND +if ( !is_hardware_domain (d) ) +break ; +
xen/arch/arm/domain.c void arch_domain_destroy(struct domain *d) · line 881
Quoted 10 lines
xen/arch/arm/domain.c +9
-0+return host_system_suspend (); +#else +break ; +#endif +default : +break ; + } + +return 0 ; }
What's wrong with
int arch_domain_shutdown(struct domain *d)
{
switch ( d->shutdown_code )
{
#ifdef CONFIG_SYSTEM_SUSPEND
case SHUTDOWN_suspend:
if ( !is_hardware_domain(d) )
break;
return host_system_suspend();#endif
default:
break;
}
return 0;
}?
xen/common/domain.c int domain_shutdown(struct domain *d, u8 reason) · line 1319
Quoted 6 lines
xen/common/domain.c +1
-1@@ -1311,13 +1316,13 @@ int domain_shutdown(struct domain *d, u8 reason) v->paused_for_shutdown =1 ; } -arch_domain_shutdown (d); + ret =arch_domain_shutdown (d);
If non-zero comes back here, is ...
xen/common/domain.c int domain_shutdown(struct domain *d, u8 reason) · line 1321
Quoted 1 line
xen/common/domain.c +0
-0__domain_finalise_shutdown (d);
... this still appropriate to call?
xen/common/domain.c int domain_shutdown(struct domain *d, u8 reason) · line 1326
Quoted 5 lines
xen/common/domain.c +1
-1spin_unlock (&d->shutdown_lock); -return 0 ; +return ret; }
Most callers don't care about the return value of this function. That likely needs to change, even if _for now_ you only alter the SHUTDOWN_suspend case (and hence some of the callers aren't immediately impacted)?
Jan
Re: [PATCH v4][PART 2 07/10] xen/arm: Add support for system suspend triggered by hardware domain
Hi, @Jan Beulich
Quoted 41 lines · Jan Beulich
Quoted 14 lines · Mykola Kvach
xen/arch/arm/domain.c +8
-1@@ -857,8 +860,24 @@ void arch_domain_destroy(struct domain *d)domain_io_free (d); } -void arch_domain_shutdown (struct domain *d) +int arch_domain_shutdown (struct domain *d) { +switch ( d->shutdown_code ) + { +case SHUTDOWN_suspend: +#ifdef CONFIG_SYSTEM_SUSPEND +if ( !is_hardware_domain (d) ) +break ; +xen/arch/arm/domain.c void arch_domain_destroy(struct domain *d) · line 881
Quoted 10 lines
xen/arch/arm/domain.c +9
-0+return host_system_suspend (); +#else +break ; +#endif +default : +break ; + } + +return 0 ; }What's wrong with
int
arch_domain_shutdown(struct domain *d){ switch ( d->shutdown_code ) { #ifdef CONFIG_SYSTEM_SUSPEND case SHUTDOWN_suspend: if ( !is_hardware_domain(d) ) break; return host_system_suspend();#endif
Quoted 8 lines
default: break; } return 0; }?
You're right — your version is cleaner and avoids unnecessary preprocessor spaghetti.
My original intention was to keep the SHUTDOWN_suspend case visible even when CONFIG_SYSTEM_SUSPEND is disabled, so future changes wouldn't require reintroducing the case label. But thinking about it again, if future support is needed, the code can be easily adjusted at that time.
I'll switch to your suggested version — it's simpler and more readable.
Quoted 5 lines
Quoted 5 lines
xen/common/domain.c +0
-0@@ -1311,13 +1316,13 @@ int domain_shutdown(struct domain *d, u8 reason) v->paused_for_shutdown =1 ; }
Quoted 8 lines
xen/common/domain.c int domain_shutdown(struct domain *d, u8 reason) · line 1319
Quoted 2 lines
xen/common/domain.c +1
-1-arch_domain_shutdown (d); + ret =arch_domain_shutdown (d);If non-zero comes back here, is ...
xen/common/domain.c int domain_shutdown(struct domain *d, u8 reason) · line 1321
Quoted 1 line
xen/common/domain.c +0
-0__domain_finalise_shutdown (d);... this still appropriate to call?
Thank you for catching that — you’re absolutely right, that was my oversight.
If arch_domain_shutdown returns a non-zero value, we need to undo any previous actions performed before the call to properly restore the domain’s state. Calling __domain_finalise_shutdown unconditionally in that case could lead to an inconsistent state.
I will update the code accordingly to ensure proper cleanup and state restoration.
Quoted 10 lines
xen/common/domain.c int domain_shutdown(struct domain *d, u8 reason) · line 1326
Quoted 6 lines
xen/common/domain.c +1
-1spin_unlock (&d->shutdown_lock); -return 0 ; +return ret; }Most callers don't care about the return value of this function. That likely needs to change, even if
_fornow_you only alter theSHUTDOWN_suspendcase (and hence some of the callers aren't immediately impacted)?
Thanks for pointing this out. You’re right that most callers currently ignore the return value of domain_shutdown(). This will need to be updated to properly handle non-zero returns, at least for the SHUTDOWN_suspend case where it matters.
Even if some callers aren’t immediately impacted, I agree it’s better to fix this proactively to avoid silent failures or inconsistent states.
I’ll start reviewing the callers and update them accordingly.
Quoted 2 lines
Jan
Thank you for reviewing this patch series.
Best regards,
Mykola
PATCH v4 8/10 xen/arm: Implement PSCI SYSTEM_SUSPEND call (host interface)
In reply to Mykola KvachFrom: Mirela Simonovic <[email protected]>
Invoke PSCI SYSTEM_SUSPEND to finalize Xen's suspend sequence on ARM64 platforms. Pass the resume entry point (hyp_resume) as the first argument to EL3. The resume handler is currently a stub and will be implemented later in assembly. Ignore the context ID argument, as is done in Linux.
Only enable this path when CONFIG_SYSTEM_SUSPEND is set and PSCI version is >= 1.0.
---
Changes in v4:
- select the appropriate PSCI SYSTEM_SUSPEND function ID based on arch
- update comments and commit message to reflect recent changes
Changes in v3:
- return PSCI_NOT_SUPPORTED instead of a hardcoded 1 on ARM32
- check PSCI version before invoking SYSTEM_SUSPEND in call_psci_system_suspend
--- xen/arch/arm/arm64/head.S | 8 ++++++++ xen/arch/arm/include/asm/psci.h | 1 + xen/arch/arm/include/asm/suspend.h | 2 ++ xen/arch/arm/psci.c | 23 ++++++++++++++++++++++- xen/arch/arm/suspend.c | 5 +++++ 5 files changed, 38 insertions(+), 1 deletion(-)
xen/arch/arm/arm64/head.S +8 -0
@@ -561,6 +561,14 @@ END(efi_xen_start) #endif /* CONFIG_ARM_EFI */ +#ifdef CONFIG_SYSTEM_SUSPEND + +FUNC(hyp_resume) + b . +END(hyp_resume) + +#endif /* CONFIG_SYSTEM_SUSPEND */ + /* * Local variables: * mode: ASM
xen/arch/arm/include/asm/psci.h +1 -0
@@ -23,6 +23,7 @@ int call_psci_cpu_on(int cpu);void call_psci_cpu_off (void );void call_psci_system_off (void );void call_psci_system_reset (void ); +int call_psci_system_suspend (void );/* Range of allocated PSCI function numbers */ #define PSCI_FNUM_MIN_VALUE _AC(0,U)
xen/arch/arm/include/asm/suspend.h +2 -0
@@ -7,6 +7,8 @@int host_system_suspend (void ); +void hyp_resume (void ); +#endif /* CONFIG_SYSTEM_SUSPEND */ #endif /* __ASM_ARM_SUSPEND_H__ */
xen/arch/arm/psci.c +22 -1
@@ -17,17 +17,20 @@#include <asm/cpufeature.h> #include <asm/psci.h> #include <asm/acpi.h> +#include <asm/suspend.h> /* * While a 64-bit OS can make calls with SMC32 calling conventions, for * some calls it is necessary to use SMC64 to pass or return 64-bit values. -* For such calls PSCI_0_2_FN_NATIVE(x) will choose the appropriate +* For such calls PSCI_*_FN_NATIVE(x) will choose the appropriate * (native-width) function ID. */ #ifdef CONFIG_ARM_64 #define PSCI_0_2_FN_NATIVE (name) PSCI_0_2_FN64_##name +#define PSCI_1_0_FN_NATIVE (name) PSCI_1_0_FN64_##name#else #define PSCI_0_2_FN_NATIVE (name) PSCI_0_2_FN32_##name +#define PSCI_1_0_FN_NATIVE (name) PSCI_1_0_FN32_##name#endif uint32_t psci_ver;
@@ -60,6 +63,24 @@ void call_psci_cpu_off(void) } } +int call_psci_system_suspend (void ) +{ +#ifdef CONFIG_SYSTEM_SUSPEND +struct arm_smccc_res res; + +if ( psci_ver <PSCI_VERSION (1 ,0 ) ) +return PSCI_NOT_SUPPORTED ; + +/* 2nd argument (context ID) is not used */ +arm_smccc_smc (PSCI_1_0_FN_NATIVE (SYSTEM_SUSPEND ),__pa (hyp_resume), &res); +return PSCI_RET (res); +#else +dprintk (XENLOG_WARNING , +"SYSTEM_SUSPEND not supported (CONFIG_SYSTEM_SUSPEND disabled)\n" ); +return PSCI_NOT_SUPPORTED ; +#endif +} +void call_psci_system_off (void ) {if ( psci_ver >PSCI_VERSION (0 ,1 ) )
xen/arch/arm/suspend.c +5 -0
@@ -1,5 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ +#include <asm/psci.h> #include <xen/console.h> #include <xen/cpu.h> #include <xen/sched.h>
@@ -70,6 +71,10 @@ static long system_suspend(void *data)*/ update_boot_mapping (true); + status =call_psci_system_suspend (); +if ( status ) +dprintk (XENLOG_WARNING ,"PSCI system suspend failed, err=%d\n" , status); + system_state = SYS_STATE_resume;update_boot_mapping (false);
Signature · 1 line
2.48.1
PATCH v4 9/10 xen/arm: Resume memory management on Xen resume
In reply to Mykola KvachFrom: Mirela Simonovic <[email protected]>
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. Before the MMU is enabled, the content of TTBR0_EL2 is changed to point to init_ttbr (page tables used at runtime).
On boot, init_ttbr is normally initialized during secondary CPU hotplug. On uniprocessor systems, this would leave init_ttbr uninitialized, causing resume to fail. To address this, the boot CPU now sets init_ttbr during suspend.
---
Changes in v4:
- Drop unnecessary DAIF masking; interrupts are already masked on resume
- Remove leftover TLB flush instructions; flushing is done in enable_mmu
- Avoid setting x19 in hyp_resume; not needed
- Replace prepare_secondary_mm with set_init_ttbr; call it from system_suspend
Changes in v3:
- Update commit message for clarity
- Replace create_page_tables, enable_mmu, and mmu_init_secondary_cpu with enable_secondary_cpu_mm
- Move prepare_secondary_mm to start_xen to avoid crash
- Add early UART init during resume
Changes in v2:
- Move hyp_resume to head.S to keep resume logic together
- Simplify hyp_resume using existing helpers: check_cpu_mode, cpu_init, create_page_tables, enable_mmu
--- xen/arch/arm/arm64/head.S | 16 ++++++++++++++++ xen/arch/arm/include/asm/mm.h | 2 ++ xen/arch/arm/mmu/smpboot.c | 2 +- xen/arch/arm/suspend.c | 2 ++ 4 files changed, 21 insertions(+), 1 deletion(-)
xen/arch/arm/arm64/head.S +16 -0
@@ -564,6 +564,22 @@ END(efi_xen_start) #ifdef CONFIG_SYSTEM_SUSPEND FUNC(hyp_resume) + /* 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)
xen/arch/arm/include/asm/mm.h +2 -0
@@ -363,6 +363,8 @@ static inline void page_set_xenheap_gfn(struct page_info *p, gfn_t gfn) } while ( (y = cmpxchg(&p->u.inuse.type_info, x, nx)) != x ); } +void set_init_ttbr (lpae_t *root); +#endif /* __ARCH_ARM_MM__ */ /* * Local variables:
xen/arch/arm/mmu/smpboot.c +1 -1
@@ -72,7 +72,7 @@ static void clear_boot_pagetables(void)clear_table (boot_third); } -static void set_init_ttbr (lpae_t *root) +void set_init_ttbr (lpae_t *root) {/* * init_ttbr is part of the identity mapping which is read-only. So
xen/arch/arm/suspend.c +2 -0
@@ -65,6 +65,8 @@ static long system_suspend(void *data) goto resume_console; } +set_init_ttbr (xen_pgtable); +/* * Enable identity mapping before entering suspend to simplify * the resume path
Signature · 1 line
2.48.1
PATCH v4 10/10 xen/arm: Save/restore context on suspend/resume
In reply to Mykola KvachFrom: Mirela Simonovic <[email protected]>
The context of CPU general purpose and system control registers has to be saved on suspend and restored on resume. This is implemented in hyp_suspend and before the return from hyp_resume function. The hyp_suspend is invoked just before the PSCI system suspend call is issued to the ATF. The hyp_suspend has to return a non-zero value so that the calling 'if' statement evaluates to true, causing the system suspend to be invoked. Upon the resume, context saved on suspend will be restored, including the link register. Therefore, after restoring the context the control flow will return to the address pointed by the saved link register, which is the place from which the hyp_suspend was called. To ensure that the calling 'if' statement doesn't again evaluate to true and initiate system suspend, hyp_resume has to return a zero value after restoring the context.
Note that the order of saving register context into cpu_context structure has to match the order of restoring.
Support for ARM32 is not implemented. Instead, compilation fails with a build-time error if suspend is enabled for ARM32.
---
Changes in v4:
- produce build-time error for ARM32 when CONFIG_SYSTEM_SUSPEND is enabled
- use register_t instead of uint64_t in cpu_context structure
--- xen/arch/arm/arm64/head.S | 88 +++++++++++++++++++++++++++++- xen/arch/arm/include/asm/suspend.h | 20 +++++++ xen/arch/arm/suspend.c | 23 +++++++- 3 files changed, 127 insertions(+), 4 deletions(-)
xen/arch/arm/arm64/head.S +87 -1
@@ -562,6 +562,52 @@ END(efi_xen_start) #endif /* CONFIG_ARM_EFI */ #ifdef CONFIG_SYSTEM_SUSPEND +/* + * int hyp_suspend(struct cpu_context *ptr) + * + * x0 - pointer to the storage where callee's context will be saved + * + * CPU context saved here will be restored on resume in hyp_resume function. + * hyp_suspend shall return a non-zero value. Upon restoring context + * hyp_resume shall return value zero instead. From C code that invokes + * hyp_suspend, the return value is interpreted to determine whether the context + * is saved (hyp_suspend) or restored (hyp_resume). + */ +FUNC(hyp_suspend) + /* Store callee-saved registers */ + stp x19, x20, [x0], #16 + stp x21, x22, [x0], #16 + stp x23, x24, [x0], #16 + stp x25, x26, [x0], #16 + stp x27, x28, [x0], #16 + stp x29, lr, [x0], #16 + + /* Store stack-pointer */ + mov x2, sp + str x2, [x0], #8 + + /* Store system control registers */ + mrs x2, VBAR_EL2 + str x2, [x0], #8 + mrs x2, VTCR_EL2 + str x2, [x0], #8 + mrs x2, VTTBR_EL2 + str x2, [x0], #8 + mrs x2, TPIDR_EL2 + str x2, [x0], #8 + mrs x2, MDCR_EL2 + str x2, [x0], #8 + mrs x2, HSTR_EL2 + str x2, [x0], #8 + mrs x2, CPTR_EL2 + str x2, [x0], #8 + mrs x2, HCR_EL2 + str x2, [x0], #8 + + /* hyp_suspend must return a non-zero value */ + mov x0, #1 + ret +END(hyp_suspend) FUNC(hyp_resume) /* Initialize the UART if earlyprintk has been enabled. */
@@ -580,7 +626,47 @@ FUNC(hyp_resume) b enable_secondary_cpu_mm mmu_resumed: - b . + /* Now we can access the cpu_context, so restore the context here */ + ldr x0, =cpu_context + + /* Restore callee-saved registers */ + ldp x19, x20, [x0], #16 + ldp x21, x22, [x0], #16 + ldp x23, x24, [x0], #16 + ldp x25, x26, [x0], #16 + ldp x27, x28, [x0], #16 + ldp x29, lr, [x0], #16 + + /* Restore stack pointer */ + ldr x2, [x0], #8 + mov sp, x2 + + /* Restore system control registers */ + ldr x2, [x0], #8 + msr VBAR_EL2, x2 + ldr x2, [x0], #8 + msr VTCR_EL2, x2 + ldr x2, [x0], #8 + msr VTTBR_EL2, x2 + ldr x2, [x0], #8 + msr TPIDR_EL2, x2 + ldr x2, [x0], #8 + msr MDCR_EL2, x2 + ldr x2, [x0], #8 + msr HSTR_EL2, x2 + ldr x2, [x0], #8 + msr CPTR_EL2, x2 + ldr x2, [x0], #8 + msr HCR_EL2, x2 + isb + + /* Since context is restored return from this function will appear as + * return from hyp_suspend. To distinguish a return from hyp_suspend + * which is called upon finalizing the suspend, as opposed to return + * from this function which executes on resume, we need to return zero + * value here. */ + mov x0, #0 + ret END(hyp_resume) #endif /* CONFIG_SYSTEM_SUSPEND */
xen/arch/arm/include/asm/suspend.h +20 -0
@@ -5,9 +5,29 @@#ifdef CONFIG_SYSTEM_SUSPEND +#ifdef CONFIG_ARM_64 +struct cpu_context { +register_t callee_regs[12 ]; +register_t sp; +register_t vbar_el2; +register_t vtcr_el2; +register_t vttbr_el2; +register_t tpidr_el2; +register_t mdcr_el2; +register_t hstr_el2; +register_t cptr_el2; +register_t hcr_el2; +}__aligned(16) ; +#else +#error "Define cpu_context structure for arm32" +#endif + +extern struct cpu_context cpu_context; +int host_system_suspend (void );void hyp_resume (void ); +int hyp_suspend (struct cpu_context *ptr);#endif /* CONFIG_SYSTEM_SUSPEND */
xen/arch/arm/suspend.c +20 -3
@@ -1,6 +1,7 @@/* SPDX-License-Identifier: GPL-2.0-only */ #include <asm/psci.h> +#include <asm/suspend.h> #include <xen/console.h> #include <xen/cpu.h> #include <xen/sched.h>
@@ -17,6 +18,8 @@* - Investigate feasibility and need for implementing system suspend on ARM32 */ +struct cpu_context cpu_context; +/* Xen suspend. Note: data is not used (suspend is the suspend to RAM) */ static long system_suspend (void *data) {
@@ -73,9 +76,23 @@ static long system_suspend(void *data)*/ update_boot_mapping (true); - status =call_psci_system_suspend (); -if ( status ) -dprintk (XENLOG_WARNING ,"PSCI system suspend failed, err=%d\n" , status); +if (hyp_suspend (&cpu_context) ) + { + status =call_psci_system_suspend (); +/* +* If suspend is finalized properly by above system suspend PSCI call, +* the code below in this 'if' branch will never execute. Execution +* will continue from hyp_resume which is the hypervisor's resume point. +* In hyp_resume CPU context will be restored and since link-register is +* restored as well, it will appear to return from hyp_suspend. The +* difference in returning from hyp_suspend on system suspend versus +* resume is in function's return value: on suspend, the return value is +* a non-zero value, on resume it is zero. That is why the control flow +* will not re-enter this 'if' branch on resume. +*/ +if ( status ) +dprintk (XENLOG_WARNING ,"PSCI system suspend failed, err=%d\n" , status); + } system_state = SYS_STATE_resume;update_boot_mapping (false);
Signature · 1 line
2.48.1