|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 11/16] xen/arm: Implement PSCI system suspend
Hi, On 05/03/2025 09:11, Mykola Kvach wrote: From: Mirela Simonovic <mirela.simonovic@xxxxxxxxxx> The implementation consists of: -Adding PSCI system suspend call as new PSCI function -Trapping PSCI system_suspend HVC -Implementing PSCI system suspend call (virtual interface that allows guests to suspend themselves), but currently it is only partially implemented, so suspend/resume will correctly work only for dom0 What is missing for other domains? The PSCI system suspend should be called by a guest from its boot VCPU. Non-boot VCPUs of the guest should be hot-unplugged using PSCI CPU_OFF call prior to issuing PSCI system suspend. Interrupts that are left enabled by the guest are assumed to be its wake-up interrupts. Therefore, a wake-up interrupt triggers the resume of the guest. Guest should resume regardless of the state of Xen (suspended or not). When a guest calls PSCI system suspend the respective domain will be suspended if the following conditions are met: 1) Given resume entry point is not invalid 2) Other (if any) VCPUs of the calling guest are hot-unplugged If the conditions above are met the calling domain is labeled as suspended and the calling VCPU is blocked. If nothing else wouldn't be done the suspended domain would resume from the place where it called PSCI system suspend. This is expected if processing of the PSCI system suspend call fails. However, in the case of success the calling guest should resume (continue execution after the wake-up) from the entry point which is given as the first argument of the PSCI system suspend call. In addition to the entry point, the guest expects to start within the environment whose state matches the state after reset. This means that the guest should find reset register values, MMU disabled, etc. Thereby, the context of VCPU should be 'reset' (as if the system is comming out of reset), the program counter should contain entry point, which is 1st argument, and r0/x0 should contain context ID which is 2nd argument of PSCI system suspend call. The context of VCPU is set accordingly when the PSCI system suspend is processed, so that nothing needs to be done on resume/wake-up path. 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 V3: Dropped all domain flags and related code (which touched common functions like vcpu_unblock), keeping only the necessary changes for Xen suspend/resume, i.e. suspend/resume is now fully supported only for the hardware domain. Proper support for domU suspend/resume will be added in a future patch. This patch does not yet include VCPU context reset or domain context restoration in VCPU. --- xen/arch/arm/Makefile | 1 + xen/arch/arm/include/asm/domain.h | 3 ++ xen/arch/arm/include/asm/perfc_defn.h | 1 + xen/arch/arm/include/asm/psci.h | 2 + xen/arch/arm/include/asm/suspend.h | 18 +++++++ xen/arch/arm/suspend.c | 67 +++++++++++++++++++++++++++ xen/arch/arm/vpsci.c | 32 +++++++++++++ 7 files changed, 124 insertions(+) create mode 100644 xen/arch/arm/include/asm/suspend.h create mode 100644 xen/arch/arm/suspend.c diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 43ab5e8f25..70d4b5daf8 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -53,6 +53,7 @@ obj-y += smpboot.o obj-$(CONFIG_STATIC_EVTCHN) += static-evtchn.init.o obj-$(CONFIG_STATIC_MEMORY) += static-memory.init.o obj-$(CONFIG_STATIC_SHM) += static-shmem.init.o +obj-$(CONFIG_SYSTEM_SUSPEND) += suspend.o I am a bit confused why we are tie guest suspend/resume with system suspend/resume. Shouldn't they be separate?
What's the plan for this? Looking at the code, it doesn't save the value into pc and x0/r0. Instead, it is stashing it into different fields. + vcpu_suspend_prepare(epoint, cid); + + /* Disable watchdogs of this domain */ + watchdog_domain_suspend(d); At least for guests, I was expecting psci_suspend to behave very similarly to domain_shutdown(SHUTDOWN_suspend) so it can be used with "xl suspend/resume". Is there any reason we are diverging? + + /* + * The calling domain is suspended by blocking its last running VCPU. If an + * event is pending the domain will resume right away (VCPU will not block, + * but when scheduled in it will resume from the given entry point). + */ Looking at the code, you don't seem to set x0, pc or even reset the vCPU unless the platform suspend. So are you sure the suspend will work properly if there is an event pending? + vcpu_block_unless_event_pending(current); > +> + return PSCI_SUCCESS; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/arm/vpsci.c b/xen/arch/arm/vpsci.c index d1615be8a6..96eef06c18 100644 --- a/xen/arch/arm/vpsci.c +++ b/xen/arch/arm/vpsci.c @@ -7,6 +7,7 @@ #include <asm/vgic.h> #include <asm/vpsci.h> #include <asm/event.h> +#include <asm/suspend.h>#include <public/sched.h> @@ -197,6 +198,15 @@ static void do_psci_0_2_system_reset(void) I don't understand the comment. Below, you will set "ret" only if the call doesn't return SUCCESS. Also, coding style: /* * Foo ... * Bar ... */ + * Otherwise preserve the context_id in x0. For now Per above, I don't think this is correct. + * we don't support the case where the system is suspended + * to a shallower level and PSCI_SUCCESS is returned to the + * caller. I am confused. Per the specification, PSCI_SYSTEM_SUSPEND cannot return PSCI_SUCCESS if the call is successful. Any chance you are confusing with CPU_SUSPEND? Cheers, -- Julien Grall
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |