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

[Xen-changelog] [xen-unstable] xen memory allocator: Allow per-domain bitwidth restrictions.



# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1172325454 0
# Node ID 1e5a83fb928b772eb4c4f4ad6168da5f5f78b987
# Parent  8afe591c272ba27b0aca7943ce58cfdab16630cb
xen memory allocator: Allow per-domain bitwidth restrictions.
Original patch by Jan Beulich <jbeulich@xxxxxxxxxx>
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/arch/x86/domain.c        |   12 +++++++++---
 xen/arch/x86/domain_build.c  |    6 +++++-
 xen/arch/x86/x86_64/mm.c     |    7 +++++++
 xen/common/page_alloc.c      |   22 ++++++++++++----------
 xen/include/asm-ia64/mm.h    |    2 ++
 xen/include/asm-powerpc/mm.h |    3 +++
 xen/include/asm-x86/domain.h |    3 +++
 xen/include/asm-x86/mm.h     |    5 ++++-
 8 files changed, 45 insertions(+), 15 deletions(-)

diff -r 8afe591c272b -r 1e5a83fb928b xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Sat Feb 24 12:19:22 2007 +0000
+++ b/xen/arch/x86/domain.c     Sat Feb 24 13:57:34 2007 +0000
@@ -255,7 +255,7 @@ static void release_compat_l4(struct vcp
 
 static inline int may_switch_mode(struct domain *d)
 {
-    return 1; /* XXX */
+    return (d->tot_pages == 0);
 }
 
 int switch_native(struct domain *d)
@@ -263,7 +263,7 @@ int switch_native(struct domain *d)
     l1_pgentry_t gdt_l1e;
     unsigned int vcpuid;
 
-    if ( !d )
+    if ( d == NULL )
         return -EINVAL;
     if ( !may_switch_mode(d) )
         return -EACCES;
@@ -283,6 +283,8 @@ int switch_native(struct domain *d)
             release_compat_l4(d->vcpu[vcpuid]);
     }
 
+    d->arch.physaddr_bitsize = 64;
+
     return 0;
 }
 
@@ -291,7 +293,7 @@ int switch_compat(struct domain *d)
     l1_pgentry_t gdt_l1e;
     unsigned int vcpuid;
 
-    if ( !d )
+    if ( d == NULL )
         return -EINVAL;
     if ( compat_disabled )
         return -ENOSYS;
@@ -312,6 +314,10 @@ int switch_compat(struct domain *d)
             && setup_compat_l4(d->vcpu[vcpuid]) != 0)
             return -ENOMEM;
     }
+
+    d->arch.physaddr_bitsize =
+        fls((1UL << 32) - HYPERVISOR_COMPAT_VIRT_START(d)) - 1
+        + (PAGE_SIZE - 2);
 
     return 0;
 }
