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

[Xen-changelog] We cannot allow nested C functions. They create a stack



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 8c58bf3354655a5f54e687070038e31843480155
# Parent  2052ce3345c1441f96729bc59120b3352a995112
We cannot allow nested C functions. They create a stack
trampoline when their address is taken, which causes a
fault if the system implements NX/XD.

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r 2052ce3345c1 -r 8c58bf335465 Config.mk
--- a/Config.mk Mon Aug 22 16:38:13 2005
+++ b/Config.mk Mon Aug 22 19:58:22 2005
@@ -3,7 +3,7 @@
 # Currently supported architectures: x86_32, x86_64
 XEN_COMPILE_ARCH    ?= $(shell uname -m | sed -e s/i.86/x86_32/)
 XEN_TARGET_ARCH     ?= $(XEN_COMPILE_ARCH)
-XEN_TARGET_X86_PAE  ?= n
+XEN_TARGET_X86_PAE  ?= y
 
 # Tools to run on system hosting the build
 HOSTCC     = gcc
diff -r 2052ce3345c1 -r 8c58bf335465 
linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c   Mon Aug 22 16:38:13 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c   Mon Aug 22 19:58:22 2005
@@ -368,35 +368,37 @@
 
 EXPORT_SYMBOL(direct_remap_area_pages);
 
+static int lookup_pte_fn(
+       pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
+{
+       unsigned long *ptep = (unsigned long *)data;
+       if (ptep)
+               *ptep = (pfn_to_mfn(page_to_pfn(pte_page)) <<
+                        PAGE_SHIFT) |
+                       ((unsigned long)pte & ~PAGE_MASK);
+       return 0;
+}
+
 int create_lookup_pte_addr(struct mm_struct *mm, 
                           unsigned long address,
                           unsigned long *ptep)
 {
-       int f(pte_t *pte, struct page *pte_page, unsigned long addr,
-             void *data) {
-               unsigned long *ptep = (unsigned long *)data;
-               if (ptep)
-                       *ptep = (pfn_to_mfn(page_to_pfn(pte_page)) <<
-                                PAGE_SHIFT) |
-                               ((unsigned long)pte & ~PAGE_MASK);
-               return 0;
-       }
-
-       return generic_page_range(mm, address, PAGE_SIZE, f, ptep);
+       return generic_page_range(mm, address, PAGE_SIZE, lookup_pte_fn, ptep);
 }
 
 EXPORT_SYMBOL(create_lookup_pte_addr);
+
+static int noop_fn(
+       pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
+{
+       return 0;
+}
 
 int touch_pte_range(struct mm_struct *mm,
                    unsigned long address,
                    unsigned long size)
 {
-       int f(pte_t *pte, struct page *pte_page, unsigned long addr,
-             void *data) {
-               return 0;
-       }
-
-       return generic_page_range(mm, address, size, f, NULL);
+       return generic_page_range(mm, address, size, noop_fn, NULL);
 } 
 
 EXPORT_SYMBOL(touch_pte_range);
diff -r 2052ce3345c1 -r 8c58bf335465 
linux-2.6-xen-sparse/arch/xen/x86_64/mm/ioremap.c
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/mm/ioremap.c Mon Aug 22 16:38:13 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/mm/ioremap.c Mon Aug 22 19:58:22 2005
@@ -465,33 +465,35 @@
 
 EXPORT_SYMBOL(direct_remap_area_pages);
 
+static int lookup_pte_fn(
+    pte_t *pte, struct page *pte_page, unsigned long addr, void *data) 
+{
+    unsigned long *ptep = (unsigned long *)data;
+    if (ptep) *ptep = (pfn_to_mfn(page_to_pfn(pte_page)) << PAGE_SHIFT)
+                  | ((unsigned long)pte & ~PAGE_MASK);
+    return 0;
+}
+
 int create_lookup_pte_addr(struct mm_struct *mm, 
                            unsigned long address,
                            unsigned long *ptep)
 {
-    int f(pte_t *pte, struct page *pte_page, unsigned long addr, void *data) 
-    {
-        unsigned long *ptep = (unsigned long *)data;
-        if (ptep) *ptep = (pfn_to_mfn(page_to_pfn(pte_page)) << PAGE_SHIFT)
-                       | ((unsigned long)pte & ~PAGE_MASK);
-        return 0;
-    }
-
-    return generic_page_range(mm, address, PAGE_SIZE, f, ptep);
+    return generic_page_range(mm, address, PAGE_SIZE, lookup_pte_fn, ptep);
 }
 
 EXPORT_SYMBOL(create_lookup_pte_addr);
+
+static int noop_fn(
+    pte_t *pte, struct page *pte_page, unsigned long addr, void *data) 
+{
+    return 0;
+}
 
 int touch_pte_range(struct mm_struct *mm,
                     unsigned long address,
                     unsigned long size)
 {
-    int f(pte_t *pte, struct page *pte_page, unsigned long addr, void *data) 
-    {
-        return 0;
-    }
-
-    return generic_page_range(mm, address, size, f, NULL);
-}                 
+    return generic_page_range(mm, address, size, noop_fn, NULL);
+}
 
 EXPORT_SYMBOL(touch_pte_range);
diff -r 2052ce3345c1 -r 8c58bf335465 
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Mon Aug 22 
16:38:13 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Mon Aug 22 
19:58:22 2005
@@ -434,20 +434,20 @@
        balloon_unlock(flags);
 }
 
+static int dealloc_pte_fn(
+       pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
+{
+       unsigned long mfn = pte_mfn(*pte);
+       set_pte(pte, __pte_ma(0));
+       phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] =
+               INVALID_P2M_ENTRY;
+       BUG_ON(HYPERVISOR_dom_mem_op(
+               MEMOP_decrease_reservation, &mfn, 1, 0) != 1);
+       return 0;
+}
+
 struct page *balloon_alloc_empty_page_range(unsigned long nr_pages)
 {
-       int f(pte_t *pte, struct page *pte_page,
-             unsigned long addr, void *data)
-       {
-               unsigned long mfn = pte_mfn(*pte);
-               set_pte(pte, __pte_ma(0));
-               phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] =
-                       INVALID_P2M_ENTRY;
-               BUG_ON(HYPERVISOR_dom_mem_op(
-                       MEMOP_decrease_reservation, &mfn, 1, 0) != 1);
-               return 0;
-        }
-
        unsigned long vstart, flags;
        unsigned int  order = get_order(nr_pages * PAGE_SIZE);
 
@@ -459,7 +459,7 @@
 
        balloon_lock(flags);
        BUG_ON(generic_page_range(
-               &init_mm, vstart, PAGE_SIZE << order, f, NULL) != 0);
+               &init_mm, vstart, PAGE_SIZE << order, dealloc_pte_fn, NULL));
        current_pages -= 1UL << order;
        balloon_unlock(flags);
 

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