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

[Xen-changelog] [xen-unstable] Avoid compat_arg_xlat to be a large per-CPU object



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1246877479 -3600
# Node ID bcee82a0e9d643e569fb96ac3d2ad3d27bb59a23
# Parent  83b37290ed5d10d955ebb3ead0b70e0d00b21e8b
Avoid compat_arg_xlat to be a large per-CPU object

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 xen/arch/x86/smpboot.c               |    3 +++
 xen/arch/x86/x86_64/compat/mm.c      |   10 +++++-----
 xen/arch/x86/x86_64/mm.c             |   27 +++++++++++++++++++++++++--
 xen/common/compat/domain.c           |    2 +-
 xen/common/compat/grant_table.c      |    2 +-
 xen/common/compat/memory.c           |    2 +-
 xen/include/asm-x86/x86_64/uaccess.h |    3 ++-
 7 files changed, 38 insertions(+), 11 deletions(-)

diff -r 83b37290ed5d -r bcee82a0e9d6 xen/arch/x86/smpboot.c
--- a/xen/arch/x86/smpboot.c    Mon Jul 06 11:50:30 2009 +0100
+++ b/xen/arch/x86/smpboot.c    Mon Jul 06 11:51:19 2009 +0100
@@ -878,6 +878,9 @@ static int __devinit do_boot_cpu(int api
                per_cpu(doublefault_tss, cpu) = alloc_xenheap_page();
                memset(per_cpu(doublefault_tss, cpu), 0, PAGE_SIZE);
        }
