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

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



Hi,

On 12/11/2025 10: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
+
  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)

As you moved the helper in common code. I was expecting the logic to handle CPU_HOTPLUG_ONLINE and CPU_HOTPLUG_OFFLINE to also move in common. Can you explain why this wasn't done?

+{
+#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;

Cheers,

--
Julien Grall




 


Rackspace

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