Skip to contentSkip to conversation

domain heap allocator changes - per domain address restriction

PATCH In review Jan Beulich 1 participant 1 message Feb 7, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 4/4 domain heap allocator changes - per domain address restriction

Introduce a per-domain field indicating the highest possible machine address memory may be allocated for, and set it for compat domains to be suitable for the limited m2p table size.

xen/arch/x86/domain.c +6 -1
Index: 2007-02-07/xen/arch/x86/domain.c
===================================================================
@@ -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)
@@ -283,6 +283,8 @@ int switch_native(struct domain *d)
             release_compat_l4(d->vcpu[vcpuid]);
     }
 
+    d->pa_bitsize = 0;
+
     return 0;
 }
 
@@ -313,6 +315,9 @@ int switch_compat(struct domain *d)
             return -ENOMEM;
     }
 
+    d->pa_bitsize = fls((1UL << 32) - HYPERVISOR_COMPAT_VIRT_START(d)) - 1
+                    + (PAGE_SIZE - 2);
+
     return 0;
 }
 
xen/arch/x86/domain_build.c +2 -0
Index: 2007-02-07/xen/arch/x86/domain_build.c
===================================================================
@@ -358,6 +358,8 @@ 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);
+        d->pa_bitsize = fls((1UL << 32) - HYPERVISOR_COMPAT_VIRT_START(d)) - 1
+                        + (PAGE_SIZE - 2);
         if ( value > (!IS_COMPAT(d) ?
                       HYPERVISOR_VIRT_START :
                       __HYPERVISOR_COMPAT_VIRT_START) )
xen/common/page_alloc.c +6 -1
Index: 2007-02-07/xen/common/page_alloc.c
===================================================================
@@ -718,7 +718,12 @@ struct page_info *__alloc_domheap_pages(
     if ( bits && bits <= PAGE_SHIFT + 1 )
         return NULL;
 
-    zone_hi = bits - PAGE_SHIFT - 1;
+#ifdef CONFIG_COMPAT
+    if ( d && d->pa_bitsize && bits > d->pa_bitsize )
+        zone_hi = d->pa_bitsize - PAGE_SHIFT - 1;
+    else
+#endif
+        zone_hi = bits - PAGE_SHIFT - 1;
     if ( zone_hi >= NR_ZONES )
         zone_hi = NR_ZONES - 1;
 
xen/include/xen/sched.h +4 -0
Index: 2007-02-07/xen/include/xen/sched.h
===================================================================
@@ -165,6 +165,10 @@ struct domain
 
     unsigned long    domain_flags;
 
+#ifdef CONFIG_COMPAT
+    unsigned int     pa_bitsize;
+#endif
+
     /* Boolean: Is this an HVM guest? */
     char             is_hvm;