[PATCH v2 12/26] xen/domctl: wrap vcpu_affinity_domctl() with CONFIG_MGMT_HYPERCALLS

Penny Zheng posted 26 patches 3 days, 22 hours ago
[PATCH v2 12/26] xen/domctl: wrap vcpu_affinity_domctl() with CONFIG_MGMT_HYPERCALLS
Posted by Penny Zheng 3 days, 22 hours ago
Function vcpu_affinity_domctl() is responsible for
XEN_DOMCTL_{getvcpuaffinity,setvcpuaffinity} domctl-op, and shall be
wrapped with CONFIG_MGMT_HYPERCALLS.
Tracking its calling chain, the following function shall be wrapped with
CONFIG_MGMT_HYPERCALLS too:
- vcpu_set_soft_affinity
Wrap XEN_DOMCTL_{getvcpuaffinity,setvcpuaffinity}-case transiently with
CONFIG_MGMT_HYPERCALLS, and it will be removed when introducing
CONFIG_MGMT_HYPERCALLS on the common/domctl.c in the last.

Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>
---
v1 -> v2:
- adapt to changes of "unify DOMCTL to MGMT_HYPERCALLS"
- wrap XEN_DOMCTL_{getvcpuaffinity,setvcpuaffinity}-case transiently
---
 xen/common/domctl.c     | 2 ++
 xen/common/sched/core.c | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index fb6fe90888..4a35c17060 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -515,10 +515,12 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
                                         &d->node_affinity);
         break;
 
+#ifdef CONFIG_MGMT_HYPERCALLS
     case XEN_DOMCTL_setvcpuaffinity:
     case XEN_DOMCTL_getvcpuaffinity:
         ret = vcpu_affinity_domctl(d, op->cmd, &op->u.vcpuaffinity);
         break;
+#endif /* CONFIG_MGMT_HYPERCALLS */
 
     case XEN_DOMCTL_scheduler_op:
         ret = sched_adjust(d, &op->u.scheduler_op);
diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index a0faddcb92..69972147db 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -1402,10 +1402,12 @@ int vcpu_set_hard_affinity(struct vcpu *v, const cpumask_t *affinity)
     return vcpu_set_affinity(v, affinity, v->sched_unit->cpu_hard_affinity);
 }
 
+#ifdef CONFIG_MGMT_HYPERCALLS
 static int vcpu_set_soft_affinity(struct vcpu *v, const cpumask_t *affinity)
 {
     return vcpu_set_affinity(v, affinity, v->sched_unit->cpu_soft_affinity);
 }
+#endif /* CONFIG_MGMT_HYPERCALLS */
 
 /* Block the currently-executing domain until a pertinent event occurs. */
 void vcpu_block(void)
@@ -1693,6 +1695,7 @@ int vcpuaffinity_params_invalid(const struct xen_domctl_vcpuaffinity *vcpuaff)
             guest_handle_is_null(vcpuaff->cpumap_soft.bitmap));
 }
 
+#ifdef CONFIG_MGMT_HYPERCALLS
 int vcpu_affinity_domctl(struct domain *d, uint32_t cmd,
                          struct xen_domctl_vcpuaffinity *vcpuaff)
 {
@@ -1802,6 +1805,7 @@ int vcpu_affinity_domctl(struct domain *d, uint32_t cmd,
 
     return ret;
 }
+#endif /* CONFIG_MGMT_HYPERCALLS */
 
 bool alloc_affinity_masks(struct affinity_masks *affinity)
 {
-- 
2.34.1
Re: [PATCH v2 12/26] xen/domctl: wrap vcpu_affinity_domctl() with CONFIG_MGMT_HYPERCALLS
Posted by Jan Beulich 3 days, 14 hours ago
On 10.09.2025 09:38, Penny Zheng wrote:
> --- a/xen/common/sched/core.c
> +++ b/xen/common/sched/core.c
> @@ -1402,10 +1402,12 @@ int vcpu_set_hard_affinity(struct vcpu *v, const cpumask_t *affinity)
>      return vcpu_set_affinity(v, affinity, v->sched_unit->cpu_hard_affinity);
>  }
>  
> +#ifdef CONFIG_MGMT_HYPERCALLS
>  static int vcpu_set_soft_affinity(struct vcpu *v, const cpumask_t *affinity)
>  {
>      return vcpu_set_affinity(v, affinity, v->sched_unit->cpu_soft_affinity);
>  }
> +#endif /* CONFIG_MGMT_HYPERCALLS */

Again preferable to get away with just a single #ifdef (i.e. ...

> @@ -1693,6 +1695,7 @@ int vcpuaffinity_params_invalid(const struct xen_domctl_vcpuaffinity *vcpuaff)
>              guest_handle_is_null(vcpuaff->cpumap_soft.bitmap));
>  }
>  
> +#ifdef CONFIG_MGMT_HYPERCALLS

... this one) here. In fact I question the value of the helper: It has
a single caller, so what the helper does could easily be expanded at
the sole call site ...

>  int vcpu_affinity_domctl(struct domain *d, uint32_t cmd,
>                           struct xen_domctl_vcpuaffinity *vcpuaff)
>  {

... below from here.

Jan