|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1] xen: move getdomaininfo() to domain.c
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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |