ia64/xen-unstable

changeset 6332:8c58bf335465

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@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Aug 22 19:58:22 2005 +0000 (2005-08-22)
parents 2052ce3345c1
children f3859247f2ed
files Config.mk linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c linux-2.6-xen-sparse/arch/xen/x86_64/mm/ioremap.c linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
line diff
     1.1 --- a/Config.mk	Mon Aug 22 16:38:13 2005 +0000
     1.2 +++ b/Config.mk	Mon Aug 22 19:58:22 2005 +0000
     1.3 @@ -3,7 +3,7 @@
     1.4  # Currently supported architectures: x86_32, x86_64
     1.5  XEN_COMPILE_ARCH    ?= $(shell uname -m | sed -e s/i.86/x86_32/)
     1.6  XEN_TARGET_ARCH     ?= $(XEN_COMPILE_ARCH)
     1.7 -XEN_TARGET_X86_PAE  ?= n
     1.8 +XEN_TARGET_X86_PAE  ?= y
     1.9  
    1.10  # Tools to run on system hosting the build
    1.11  HOSTCC     = gcc
     2.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c	Mon Aug 22 16:38:13 2005 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c	Mon Aug 22 19:58:22 2005 +0000
     2.3 @@ -368,35 +368,37 @@ int direct_remap_area_pages(struct mm_st
     2.4  
     2.5  EXPORT_SYMBOL(direct_remap_area_pages);
     2.6  
     2.7 +static int lookup_pte_fn(
     2.8 +	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
     2.9 +{
    2.10 +	unsigned long *ptep = (unsigned long *)data;
    2.11 +	if (ptep)
    2.12 +		*ptep = (pfn_to_mfn(page_to_pfn(pte_page)) <<
    2.13 +			 PAGE_SHIFT) |
    2.14 +			((unsigned long)pte & ~PAGE_MASK);
    2.15 +	return 0;
    2.16 +}
    2.17 +
    2.18  int create_lookup_pte_addr(struct mm_struct *mm, 
    2.19  			   unsigned long address,
    2.20  			   unsigned long *ptep)
    2.21  {
    2.22 -	int f(pte_t *pte, struct page *pte_page, unsigned long addr,
    2.23 -	      void *data) {
    2.24 -		unsigned long *ptep = (unsigned long *)data;
    2.25 -		if (ptep)
    2.26 -			*ptep = (pfn_to_mfn(page_to_pfn(pte_page)) <<
    2.27 -				 PAGE_SHIFT) |
    2.28 -				((unsigned long)pte & ~PAGE_MASK);
    2.29 -		return 0;
    2.30 -	}
    2.31 -
    2.32 -	return generic_page_range(mm, address, PAGE_SIZE, f, ptep);
    2.33 +	return generic_page_range(mm, address, PAGE_SIZE, lookup_pte_fn, ptep);
    2.34  }
    2.35  
    2.36  EXPORT_SYMBOL(create_lookup_pte_addr);
    2.37  
    2.38 +static int noop_fn(
    2.39 +	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
    2.40 +{
    2.41 +	return 0;
    2.42 +}
    2.43 +
    2.44  int touch_pte_range(struct mm_struct *mm,
    2.45  		    unsigned long address,
    2.46  		    unsigned long size)
    2.47  {
    2.48 -	int f(pte_t *pte, struct page *pte_page, unsigned long addr,
    2.49 -	      void *data) {
    2.50 -		return 0;
    2.51 -	}
    2.52 -
    2.53 -	return generic_page_range(mm, address, size, f, NULL);
    2.54 +	return generic_page_range(mm, address, size, noop_fn, NULL);
    2.55  } 
    2.56  
    2.57  EXPORT_SYMBOL(touch_pte_range);
     3.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/mm/ioremap.c	Mon Aug 22 16:38:13 2005 +0000
     3.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/mm/ioremap.c	Mon Aug 22 19:58:22 2005 +0000
     3.3 @@ -465,33 +465,35 @@ int direct_remap_area_pages(struct mm_st
     3.4  
     3.5  EXPORT_SYMBOL(direct_remap_area_pages);
     3.6  
     3.7 +static int lookup_pte_fn(
     3.8 +    pte_t *pte, struct page *pte_page, unsigned long addr, void *data) 
     3.9 +{
    3.10 +    unsigned long *ptep = (unsigned long *)data;
    3.11 +    if (ptep) *ptep = (pfn_to_mfn(page_to_pfn(pte_page)) << PAGE_SHIFT)
    3.12 +                  | ((unsigned long)pte & ~PAGE_MASK);
    3.13 +    return 0;
    3.14 +}
    3.15 +
    3.16  int create_lookup_pte_addr(struct mm_struct *mm, 
    3.17                             unsigned long address,
    3.18                             unsigned long *ptep)
    3.19  {
    3.20 -    int f(pte_t *pte, struct page *pte_page, unsigned long addr, void *data) 
    3.21 -    {
    3.22 -        unsigned long *ptep = (unsigned long *)data;
    3.23 -        if (ptep) *ptep = (pfn_to_mfn(page_to_pfn(pte_page)) << PAGE_SHIFT)
    3.24 -                       | ((unsigned long)pte & ~PAGE_MASK);
    3.25 -        return 0;
    3.26 -    }
    3.27 -
    3.28 -    return generic_page_range(mm, address, PAGE_SIZE, f, ptep);
    3.29 +    return generic_page_range(mm, address, PAGE_SIZE, lookup_pte_fn, ptep);
    3.30  }
    3.31  
    3.32  EXPORT_SYMBOL(create_lookup_pte_addr);
    3.33  
    3.34 +static int noop_fn(
    3.35 +    pte_t *pte, struct page *pte_page, unsigned long addr, void *data) 
    3.36 +{
    3.37 +    return 0;
    3.38 +}
    3.39 +
    3.40  int touch_pte_range(struct mm_struct *mm,
    3.41                      unsigned long address,
    3.42                      unsigned long size)
    3.43  {
    3.44 -    int f(pte_t *pte, struct page *pte_page, unsigned long addr, void *data) 
    3.45 -    {
    3.46 -        return 0;
    3.47 -    }
    3.48 -
    3.49 -    return generic_page_range(mm, address, size, f, NULL);
    3.50 -}                 
    3.51 +    return generic_page_range(mm, address, size, noop_fn, NULL);
    3.52 +}
    3.53  
    3.54  EXPORT_SYMBOL(touch_pte_range);
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Mon Aug 22 16:38:13 2005 +0000
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Mon Aug 22 19:58:22 2005 +0000
     4.3 @@ -434,20 +434,20 @@ void balloon_update_driver_allowance(lon
     4.4  	balloon_unlock(flags);
     4.5  }
     4.6  
     4.7 +static int dealloc_pte_fn(
     4.8 +	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
     4.9 +{
    4.10 +	unsigned long mfn = pte_mfn(*pte);
    4.11 +	set_pte(pte, __pte_ma(0));
    4.12 +	phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] =
    4.13 +		INVALID_P2M_ENTRY;
    4.14 +	BUG_ON(HYPERVISOR_dom_mem_op(
    4.15 +		MEMOP_decrease_reservation, &mfn, 1, 0) != 1);
    4.16 +	return 0;
    4.17 +}
    4.18 +
    4.19  struct page *balloon_alloc_empty_page_range(unsigned long nr_pages)
    4.20  {
    4.21 -	int f(pte_t *pte, struct page *pte_page,
    4.22 -	      unsigned long addr, void *data)
    4.23 -	{
    4.24 -		unsigned long mfn = pte_mfn(*pte);
    4.25 -		set_pte(pte, __pte_ma(0));
    4.26 -		phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] =
    4.27 -			INVALID_P2M_ENTRY;
    4.28 -		BUG_ON(HYPERVISOR_dom_mem_op(
    4.29 -			MEMOP_decrease_reservation, &mfn, 1, 0) != 1);
    4.30 -		return 0;
    4.31 -        }
    4.32 -
    4.33  	unsigned long vstart, flags;
    4.34  	unsigned int  order = get_order(nr_pages * PAGE_SIZE);
    4.35  
    4.36 @@ -459,7 +459,7 @@ struct page *balloon_alloc_empty_page_ra
    4.37  
    4.38  	balloon_lock(flags);
    4.39  	BUG_ON(generic_page_range(
    4.40 -		&init_mm, vstart, PAGE_SIZE << order, f, NULL) != 0);
    4.41 +		&init_mm, vstart, PAGE_SIZE << order, dealloc_pte_fn, NULL));
    4.42  	current_pages -= 1UL << order;
    4.43  	balloon_unlock(flags);
    4.44