[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v4 6/8] arm/sysctl: Implement cpu hotplug ops


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>
  • Date: Wed, 12 Nov 2025 10:51:48 +0000
  • Accept-language: en-US
  • 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=RK3xjJT1/m7h8Eiq8scWUKysHO6uL/FasxMvbQpKdSo=; b=tjeCWW4PqlQHCqLy1MnansX6f+goo0eWfOj/q1YwjTxcs+L4JJkgOq22lfmBAf2dIRVi5Sj7E9wgS6kmu+QuVpLICCp1FOrOuVWtOkKugguQuYWNpIHZhuwjw5fZVmWbE/MCjjx8HZieHziwgc7Hzz9LHXZD2eQy25zVwD3T0jK0tsfyL+xuTsBfBhicfgPLwqQZQnjDA2lQw/QkBolhNdo+9oCTG2A3Bsu096Q36OnwlpRO/kSXEEdkbwYcuYeyT+FR+yBC8Rb3c5SPRuAF11VmWKVUmh3oPn+hy/ksjhFTSkperMH0icM7aoRgVVEmIRObWIdAJP/qMJGvp3fciQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=unIW4zEC0wHFFctVtNHkc+oWco2vI6W1nDkCgucoqWIbUAiS/besPfKUvjccDuve2aCAulbtwn6GrMz9f56y29H5DbdpwemPUMsSZSoGkXiqa1U8hScPDIGEKhP5OoZm+HK6qB3MdWdPtX9lj3wgHWAtDgpEItkiUjuOXNQycpv6F3s0Rkm8wblBETqRrxFJvcNIkzh+pqsCzDsAerMA++SrRyvQsF490F0tYqCJ8e/bhC46IADilpm4iP0l3Ffa1XV1u4D1nLSpZpZpG8wc82ytRPff8q2jIBdnnEpPl613lQG2vSmWrE2lL55B/5Ld9jIv3GEErPSwUZye/HhQiw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>, 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>
  • Delivery-date: Wed, 12 Nov 2025 10:51:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcU8JY4MUEJP5v5ECe3RrLj+fwXw==
  • Thread-topic: [PATCH v4 6/8] arm/sysctl: Implement cpu hotplug ops

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
+
 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;
-- 
2.51.2



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.