Message ID | 3c5ec1f22e9ae6bac7ee98f63a0a700d7c3ec11f.1665137247.git.mykyta_poturai@epam.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/19] xen/arm: Implement PSCI system suspend | expand |
Hi, On 07/10/2022 11:32, Mykyta Poturai wrote: > From: Mirela Simonovic <mirela.simonovic@aggios.com> > > PSCI system suspend function shall be invoked to finalize Xen suspend > procedure. Resume entry point, which needs to be passed via 1st argument > of PSCI system suspend call to the EL3, is hyp_resume. For now, hyp_resume > is just a placeholder that will be implemented in assembly. Context ID, > which is 2nd argument of system suspend PSCI call, is unused, as in Linux. > > Update: moved hyp_resume to head.S to place it near the rest of the > start code > > Signed-off-by: Mirela Simonovic <mirela.simonovic@aggios.com> > Signed-off-by: Saeed Nowshadi <saeed.nowshadi@xilinx.com> > Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com> > --- > xen/arch/arm/arm64/head.S | 3 +++ > xen/arch/arm/psci.c | 16 ++++++++++++++++ > xen/arch/arm/suspend.c | 4 ++++ > xen/include/asm-arm/psci.h | 1 + > xen/include/asm-arm/suspend.h | 1 + > 5 files changed, 25 insertions(+) > > diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S > index aa1f88c764..8857955699 100644 > --- a/xen/arch/arm/arm64/head.S > +++ b/xen/arch/arm/arm64/head.S > @@ -957,6 +957,9 @@ ENTRY(efi_xen_start) > b real_start_efi > ENDPROC(efi_xen_start) > > +ENTRY(hyp_resume) > + b . This needs to be part of the idmap. At the moment, this will only cover up to _end_boot. > + > /* > * Local variables: > * mode: ASM > diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c > index 0c90c2305c..43a67eb345 100644 > --- a/xen/arch/arm/psci.c > +++ b/xen/arch/arm/psci.c > @@ -25,6 +25,7 @@ > #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 > @@ -68,6 +69,21 @@ void call_psci_cpu_off(void) > } > } > > +int call_psci_system_suspend(void) > +{ > +#ifdef CONFIG_ARM_64 > + struct arm_smccc_res res; > + > + /* 2nd argument (context ID) is not used */ > + arm_smccc_smc(PSCI_1_0_FN64_SYSTEM_SUSPEND, __pa(hyp_resume), &res); > + > + return PSCI_RET(res); > +#else > + /* not supported */ > + return 1; > +#endif > +} > + > void call_psci_system_off(void) > { > if ( psci_ver > PSCI_VERSION(0, 1) ) > diff --git a/xen/arch/arm/suspend.c b/xen/arch/arm/suspend.c > index 05c43ce502..a0258befc9 100644 > --- a/xen/arch/arm/suspend.c > +++ b/xen/arch/arm/suspend.c > @@ -161,6 +161,10 @@ static long system_suspend(void *data) > goto resume_irqs; > } > > + status = call_psci_system_suspend(); > + if ( status ) > + dprintk(XENLOG_ERR, "PSCI system suspend failed, err=%d\n", status); > + > system_state = SYS_STATE_resume; > > gic_resume(); > diff --git a/xen/include/asm-arm/psci.h b/xen/include/asm-arm/psci.h > index 26462d0c47..9f6116a224 100644 > --- a/xen/include/asm-arm/psci.h > +++ b/xen/include/asm-arm/psci.h > @@ -20,6 +20,7 @@ extern uint32_t psci_ver; > > int psci_init(void); > int call_psci_cpu_on(int cpu); > +int call_psci_system_suspend(void); > void call_psci_cpu_off(void); > void call_psci_system_off(void); > void call_psci_system_reset(void); > diff --git a/xen/include/asm-arm/suspend.h b/xen/include/asm-arm/suspend.h > index fbaa414f0c..29420e27fa 100644 > --- a/xen/include/asm-arm/suspend.h > +++ b/xen/include/asm-arm/suspend.h > @@ -3,6 +3,7 @@ > > int32_t domain_suspend(register_t epoint, register_t cid); > void vcpu_resume(struct vcpu *v); > +void hyp_resume(void); > > #endif > Cheers,
diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index aa1f88c764..8857955699 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -957,6 +957,9 @@ ENTRY(efi_xen_start) b real_start_efi ENDPROC(efi_xen_start) +ENTRY(hyp_resume) + b . + /* * Local variables: * mode: ASM diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c index 0c90c2305c..43a67eb345 100644 --- a/xen/arch/arm/psci.c +++ b/xen/arch/arm/psci.c @@ -25,6 +25,7 @@ #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 @@ -68,6 +69,21 @@ void call_psci_cpu_off(void) } } +int call_psci_system_suspend(void) +{ +#ifdef CONFIG_ARM_64 + struct arm_smccc_res res; + + /* 2nd argument (context ID) is not used */ + arm_smccc_smc(PSCI_1_0_FN64_SYSTEM_SUSPEND, __pa(hyp_resume), &res); + + return PSCI_RET(res); +#else + /* not supported */ + return 1; +#endif +} + void call_psci_system_off(void) { if ( psci_ver > PSCI_VERSION(0, 1) ) diff --git a/xen/arch/arm/suspend.c b/xen/arch/arm/suspend.c index 05c43ce502..a0258befc9 100644 --- a/xen/arch/arm/suspend.c +++ b/xen/arch/arm/suspend.c @@ -161,6 +161,10 @@ static long system_suspend(void *data) goto resume_irqs; } + status = call_psci_system_suspend(); + if ( status ) + dprintk(XENLOG_ERR, "PSCI system suspend failed, err=%d\n", status); + system_state = SYS_STATE_resume; gic_resume(); diff --git a/xen/include/asm-arm/psci.h b/xen/include/asm-arm/psci.h index 26462d0c47..9f6116a224 100644 --- a/xen/include/asm-arm/psci.h +++ b/xen/include/asm-arm/psci.h @@ -20,6 +20,7 @@ extern uint32_t psci_ver; int psci_init(void); int call_psci_cpu_on(int cpu); +int call_psci_system_suspend(void); void call_psci_cpu_off(void); void call_psci_system_off(void); void call_psci_system_reset(void); diff --git a/xen/include/asm-arm/suspend.h b/xen/include/asm-arm/suspend.h index fbaa414f0c..29420e27fa 100644 --- a/xen/include/asm-arm/suspend.h +++ b/xen/include/asm-arm/suspend.h @@ -3,6 +3,7 @@ int32_t domain_suspend(register_t epoint, register_t cid); void vcpu_resume(struct vcpu *v); +void hyp_resume(void); #endif