direct-io.hg

changeset 3582:6d98eb831816

bitkeeper revision 1.1159.212.52 (41fa6980PfhDt-hKCfacnyHcFB7DNQ)

Make page allocator 64-bit safe.
Signed-off-by: keir.fraser@cl.cam.ac.uk
author kaf24@scramble.cl.cam.ac.uk
date Fri Jan 28 16:34:08 2005 +0000 (2005-01-28)
parents ec53c623cf23
children 5e111ac8c357
files xen/arch/x86/memory.c xen/common/page_alloc.c
line diff
     1.1 --- a/xen/arch/x86/memory.c	Fri Jan 28 15:39:56 2005 +0000
     1.2 +++ b/xen/arch/x86/memory.c	Fri Jan 28 16:34:08 2005 +0000
     1.3 @@ -148,13 +148,18 @@ unsigned long max_page;
     1.4  
     1.5  void __init init_frametable(void)
     1.6  {
     1.7 -#ifdef __i386__
     1.8 +#if defined(__i386__)
     1.9      unsigned long i, p;
    1.10 +#endif
    1.11  
    1.12 -    frame_table      = (struct pfn_info *)FRAMETABLE_VIRT_START;
    1.13      frame_table_size = max_page * sizeof(struct pfn_info);
    1.14      frame_table_size = (frame_table_size + PAGE_SIZE - 1) & PAGE_MASK;
    1.15  
    1.16 +#if defined(__x86_64__)
    1.17 +    frame_table = __va(alloc_boot_pages(frame_table_size, 4UL << 20));
    1.18 +#elif defined(__i386__)
    1.19 +    frame_table = (struct pfn_info *)FRAMETABLE_VIRT_START;
    1.20 +
    1.21      for ( i = 0; i < frame_table_size; i += (4UL << 20) )
    1.22      {
    1.23          p = alloc_boot_pages(min(frame_table_size - i, 4UL << 20), 4UL << 20);
    1.24 @@ -163,9 +168,9 @@ void __init init_frametable(void)
    1.25          idle_pg_table[(FRAMETABLE_VIRT_START + i) >> L2_PAGETABLE_SHIFT] =
    1.26              mk_l2_pgentry(p | __PAGE_HYPERVISOR | _PAGE_PSE);
    1.27      }
    1.28 +#endif
    1.29  
    1.30      memset(frame_table, 0, frame_table_size);
    1.31 -#endif
    1.32  }
    1.33  
    1.34  void arch_init_memory(void)
     2.1 --- a/xen/common/page_alloc.c	Fri Jan 28 15:39:56 2005 +0000
     2.2 +++ b/xen/common/page_alloc.c	Fri Jan 28 16:34:08 2005 +0000
     2.3 @@ -49,8 +49,9 @@ static unsigned long  bitmap_size; /* in
     2.4  static unsigned long *alloc_bitmap;
     2.5  #define PAGES_PER_MAPWORD (sizeof(unsigned long) * 8)
     2.6  
     2.7 -#define allocated_in_map(_pn) \
     2.8 -(alloc_bitmap[(_pn)/PAGES_PER_MAPWORD] & (1<<((_pn)&(PAGES_PER_MAPWORD-1))))
     2.9 +#define allocated_in_map(_pn)                 \
    2.10 +( !! (alloc_bitmap[(_pn)/PAGES_PER_MAPWORD] & \
    2.11 +     (1UL<<((_pn)&(PAGES_PER_MAPWORD-1)))) )
    2.12  
    2.13  /*
    2.14   * Hint regarding bitwise arithmetic in map_{alloc,free}:
    2.15 @@ -79,13 +80,13 @@ static void map_alloc(unsigned long firs
    2.16  
    2.17      if ( curr_idx == end_idx )
    2.18      {
    2.19 -        alloc_bitmap[curr_idx] |= ((1<<end_off)-1) & -(1<<start_off);
    2.20 +        alloc_bitmap[curr_idx] |= ((1UL<<end_off)-1) & -(1UL<<start_off);
    2.21      }
    2.22      else 
    2.23      {
    2.24 -        alloc_bitmap[curr_idx] |= -(1<<start_off);
    2.25 -        while ( ++curr_idx < end_idx ) alloc_bitmap[curr_idx] = ~0L;
    2.26 -        alloc_bitmap[curr_idx] |= (1<<end_off)-1;
    2.27 +        alloc_bitmap[curr_idx] |= -(1UL<<start_off);
    2.28 +        while ( ++curr_idx < end_idx ) alloc_bitmap[curr_idx] = ~0UL;
    2.29 +        alloc_bitmap[curr_idx] |= (1UL<<end_off)-1;
    2.30      }
    2.31  }
    2.32  
    2.33 @@ -108,13 +109,13 @@ static void map_free(unsigned long first
    2.34  
    2.35      if ( curr_idx == end_idx )
    2.36      {
    2.37 -        alloc_bitmap[curr_idx] &= -(1<<end_off) | ((1<<start_off)-1);
    2.38 +        alloc_bitmap[curr_idx] &= -(1UL<<end_off) | ((1UL<<start_off)-1);
    2.39      }
    2.40      else 
    2.41      {
    2.42 -        alloc_bitmap[curr_idx] &= (1<<start_off)-1;
    2.43 +        alloc_bitmap[curr_idx] &= (1UL<<start_off)-1;
    2.44          while ( ++curr_idx != end_idx ) alloc_bitmap[curr_idx] = 0;
    2.45 -        alloc_bitmap[curr_idx] &= -(1<<end_off);
    2.46 +        alloc_bitmap[curr_idx] &= -(1UL<<end_off);
    2.47      }
    2.48  }
    2.49  
    2.50 @@ -483,11 +484,11 @@ struct pfn_info *alloc_domheap_pages(str
    2.51              pfn_stamp = pg[i].tlbflush_timestamp;
    2.52              for ( j = 0; (mask != 0) && (j < smp_num_cpus); j++ )
    2.53              {
    2.54 -                if ( mask & (1<<j) )
    2.55 +                if ( mask & (1UL<<j) )
    2.56                  {
    2.57                      cpu_stamp = tlbflush_time[j];
    2.58                      if ( !NEED_FLUSH(cpu_stamp, pfn_stamp) )
    2.59 -                        mask &= ~(1<<j);
    2.60 +                        mask &= ~(1UL<<j);
    2.61                  }
    2.62              }
    2.63