From: Andrew Cooper Subject: [PATCH 1/4] xen/domain: Introduce domain_max_vcpus() helper and implement per arch Date: Mon, 19 Jan 2015 11:21:33 +0000 Message-ID: <1421666496-10676-2-git-send-email-andrew.cooper3@citrix.com> References: <1421666496-10676-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1421666496-10676-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Keir Fraser , Ian Campbell , Andrew Cooper , Tim Deegan , Stefano Stabellini , Jan Beulich List-Id: xen-devel@lists.xenproject.org This allows the common XEN_DOMCTL_max_vcpus handler to loose some x86-specific architecture knowledge. It turns out that Xen had the same magic number twice in-tree with different names (HVM_MAX_VCPUS and MAX_HVM_VCPUS). This removes all use of MAX_HVM_VCPUS, and x86 uses HVM_MAX_VCPUS from the public headers. Signed-off-by: Andrew Cooper CC: Keir Fraser CC: Jan Beulich CC: Ian Campbell CC: Stefano Stabellini CC: Tim Deegan --- xen/arch/arm/domain.c | 5 +++++ xen/arch/x86/domain.c | 9 +++++++++ xen/common/domctl.c | 3 +-- xen/include/asm-arm/config.h | 1 - xen/include/asm-x86/config.h | 3 --- xen/include/xen/domain.h | 3 +++ 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index cfc7ab4..0b09f02 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -400,6 +400,11 @@ void startup_cpu_idle_loop(void) reset_stack_and_jump(idle_loop); } +unsigned int domain_max_vcpus(const struct domain *d) +{ + return MAX_VIRT_CPUS; +} + struct domain *alloc_domain_struct(void) { struct domain *d; diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index c8832c6..9d3e01a 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -204,6 +205,14 @@ smap_check_policy_t smap_policy_change(struct vcpu *v, return old_policy; } +unsigned int domain_max_vcpus(const struct domain *d) +{ + if ( is_hvm_domain(d) ) + return HVM_MAX_VCPUS; + else + return MAX_VIRT_CPUS; +} + /* * The hole may be at or above the 44-bit boundary, so we need to determine * the total bit count until reaching 32 significant (not squashed out) bits diff --git a/xen/common/domctl.c b/xen/common/domctl.c index ee578c0..33ecd45 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -608,8 +608,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) ret = -EINVAL; if ( (d == current->domain) || /* no domain_pause() */ - (max > MAX_VIRT_CPUS) || - (is_hvm_domain(d) && (max > MAX_HVM_VCPUS)) ) + (max > domain_max_vcpus(d)) ) break; /* Until Xenoprof can dynamically grow its vcpu-s array... */ diff --git a/xen/include/asm-arm/config.h b/xen/include/asm-arm/config.h index 1b5a842..3b23e05 100644 --- a/xen/include/asm-arm/config.h +++ b/xen/include/asm-arm/config.h @@ -48,7 +48,6 @@ #endif #define MAX_VIRT_CPUS 8 -#define MAX_HVM_VCPUS MAX_VIRT_CPUS #define asmlinkage /* Nothing needed */ diff --git a/xen/include/asm-x86/config.h b/xen/include/asm-x86/config.h index ad52d5b..2fbd68d 100644 --- a/xen/include/asm-x86/config.h +++ b/xen/include/asm-x86/config.h @@ -67,9 +67,6 @@ #define NR_CPUS 256 #endif -/* Maximum we can support with current vLAPIC ID mapping. */ -#define MAX_HVM_VCPUS 128 - /* Linkage for x86 */ #define __ALIGN .align 16,0x90 #define __ALIGN_STR ".align 16,0x90" diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 72667da..05ef1ed 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -22,6 +22,9 @@ void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info); * Arch-specifics. */ +/* Maximum number of vcpus supported for a specific domain. */ +unsigned int domain_max_vcpus(const struct domain *d); + /* Allocate/free a domain structure. */ struct domain *alloc_domain_struct(void); void free_domain_struct(struct domain *d); -- 1.7.10.4