[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 6/8] arm/sysctl: Implement cpu hotplug ops
- To: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
- Date: Thu, 13 Nov 2025 17:49:28 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6BTLe24zyhgN7TPU4Vo4apGxqyibwRLw7bikjIC6hT8=; b=Xbgt9ys7RUIqtDMGdjyqCOtDYqLHBjIynjUoRVlQ5UkOyGATcobqJgUo0G47PBRwXWh4jaaAAHpPjIT2sXLs/2J9OswtjxRHT1n+bleWuESRPBLX6tnQi0dG9dOOKpvOWP1UF7gQlpKTa1QCjJd82x2xUbhTyXPuXhezJyVxw7KV+nU66IaruLNYIn85FXEzW4clrhv6B96mjMSVS/qrJTHshKTHK6mQvQta756mxAUZkeXkXIUTRbbSheuTtY7hbzuoro060vHTxQUN25OKcd0veDyMDwIk5TTMZ71/DFcYAJMfuye7l7tUmvyyWbbD81tK3K4nsZ/8vPV9ISixOA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RmTU7y+AjFdRVNhmOD1masQSx3fVQl/SovaNlD5j8MaGJKB3vJZfS2nmCcN7xkgAy2WXueFaqnpVPG5VOLyrN23tUqT5xw2GoOSr6gApCac4D9jZ3r+ozVAfj/sl0MhsSV6Bk2ChGBrLUL+tXsXxn70R57DtYhkcLNf0t4JIq6Zz3y1JxNjugqeP6r3G2mp2n8kkRqMxZ3Qb3Xrw8w2Xv7KVlTCPIc/pR8wn0ekDiy2BbmdoVRzg0Yc1fJOaipT+LU1enF0h499nZUummu8ZwUv5pF21w/yA1vpI2JYzZQIBfHDnA05skfDCUFjLpuvbJw5WhPyGBBgqVsHK32zaww==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
- Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, "Alejandro.GarciaVallejo@xxxxxxx" <Alejandro.GarciaVallejo@xxxxxxx>
- Delivery-date: Thu, 13 Nov 2025 15:49:42 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 12.11.25 12:51, Mykyta Poturai wrote:
Implement XEN_SYSCTL_CPU_HOTPLUG_{ONLINE,OFFLINE} calls to allow for
enabling/disabling CPU cores in runtime.
For now this operations only support Arm64. For proper Arm32 support,
there needs to be a mechanism to free per-cpu page tables, allocated in
init_domheap_mappings.
Also, hotplug is not supported if ITS, FFA, or TEE is enabled, as they
use non-static IRQ actions.
Create a Kconfig option RUNTIME_CPU_CONTROL that reflects this
constraints.
Signed-off-by: Mykyta Poturai <mykyta_poturai@xxxxxxxx>
v3->v4:
* don't reimplement cpu_up/down helpers
* add Kconfig option
* fixup formatting
v2->v3:
* no changes
v1->v2:
* remove SMT ops
* remove cpu == 0 checks
* add XSM hooks
* only implement for 64bit Arm
---
xen/arch/arm/Kconfig | 4 ++++
xen/arch/arm/sysctl.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index cf6af68299..931ae51575 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -274,6 +274,10 @@ config PCI_PASSTHROUGH
help
This option enables PCI device passthrough
+config RUNTIME_CPU_CONTROL
+ def_bool y
+ depends on ARM_64 && !TEE && !FFA && !HAS_ITS
+
Having it in arch code I think right as Arch can have own deps
(Linux does it this way), but name has to be fixed and documented (docs).
may be more common name HOTPLUG_CPU (like in linux)?
naming is up to you.
endmenu
menu "ARM errata workaround via the alternative framework"
diff --git a/xen/arch/arm/sysctl.c b/xen/arch/arm/sysctl.c
index 32cab4feff..3c4e29d82c 100644
--- a/xen/arch/arm/sysctl.c
+++ b/xen/arch/arm/sysctl.c
@@ -12,6 +12,7 @@
#include <xen/dt-overlay.h>
#include <xen/errno.h>
#include <xen/hypercall.h>
+#include <xsm/xsm.h>
#include <asm/arm64/sve.h>
#include <public/sysctl.h>
@@ -23,6 +24,33 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi)
XEN_SYSCTL_PHYSCAP_ARM_SVE_MASK);
}
+static long cpu_hotplug_sysctl(struct xen_sysctl_cpu_hotplug *hotplug)
+{
+#ifdef CONFIG_RUNTIME_CPU_CONTROL
+ int ret;
+
+ switch ( hotplug->op )
+ {
+ case XEN_SYSCTL_CPU_HOTPLUG_ONLINE:
+ ret = xsm_resource_plug_core(XSM_HOOK);
+ if ( ret )
+ return ret;
+ return continue_hypercall_on_cpu(0, cpu_up_helper, _p(hotplug->cpu));
+
+ case XEN_SYSCTL_CPU_HOTPLUG_OFFLINE:
+ ret = xsm_resource_unplug_core(XSM_HOOK);
+ if ( ret )
+ return ret;
+ return continue_hypercall_on_cpu(0, cpu_down_helper, _p(hotplug->cpu));
+
+ default:
+ return -EOPNOTSUPP;
+ }
+#else
+ return -EOPNOTSUPP;
+#endif
+}
+
long arch_do_sysctl(struct xen_sysctl *sysctl,
XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
{
@@ -34,6 +62,10 @@ long arch_do_sysctl(struct xen_sysctl *sysctl,
ret = dt_overlay_sysctl(&sysctl->u.dt_overlay);
break;
+ case XEN_SYSCTL_cpu_hotplug:
+ ret = cpu_hotplug_sysctl(&sysctl->u.cpu_hotplug);
+ break;
+
default:
ret = -ENOSYS;
break;
Common code need to be placed under same config guards.
--
Best regards,
-grygorii
|