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

[PATCH v1] xen: move getdomaininfo() to domain.c


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Tue, 22 Jul 2025 13:04:10 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=temperror 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=hpJdRphsoJmZDkA9Foxsya8yC/yMG5waBZZcd72Zl44=; b=gFRyfd/HCGFieJUJIy6h3r+MsnXLjMsBOtg1P5ivNzOwAQAMOtqij0RhAZWZNyS5+XB/d/c8fklkOeQRaxhNiz77uO9yoJxizdWZcdAwMlWpW++1aI0t+DLwyNsf1xx+bGHRbimgBVQ+Pj9KI3wsm7qOjijW/dYoG7C6rfGwEzrHtynKFZA8eTR1/BhmRiXEWw4ZQ4UCXiDm11BSqW2/F0tZXlLRlWo0jUhYhcG9bElhGjwpRHPToBfXigq8Oc5b/WjpZdEMiobSKa87epqLpYXTIcw8pvcMKBVaqXZtMYMLiQx6E3GMZBSYmBlqDW5oYZXc5mqvMT9qWJltWui5jw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Xd1ELJBMuzCCD9TaciiQsJ7TYAphWMTcmX27uMhOB2GTSuGV0dlxmRKVcPXCGxLe0FkaGZIDwQ/QTDgDGUkt5jwDQdCqWi7KXWLTC1fz1ujr+9x3YOYoRPNSuz8GH0CP7HFwSv8GJJduOLB5l0uKFH17NNfTPaeW0gMhCH1K5/ejoBFuSGFWmU0NKsAWr7Ur15XtAjb1Uc8MFROMtmv/YatZacQ1j5BoiC2E219le7C5vB5/g3IwwxxzeXGiyqunMq2hqp3xkh8Z5eKU0nY9ULj1FgrjnCkPf1OiWtdFBwvouDonXWDtVZB0+BcWbDT26ats2fhpWbpJS37uhNkTPQ==
  • Cc: <ray.huang@xxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 22 Jul 2025 05:05:06 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Function getdomaininfo() is not only invoked by domctl-op, but also sysctl-op,
so it shall better live in domain.c, rather than domctl.c. Which is also
applied for arch_get_domain_info(). Style corrections shall be applied at
the same time while moving these functions, such as converting u64 to
uint64_t.

The movement could also fix CI error of a randconfig picking both SYSCTL=y
and PV_SHIM_EXCLUSIVE=y results in sysctl.c being built, but domctl.c not
being built, which leaves getdomaininfo() undefined, causing linking to fail.

Fixes: 34317c508294 ("xen/sysctl: wrap around sysctl hypercall")
Reported-by: Jan Beulich <jbeulich@xxxxxxxx>
Signed-off-by: Penny Zheng <Penny.Zheng@xxxxxxx>
---
 xen/arch/arm/domain.c |  9 ++++++
 xen/arch/arm/domctl.c |  9 ------
 xen/arch/x86/domain.c | 10 +++++++
 xen/arch/x86/domctl.c | 10 -------
 xen/common/domain.c   | 64 +++++++++++++++++++++++++++++++++++++++++++
 xen/common/domctl.c   | 64 -------------------------------------------
 6 files changed, 83 insertions(+), 83 deletions(-)

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 79a144e61b..2c2ef639ee 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -1206,6 +1206,15 @@ void vcpu_kick(struct vcpu *v)
     }
 }
 