diff -r 8afe591c272b -r 1e5a83fb928b xen/arch/x86/domain_build.c
--- a/xen/arch/x86/domain_build.c       Sat Feb 24 12:19:22 2007 +0000
+++ b/xen/arch/x86/domain_build.c       Sat Feb 24 13:57:34 2007 +0000
@@ -357,7 +357,11 @@ int construct_dom0(struct domain *d,
 
         value = (parms.virt_hv_start_low + mask) & ~mask;
 #ifdef CONFIG_COMPAT
-        HYPERVISOR_COMPAT_VIRT_START(d) = max_t(unsigned int, 
m2p_compat_vstart, value);
+        HYPERVISOR_COMPAT_VIRT_START(d) =
+            max_t(unsigned int, m2p_compat_vstart, value);
+        d->arch.physaddr_bitsize = !IS_COMPAT(d) ? 64 :
+            fls((1UL << 32) - HYPERVISOR_COMPAT_VIRT_START(d)) - 1
+            + (PAGE_SIZE - 2);
         if ( value > (!IS_COMPAT(d) ?
                       HYPERVISOR_VIRT_START :
                       __HYPERVISOR_COMPAT_VIRT_START) )
diff -r 8afe591c272b -r 1e5a83fb928b xen/arch/x86/x86_64/mm.c
--- a/xen/arch/x86/x86_64/mm.c  Sat Feb 24 12:19:22 2007 +0000
+++ b/xen/arch/x86/x86_64/mm.c  Sat Feb 24 13:57:34 2007 +0000
@@ -409,6 +409,13 @@ int check_descriptor(const struct domain
     return 0;
 }
 
+unsigned int domain_clamp_alloc_bitsize(struct domain *d, unsigned int bits)
+{
+    if ( d == NULL )
+        return bits;
+    return min(d->arch.physaddr_bitsize, bits);
+}
+
 #include "compat/mm.c"
 
 /*
diff -r 8afe591c272b -r 1e5a83fb928b xen/common/page_alloc.c
--- a/xen/common/page_alloc.c   Sat Feb 24 12:19:22 2007 +0000
+++ b/xen/common/page_alloc.c   Sat Feb 24 13:57:34 2007 +0000
@@ -764,19 +764,21 @@ struct page_info *__alloc_domheap_pages(
     struct page_info *pg = NULL;
     cpumask_t mask;
     unsigned long i;
-    unsigned int bits = memflags >> _MEMF_bits, zone_hi;
+    unsigned int bits = memflags >> _MEMF_bits, zone_hi = NR_ZONES - 1;
 
     ASSERT(!in_irq());
 
-    if ( bits && bits <= PAGE_SHIFT + 1 )
-        return NULL;
-
-    zone_hi = bits - PAGE_SHIFT - 1;
-    if ( zone_hi >= NR_ZONES )
-        zone_hi = NR_ZONES - 1;
-
-    if ( NR_ZONES + PAGE_SHIFT > dma_bitsize &&
-         (!bits || bits > dma_bitsize) )
+    if ( bits )
+    {
+        bits = domain_clamp_alloc_bitsize(d, bits);
+        if ( bits <= (PAGE_SHIFT + 1) )
+            return NULL;
+        bits -= PAGE_SHIFT + 1;
+        if ( bits < zone_hi )
+            zone_hi = bits;
+    }
+
+    if ( (zone_hi + PAGE_SHIFT) >= dma_bitsize )
     {
         pg = alloc_heap_pages(dma_bitsize - PAGE_SHIFT, zone_hi, cpu, order);
 
diff -r 8afe591c272b -r 1e5a83fb928b xen/include/asm-ia64/mm.h
--- a/xen/include/asm-ia64/mm.h Sat Feb 24 12:19:22 2007 +0000
+++ b/xen/include/asm-ia64/mm.h Sat Feb 24 13:57:34 2007 +0000
@@ -509,4 +509,6 @@ int steal_page(
 int steal_page(
     struct domain *d, struct page_info *page, unsigned int memflags);
 
+#define domain_clamp_alloc_bitsize(d, b) (b)
+
 #endif /* __ASM_IA64_MM_H__ */
diff -r 8afe591c272b -r 1e5a83fb928b xen/include/asm-powerpc/mm.h
--- a/xen/include/asm-powerpc/mm.h      Sat Feb 24 12:19:22 2007 +0000
+++ b/xen/include/asm-powerpc/mm.h      Sat Feb 24 13:57:34 2007 +0000
@@ -289,4 +289,7 @@ extern int steal_page(struct domain *d, 
 /* XXX these just exist until we can stop #including x86 code */
 #define access_ok(addr,size) 1
 #define array_access_ok(addr,count,size) 1
+
+#define domain_clamp_alloc_bitsize(d, b) (b)
+
 #endif
diff -r 8afe591c272b -r 1e5a83fb928b xen/include/asm-x86/domain.h
--- a/xen/include/asm-x86/domain.h      Sat Feb 24 12:19:22 2007 +0000
+++ b/xen/include/asm-x86/domain.h      Sat Feb 24 13:57:34 2007 +0000
@@ -179,6 +179,9 @@ struct arch_domain
     /* Pseudophysical e820 map (XENMEM_memory_map).  */
     struct e820entry e820[3];
     unsigned int nr_e820;
+
+    /* Maximum physical-address bitwidth supported by this guest. */
+    unsigned int physaddr_bitsize;
 } __cacheline_aligned;
 
 #ifdef CONFIG_X86_PAE
diff -r 8afe591c272b -r 1e5a83fb928b xen/include/asm-x86/mm.h
--- a/xen/include/asm-x86/mm.h  Sat Feb 24 12:19:22 2007 +0000
+++ b/xen/include/asm-x86/mm.h  Sat Feb 24 13:57:34 2007 +0000
@@ -398,8 +398,11 @@ int map_ldt_shadow_page(unsigned int);
 
 #ifdef CONFIG_COMPAT
 int setup_arg_xlat_area(struct vcpu *, l4_pgentry_t *);
+unsigned int domain_clamp_alloc_bitsize(struct domain *d, unsigned int bits);
 #else
 # define setup_arg_xlat_area(vcpu, l4tab) 0
-#endif
+# define domain_clamp_alloc_bitsize(d, b) (b)
+#endif
+
 
 #endif /* __ASM_X86_MM_H__ */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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