Index: 2007-02-20/xen/arch/x86/domain.c =================================================================== --- 2007-02-20.orig/xen/arch/x86/domain.c 2007-02-26 15:41:28.000000000 +0100 +++ 2007-02-20/xen/arch/x86/domain.c 2007-01-08 14:54:35.000000000 +0100 @@ -253,7 +253,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) @@ -281,6 +281,8 @@ int switch_native(struct domain *d) release_compat_l4(d->vcpu[vcpuid]); } + d->pa_bitsize = 0; + return 0; } @@ -311,6 +313,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-20/xen/arch/x86/domain_build.c =================================================================== --- 2007-02-20.orig/xen/arch/x86/domain_build.c 2007-02-26 15:41:28.000000000 +0100 +++ 2007-02-20/xen/arch/x86/domain_build.c 2007-02-26 15:42:27.000000000 +0100 @@ -396,6 +396,8 @@ int construct_dom0(struct domain *d, value = (value + mask) & ~mask; #ifdef CONFIG_COMPAT HYPERVISOR_COMPAT_VIRT_START(d) = max_t(unsigned int, m2p_compat_vstart, value); + d->pa_bitsize = !IS_COMPAT(d) ? 0 : + 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-20/xen/common/page_alloc.c =================================================================== --- 2007-02-20.orig/xen/common/page_alloc.c 2007-02-26 15:41:28.000000000 +0100 +++ 2007-02-20/xen/common/page_alloc.c 2007-01-08 14:54:35.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-20/xen/include/xen/sched.h =================================================================== --- 2007-02-20.orig/xen/include/xen/sched.h 2007-02-26 15:41:28.000000000 +0100 +++ 2007-02-20/xen/include/xen/sched.h 2007-01-08 14:54:35.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;