+void arch_get_domain_info(const struct domain *d,
+                          struct xen_domctl_getdomaininfo *info)
+{
+    /* All ARM domains use hardware assisted paging. */
+    info->flags |= XEN_DOMINF_hap;
+
+    info->gpaddr_bits = p2m_ipa_bits;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c
index ad914c915f..e0ea73005a 100644
--- a/xen/arch/arm/domctl.c
+++ b/xen/arch/arm/domctl.c
@@ -17,15 +17,6 @@
 #include <xsm/xsm.h>
 #include <public/domctl.h>
 
-void arch_get_domain_info(const struct domain *d,
-                          struct xen_domctl_getdomaininfo *info)
-{
-    /* All ARM domains use hardware assisted paging. */
-    info->flags |= XEN_DOMINF_hap;
-
-    info->gpaddr_bits = p2m_ipa_bits;
-}
-
 static int handle_vuart_init(struct domain *d, 
                              struct xen_domctl_vuart_op *vuart_op)
 {
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 56c3816187..4af9f41cca 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -2639,6 +2639,16 @@ unsigned int domain_max_paddr_bits(const struct domain 
*d)
     return bits;
 }
 
+void arch_get_domain_info(const struct domain *d,
+                          struct xen_domctl_getdomaininfo *info)
+{
+    if ( paging_mode_hap(d) )
+        info->flags |= XEN_DOMINF_hap;
+
+    info->arch_config.emulation_flags = d->arch.emulation_flags;
+    info->gpaddr_bits = hap_paddr_bits;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 3044f706de..35572767ba 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -138,16 +138,6 @@ static int vcpu_set_vmce(struct vcpu *v,
     return vmce_restore_vcpu(v, &vmce);
 }
 
-void arch_get_domain_info(const struct domain *d,
-                          struct xen_domctl_getdomaininfo *info)
-{
-    if ( paging_mode_hap(d) )
-        info->flags |= XEN_DOMINF_hap;
-
-    info->arch_config.emulation_flags = d->arch.emulation_flags;
-    info->gpaddr_bits = hap_paddr_bits;
-}
-
 static int do_vmtrace_op(struct domain *d, struct xen_domctl_vmtrace_op *op,
                          XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
 {
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 303c338ef2..b74d4c7549 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -2440,6 +2440,70 @@ void thaw_domains(void)
 
 #endif /* CONFIG_SYSTEM_SUSPEND */
 
+void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info)
+{
+    struct vcpu *v;
+    uint64_t cpu_time = 0;
+    int flags = XEN_DOMINF_blocked;
+    struct vcpu_runstate_info runstate;
+
+    memset(info, 0, sizeof(*info));
+
+    info->domain = d->domain_id;
+    info->max_vcpu_id = XEN_INVALID_MAX_VCPU_ID;
+
+    /*
+     * - domain is marked as blocked only if all its vcpus are blocked
+     * - domain is marked as running if any of its vcpus is running
+     */
+    for_each_vcpu ( d, v )
+    {
+        vcpu_runstate_get(v, &runstate);
+        cpu_time += runstate.time[RUNSTATE_running];
+        info->max_vcpu_id = v->vcpu_id;
+        if ( !(v->pause_flags & VPF_down) )
+        {
+            if ( !(v->pause_flags & VPF_blocked) )
+                flags &= ~XEN_DOMINF_blocked;
+            if ( v->is_running )
+                flags |= XEN_DOMINF_running;
+            info->nr_online_vcpus++;
+        }
+    }
+
+    info->cpu_time = cpu_time;
+
+    info->flags = (info->nr_online_vcpus ? flags : 0) |
+        ((d->is_dying == DOMDYING_dead) ? XEN_DOMINF_dying     : 0) |
+        (d->is_shut_down                ? XEN_DOMINF_shutdown  : 0) |
+        (d->controller_pause_count > 0  ? XEN_DOMINF_paused    : 0) |
+        (d->debugger_attached           ? XEN_DOMINF_debugged  : 0) |
+        (is_xenstore_domain(d)          ? XEN_DOMINF_xs_domain : 0) |
+        (is_hvm_domain(d)               ? XEN_DOMINF_hvm_guest : 0) |
+        d->shutdown_code << XEN_DOMINF_shutdownshift;
+
+    xsm_security_domaininfo(d, info);
+
+    info->tot_pages         = domain_tot_pages(d);
+    info->max_pages         = d->max_pages;
+    info->outstanding_pages = d->outstanding_pages;
+#ifdef CONFIG_MEM_SHARING
+    info->shr_pages         = atomic_read(&d->shr_pages);
+#endif
+#ifdef CONFIG_MEM_PAGING
+    info->paged_pages       = atomic_read(&d->paged_pages);
+#endif
+    info->shared_info_frame =
+        gfn_x(mfn_to_gfn(d, _mfn(virt_to_mfn(d->shared_info))));
+    BUG_ON(SHARED_M2P(info->shared_info_frame));
+
+    info->cpupool = cpupool_get_id(d);
+
+    memcpy(info->handle, d->handle, sizeof(xen_domain_handle_t));
+
+    arch_get_domain_info(d, info);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index f2a7caaf85..99de77380f 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -65,70 +65,6 @@ static inline int is_free_domid(domid_t dom)
     return 0;
 }
 
-void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info)
-{
-    struct vcpu *v;
-    u64 cpu_time = 0;
-    int flags = XEN_DOMINF_blocked;
-    struct vcpu_runstate_info runstate;
-
-    memset(info, 0, sizeof(*info));
-
-    info->domain = d->domain_id;
-    info->max_vcpu_id = XEN_INVALID_MAX_VCPU_ID;
-
-    /*
-     * - domain is marked as blocked only if all its vcpus are blocked
-     * - domain is marked as running if any of its vcpus is running
-     */
-    for_each_vcpu ( d, v )
-    {
-        vcpu_runstate_get(v, &runstate);
-        cpu_time += runstate.time[RUNSTATE_running];
-        info->max_vcpu_id = v->vcpu_id;
-        if ( !(v->pause_flags & VPF_down) )
-        {
-            if ( !(v->pause_flags & VPF_blocked) )
-                flags &= ~XEN_DOMINF_blocked;
-            if ( v->is_running )
-                flags |= XEN_DOMINF_running;
-            info->nr_online_vcpus++;
-        }
-    }
-
-    info->cpu_time = cpu_time;
-
-    info->flags = (info->nr_online_vcpus ? flags : 0) |
-        ((d->is_dying == DOMDYING_dead) ? XEN_DOMINF_dying     : 0) |
-        (d->is_shut_down                ? XEN_DOMINF_shutdown  : 0) |
-        (d->controller_pause_count > 0  ? XEN_DOMINF_paused    : 0) |
-        (d->debugger_attached           ? XEN_DOMINF_debugged  : 0) |
-        (is_xenstore_domain(d)          ? XEN_DOMINF_xs_domain : 0) |
-        (is_hvm_domain(d)               ? XEN_DOMINF_hvm_guest : 0) |
-        d->shutdown_code << XEN_DOMINF_shutdownshift;
-
-    xsm_security_domaininfo(d, info);
-
-    info->tot_pages         = domain_tot_pages(d);
-    info->max_pages         = d->max_pages;
-    info->outstanding_pages = d->outstanding_pages;
-#ifdef CONFIG_MEM_SHARING
-    info->shr_pages         = atomic_read(&d->shr_pages);
-#endif
-#ifdef CONFIG_MEM_PAGING
-    info->paged_pages       = atomic_read(&d->paged_pages);
-#endif
-    info->shared_info_frame =
-        gfn_x(mfn_to_gfn(d, _mfn(virt_to_mfn(d->shared_info))));
-    BUG_ON(SHARED_M2P(info->shared_info_frame));
-
-    info->cpupool = cpupool_get_id(d);
-
-    memcpy(info->handle, d->handle, sizeof(xen_domain_handle_t));
-
-    arch_get_domain_info(d, info);
-}
-
 bool domctl_lock_acquire(void)
 {
     /*
-- 
2.34.1




 


Rackspace

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