From: Andrew Cooper Subject: [PATCH v2 1/4] xen/domain: Introduce domain_max_vcpus() helper and implement per arch Date: Tue, 20 Jan 2015 14:06:37 +0000 Message-ID: <1421762797-26257-1-git-send-email-andrew.cooper3@citrix.com> References: <54BE3B890200007800056E1A@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <54BE3B890200007800056E1A@mail.emea.novell.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: Andrew Cooper , Stefano Stabellini , Keir Fraser , Jan Beulich , Tim Deegan List-Id: xen-devel@lists.xenproject.org This allows the common XEN_DOMCTL_max_vcpus handler to lose 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 Acked-by: Ian Campbell CC: Keir Fraser CC: Jan Beulich CC: Stefano Stabellini CC: Tim Deegan --- v2: inline implementations in arch domain.h files I would really have prefered to have the x86 implementation as a static inline like the arm side, but because of the inclusion order, is_hvm_domain() is not available in asm-x86/domain.h I lack sufficient tuits to untangle this at the moment. --- xen/common/domctl.c | 3 +-- xen/include/asm-arm/config.h | 1 - xen/include/asm-arm/domain.h | 5 +++++ xen/include/asm-x86/config.h | 3 --- xen/include/asm-x86/domain.h | 3 +++ 5 files changed, 9 insertions(+), 6 deletions(-) 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-arm/domain.h b/xen/include/asm-arm/domain.h index 8b7dd85..9018c6a 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -249,6 +249,11 @@ struct arch_vcpu void vcpu_show_execution_state(struct vcpu *); void vcpu_show_registers(const struct vcpu *); +static inline unsigned int domain_max_vcpus(const struct domain *d) +{ + return MAX_VIRT_CPUS; +} + #endif /* __ASM_DOMAIN_H__ */ /* 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/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 6a77a93..b233fbc 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -9,6 +9,7 @@ #include #include #include +#include #define has_32bit_shinfo(d) ((d)->arch.has_32bit_shinfo) #define is_pv_32bit_domain(d) ((d)->arch.is_32bit_pv) @@ -527,6 +528,8 @@ void domain_cpuid(struct domain *d, unsigned int *ecx, unsigned int *edx); +#define domain_max_vcpus(d) (is_hvm_domain(d) ? HVM_MAX_VCPUS : MAX_VIRT_CPUS) + #endif /* __ASM_DOMAIN_H__ */ /* -- 1.7.10.4