Jan Beulich
2007-Feb-07 17:12 UTC
[Xen-devel] [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. Signed-off-by: Jan Beulich <jbeulich@novell.com> Index: 2007-02-07/xen/arch/x86/domain.c ==================================================================--- 2007-02-07.orig/xen/arch/x86/domain.c 2007-02-01 17:41:08.000000000 +0100 +++ 2007-02-07/xen/arch/x86/domain.c 2007-02-07 16:27:53.000000000 +0100 @@ -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; } Index: 2007-02-07/xen/arch/x86/domain_build.c ==================================================================--- 2007-02-07.orig/xen/arch/x86/domain_build.c 2007-02-07 16:26:50.000000000 +0100 +++ 2007-02-07/xen/arch/x86/domain_build.c 2007-02-07 16:27:53.000000000 +0100 @@ -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) ) Index: 2007-02-07/xen/common/page_alloc.c ==================================================================--- 2007-02-07.orig/xen/common/page_alloc.c 2007-02-07 16:26:50.000000000 +0100 +++ 2007-02-07/xen/common/page_alloc.c 2007-02-07 16:27:53.000000000 +0100 @@ -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; Index: 2007-02-07/xen/include/xen/sched.h ==================================================================--- 2007-02-07.orig/xen/include/xen/sched.h 2007-01-30 10:23:31.000000000 +0100 +++ 2007-02-07/xen/include/xen/sched.h 2007-02-07 16:27:53.000000000 +0100 @@ -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; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel