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

[Xen-changelog] [xen-unstable] x86/32on64: fix physical address restriction



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1213283135 -3600
# Node ID 52c0117dd37446bef59e82de133a85a6565b237f
# Parent  5e98eb873e137a10b35bcb34ddb993be0d00567f
x86/32on64: fix physical address restriction

The allocation bit size setting wasn't working anymore after the
recent fix to properly use PAGE_SHIFT instead of PAGE_SIZE. This was
because the bit size implies a power-of-two range that's accessible,
but if all memory is accessible anyway (and its upper boundary is not
a power of two), the domain would either be needlessly restricted or
wouldn't be able to allocate as much memory as was intended for it
(specifically the case for Dom0 without dom0_mem= boot
parameter). Consequently, don't restrict the bit width if all memory
can be accessed.

To avoid needing to adjust this code in two places in the future (it
may need further touching when memory hotplug gets supported), fold
the logic into a function.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 xen/arch/x86/domain.c       |    6 +-----
 xen/arch/x86/domain_build.c |    9 +--------
 xen/arch/x86/x86_64/mm.c    |   16 ++++++++++++++--
 xen/include/asm-x86/mm.h    |    2 ++
 4 files changed, 18 insertions(+), 15 deletions(-)

diff -r 5e98eb873e13 -r 52c0117dd374 xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Thu Jun 12 15:47:45 2008 +0100
+++ b/xen/arch/x86/domain.c     Thu Jun 12 16:05:35 2008 +0100
@@ -254,11 +254,7 @@ int switch_compat(struct domain *d)
                                  FIRST_RESERVED_GDT_PAGE)] = gdt_l1e;
     }
 
-    d->arch.physaddr_bitsize =
-        /* 2^n entries can be contained in guest's p2m mapping space */
-        fls((1UL << 32) - HYPERVISOR_COMPAT_VIRT_START(d)) - 3
-        /* 2^n pages -> 2^(n+PAGE_SHIFT) bits */
-        + PAGE_SHIFT;
+    domain_set_alloc_bitsize(d);
 
     return 0;
 
diff -r 5e98eb873e13 -r 52c0117dd374 xen/arch/x86/domain_build.c
--- a/xen/arch/x86/domain_build.c       Thu Jun 12 15:47:45 2008 +0100
+++ b/xen/arch/x86/domain_build.c       Thu Jun 12 16:05:35 2008 +0100
@@ -353,14 +353,7 @@ int __init construct_dom0(
 #endif
     }
 
-#if defined(__x86_64__)
-    if ( is_pv_32on64_domain(d) )
-        d->arch.physaddr_bitsize =
-            /* 2^n entries can be contained in guest's p2m mapping space */
-            fls((1UL << 32) - HYPERVISOR_COMPAT_VIRT_START(d)) - 3
-            /* 2^n pages -> 2^(n+PAGE_SHIFT) bits */
-            + PAGE_SHIFT;
-#endif
+    domain_set_alloc_bitsize(d);
 
     /*
      * Why do we need this? The number of page-table frames depends on the 
diff -r 5e98eb873e13 -r 52c0117dd374 xen/arch/x86/x86_64/mm.c
--- a/xen/arch/x86/x86_64/mm.c  Thu Jun 12 15:47:45 2008 +0100
+++ b/xen/arch/x86/x86_64/mm.c  Thu Jun 12 16:05:35 2008 +0100
@@ -168,7 +168,7 @@ void __init paging_init(void)
     if ( mpt_size > RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START )
         mpt_size = RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START;
     mpt_size &= ~((1UL << L2_PAGETABLE_SHIFT) - 1UL);
-    if ( m2p_compat_vstart + mpt_size < MACH2PHYS_COMPAT_VIRT_END )
+    if ( (m2p_compat_vstart + mpt_size) < MACH2PHYS_COMPAT_VIRT_END )
         m2p_compat_vstart = MACH2PHYS_COMPAT_VIRT_END - mpt_size;
     for ( i = 0; i < (mpt_size >> L2_PAGETABLE_SHIFT); i++ )
     {
@@ -472,9 +472,21 @@ int check_descriptor(const struct domain
     return 0;
 }
 
+void domain_set_alloc_bitsize(struct domain *d)
+{
+    if ( !is_pv_32on64_domain(d) ||
+         (MACH2PHYS_COMPAT_NR_ENTRIES(d) >= max_page) )
+        return;
+    d->arch.physaddr_bitsize =
+        /* 2^n entries can be contained in guest's p2m mapping space */
+        fls(MACH2PHYS_COMPAT_NR_ENTRIES(d)) - 1
+        /* 2^n pages -> 2^(n+PAGE_SHIFT) bits */
+        + PAGE_SHIFT;
+}
+
 unsigned int domain_clamp_alloc_bitsize(struct domain *d, unsigned int bits)
 {
-    if ( (d == NULL) || !is_pv_32on64_domain(d) )
+    if ( (d == NULL) || (d->arch.physaddr_bitsize == 0) )
         return bits;
     return min(d->arch.physaddr_bitsize, bits);
 }
diff -r 5e98eb873e13 -r 52c0117dd374 xen/include/asm-x86/mm.h
--- a/xen/include/asm-x86/mm.h  Thu Jun 12 15:47:45 2008 +0100
+++ b/xen/include/asm-x86/mm.h  Thu Jun 12 16:05:35 2008 +0100
@@ -342,8 +342,10 @@ int map_ldt_shadow_page(unsigned int);
 int map_ldt_shadow_page(unsigned int);
 
 #ifdef CONFIG_COMPAT
+void domain_set_alloc_bitsize(struct domain *d);
 unsigned int domain_clamp_alloc_bitsize(struct domain *d, unsigned int bits);
 #else
+# define domain_set_alloc_bitsize(d) ((void)0)
 # define domain_clamp_alloc_bitsize(d, b) (b)
 #endif
 

_______________________________________________
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®.