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

[PATCH] x86/domctl: Conditionalise x86 domctl using DCE rather than ifdef


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
  • Date: Tue, 10 Feb 2026 16:10:06 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=NIngIZTcnXGIxQjeT4SDwU/7/bqa+59yxS7k6+duN9A=; b=uXBWNk1wVTqKbwwzV/nXkQwDx+aa8af0SMY6X+sj5i8dXRwWSP+m1vqqQDR8IKwoFbpOS5HMxtm3HYBId7iPpKIEdppzB7BsVImcPFGcwS+H1nJmgoXZ8YHArWUrkXlVaqUPbw84TbREzdxerMGzd+rpBWrGLHCd0OTEm82JWK1DSD0uTPPW7jR/u8z/dR4iz0RPod4VbXaDE8RUk3+BZs7hCKPo831gROe7YeSb7PKU95raW3QU4Mqt/W6sOUeRYPaB/tzgRyiuhetaLiyHxJV7FItz+ni6GT+2Bty5IQVi1y4b67f35IZqLTX5MbKxBZ9gOui9oSvBKXlcYi7yXQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fgOgGCHjAjL/ADprDYcQ+DgDWKYMjJ1j6VkuWUE/IvP9F13vlarRs3RuSWp7E1Zhs0kDa4RhAABI6j0Adn7JaqEmRUElfGNH92ecUre0qMz9LQxgGIOZ2EsJin5VF7GTScxYN6ow2/fhkDqZNWEgrXuwzyHWvj+u8KWKmH1UfUVHBMNru0CrZwCczf8paX8yxFIkGdn3umbD9wTSXCsjtPupL7Quc0vTO4skPaouHJ3evJ5TWpx4ZSMezSPUEExKVnk7E7erxZ13ydhoef6Eke0A1pQhD7htTmhzkgJwuIOoJhdEIHidG15d+UV/rJV4NVLFtOr5WoKyLfxriHV/Dw==
  • Cc: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 10 Feb 2026 15:10:29 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Make them uniformly return EOPNOTSUPP when their dependent features
are absent. Otherwise the compiler loses context and they might return
ENOSYS instead.

debug_op, mem_sharing_op and psr_alloc change behaviour and return
EOPNOTSUPP when compiled out, rather than ENOSYS.

While at it, remove the public headers from mem_sharing.h (forward
declarations are fine) and add a missing xen/sched.h include (for
complete struct domain definition).

Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
---
 xen/arch/x86/domctl.c                  | 27 +++++++++++++++-----------
 xen/arch/x86/include/asm/mem_sharing.h | 11 +++++++----
 2 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index d9521808dc..7066a18735 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -220,15 +220,15 @@ long arch_do_domctl(
     {
 
     case XEN_DOMCTL_shadow_op:
-#ifdef CONFIG_PAGING
+        ret = -EOPNOTSUPP;
+        if ( !IS_ENABLED(CONFIG_PAGING) )
+            break;
+
         ret = paging_domctl(d, &domctl->u.shadow_op, u_domctl, 0);
         if ( ret == -ERESTART )
             return hypercall_create_continuation(
                        __HYPERVISOR_paging_domctl_cont, "h", u_domctl);
         copyback = true;
-#else
-        ret = -EOPNOTSUPP;
-#endif
         break;
 
     case XEN_DOMCTL_ioport_permission:
@@ -842,11 +842,14 @@ long arch_do_domctl(
         }
         break;
 
-#ifdef CONFIG_HVM
     case XEN_DOMCTL_debug_op:
     {
         struct vcpu *v;
 
+        ret = -EOPNOTSUPP;
+        if ( !IS_ENABLED(CONFIG_HVM) )
+            break;
+
         ret = -EINVAL;
         if ( (domctl->u.debug_op.vcpu >= d->max_vcpus) ||
              ((v = d->vcpu[domctl->u.debug_op.vcpu]) == NULL) )
@@ -860,7 +863,6 @@ long arch_do_domctl(
         ret = hvm_debug_op(v, domctl->u.debug_op.op);
         break;
     }
-#endif
 
     case XEN_DOMCTL_gdbsx_guestmemio:
     case XEN_DOMCTL_gdbsx_pausevcpu:
@@ -1033,11 +1035,13 @@ long arch_do_domctl(
         break;
     }
 
-#ifdef CONFIG_MEM_SHARING
     case XEN_DOMCTL_mem_sharing_op:
+        ret = -EOPNOTSUPP;
+        if ( !IS_ENABLED(CONFIG_MEM_SHARING) )
+            break;
+
         ret = mem_sharing_domctl(d, &domctl->u.mem_sharing_op);
         break;
-#endif
 
 #if P2M_AUDIT
     case XEN_DOMCTL_audit_p2m:
@@ -1240,9 +1244,12 @@ long arch_do_domctl(
         break;
 
     case XEN_DOMCTL_psr_alloc:
+        ret = -EOPNOTSUPP;
+        if ( IS_ENABLED(CONFIG_X86_PSR) )
+            break;
+
         switch ( domctl->u.psr_alloc.cmd )
         {
-#ifdef CONFIG_X86_PSR
         case XEN_DOMCTL_PSR_SET_L3_CBM:
             ret = psr_set_val(d, domctl->u.psr_alloc.target,
                               domctl->u.psr_alloc.data,
@@ -1305,8 +1312,6 @@ long arch_do_domctl(
 
 #undef domctl_psr_get_val
 
-#endif /* CONFIG_X86_PSR */
-
         default:
             ret = -EOPNOTSUPP;
             break;
diff --git a/xen/arch/x86/include/asm/mem_sharing.h 
b/xen/arch/x86/include/asm/mem_sharing.h
index 040962f690..7ee783fde8 100644
--- a/xen/arch/x86/include/asm/mem_sharing.h
+++ b/xen/arch/x86/include/asm/mem_sharing.h
@@ -9,8 +9,13 @@
 #ifndef __MEM_SHARING_H__
 #define __MEM_SHARING_H__
 
-#include <public/domctl.h>
-#include <public/memory.h>
+#include <xen/sched.h>
+
+struct xen_domctl_mem_sharing_op;
+struct xen_mem_sharing_op;
+
+int mem_sharing_domctl(struct domain *d,
+                       struct xen_domctl_mem_sharing_op *mec);
 
 #ifdef CONFIG_MEM_SHARING
 
@@ -92,8 +97,6 @@ int mem_sharing_fork_reset(struct domain *d, bool reset_state,
 int mem_sharing_notify_enomem(struct domain *d, unsigned long gfn,
                               bool allow_sleep);
 int mem_sharing_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_sharing_op_t) arg);
-int mem_sharing_domctl(struct domain *d,
-                       struct xen_domctl_mem_sharing_op *mec);
 
 /*
  * Scans the p2m and relinquishes any shared pages, destroying

base-commit: 2fa468919c39aac189623b6c580ce4ff8592d799
-- 
2.43.0




 


Rackspace

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