From nobody Fri Oct 31 03:56:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1754945364; cv=none; d=zohomail.com; s=zohoarc; b=CqW8IJm/WZ5ZMYVCt9WbbRMbdaDfCBM5CXZSmqpHR0NEfPYxBfMajpBK2barI/kEfmztsikvtfCGTUcu0/GV9OqA5qreqCWJuyZ2+95kB2SUUWGv841Ay8ba0FHUEvUrkUurOCluB+rsBNP4cTlYDrKm3z3QjGj5BWn8JPsdwww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754945364; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WV3I3iVcTMMqNyOJNyQt08YG5fWdAf6qVI+oDW1WgEk=; b=flhKzc7rXUYeOvFJoVXG9iY9mxf/ytttG+KqxW/3NCJjw630Ia/rxRT6H1akwLB1api6VY7/jKe802C9nvBgKvnFa7qdGdLksr1crgex4O6agcRpIwXhwFO+UaSz0S001Vo246akvzwM/ecJdwv10TkcYvmWc6dOpr5sxreKmdY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1754945364765838.0920469655823; Mon, 11 Aug 2025 13:49:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1077954.1439025 (Exim 4.92) (envelope-from ) id 1ulZS5-0007qA-7B; Mon, 11 Aug 2025 20:49:05 +0000 Received: by outflank-mailman (output) from mailman id 1077954.1439025; Mon, 11 Aug 2025 20:49:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ulZS5-0007po-1j; Mon, 11 Aug 2025 20:49:05 +0000 Received: by outflank-mailman (input) for mailman id 1077954; Mon, 11 Aug 2025 20:49:03 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ulZS3-0005co-Io for xen-devel@lists.xenproject.org; Mon, 11 Aug 2025 20:49:03 +0000 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [2a00:1450:4864:20::631]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9c916888-76f4-11f0-a327-13f23c93f187; Mon, 11 Aug 2025 22:49:02 +0200 (CEST) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-af9a25f091fso642644066b.0 for ; Mon, 11 Aug 2025 13:49:02 -0700 (PDT) Received: from yp-VivoBook-ASUSLaptop-M1503QA-M1503QA.Dlink ([77.52.179.38]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-af91a0a3bd2sm2065710466b.54.2025.08.11.13.48.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Aug 2025 13:49:00 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 9c916888-76f4-11f0-a327-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754945341; x=1755550141; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WV3I3iVcTMMqNyOJNyQt08YG5fWdAf6qVI+oDW1WgEk=; b=cKJuw1XecDJZ8r3iZ/XGO0iRRYWQOExemJyAASxe95qw/V3a39O5JPFAzCaaSWCbVV p6gMtcI6aqhv97XcLr5Astq1zgLzyvO+b7K/TZzKVEo5VKecuDtGVfJ31NAgZ694XdwI oS5+rR8Muz1czrdCLOGrIb/67NJaymkPpuSVETaQnU+Fre9GCkX/7cmrp36s0BIzrZTk YwexBTOk2DYu22R4wkqFwHsUqXgtRAZusYYdxK5yKuvIMpy8kX/paXGK+/gKPEhb1hAU oydJJqy6mvNOVoaxzKeNLzmk8K8uwkJ16ugTc2mhGEW1Qdj/EGSOUlmLXDIQXUG4vIW4 XveA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754945341; x=1755550141; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WV3I3iVcTMMqNyOJNyQt08YG5fWdAf6qVI+oDW1WgEk=; b=L4B6LUv6b5/9x7XKwuzt+qaMjHl4TKK7dbgxjkmZb4bi/NHa1FHZGsJ8ocdiIU20WY 8hLQXxZizGan030sTfWgIYnAe7X7+JKn5SO2TMclofmuxdXNVCtziCZYX211cBty8EDH GoePd2d6xf1kXXivSXA3/IF7e7xpXLWq1jgTT7MS3mjjYcYy4INUtwXF1Ff3M/nxYLgh zL8BXCYtGUHhXXmbmWIPGKUhzi1BainhSOIX46cMr7p4qlfeoS/u0hdldlOdlaUm5KKl 4n+RW/g6nAyvByALCpys7f6xW9l3K9W+PdY5iVY0JB4/rSaV3aXEY1TkPYISbswG/+yE qQKg== X-Gm-Message-State: AOJu0Yxewy7hGe3ExZSzk7GlO7UPQao++YTypEbDvnvGOyTMTfR7z7XE JCHOMADFwc9YrKlFhWN/T8nVLW7ZkEBp6CqFwMH2QRMiiLhAZMFkZNbKEsrpNg== X-Gm-Gg: ASbGncuao7HGlF4Qa3XsxbGPsyBvDRKawS8L5z7iCaTURDnGWVNf79YQxkDGS9d07xS XeUxJv2uAsZ+r/d9jqQMCziRc86EwIOPzf26E6NAxnwGupjYGz2U2FcKTjCaVvDw4x3mvfOFXh0 SQLx5vDTydr3+H3Rwoqe/qCxLLtO8N7eAZ3NFfSMwJHc0+i4VGOyR1F3RtARB9Y7Y0VcUjRHn+5 cNWcWvjJJv+lFikjobhYd8/oEUob5t/CPa/ce3LMrA2EkCyuqtx9qBWhvAIhpA/WPIIudsxjhYy hCM6ZC+OzYvSl1Je2XSfHd1fVgc0BNXeHyRncNtxgUKKcPjWK2eZ6EIoY26lvpMNWqaY3MLNApA eQshwr3ypTCvk7jq02ajNPOEkF5sZsRTB2QJfXQMTdo8rdPlCJqln2gYI/DENW1MhfCk= X-Google-Smtp-Source: AGHT+IH8tgHqjKRy9ou+a/j6Sb5A7FZAPXUwRxtrBIzlXSCp55Ks+Gv58Suvi0Zmu2sioQAf9PPhBQ== X-Received: by 2002:a17:907:3dab:b0:adf:7740:9284 with SMTP id a640c23a62f3a-afa1e13bccemr83193966b.57.1754945340811; Mon, 11 Aug 2025 13:49:00 -0700 (PDT) From: Mykola Kvach To: xen-devel@lists.xenproject.org Cc: Mirela Simonovic , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Saeed Nowshadi , Mykyta Poturai , Mykola Kvach Subject: [PATCH v5 08/12] xen/arm: Implement PSCI SYSTEM_SUSPEND call (host interface) Date: Mon, 11 Aug 2025 23:48:04 +0300 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1754945366757116600 Content-Type: text/plain; charset="utf-8" From: Mirela Simonovic Invoke PSCI SYSTEM_SUSPEND to finalize Xen's suspend sequence on ARM64 plat= forms. 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. Igno= re the context ID argument, as is done in Linux. Only enable this path when CONFIG_SYSTEM_SUSPEND is set and PSCI version is >=3D 1.0. Signed-off-by: Mirela Simonovic Signed-off-by: Saeed Nowshadi Signed-off-by: Mykyta Poturai Signed-off-by: Mykola Kvach --- Changes in v4: - select the appropriate PSCI SYSTEM_SUSPEND function ID based on platform - 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_s= uspend --- 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(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 72c7b24498..3522c497c5 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -561,6 +561,14 @@ END(efi_xen_start) =20 #endif /* CONFIG_ARM_EFI */ =20 +#ifdef CONFIG_SYSTEM_SUSPEND + +FUNC(hyp_resume) + b . +END(hyp_resume) + +#endif /* CONFIG_SYSTEM_SUSPEND */ + /* * Local variables: * mode: ASM diff --git a/xen/arch/arm/include/asm/psci.h b/xen/arch/arm/include/asm/psc= i.h index 48a93e6b79..bb3c73496e 100644 --- a/xen/arch/arm/include/asm/psci.h +++ b/xen/arch/arm/include/asm/psci.h @@ -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); =20 /* Range of allocated PSCI function numbers */ #define PSCI_FNUM_MIN_VALUE _AC(0,U) diff --git a/xen/arch/arm/include/asm/suspend.h b/xen/arch/arm/include/asm/= suspend.h index 78d0e2383b..55041a5d06 100644 --- a/xen/arch/arm/include/asm/suspend.h +++ b/xen/arch/arm/include/asm/suspend.h @@ -7,6 +7,8 @@ =20 int host_system_suspend(void); =20 +void hyp_resume(void); + #endif /* CONFIG_SYSTEM_SUSPEND */ =20 #endif /* __ASM_ARM_SUSPEND_H__ */ diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c index b6860a7760..c9d126b195 100644 --- a/xen/arch/arm/psci.c +++ b/xen/arch/arm/psci.c @@ -17,17 +17,20 @@ #include #include #include +#include =20 /* * 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 =20 uint32_t psci_ver; @@ -60,6 +63,24 @@ void call_psci_cpu_off(void) } } =20 +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), &r= es); + 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) ) diff --git a/xen/arch/arm/suspend.c b/xen/arch/arm/suspend.c index abf4b928ce..11e86b7f51 100644 --- a/xen/arch/arm/suspend.c +++ b/xen/arch/arm/suspend.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ =20 +#include #include #include #include @@ -70,6 +71,10 @@ static long system_suspend(void *data) */ update_boot_mapping(true); =20 + status =3D call_psci_system_suspend(); + if ( status ) + dprintk(XENLOG_WARNING, "PSCI system suspend failed, err=3D%d\n", = status); + system_state =3D SYS_STATE_resume; update_boot_mapping(false); =20 --=20 2.48.1