+#else
+       if (!per_cpu(compat_arg_xlat, cpu))
+               setup_compat_arg_xlat(cpu, apicid_to_node[apicid]);
 #endif
 
        if (!idt_tables[cpu]) {
diff -r 83b37290ed5d -r bcee82a0e9d6 xen/arch/x86/x86_64/compat/mm.c
--- a/xen/arch/x86/x86_64/compat/mm.c   Mon Jul 06 11:50:30 2009 +0100
+++ b/xen/arch/x86/x86_64/compat/mm.c   Mon Jul 06 11:51:19 2009 +0100
@@ -58,7 +58,7 @@ int compat_arch_memory_op(int op, XEN_GU
     case XENMEM_add_to_physmap:
     {
         struct compat_add_to_physmap cmp;
-        struct xen_add_to_physmap *nat = (void *)COMPAT_ARG_XLAT_VIRT_BASE;
+        struct xen_add_to_physmap *nat = COMPAT_ARG_XLAT_VIRT_BASE;
 
         if ( copy_from_guest(&cmp, arg, 1) )
             return -EFAULT;
@@ -72,7 +72,7 @@ int compat_arch_memory_op(int op, XEN_GU
     case XENMEM_set_memory_map:
     {
         struct compat_foreign_memory_map cmp;
-        struct xen_foreign_memory_map *nat = (void *)COMPAT_ARG_XLAT_VIRT_BASE;
+        struct xen_foreign_memory_map *nat = COMPAT_ARG_XLAT_VIRT_BASE;
 
         if ( copy_from_guest(&cmp, arg, 1) )
             return -EFAULT;
@@ -91,7 +91,7 @@ int compat_arch_memory_op(int op, XEN_GU
     case XENMEM_machine_memory_map:
     {
         struct compat_memory_map cmp;
-        struct xen_memory_map *nat = (void *)COMPAT_ARG_XLAT_VIRT_BASE;
+        struct xen_memory_map *nat = COMPAT_ARG_XLAT_VIRT_BASE;
 
         if ( copy_from_guest(&cmp, arg, 1) )
             return -EFAULT;
@@ -118,7 +118,7 @@ int compat_arch_memory_op(int op, XEN_GU
     case XENMEM_get_pod_target:
     {
         struct compat_pod_target cmp;
-        struct xen_pod_target *nat = (void *)COMPAT_ARG_XLAT_VIRT_BASE;
+        struct xen_pod_target *nat = COMPAT_ARG_XLAT_VIRT_BASE;
 
         if ( copy_from_guest(&cmp, arg, 1) )
             return -EFAULT;
@@ -212,7 +212,7 @@ int compat_mmuext_op(XEN_GUEST_HANDLE(mm
     if ( unlikely(!guest_handle_okay(cmp_uops, count)) )
         return -EFAULT;
 
-    set_xen_guest_handle(nat_ops, (void *)COMPAT_ARG_XLAT_VIRT_BASE);
+    set_xen_guest_handle(nat_ops, COMPAT_ARG_XLAT_VIRT_BASE);
 
     for ( ; count; count -= i )
     {
diff -r 83b37290ed5d -r bcee82a0e9d6 xen/arch/x86/x86_64/mm.c
--- a/xen/arch/x86/x86_64/mm.c  Mon Jul 06 11:50:30 2009 +0100
+++ b/xen/arch/x86/x86_64/mm.c  Mon Jul 06 11:51:19 2009 +0100
@@ -22,6 +22,7 @@
 #include <xen/init.h>
 #include <xen/mm.h>
 #include <xen/sched.h>
+#include <xen/numa.h>
 #include <xen/guest_access.h>
 #include <asm/current.h>
 #include <asm/asm_defns.h>
@@ -30,14 +31,13 @@
 #include <asm/fixmap.h>
 #include <asm/hypercall.h>
 #include <asm/msr.h>
-#include <asm/numa.h>
 #include <public/memory.h>
 
 #ifdef CONFIG_COMPAT
 unsigned int m2p_compat_vstart = __HYPERVISOR_COMPAT_VIRT_START;
 #endif
 
-DEFINE_PER_CPU(char, compat_arg_xlat[COMPAT_ARG_XLAT_SIZE]);
+DEFINE_PER_CPU(void *, compat_arg_xlat);
 
 /* Top-level master (and idle-domain) page directory. */
 l4_pgentry_t __attribute__ ((__section__ (".bss.page_aligned")))
@@ -293,6 +293,25 @@ void __init zap_low_mappings(void)
                      0x10, __PAGE_HYPERVISOR);
 }
 
+int __cpuinit setup_compat_arg_xlat(unsigned int cpu, int node)
+{
+    unsigned int order = get_order_from_bytes(COMPAT_ARG_XLAT_SIZE);
+    unsigned long sz = PAGE_SIZE << order;
+    unsigned int memflags = node != NUMA_NO_NODE ? MEMF_node(node) : 0;
+    struct page_info *pg;
+
+    pg = alloc_domheap_pages(NULL, order, memflags);
+    if ( !pg )
+        return -ENOMEM;
+
+    for ( ; (sz -= PAGE_SIZE) >= COMPAT_ARG_XLAT_SIZE; ++pg )
+        free_domheap_page(pg);
+
+    per_cpu(compat_arg_xlat, cpu) = page_to_virt(pg);
+
+    return 0;
+}
+
 void __init subarch_init_memory(void)
 {
     unsigned long i, n, v, m2p_start_mfn;
@@ -350,6 +369,10 @@ void __init subarch_init_memory(void)
             share_xen_page_with_privileged_guests(page, XENSHARE_readonly);
         }
     }
+
+    if ( setup_compat_arg_xlat(smp_processor_id(),
+                               apicid_to_node[boot_cpu_physical_apicid]) )
+        panic("Could not setup argument translation area");
 }
 
 long subarch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
diff -r 83b37290ed5d -r bcee82a0e9d6 xen/common/compat/domain.c
--- a/xen/common/compat/domain.c        Mon Jul 06 11:50:30 2009 +0100
+++ b/xen/common/compat/domain.c        Mon Jul 06 11:51:19 2009 +0100
@@ -87,7 +87,7 @@ int compat_vcpu_op(int cmd, int vcpuid, 
 
         if ( copy_from_guest(&cmp, arg, 1) )
             return -EFAULT;
-        nat = (void *)COMPAT_ARG_XLAT_VIRT_BASE;
+        nat = COMPAT_ARG_XLAT_VIRT_BASE;
         XLAT_vcpu_set_singleshot_timer(nat, &cmp);
         rc = do_vcpu_op(cmd, vcpuid, guest_handle_from_ptr(nat, void));
         break;
diff -r 83b37290ed5d -r bcee82a0e9d6 xen/common/compat/grant_table.c
--- a/xen/common/compat/grant_table.c   Mon Jul 06 11:50:30 2009 +0100
+++ b/xen/common/compat/grant_table.c   Mon Jul 06 11:51:19 2009 +0100
@@ -97,7 +97,7 @@ int compat_grant_table_op(unsigned int c
             struct compat_gnttab_copy copy;
         } cmp;
 
-        set_xen_guest_handle(nat.uop, (void *)COMPAT_ARG_XLAT_VIRT_BASE);
+        set_xen_guest_handle(nat.uop, COMPAT_ARG_XLAT_VIRT_BASE);
         switch ( cmd )
         {
         case GNTTABOP_setup_table:
diff -r 83b37290ed5d -r bcee82a0e9d6 xen/common/compat/memory.c
--- a/xen/common/compat/memory.c        Mon Jul 06 11:50:30 2009 +0100
+++ b/xen/common/compat/memory.c        Mon Jul 06 11:51:19 2009 +0100
@@ -25,7 +25,7 @@ int compat_memory_op(unsigned int cmd, X
             struct compat_memory_exchange xchg;
         } cmp;
 
-        set_xen_guest_handle(nat.hnd, (void *)COMPAT_ARG_XLAT_VIRT_BASE);
+        set_xen_guest_handle(nat.hnd, COMPAT_ARG_XLAT_VIRT_BASE);
         split = 0;
         switch ( op )
         {
diff -r 83b37290ed5d -r bcee82a0e9d6 xen/include/asm-x86/x86_64/uaccess.h
--- a/xen/include/asm-x86/x86_64/uaccess.h      Mon Jul 06 11:50:30 2009 +0100
+++ b/xen/include/asm-x86/x86_64/uaccess.h      Mon Jul 06 11:51:19 2009 +0100
@@ -3,7 +3,8 @@
 
 #define COMPAT_ARG_XLAT_VIRT_BASE this_cpu(compat_arg_xlat)
 #define COMPAT_ARG_XLAT_SIZE      PAGE_SIZE
-DECLARE_PER_CPU(char, compat_arg_xlat[COMPAT_ARG_XLAT_SIZE]);
+DECLARE_PER_CPU(void *, compat_arg_xlat);
+int setup_compat_arg_xlat(unsigned int cpu, int node);
 #define is_compat_arg_xlat_range(addr, size) ({                               \
     unsigned long __off;                                                      \
     __off = (unsigned long)(addr) - (unsigned long)COMPAT_ARG_XLAT_VIRT_BASE; \

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