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

[Xen-devel] [PATCH 1/4] xen/domain: Introduce domain_max_vcpus() helper and implement per arch



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 <andrew.cooper3@xxxxxxxxxx>
CC: Keir Fraser <keir@xxxxxxx>
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Ian Campbell <ian.campbell@xxxxxxxxxx>
CC: Stefano Stabellini <stefano.stabellini@xxxxxxxxxx>
CC: Tim Deegan <tim@xxxxxxx>
---
 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 <xen/wait.h>
 #include <xen/guest_access.h>
 #include <public/sysctl.h>
+#include <public/hvm/hvm_info_table.h>
 #include <asm/regs.h>
 #include <asm/mc146818rtc.h>
 #include <asm/system.h>
@@ -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


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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